blob: f2374b2751d1dfea7b9187f3c960d1fa6f2016e5 [file] [log] [blame]
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 312
; Schema: 0
OpCapability Shader
%48 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %computeMain "computeMain" %global_id_1
OpExecutionMode %computeMain LocalSize 4 2 4
OpName %global_id_1 "global_id_1"
OpName %Camera "Camera"
OpMemberName %Camera 0 "projection"
OpMemberName %Camera 1 "inverseProjection"
OpMemberName %Camera 2 "view"
OpMemberName %Camera 3 "position"
OpMemberName %Camera 4 "time"
OpMemberName %Camera 5 "outputSize"
OpMemberName %Camera 6 "zNear"
OpMemberName %Camera 7 "zFar"
OpName %camera "camera"
OpName %Clusters "Clusters"
OpMemberName %Clusters 0 "bounds"
OpName %ClusterBounds "ClusterBounds"
OpMemberName %ClusterBounds 0 "minAABB"
OpMemberName %ClusterBounds 1 "maxAABB"
OpName %clusters "clusters"
OpName %ClusterLightGroup "ClusterLightGroup"
OpMemberName %ClusterLightGroup 0 "offset"
OpMemberName %ClusterLightGroup 1 "lights"
OpName %ClusterLights "ClusterLights"
OpMemberName %ClusterLights 0 "offset"
OpMemberName %ClusterLights 1 "count"
OpMemberName %ClusterLightGroup 2 "indices"
OpName %clusterLights "clusterLights"
OpName %GlobalLights "GlobalLights"
OpMemberName %GlobalLights 0 "ambient"
OpMemberName %GlobalLights 1 "dirColor"
OpMemberName %GlobalLights 2 "dirIntensity"
OpMemberName %GlobalLights 3 "dirDirection"
OpMemberName %GlobalLights 4 "lightCount"
OpMemberName %GlobalLights 5 "lights"
OpName %Light "Light"
OpMemberName %Light 0 "position"
OpMemberName %Light 1 "range"
OpMemberName %Light 2 "color"
OpMemberName %Light 3 "intensity"
OpName %globalLights "globalLights"
OpName %tileCount "tileCount"
OpName %linearDepth "linearDepth"
OpName %depthSample "depthSample"
OpName %getTile "getTile"
OpName %fragCoord "fragCoord"
OpName %getClusterIndex "getClusterIndex"
OpName %fragCoord_0 "fragCoord"
OpName %sqDistPointAABB "sqDistPointAABB"
OpName %point "point"
OpName %minAABB "minAABB"
OpName %maxAABB "maxAABB"
OpName %sqDist "sqDist"
OpName %i "i"
OpName %computeMain_inner "computeMain_inner"
OpName %global_id "global_id"
OpName %clusterLightCount "clusterLightCount"
OpName %cluserLightIndices "cluserLightIndices"
OpName %i_0 "i"
OpName %lightInCluster "lightInCluster"
OpName %offset "offset"
OpName %i_1 "i"
OpName %computeMain "computeMain"
OpDecorate %global_id_1 BuiltIn GlobalInvocationId
OpDecorate %Camera Block
OpMemberDecorate %Camera 0 Offset 0
OpMemberDecorate %Camera 0 ColMajor
OpMemberDecorate %Camera 0 MatrixStride 16
OpMemberDecorate %Camera 1 Offset 64
OpMemberDecorate %Camera 1 ColMajor
OpMemberDecorate %Camera 1 MatrixStride 16
OpMemberDecorate %Camera 2 Offset 128
OpMemberDecorate %Camera 2 ColMajor
OpMemberDecorate %Camera 2 MatrixStride 16
OpMemberDecorate %Camera 3 Offset 192
OpMemberDecorate %Camera 4 Offset 204
OpMemberDecorate %Camera 5 Offset 208
OpMemberDecorate %Camera 6 Offset 216
OpMemberDecorate %Camera 7 Offset 220
OpDecorate %camera NonWritable
OpDecorate %camera DescriptorSet 0
OpDecorate %camera Binding 0
OpDecorate %Clusters Block
OpMemberDecorate %Clusters 0 Offset 0
OpMemberDecorate %ClusterBounds 0 Offset 0
OpMemberDecorate %ClusterBounds 1 Offset 16
OpDecorate %_arr_ClusterBounds_uint_27648 ArrayStride 32
OpDecorate %clusters NonWritable
OpDecorate %clusters DescriptorSet 0
OpDecorate %clusters Binding 1
OpDecorate %ClusterLightGroup Block
OpMemberDecorate %ClusterLightGroup 0 Offset 0
OpMemberDecorate %ClusterLightGroup 1 Offset 4
OpMemberDecorate %ClusterLights 0 Offset 0
OpMemberDecorate %ClusterLights 1 Offset 4
OpDecorate %_arr_ClusterLights_uint_27648 ArrayStride 8
OpMemberDecorate %ClusterLightGroup 2 Offset 221188
OpDecorate %_arr_uint_uint_1769472 ArrayStride 4
OpDecorate %clusterLights DescriptorSet 0
OpDecorate %clusterLights Binding 2
OpDecorate %GlobalLights Block
OpMemberDecorate %GlobalLights 0 Offset 0
OpMemberDecorate %GlobalLights 1 Offset 16
OpMemberDecorate %GlobalLights 2 Offset 28
OpMemberDecorate %GlobalLights 3 Offset 32
OpMemberDecorate %GlobalLights 4 Offset 44
OpMemberDecorate %GlobalLights 5 Offset 48
OpMemberDecorate %Light 0 Offset 0
OpMemberDecorate %Light 1 Offset 12
OpMemberDecorate %Light 2 Offset 16
OpMemberDecorate %Light 3 Offset 28
OpDecorate %_runtimearr_Light ArrayStride 32
OpDecorate %globalLights NonWritable
OpDecorate %globalLights DescriptorSet 0
OpDecorate %globalLights Binding 3
OpDecorate %_arr_uint_uint_256 ArrayStride 4
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%global_id_1 = OpVariable %_ptr_Input_v3uint Input
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%mat4v4float = OpTypeMatrix %v4float 4
%v3float = OpTypeVector %float 3
%v2float = OpTypeVector %float 2
%Camera = OpTypeStruct %mat4v4float %mat4v4float %mat4v4float %v3float %float %v2float %float %float
%_ptr_Uniform_Camera = OpTypePointer Uniform %Camera
%camera = OpVariable %_ptr_Uniform_Camera Uniform
%ClusterBounds = OpTypeStruct %v3float %v3float
%uint_27648 = OpConstant %uint 27648
%_arr_ClusterBounds_uint_27648 = OpTypeArray %ClusterBounds %uint_27648
%Clusters = OpTypeStruct %_arr_ClusterBounds_uint_27648
%_ptr_StorageBuffer_Clusters = OpTypePointer StorageBuffer %Clusters
%clusters = OpVariable %_ptr_StorageBuffer_Clusters StorageBuffer
%ClusterLights = OpTypeStruct %uint %uint
%_arr_ClusterLights_uint_27648 = OpTypeArray %ClusterLights %uint_27648
%uint_1769472 = OpConstant %uint 1769472
%_arr_uint_uint_1769472 = OpTypeArray %uint %uint_1769472
%ClusterLightGroup = OpTypeStruct %uint %_arr_ClusterLights_uint_27648 %_arr_uint_uint_1769472
%_ptr_StorageBuffer_ClusterLightGroup = OpTypePointer StorageBuffer %ClusterLightGroup
%clusterLights = OpVariable %_ptr_StorageBuffer_ClusterLightGroup StorageBuffer
%Light = OpTypeStruct %v3float %float %v3float %float
%_runtimearr_Light = OpTypeRuntimeArray %Light
%GlobalLights = OpTypeStruct %v3float %v3float %float %v3float %uint %_runtimearr_Light
%_ptr_StorageBuffer_GlobalLights = OpTypePointer StorageBuffer %GlobalLights
%globalLights = OpVariable %_ptr_StorageBuffer_GlobalLights StorageBuffer
%uint_32 = OpConstant %uint 32
%uint_18 = OpConstant %uint 18
%uint_48 = OpConstant %uint 48
%tileCount = OpConstantComposite %v3uint %uint_32 %uint_18 %uint_48
%35 = OpTypeFunction %float %float
%uint_7 = OpConstant %uint 7
%_ptr_Uniform_float = OpTypePointer Uniform %float
%uint_6 = OpConstant %uint 6
%57 = OpTypeFunction %v3uint %v4float
%float_0 = OpConstant %float 0
%uint_5 = OpConstant %uint 5
%uint_0 = OpConstant %uint 0
%uint_1 = OpConstant %uint 1
%112 = OpTypeFunction %uint %v4float
%128 = OpTypeFunction %float %v3float %v3float %v3float
%_ptr_Function_float = OpTypePointer Function %float
%136 = OpConstantNull %float
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%_ptr_Function_int = OpTypePointer Function %int
%141 = OpConstantNull %int
%int_3 = OpConstant %int 3
%bool = OpTypeBool
%int_1 = OpConstant %int 1
%void = OpTypeVoid
%187 = OpTypeFunction %void %v3uint
%_ptr_Function_uint = OpTypePointer Function %uint
%205 = OpConstantNull %uint
%uint_256 = OpConstant %uint 256
%_arr_uint_uint_256 = OpTypeArray %uint %uint_256
%_ptr_Function__arr_uint_uint_256 = OpTypePointer Function %_arr_uint_uint_256
%210 = OpConstantNull %_arr_uint_uint_256
%uint_4 = OpConstant %uint 4
%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float
%_ptr_Function_bool = OpTypePointer Function %bool
%232 = OpConstantNull %bool
%uint_2 = OpConstant %uint 2
%_ptr_Uniform_mat4v4float = OpTypePointer Uniform %mat4v4float
%_ptr_StorageBuffer_v3float = OpTypePointer StorageBuffer %v3float
%float_1 = OpConstant %float 1
%_ptr_StorageBuffer_uint_0 = OpTypePointer StorageBuffer %uint
%307 = OpTypeFunction %void
%linearDepth = OpFunction %float None %35
%depthSample = OpFunctionParameter %float
%38 = OpLabel
%41 = OpAccessChain %_ptr_Uniform_float %camera %uint_7
%42 = OpLoad %float %41
%44 = OpAccessChain %_ptr_Uniform_float %camera %uint_6
%45 = OpLoad %float %44
%46 = OpFMul %float %42 %45
%49 = OpAccessChain %_ptr_Uniform_float %camera %uint_6
%50 = OpLoad %float %49
%51 = OpAccessChain %_ptr_Uniform_float %camera %uint_7
%52 = OpLoad %float %51
%53 = OpFSub %float %50 %52
%54 = OpAccessChain %_ptr_Uniform_float %camera %uint_7
%55 = OpLoad %float %54
%47 = OpExtInst %float %48 Fma %depthSample %53 %55
%56 = OpFDiv %float %46 %47
OpReturnValue %56
OpFunctionEnd
%getTile = OpFunction %v3uint None %57
%fragCoord = OpFunctionParameter %v4float
%60 = OpLabel
%62 = OpCompositeExtract %uint %tileCount 2
%61 = OpConvertUToF %float %62
%64 = OpAccessChain %_ptr_Uniform_float %camera %uint_7
%65 = OpLoad %float %64
%66 = OpAccessChain %_ptr_Uniform_float %camera %uint_6
%67 = OpLoad %float %66
%68 = OpFDiv %float %65 %67
%63 = OpExtInst %float %48 Log2 %68
%69 = OpFDiv %float %61 %63
%72 = OpCompositeExtract %uint %tileCount 2
%71 = OpConvertUToF %float %72
%74 = OpAccessChain %_ptr_Uniform_float %camera %uint_6
%75 = OpLoad %float %74
%73 = OpExtInst %float %48 Log2 %75
%76 = OpFMul %float %71 %73
%78 = OpAccessChain %_ptr_Uniform_float %camera %uint_7
%79 = OpLoad %float %78
%80 = OpAccessChain %_ptr_Uniform_float %camera %uint_6
%81 = OpLoad %float %80
%82 = OpFDiv %float %79 %81
%77 = OpExtInst %float %48 Log2 %82
%83 = OpFDiv %float %76 %77
%70 = OpFNegate %float %83
%88 = OpCompositeExtract %float %fragCoord 2
%87 = OpFunctionCall %float %linearDepth %88
%86 = OpExtInst %float %48 Log2 %87
%89 = OpFMul %float %86 %69
%90 = OpFAdd %float %89 %70
%85 = OpExtInst %float %48 NMax %90 %float_0
%84 = OpConvertFToU %uint %85
%93 = OpCompositeExtract %float %fragCoord 0
%96 = OpAccessChain %_ptr_Uniform_float %camera %uint_5 %uint_0
%97 = OpLoad %float %96
%99 = OpCompositeExtract %uint %tileCount 0
%98 = OpConvertUToF %float %99
%100 = OpFDiv %float %97 %98
%101 = OpFDiv %float %93 %100
%92 = OpConvertFToU %uint %101
%103 = OpCompositeExtract %float %fragCoord 1
%105 = OpAccessChain %_ptr_Uniform_float %camera %uint_5 %uint_1
%106 = OpLoad %float %105
%108 = OpCompositeExtract %uint %tileCount 1
%107 = OpConvertUToF %float %108
%109 = OpFDiv %float %106 %107
%110 = OpFDiv %float %103 %109
%102 = OpConvertFToU %uint %110
%111 = OpCompositeConstruct %v3uint %92 %102 %84
OpReturnValue %111
OpFunctionEnd
%getClusterIndex = OpFunction %uint None %112
%fragCoord_0 = OpFunctionParameter %v4float
%115 = OpLabel
%116 = OpFunctionCall %v3uint %getTile %fragCoord_0
%117 = OpCompositeExtract %uint %116 0
%118 = OpCompositeExtract %uint %116 1
%119 = OpCompositeExtract %uint %tileCount 0
%120 = OpIMul %uint %118 %119
%121 = OpIAdd %uint %117 %120
%122 = OpCompositeExtract %uint %116 2
%123 = OpCompositeExtract %uint %tileCount 0
%124 = OpIMul %uint %122 %123
%125 = OpCompositeExtract %uint %tileCount 1
%126 = OpIMul %uint %124 %125
%127 = OpIAdd %uint %121 %126
OpReturnValue %127
OpFunctionEnd
%sqDistPointAABB = OpFunction %float None %128
%point = OpFunctionParameter %v3float
%minAABB = OpFunctionParameter %v3float
%maxAABB = OpFunctionParameter %v3float
%133 = OpLabel
%sqDist = OpVariable %_ptr_Function_float Function %136
%i = OpVariable %_ptr_Function_int Function %141
OpStore %sqDist %float_0
OpStore %i %int_0
OpBranch %142
%142 = OpLabel
OpLoopMerge %143 %144 None
OpBranch %145
%145 = OpLabel
%147 = OpLoad %int %i
%149 = OpSLessThan %bool %147 %int_3
%146 = OpLogicalNot %bool %149
OpSelectionMerge %151 None
OpBranchConditional %146 %152 %151
%152 = OpLabel
OpBranch %143
%151 = OpLabel
%153 = OpLoad %int %i
%154 = OpVectorExtractDynamic %float %point %153
%155 = OpLoad %int %i
%156 = OpVectorExtractDynamic %float %minAABB %155
%157 = OpFOrdLessThan %bool %154 %156
OpSelectionMerge %158 None
OpBranchConditional %157 %159 %158
%159 = OpLabel
%160 = OpLoad %float %sqDist
%161 = OpLoad %int %i
%162 = OpVectorExtractDynamic %float %minAABB %161
%163 = OpFSub %float %162 %154
%164 = OpLoad %int %i
%165 = OpVectorExtractDynamic %float %minAABB %164
%166 = OpFSub %float %165 %154
%167 = OpFMul %float %163 %166
%168 = OpFAdd %float %160 %167
OpStore %sqDist %168
OpBranch %158
%158 = OpLabel
%169 = OpLoad %int %i
%170 = OpVectorExtractDynamic %float %maxAABB %169
%171 = OpFOrdGreaterThan %bool %154 %170
OpSelectionMerge %172 None
OpBranchConditional %171 %173 %172
%173 = OpLabel
%174 = OpLoad %float %sqDist
%175 = OpLoad %int %i
%176 = OpVectorExtractDynamic %float %maxAABB %175
%177 = OpFSub %float %154 %176
%178 = OpLoad %int %i
%179 = OpVectorExtractDynamic %float %maxAABB %178
%180 = OpFSub %float %154 %179
%181 = OpFMul %float %177 %180
%182 = OpFAdd %float %174 %181
OpStore %sqDist %182
OpBranch %172
%172 = OpLabel
OpBranch %144
%144 = OpLabel
%183 = OpLoad %int %i
%185 = OpIAdd %int %183 %int_1
OpStore %i %185
OpBranch %142
%143 = OpLabel
%186 = OpLoad %float %sqDist
OpReturnValue %186
OpFunctionEnd
%computeMain_inner = OpFunction %void None %187
%global_id = OpFunctionParameter %v3uint
%191 = OpLabel
%clusterLightCount = OpVariable %_ptr_Function_uint Function %205
%cluserLightIndices = OpVariable %_ptr_Function__arr_uint_uint_256 Function %210
%i_0 = OpVariable %_ptr_Function_uint Function %205
%lightInCluster = OpVariable %_ptr_Function_bool Function %232
%offset = OpVariable %_ptr_Function_uint Function %205
%i_1 = OpVariable %_ptr_Function_uint Function %205
%192 = OpCompositeExtract %uint %global_id 0
%193 = OpCompositeExtract %uint %global_id 1
%194 = OpCompositeExtract %uint %tileCount 0
%195 = OpIMul %uint %193 %194
%196 = OpIAdd %uint %192 %195
%197 = OpCompositeExtract %uint %global_id 2
%198 = OpCompositeExtract %uint %tileCount 0
%199 = OpIMul %uint %197 %198
%200 = OpCompositeExtract %uint %tileCount 1
%201 = OpIMul %uint %199 %200
%202 = OpIAdd %uint %196 %201
OpStore %clusterLightCount %uint_0
OpStore %i_0 %uint_0
OpBranch %212
%212 = OpLabel
OpLoopMerge %213 %214 None
OpBranch %215
%215 = OpLabel
%217 = OpLoad %uint %i_0
%220 = OpAccessChain %_ptr_StorageBuffer_uint %globalLights %uint_4
%221 = OpLoad %uint %220
%222 = OpULessThan %bool %217 %221
%216 = OpLogicalNot %bool %222
OpSelectionMerge %223 None
OpBranchConditional %216 %224 %223
%224 = OpLabel
OpBranch %213
%223 = OpLabel
%225 = OpLoad %uint %i_0
%227 = OpAccessChain %_ptr_StorageBuffer_float %globalLights %uint_5 %225 %uint_1
%228 = OpLoad %float %227
%229 = OpFOrdLessThanEqual %bool %228 %float_0
OpStore %lightInCluster %229
%234 = OpLoad %bool %lightInCluster
%233 = OpLogicalNot %bool %234
OpSelectionMerge %235 None
OpBranchConditional %233 %236 %235
%236 = OpLabel
%239 = OpAccessChain %_ptr_Uniform_mat4v4float %camera %uint_2
%240 = OpLoad %mat4v4float %239
%241 = OpLoad %uint %i_0
%243 = OpAccessChain %_ptr_StorageBuffer_v3float %globalLights %uint_5 %241 %uint_0
%244 = OpLoad %v3float %243
%245 = OpCompositeExtract %float %244 0
%246 = OpCompositeExtract %float %244 1
%247 = OpCompositeExtract %float %244 2
%249 = OpCompositeConstruct %v4float %245 %246 %247 %float_1
%250 = OpMatrixTimesVector %v4float %240 %249
%252 = OpVectorShuffle %v3float %250 %250 0 1 2
%253 = OpAccessChain %_ptr_StorageBuffer_v3float %clusters %uint_0 %202 %uint_0
%254 = OpLoad %v3float %253
%255 = OpAccessChain %_ptr_StorageBuffer_v3float %clusters %uint_0 %202 %uint_1
%256 = OpLoad %v3float %255
%251 = OpFunctionCall %float %sqDistPointAABB %252 %254 %256
%257 = OpFMul %float %228 %228
%258 = OpFOrdLessThanEqual %bool %251 %257
OpStore %lightInCluster %258
OpBranch %235
%235 = OpLabel
%259 = OpLoad %bool %lightInCluster
OpSelectionMerge %260 None
OpBranchConditional %259 %261 %260
%261 = OpLabel
%262 = OpLoad %uint %clusterLightCount
%263 = OpAccessChain %_ptr_Function_uint %cluserLightIndices %262
%264 = OpLoad %uint %i_0
OpStore %263 %264
%265 = OpLoad %uint %clusterLightCount
%266 = OpIAdd %uint %265 %uint_1
OpStore %clusterLightCount %266
OpBranch %260
%260 = OpLabel
%267 = OpLoad %uint %clusterLightCount
%268 = OpIEqual %bool %267 %uint_256
OpSelectionMerge %269 None
OpBranchConditional %268 %270 %269
%270 = OpLabel
OpBranch %213
%269 = OpLabel
OpBranch %214
%214 = OpLabel
%271 = OpLoad %uint %i_0
%272 = OpIAdd %uint %271 %uint_1
OpStore %i_0 %272
OpBranch %212
%213 = OpLabel
%273 = OpLoad %uint %clusterLightCount
%277 = OpAccessChain %_ptr_StorageBuffer_uint_0 %clusterLights %uint_0
%274 = OpAtomicIAdd %uint %277 %uint_1 %uint_0 %273
OpStore %offset %274
%279 = OpLoad %uint %offset
%280 = OpUGreaterThanEqual %bool %279 %uint_1769472
OpSelectionMerge %281 None
OpBranchConditional %280 %282 %281
%282 = OpLabel
OpReturn
%281 = OpLabel
OpStore %i_1 %uint_0
OpBranch %284
%284 = OpLabel
OpLoopMerge %285 %286 None
OpBranch %287
%287 = OpLabel
%289 = OpLoad %uint %i_1
%290 = OpLoad %uint %clusterLightCount
%291 = OpULessThan %bool %289 %290
%288 = OpLogicalNot %bool %291
OpSelectionMerge %292 None
OpBranchConditional %288 %293 %292
%293 = OpLabel
OpBranch %285
%292 = OpLabel
%294 = OpLoad %uint %offset
%295 = OpLoad %uint %i_1
%296 = OpIAdd %uint %294 %295
%297 = OpAccessChain %_ptr_StorageBuffer_uint %clusterLights %uint_2 %296
%298 = OpLoad %uint %i_1
%299 = OpAccessChain %_ptr_Function_uint %cluserLightIndices %298
%300 = OpLoad %uint %299
OpStore %297 %300
OpBranch %286
%286 = OpLabel
%301 = OpLoad %uint %i_1
%302 = OpIAdd %uint %301 %uint_1
OpStore %i_1 %302
OpBranch %284
%285 = OpLabel
%303 = OpAccessChain %_ptr_StorageBuffer_uint %clusterLights %uint_1 %202 %uint_0
%304 = OpLoad %uint %offset
OpStore %303 %304
%305 = OpAccessChain %_ptr_StorageBuffer_uint %clusterLights %uint_1 %202 %uint_1
%306 = OpLoad %uint %clusterLightCount
OpStore %305 %306
OpReturn
OpFunctionEnd
%computeMain = OpFunction %void None %307
%309 = OpLabel
%311 = OpLoad %v3uint %global_id_1
%310 = OpFunctionCall %void %computeMain_inner %311
OpReturn
OpFunctionEnd