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
Vulkan: Implement pipeline UID cache #4449
Conversation
Review status: 0 of 5 files reviewed at latest revision, 6 unresolved discussions. Source/Core/VideoBackends/Vulkan/ObjectCache.cpp, line 162 at r1 (raw file):
This should probably return a tuple or pair containing vkPipeline and a boolean instead of using an out parameter. Source/Core/VideoBackends/Vulkan/ObjectCache.cpp, line 385 at r1 (raw file):
@degasus Did you update the buildbot to GCC 5 yet? This is a prime candidate for having static_assert(std::is_trivially_copyable<VK_PIPELINE_CACHE_HEADER>(), "Header must be trivially copyable"); after it. Source/Core/VideoBackends/Vulkan/StateTracker.cpp, line 123 at r1 (raw file):
This should be Source/Core/VideoBackends/Vulkan/StateTracker.cpp, line 126 at r1 (raw file):
Source/Core/VideoBackends/Vulkan/StateTracker.cpp, line 167 at r1 (raw file):
These and the following if statement should probably be their own function. Source/Core/VideoBackends/Vulkan/StateTracker.cpp, line 174 at r1 (raw file):
You can use Comments from Reviewable |
Review status: 0 of 7 files reviewed at latest revision, 6 unresolved discussions, some commit checks failed. Source/Core/VideoBackends/Vulkan/ObjectCache.cpp, line 162 at r1 (raw file):
|
Sounds fine. Reviewed 2 of 5 files at r1, 5 of 5 files at r2. Source/Core/VideoBackends/Vulkan/ObjectCache.cpp, line 291 at r2 (raw file):
return GetPipelineWithCacheResult(info).first; Do you need both functions? Source/Core/VideoBackends/Vulkan/StateTracker.cpp, line 140 at r2 (raw file):
Feel free to change the API of our LinearDiskCache to use a std::function ;) Source/Core/VideoBackends/Vulkan/StateTracker.cpp, line 154 at r2 (raw file):
Out of curiosity, is this the global config option, for the hardware support, or the global state? I wonder why this isn't within the ps_uid. Source/Core/VideoBackends/Vulkan/StateTracker.cpp, line 923 at r2 (raw file):
Should there be a function for this code as it's used twice?
Comments from Reviewable |
This stores enough information to recreate the pipeline, including the shader UIDs, blend/depth/rasterization state, primitive and vertex format.
The user could switch back again, and this would mean this data would be lost. Disk space is cheap, and it's not going to be much.
This ensures that if a user changes adapters or vendors we're not passing invalid data to the driver.
Review status: 3 of 7 files reviewed at latest revision, 10 unresolved discussions. Source/Core/VideoBackends/Vulkan/ObjectCache.cpp, line 291 at r2 (raw file): Previously, degasus (Markus Wick) wrote…
I've simplified the GetPipeline() method. I originally just had it as an out parameter of GetPipeline, but following Lioncash's recommendation I used a pair return instead. This was the cleanest way I could think of accomplishing this without modifying all the callers (which all except one don't care about whether it was a cache miss). Source/Core/VideoBackends/Vulkan/StateTracker.cpp, line 140 at r2 (raw file): Previously, degasus (Markus Wick) wrote…
Sounds like a good idea, outside of the scope of this PR I think. Source/Core/VideoBackends/Vulkan/StateTracker.cpp, line 154 at r2 (raw file): Previously, degasus (Markus Wick) wrote…
It's an variable here because I use a different pipeline layout depending on whether bbox is enabled or not (avoiding the need to bind the shader storage buffer). But you're right about it being part of the ps_uid, I've simplified things and used that field instead. Could probably remove the boolean from StateTracker too, later on. Source/Core/VideoBackends/Vulkan/StateTracker.cpp, line 923 at r2 (raw file): Previously, degasus (Markus Wick) wrote…
Done. Comments from Reviewable |
Reviewed 4 of 4 files at r3. Comments from Reviewable |
This stores enough information to recreate the pipeline, including the shader UIDs, blend/depth/rasterization state, primitive and vertex format.
Should get rid of shader compiling stutter on second boots of games to the same degree that it is mitigated on the D3D/GL backends, if not even better, because we won't be hitting shader recompiles due to state changes (all these are tracked).
Especially makes a difference for AMD users, where the Vulkan pipeline cache does not appear to be populated with any data, so every boot resulted in full recompiles (apart from the initial GLSL generation being skipped).
Also adds validation of pipeline objects, I assume drivers should be doing this already, but just in case.
NOTE: Currently if a user flips between MSAA/SSAA on/off, this will increase the boot time of games because all variations of shaders will be generated. This is an issue that affects all backends, when/if we decouple MSAA state from the UIDs it will sort itself out.
This change is