Skip to content

shaderc selects colliding slots for uniforms and globals. #3592

@mcourteaux

Description

@mcourteaux

Describe the bug
Have a shader like this:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions