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

SPIRV validation error in test with double continue switches #5658

Open
Imberflur opened this issue May 4, 2024 · 0 comments
Open

SPIRV validation error in test with double continue switches #5658

Imberflur opened this issue May 4, 2024 · 0 comments
Labels
area: naga back-end Outputs of naga shader conversion lang: SPIR-V Vulkan's Shading Language naga Shader Translator type: bug Something isn't working

Comments

@Imberflur
Copy link
Contributor

I ran into a SPIRV validation issue in a test case I added in my PR #5654 (comment). I've been able to reduce it down to:

This input wgsl

@compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
    loop {
        switch 0 {
            default: {
                continue;
            }
        }
        switch 0 {
            default: {
                continue;
            }
        }
    }
}

This output spirv

; SPIR-V
; Version: 1.6
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 22
; Schema: 0
               OpCapability Shader
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint GLCompute %2 "main" %gl_GlobalInvocationID
               OpExecutionMode %2 LocalSize 1 1 1
               OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
       %void = OpTypeVoid
       %uint = OpTypeInt 32 0
     %v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
          %8 = OpTypeFunction %void
        %int = OpTypeInt 32 1
      %int_0 = OpConstant %int 0
          %2 = OpFunction %void None %8
         %11 = OpLabel
         %12 = OpLoad %v3uint %gl_GlobalInvocationID
               OpBranch %13
         %13 = OpLabel
               OpBranch %14
         %14 = OpLabel
               OpLoopMerge %15 %16 None
               OpBranch %17
         %17 = OpLabel
               OpSelectionMerge %18 None
               OpSwitch %int_0 %19
         %19 = OpLabel
               OpBranch %16
         %18 = OpLabel
               OpSelectionMerge %20 None
               OpSwitch %int_0 %21
         %21 = OpLabel
               OpBranch %16
         %20 = OpLabel
               OpBranch %16
         %16 = OpLabel
               OpBranch %14
         %15 = OpLabel
               OpReturn
               OpFunctionEnd

This error:

error: line 32: Case construct that targets '21[%21]' has invalid branch to block '16[%16]' (not another case construct, corresponding merge, outer loop merge or outer loop continue)
  %21 = OpLabel

line 32 is the OpBranch %16 in %21 = OpLabel

Afaict %16 is actually an outer loop continue, is this a spirv validator bug?

@teoxoy teoxoy added type: bug Something isn't working area: naga back-end Outputs of naga shader conversion naga Shader Translator lang: SPIR-V Vulkan's Shading Language labels May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga back-end Outputs of naga shader conversion lang: SPIR-V Vulkan's Shading Language naga Shader Translator type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants