-
Notifications
You must be signed in to change notification settings - Fork 61
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
How to share multiple uniform blocks between shaders? #46
Comments
I agree it's annoying (happens for all sorts of "bind slots", e.g. textures). I think (but am not entirely sure) this is caused by SPIRV-Tools optimizer passes (see here: Lines 101 to 154 in ad01696
I'm really not sure what to do about those optimizer-passes. On one hand they are important for OpenGL implementations with bad drivers (similar to what glsl-optimizer does), on the other hand they are entirely unpredictable and cause problems with WebGL. |
From reading https://github.com/KhronosGroup/SPIRV-Tools/blob/master/include/spirv-tools/optimizer.hpp |
I also wonder if we could use |
I was reading: KhronosGroup/SPIRV-Tools#5524 https://github.com/s-perron/SPIRV-Tools/blob/ac11724763cec72056a10be759458fef9826bf83/source/opt/optimizer.cpp#L142 |
Oh, wait looks like we do that now, maybe this issue is resolved? |
Yeah, sokol-shdc is using the DCEPass hints, but this doesn't help with all cases where unused uniforms are removed (I think what it mainly helped with was not removing unused shader inputs/outputs - most importantly vertex attributes). Other then that there's not much sokol-shdc can do. The same problem can even happen at runtime in OpenGL drivers (e.g. OpenGL drivers are free to remove unused uniforms during shader compilation). |
This is actually something we could explore, yeah. |
I'm able to share my primary uniform bloc between vertex and fragment using the same name:
So I can use the "time" uniform in Vertex and Fragment.
But when I try to add a second bloc, it's doesn't work:
I got this error:
Maybe I'm misunderstood something ?
Edit:
I found my problem, the compiler seems to "randomly" optimize out my uniform block in Vertex and/or Fragment Shader, So I got a mismatch.
This is very annoying, is there a ways to prevent the compiler from removing it?
Edit2:
This is worse than I thought, there seems to be a random reordering according to the order of using the variables which also causes a mismatch.
(So first use of uniform must be in same order both in Vertex and Fragment)
My 2 cents solution:
Or in little more elegant way:
The text was updated successfully, but these errors were encountered: