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

Missing SPIR-V test testing struct entry point parameters #2148

Open
karolherbst opened this issue Nov 14, 2024 · 1 comment
Open

Missing SPIR-V test testing struct entry point parameters #2148

karolherbst opened this issue Nov 14, 2024 · 1 comment

Comments

@karolherbst
Copy link
Contributor

karolherbst commented Nov 14, 2024

We got a bug report for this in mesa: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12149

The tldr: The SPIR-V env spec allows struct parameters, but the SPIR-V-LLVM-Translator never ends up making use of this. What the translator is doing is to create a pointer parameter with the ByVal decoration instead.

We should add a specific test for this to ensure all implementations are handling this correctly and in order to catch regressions, because it's really not wildly tested.

SPIR-V from the bug:

; SPIR-V
; Version: 1.0
; Generator: Khronos LLVM/SPIR-V Translator; 14
; Bound: 31
; Schema: 0
               OpCapability Addresses
               OpCapability Linkage
               OpCapability Kernel
               OpCapability Int64
          %1 = OpExtInstImport "OpenCL.std"
               OpMemoryModel Physical64 OpenCL
               OpEntryPoint Kernel %k "k"
               OpExecutionMode %k ContractionOff
               OpSource OpenCL_C 200000
               OpName %struct_Vec3 "struct.Vec3"
               OpName %k "k"
               OpName %out "out"
               OpName %v "v"
               OpName %entry "entry"
               OpName %add "add"
               OpName %add1 "add1"
               OpDecorate %out FuncParamAttr NoCapture
               OpDecorate %out Alignment 4
      %ulong = OpTypeInt 64 0
       %uint = OpTypeInt 32 0
    %ulong_0 = OpConstant %ulong 0
     %uint_1 = OpConstant %uint 1
     %uint_2 = OpConstant %uint 2
       %void = OpTypeVoid
      %float = OpTypeFloat 32
%_ptr_CrossWorkgroup_float = OpTypePointer CrossWorkgroup %float
%struct_Vec3 = OpTypeStruct %float %float %float
%_ptr_Function_struct_Vec3 = OpTypePointer Function %struct_Vec3
          %7 = OpTypeFunction %void %_ptr_CrossWorkgroup_float %struct_Vec3
%_ptr_Function_float = OpTypePointer Function %float
          %k = OpFunction %void None %7
        %out = OpFunctionParameter %_ptr_CrossWorkgroup_float
          %v = OpFunctionParameter %struct_Vec3
      %entry = OpLabel
         %14 = OpCompositeExtract %float %v 0
         %20 = OpCompositeExtract %float %v 1
        %add = OpFAdd %float %14 %20
         %24 = OpCompositeExtract %float %v 2
       %add1 = OpFAdd %float %add %24
               OpStore %out %add1 Aligned 4
               OpReturn
               OpFunctionEnd
@bashbaug
Copy link
Contributor

Related: KhronosGroup/SPIRV-LLVM-Translator#2510

We have had some discussion about this in the OpenCL tooling TSG teleconferences, also.

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