Render State Caching

Reporter: RobertBColton  |  Status: open  |  Last Modified: April 11, 2019, 12:10:34 AM

This is a problem that I've been thinking about for a while, and I think I may have found an idea that I like. So, newer graphics APIs like Vulkan put all of the render state in a single giant block and you have to basically recreate the entire state block all at once just to change one state. Direct3D11 has state blocks that are more granular, but Direct3D12 is apparently the same as Vulkan according to Rusky. That's obviously too inefficient, so what we would ideally do is just cache all of the render state generically. Then when the user goes to draw, we flush all of the render state at once.

This idea has advantages and disadvantages to it. The biggest advantage is that redundant state changes are ignored, and GM users are prone to making these, so that's a good thing. Another advantage is that it's clearly going to result in the simplification and deduplication of much of our graphics systems. Things like d3d_start will then be possible to move to General/ like Josh has always wanted. Now, one disadvantage I can see right now is that this will mean our graphics are no longer as hookable by user extensions. If a user extension draws its own vertex buffer it won't have any of our render state because none of it has been flushed to the device/context.

codecov[bot]  
>Codecov Report

Merging #1636 into master will decrease coverage by 0.11%.
The diff coverage is 38.4%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1636      +/-   ##
=========================================
- Coverage   18.82%   18.7%   -0.12%     
=========================================
  Files         169     166       -3     
  Lines       16782   17098     +316     
=========================================
+ Hits         3159    3198      +39     
- Misses      13623   13900     +277
Impacted Files Coverage Δ
...system/SHELL/Graphics_Systems/General/GSmatrix.cpp 14.34% <ø> (+0.49%) ⬆️
...system/SHELL/Graphics_Systems/OpenGL1/GLstdraw.cpp 1.05% <ø> (+1.05%) ⬆️
...MAsystem/SHELL/Graphics_Systems/General/GSstdraw.h 0% <ø> (ø)
...Asystem/SHELL/Graphics_Systems/General/GSblend.cpp 0% <0%> (ø) ⬆️
...ystem/SHELL/Graphics_Systems/OpenGL1/OPENGLStd.cpp 34.92% <100%> (+2.13%) ⬆️
...system/SHELL/Graphics_Systems/OpenGL1/GLvertex.cpp 69.23% <100%> (ø) ⬆️
...em/SHELL/Graphics_Systems/General/GSprimitives.cpp 65.71% <100%> (ø) ⬆️
...GMAsystem/SHELL/Graphics_Systems/General/GSd3d.cpp 22.78% <22.78%> (+22.78%) ⬆️
...system/SHELL/Graphics_Systems/General/GSstdraw.cpp 7.36% <40.9%> (+0.89%) ⬆️
...GMAsystem/SHELL/Graphics_Systems/OpenGL1/GLd3d.cpp 23.61% <95.23%> (+2.68%) ⬆️
... and 32 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb9d867...7ffc3f0. Read the comment docs.

Please sign in to post comments, or you can view this issue on GitHub.