Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State and cache optimization #27

Merged
merged 8 commits into from
Jun 28, 2024

Conversation

riperiperi
Copy link

  • Greatly optimized pipeline and depth state cache. Managing these as metal objects incurs a huge amount of allocations as they change for each draw, not to mention the individual pinvoke objc calls to set each field, and to get it back for use in the cache.
    • Similar to Vulkan, this uses a tightly packed struct with getter/setter methods to place things in the right bit positions. This incurs a bit extra cost to set the state at the benefit of very fast equality checks and hashing, which happens a lot more than a state change.
  • Pipeline caches are now owned by the programs. This allows them to be disposed when their associated program has been disposed. It also brings things a bit closer to Vulkan so it will be a little easier to do async shader compile.
  • Don't copy the entire state for every helper shader. Similar to vulkan, the helper shader has its own pipeline state that it manages. This is swapped to when performing pipeline actions. Due to the nature of the clear and draw texture shaders, though, they allow some state to be inherited/retained (and then reset afterwards).
  • Fixed a bug where sometimes clear would apply to too many targets, or apply incorrectly in general. Fixes sky in FEZ.

Remaining performance issues are likely in buffer updates and descriptor set updates.

@github-actions github-actions bot added the gpu label Jun 28, 2024
@IsaacMarovitz IsaacMarovitz merged commit 452dca2 into IsaacMarovitz:metal Jun 28, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants