glslang icon indicating copy to clipboard operation
glslang copied to clipboard

Extra SpecId when using LocalSizeId for SPIRV 1.6

Open sfricke-samsung opened this issue 3 years ago • 2 comments

With a shader

#version 450
layout(local_size_x_id = 18, local_size_z_id = 19) in;
layout(local_size_x = 32) in;
void main() {}

running

glslangValidator -V shader.comp --target-env vulkan1.3

I am getting

               OpCapability Shader
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint GLCompute %main "main"
               OpExecutionModeId %main LocalSizeId %7 %uint_1 %9
               OpSource GLSL 450
               OpName %main "main"
               OpDecorate %7 SpecId 18
               OpDecorate %9 SpecId 19
               OpDecorate %10 SpecId 18
               OpDecorate %11 SpecId 19
       %void = OpTypeVoid
          %3 = OpTypeFunction %void
       %uint = OpTypeInt 32 0
          %7 = OpSpecConstant %uint 32
     %uint_1 = OpConstant %uint 1
          %9 = OpSpecConstant %uint 1
         %10 = OpSpecConstant %uint 32
         %11 = OpSpecConstant %uint 1
     %v3uint = OpTypeVector %uint 3
         %13 = OpSpecConstantComposite %v3uint %10 %uint_1 %11
       %main = OpFunction %void None %3
          %5 = OpLabel
               OpReturn
               OpFunctionEnd

Where there is a double pair of OpDecorate %_ SpecId and the following is not used

               OpDecorate %10 SpecId 18
               OpDecorate %11 SpecId 19
         %10 = OpSpecConstant %uint 32
         %11 = OpSpecConstant %uint 1
     %v3uint = OpTypeVector %uint 3
         %13 = OpSpecConstantComposite %v3uint %10 %uint_1 %11

I see the spv.1.6.specConstant.comp test is using gl_WorkGroupSize so it makes sense why it needs the OpSpecConstantComposite but should probably have a test case that doesn't read from gl_WorkGroupSize that sets LocalSizeId

sfricke-samsung avatar Feb 12 '22 01:02 sfricke-samsung

So the concern here is not incorrect code, but just unnecessary code? Correct?

Is this a shader that might appear in real life? Just trying to triage urgency. Thanks!

greg-lunarg avatar Feb 14 '22 17:02 greg-lunarg

(the urgency is low, just wanted to note this as it seems there isn't much testing for LocalSizeId as it just recently became supported)

Yes, the issue with this case is just unnecessary code, but wanted to report incase this had deeper underlying issues that might propagate in another valid usage of LocalSizeId

sfricke-samsung avatar Feb 14 '22 18:02 sfricke-samsung