-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Uniform buffer length validation incorrect for arrays with pipeline-defined constant lengths ("Uniform buffer supplied (binding: 0) size (48 is smaller than size of shader uniform: (-16).") #94881
Comments
I don't seem to reproduce the issue on Fedora 40 with either of my AMD GPUs with Mesa 24.1.4.
I'm not sure I understood how to reproduce the bug exactly, but is that correct that the MRP is supposed to trigger the bug out of the box? If so it might be GPU / driver specific. |
Able to reproduce it on my other computer: The output window shows this for a failed (unmodified) run:
and then on the Debugger -> Errors tab, it shows these three errors:
If I change the named constant on line 12 of the glsl file to a literal
(which is close enough to what the integers should be for this toy example) or on my laptop, which either uses more precise floats or rounds the results:
|
I can confirm the bug on an M2 Macbook (Vulkan API 1.2.231 - Forward+ - Using Vulkan Device #0: Apple - Apple M2). I suspect that the issue comes from the specialization constant not being initialized correctly. Taking a deeper look now Edit I can also reproduce on my linux computer (Vulkan API 1.3.274 - Forward+ - Using Vulkan Device #0: Intel - Intel(R) Xe Graphics (TGL GT2)) |
Taking a closer look. It seems that the values are set correctly. I suspect that the issue is in our shader validation code. We extract some reflection data from the shader when it is compiled to SPIRV. However, at the time we compile to SPIRV, we don't have a stable value for the specialization constants (we have defaults only). At run time, we use that reflection data to validate the inputs to the shader. But since we don't know how long the uniform buffer is supposed to be the validation fails and leads to the error you see. If my theory is correct the solution is going to be very difficult. I see the following options:
CC @RandomShaper who may also be interested in this. For now I would avoid using a specialization constant to set the size of a uniform buffer array. |
Compute shaders also fail to compile if a specialization constant is used as the offset in a texture + offset function (tested in 4.3 beta). The error reports that a compile-time constant is required. (Per this glslang issue, it appears they were intended to be considered compile-time constants.) This error is at compilation, not runtime like the array length, but is it possibly a similar root cause in how they're treated by the compiler? |
Reproduced on 4.2. Cannot repro in 4.3 because reflection retrieves 16 as the uniform buffer size (instead of @clayjohn's analysis is accurate. Option 1 is feasible. And that's so true that... #94985 |
Tested versions
I've only tried in 4.2.2. This is very unlikely to be a regression.
System information
Godot v4.2.2.stable - Debian GNU/Linux trixie/sid trixie - Wayland - Vulkan (Forward+) - integrated Intel(R) Graphics (RPL-P) () - 13th Gen Intel(R) Core(TM) i7-1360P (16 Threads)
Issue description
When using
RDPipelineSpecificConstant
to define a constant that is used as the length of an array, it is impossible to construct a uniform set that godot will allow you to assign to that array even though the graphics card would have accepted the buffer. This is because the expected size ends up being negative.Additionally, there's a missing parenthesis in the error message, but that's not worth a separate ticket.
Steps to reproduce
3
Minimal reproduction project (MRP)
Compute Constant Uniform Buffer.zip
The text was updated successfully, but these errors were encountered: