-
Notifications
You must be signed in to change notification settings - Fork 699
various improvements & cleanup for shader compilation #1650
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
base: main
Are you sure you want to change the base?
Conversation
CleanupAfterCompile is already done in LatteShader_CreateRendererShader WaitForCompiled is already done in PreponeCompilation
…a shader later in the queue is already compiled
…shader compilation
I think Mesa's is the only implementation that actually compiles shaders in There are also issues with |
I guess it didn't click that you can call glLinkProgram before checking if the shaders compiled successfully. I've changed it now so it issues both compilation and linking immediately and checks both in IsCompiled(). In that thread Nvidia keeps insisting that their drivers are fine and I think I agree with their reasoning. The fact that querying shader completion status always returns 1 and is a blocking operation is not an issue when they say that |
In the initial post I was wrong and you're right @Exzap. As long as glCompileShader is light (just parsing for syntax errors) and the intensive compilation is done in glLinkProgram then the current implementation would be fine if it weren't for storeBinary also being called immediately in the constructor, which forces synchronization on glLinkProgram. |
OpenGL parallel shader compilation fix
Move finishing shader compilation to WaitForCompiled.
If my understanding is correct ARB_parallel_shader_compile makes glCompileShader non-blocking.
However before this change cemu would immediately call glGetShaderiv GL_COMPILE_STATUS to check for compilation errors which then forces the shader to be done compiling. That means the blocking compilation operation is just moved down a few lines and no parallelism can take place.
I have changed it so the checking doesn't happen until WaitForCompiled. That means that multiple glCompileShader calls can happen before cemu runs a blocking glGetShaderiv call.
While I have not observed substantial speedups on my driver I think my changes are theoretically correct.
I have also changed IsCompiled so it returns the extensions GL_COMPLETION_STATUS_ARB which allows cemu to query compilation status in the same way as with vulkan shaders.
I used this change in the shader cache compilation queue logic so that it only forces the first entry to compile when the queue is full and there are no already compiled shaders. This potentially improves performance in a scenario where the queue is full and the first entry is slower to compile than shaders later in the queue, because it allows the queue to be filled immediately rather than be drained while the slow shader finishes.
misc.