Skip to content
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

Illegal debug information generated for array sized by specialisation constant #3830

Open
AnyOldName3 opened this issue Jan 7, 2025 · 1 comment

Comments

@AnyOldName3
Copy link
Contributor

If a GLSL file containing

layout(constant_id = 3) const int lightDataSize = 256;
layout(set = VIEW_DESCRIPTOR_SET, binding = 0) uniform LightData
{
    vec4 values[lightDataSize];
} lightData;

is compiled with glslang, it can turn into SPIR-V like

%lightDataSize = OpSpecConstant %int 256
%_arr_v4float_lightDataSize = OpTypeArray %v4float %lightDataSize
        %150 = OpExtInst %void %1 DebugTypeArray %139 %lightDataSize
  %LightData = OpTypeStruct %_arr_v4float_lightDataSize

According to the NonSemantic.Shader.DebugInfo.100 spec

Component Count must be a Result <id> of an OpConstant, DebugGlobalVariable, or DebugLocalVariable. If it is an OpConstant, its type must be a 32-bit or 64-bit integer type. Otherwise its type must be a DebugTypeBasic whose Size is 32 or 64 and whose Encoding is Unsigned.

However, here it's an OpSpecConstant.

I don't think there's a good reason why it can't be an OpSpecConstant instead of just a OpConstant, but the spec says what it says, and SPIRV-Tools-opt will complain about this.

@arcady-lunarg
Copy link
Contributor

I think this is potentially a SPIR-V spec issue, if indeed it should be allowed. Otherwise I suppose it could be generated using a DebugGlobalVariable for the spec constant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants