Add test for multi-function Private LUT.

This commit is contained in:
Hans-Kristian Arntzen 2024-03-18 11:25:59 +01:00
parent 48bede6a2a
commit 48aba6ab03
3 changed files with 129 additions and 0 deletions

View File

@ -0,0 +1,15 @@
#version 450
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
const uint _21[8] = uint[](1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u);
layout(binding = 0, std430) buffer SSBO
{
uint data[];
} _14;
void main()
{
_14.data[gl_GlobalInvocationID.x] = _21[gl_LocalInvocationID.x] + _21[_21[gl_LocalInvocationID.y]];
}

View File

@ -0,0 +1,22 @@
#version 450
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
const uint _21[8] = uint[](1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u);
layout(binding = 0, std430) buffer SSBO
{
uint data[];
} _14;
uint load_lut(uint index)
{
return _21[index];
}
void main()
{
uint param = _21[gl_LocalInvocationID.y];
uint v = _21[gl_LocalInvocationID.x] + load_lut(param);
_14.data[gl_GlobalInvocationID.x] = v;
}

View File

@ -0,0 +1,92 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 61
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %gl_LocalInvocationID %gl_GlobalInvocationID
OpExecutionMode %main LocalSize 8 8 1
OpSource GLSL 450
OpName %main "main"
OpName %load_lut_u1_ "load_lut(u1;"
OpName %index "index"
OpName %v "v"
OpName %gl_LocalInvocationID "gl_LocalInvocationID"
OpName %param "param"
OpName %SSBO "SSBO"
OpMemberName %SSBO 0 "data"
OpName %_ ""
OpName %gl_GlobalInvocationID "gl_GlobalInvocationID"
OpDecorate %gl_LocalInvocationID BuiltIn LocalInvocationId
OpDecorate %_runtimearr_uint ArrayStride 4
OpMemberDecorate %SSBO 0 Offset 0
OpDecorate %SSBO BufferBlock
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 0
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
%void = OpTypeVoid
%3 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%_ptr_Function_uint = OpTypePointer Function %uint
%_ptr_Private_uint = OpTypePointer Private %uint
%8 = OpTypeFunction %uint %_ptr_Function_uint
%uint_8 = OpConstant %uint 8
%_arr_uint_uint_8 = OpTypeArray %uint %uint_8
%uint_1 = OpConstant %uint 1
%uint_2 = OpConstant %uint 2
%uint_3 = OpConstant %uint 3
%uint_4 = OpConstant %uint 4
%uint_5 = OpConstant %uint 5
%uint_6 = OpConstant %uint 6
%uint_7 = OpConstant %uint 7
%21 = OpConstantComposite %_arr_uint_uint_8 %uint_1 %uint_2 %uint_3 %uint_4 %uint_5 %uint_6 %uint_7 %uint_8
%_ptr_Private__arr_uint_uint_8 = OpTypePointer Private %_arr_uint_uint_8
%lut = OpVariable %_ptr_Private__arr_uint_uint_8 Private %21
%v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%gl_LocalInvocationID = OpVariable %_ptr_Input_v3uint Input
%uint_0 = OpConstant %uint 0
%_ptr_Input_uint = OpTypePointer Input %uint
%_runtimearr_uint = OpTypeRuntimeArray %uint
%SSBO = OpTypeStruct %_runtimearr_uint
%_ptr_Uniform_SSBO = OpTypePointer Uniform %SSBO
%_ = OpVariable %_ptr_Uniform_SSBO Uniform
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
%_ptr_Uniform_uint = OpTypePointer Uniform %uint
%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_8 %uint_8 %uint_1
%main = OpFunction %void None %3
%5 = OpLabel
%v = OpVariable %_ptr_Function_uint Function
%param = OpVariable %_ptr_Function_uint Function
%35 = OpAccessChain %_ptr_Input_uint %gl_LocalInvocationID %uint_0
%36 = OpLoad %uint %35
%38 = OpAccessChain %_ptr_Private_uint %lut %36
%39 = OpLoad %uint %38
%40 = OpAccessChain %_ptr_Input_uint %gl_LocalInvocationID %uint_1
%41 = OpLoad %uint %40
%44 = OpAccessChain %_ptr_Private_uint %lut %41
%45 = OpLoad %uint %44
OpStore %param %45
%46 = OpFunctionCall %uint %load_lut_u1_ %param
%47 = OpIAdd %uint %39 %46
OpStore %v %47
%55 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0
%56 = OpLoad %uint %55
%57 = OpLoad %uint %v
%59 = OpAccessChain %_ptr_Uniform_uint %_ %int_0 %56
OpStore %59 %57
OpReturn
OpFunctionEnd
%load_lut_u1_ = OpFunction %uint None %8
%index = OpFunctionParameter %_ptr_Function_uint
%11 = OpLabel
%22 = OpLoad %uint %index
%25 = OpAccessChain %_ptr_Private_uint %lut %22
%26 = OpLoad %uint %25
OpReturnValue %26
OpFunctionEnd