shader-slang / slang

Making it easier to work with shaders
MIT License
1.94k stars 166 forks source link

Illegal SPIRV generated with inline spirv_asm #4573

Closed pradyumans closed 1 month ago

pradyumans commented 1 month ago

Following inlined spirv slang testcase generates illegal OpExecutionModeId inserted inside OpFunction declaration

[shader("compute")]
[numthreads(16, 16, 1)]
void root()
{
    spirv_asm
    {
        OpCapability Kernel;
        OpExecutionModeId $root VecTypeHint $(0);
        OpExecutionModeId $root LocalSizeHintId $(1) $(1) $(1);
    };
}

// Disassembled SPIRV with spirv-dis

; SPIR-V
; Version: 1.3
; Generator: Khronos; 40
; Bound: 8
; Schema: 0
               OpCapability Kernel
               OpCapability Shader
               OpMemoryModel Logical GLSL450
               OpEntryPoint GLCompute %root "root"
               OpExecutionMode %root LocalSize 16 16 1
               OpSource Slang 1
               OpName %root "root"
       %void = OpTypeVoid
          %3 = OpTypeFunction %void
        %int = OpTypeInt 32 1
      %int_1 = OpConstant %int 1
       %root = OpFunction %void None %3
          %4 = OpLabel
               **OpExecutionModeId %root VecTypeHint 6  // ILLEGAL
               OpExecutionModeId %root LocalSizeHintId %int_1 %int_1 %int_1 // ILLEGAL**
               OpReturn
               OpFunctionEnd
pradyumans commented 1 month ago

Similar issue with OpDecorateId as well