#3592·bgfx

shaderc selects colliding slots for uniforms and globals.

Author: mcourteauxCreated Feb 13, 2026Updated Feb 14, 2026

Describe the bug Have a shader like this:

glsl

uniform vec4 u_some_param;
mat3 some_matrix = mtxFromRows(vec3(1), vec3(2), vec3(3));

And compile with shaderc to spirv. Then in the vulkan backend you should see non-unique register slots when compiled with trace-level logging when the shader gets loaded.

Note that the actual some_matrix global is not even marked as uniform.

This bug was revealed when https://github.com/bkaradzic/bgfx/pull/3536/changes landed, and I had to change mtxFromRows3 to mtxFromRows. This new approach is however not a constant expression anymore, so I had to drop the const qualifier from the global declaration.

Screenshots

In screenshot see how u_crop is at offset 48, and how the selected line m_XYZ_to_ProPhoto is at offset 48.

Image

I'm not sure if non-const globals being treated as uniforms is an intentional way of getting constant data into the shader.