diff options
author | Hans-Kristian Arntzen <post@arntzen-software.no> | 2022-01-05 17:53:51 +0300 |
---|---|---|
committer | Hans-Kristian Arntzen <post@arntzen-software.no> | 2022-01-06 15:57:10 +0300 |
commit | 7c83fc22fa4b60d5602c05553664299edcff08ad (patch) | |
tree | 735d55c8d0e0dde5d44fb0609a3c424aad5d3cba /shaders-msl-no-opt | |
parent | 35bb32844306f5f5b452c21b6bd618ee882c2cda (diff) |
Add support for LocalSizeId.
WorkgroupSize builtin is deprecated in 1.6 and LocalSizeId is supported
in Vulkan starting with maintenance4.
Diffstat (limited to 'shaders-msl-no-opt')
-rw-r--r-- | shaders-msl-no-opt/asm/comp/local-size-id-override.asm.comp | 60 | ||||
-rw-r--r-- | shaders-msl-no-opt/asm/comp/local-size-id.asm.comp | 76 |
2 files changed, 136 insertions, 0 deletions
diff --git a/shaders-msl-no-opt/asm/comp/local-size-id-override.asm.comp b/shaders-msl-no-opt/asm/comp/local-size-id-override.asm.comp new file mode 100644 index 00000000..2eaef4bd --- /dev/null +++ b/shaders-msl-no-opt/asm/comp/local-size-id-override.asm.comp @@ -0,0 +1,60 @@ + 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 + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %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 + %spec_1 = OpSpecConstant %uint 11 + %spec_2 = OpSpecConstant %uint 12 + %spec_3 = OpSpecConstant %uint 13 + %spec_4 = OpSpecConstant %uint 14 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %uint_3 %spec_1 %spec_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 + %28 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %21 + OpStore %28 %27 + OpReturn + OpFunctionEnd diff --git a/shaders-msl-no-opt/asm/comp/local-size-id.asm.comp b/shaders-msl-no-opt/asm/comp/local-size-id.asm.comp new file mode 100644 index 00000000..3031f4bb --- /dev/null +++ b/shaders-msl-no-opt/asm/comp/local-size-id.asm.comp @@ -0,0 +1,76 @@ + 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 |