| ; Generated by DXC from the HLSL below with: | |
| ; dxc -spirv -T cs_6_2 -E main -fspv-target-env=vulkan1.1 -O3 -HV 2021 atomic_load_loop_bound.hlsl | |
| ; | |
| ; groupshared uint g; | |
| ; RWStructuredBuffer<uint> buf; | |
| ; | |
| ; [numthreads(64, 1, 1)] | |
| ; void main(uint idx : SV_GroupIndex) { | |
| ; if (idx == 0) { | |
| ; g = 0; | |
| ; } | |
| ; GroupMemoryBarrierWithGroupSync(); | |
| ; InterlockedMax(g, buf[idx] & 7); | |
| ; GroupMemoryBarrierWithGroupSync(); | |
| ; uint n = g; | |
| ; for (uint i = 0; i < n; i++) { | |
| ; buf[idx] += i; | |
| ; GroupMemoryBarrierWithGroupSync(); | |
| ; } | |
| ; } | |
| ; SPIR-V | |
| ; Version: 1.3 | |
| ; Generator: Google spiregg; 0 | |
| ; Bound: 40 | |
| ; Schema: 0 | |
| OpCapability Shader | |
| OpMemoryModel Logical GLSL450 | |
| OpEntryPoint GLCompute %main "main" %gl_LocalInvocationIndex | |
| OpExecutionMode %main LocalSize 64 1 1 | |
| OpSource HLSL 620 | |
| OpName %g "g" | |
| OpName %type_RWStructuredBuffer_uint "type.RWStructuredBuffer.uint" | |
| OpName %buf "buf" | |
| OpName %main "main" | |
| OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex | |
| OpDecorate %buf DescriptorSet 0 | |
| OpDecorate %buf Binding 0 | |
| OpDecorate %_runtimearr_uint ArrayStride 4 | |
| OpMemberDecorate %type_RWStructuredBuffer_uint 0 Offset 0 | |
| OpDecorate %type_RWStructuredBuffer_uint BufferBlock | |
| %uint = OpTypeInt 32 0 | |
| %uint_0 = OpConstant %uint 0 | |
| %int = OpTypeInt 32 1 | |
| %int_0 = OpConstant %int 0 | |
| %uint_7 = OpConstant %uint 7 | |
| %uint_1 = OpConstant %uint 1 | |
| %_ptr_Workgroup_uint = OpTypePointer Workgroup %uint | |
| %_runtimearr_uint = OpTypeRuntimeArray %uint | |
| %type_RWStructuredBuffer_uint = OpTypeStruct %_runtimearr_uint | |
| %_ptr_Uniform_type_RWStructuredBuffer_uint = OpTypePointer Uniform %type_RWStructuredBuffer_uint | |
| %_ptr_Input_uint = OpTypePointer Input %uint | |
| %void = OpTypeVoid | |
| %17 = OpTypeFunction %void | |
| %bool = OpTypeBool | |
| %uint_2 = OpConstant %uint 2 | |
| %uint_264 = OpConstant %uint 264 | |
| %_ptr_Uniform_uint = OpTypePointer Uniform %uint | |
| %g = OpVariable %_ptr_Workgroup_uint Workgroup | |
| %buf = OpVariable %_ptr_Uniform_type_RWStructuredBuffer_uint Uniform | |
| %gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input | |
| %main = OpFunction %void None %17 | |
| %22 = OpLabel | |
| %23 = OpLoad %uint %gl_LocalInvocationIndex | |
| %24 = OpIEqual %bool %23 %uint_0 | |
| OpSelectionMerge %25 None | |
| OpBranchConditional %24 %26 %25 | |
| %26 = OpLabel | |
| OpStore %g %uint_0 | |
| OpBranch %25 | |
| %25 = OpLabel | |
| OpControlBarrier %uint_2 %uint_2 %uint_264 | |
| %27 = OpAccessChain %_ptr_Uniform_uint %buf %int_0 %23 | |
| %28 = OpLoad %uint %27 | |
| %29 = OpBitwiseAnd %uint %28 %uint_7 | |
| %30 = OpAtomicUMax %uint %g %uint_2 %uint_0 %29 | |
| OpControlBarrier %uint_2 %uint_2 %uint_264 | |
| %31 = OpLoad %uint %g | |
| OpBranch %32 | |
| %32 = OpLabel | |
| %33 = OpPhi %uint %uint_0 %25 %34 %35 | |
| %36 = OpULessThan %bool %33 %31 | |
| OpLoopMerge %37 %35 None | |
| OpBranchConditional %36 %35 %37 | |
| %35 = OpLabel | |
| %38 = OpLoad %uint %27 | |
| %39 = OpIAdd %uint %38 %33 | |
| OpStore %27 %39 | |
| OpControlBarrier %uint_2 %uint_2 %uint_264 | |
| %34 = OpIAdd %uint %33 %uint_1 | |
| OpBranch %32 | |
| %37 = OpLabel | |
| OpReturn | |
| OpFunctionEnd |