SPIRV-Cross/shaders-no-opt/asm/comp/local-size-id.vk.asm.comp
Hans-Kristian Arntzen 7c83fc22fa Add support for LocalSizeId.
WorkgroupSize builtin is deprecated in 1.6 and LocalSizeId is supported
in Vulkan starting with maintenance4.
2022-01-06 13:57:10 +01:00

77 lines
3.4 KiB
Plaintext

OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID
OpExecutionModeId %main LocalSizeId %spec_3 %spec_4 %uint_2
OpSource GLSL 450
OpName %main "main"
OpName %SSBO "SSBO"
OpMemberName %SSBO 0 "values"
OpName %_ ""
OpName %gl_GlobalInvocationID "gl_GlobalInvocationID"
OpDecorate %_runtimearr_v4float ArrayStride 16
OpMemberDecorate %SSBO 0 Offset 0
OpDecorate %SSBO Block
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 0
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %spec_1 SpecId 1
OpDecorate %spec_2 SpecId 2
OpDecorate %spec_3 SpecId 3
OpDecorate %spec_4 SpecId 4
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v3float = OpTypeVector %float 3
%v4float = OpTypeVector %float 4
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%SSBO = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_SSBO = OpTypePointer StorageBuffer %SSBO
%_ = OpVariable %_ptr_Uniform_SSBO StorageBuffer
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
%uint_0 = OpConstant %uint 0
%_ptr_Input_uint = OpTypePointer Input %uint
%float_2 = OpConstant %float 2
%_ptr_Uniform_v4float = OpTypePointer StorageBuffer %v4float
; Test that we can declare the spec constant as signed.
; Needs implicit bitcast since WorkGroupSize is uint.
%spec_1 = OpSpecConstant %int 11
%spec_2 = OpSpecConstant %int 12
%spec_3 = OpSpecConstant %int 13
%spec_4 = OpSpecConstant %int 14
%uint_1 = OpConstant %uint 1
%uint_2 = OpConstant %uint 2
%uint_3 = OpConstant %uint 3
; Test that we can build spec constant composites out of local size id values.
; Needs special case handling.
%spec_3_op = OpSpecConstantOp %uint IAdd %spec_3 %uint_3
%WorkGroupSize = OpSpecConstantComposite %v3uint %spec_3_op %spec_4 %uint_2
%main = OpFunction %void None %3
%5 = OpLabel
%20 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0
%21 = OpLoad %uint %20
%24 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %21
%25 = OpLoad %v4float %24
%26 = OpCompositeConstruct %v4float %float_2 %float_2 %float_2 %float_2
%27 = OpFAdd %v4float %25 %26
%wg_f = OpConvertUToF %v3float %WorkGroupSize
%wg_f4 = OpVectorShuffle %v4float %wg_f %wg_f 0 1 2 2
; Test that we can use the spec constants directly which needs to translate to gl_WorkGroupSize.elem.
; Needs special case handling.
%res = OpFAdd %v4float %27 %wg_f4
%f0 = OpConvertSToF %float %spec_3
%f1 = OpConvertSToF %float %spec_4
%f2 = OpConvertSToF %float %uint_2
%res1 = OpVectorTimesScalar %v4float %res %f0
%res2 = OpVectorTimesScalar %v4float %res1 %f1
%res3 = OpVectorTimesScalar %v4float %res2 %f2
%28 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %21
OpStore %28 %res3
OpReturn
OpFunctionEnd