test: Add more reported bug cases
Bug: tint:943
Bug: tint:948
Bug: tint:949
Change-Id: Ib511b69d9e4308b106de2c191bae91f5cade2507
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56770
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/test/bug/tint/943.spvasm b/test/bug/tint/943.spvasm
new file mode 100644
index 0000000..7fa5462
--- /dev/null
+++ b/test/bug/tint/943.spvasm
@@ -0,0 +1,841 @@
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 10
+; Bound: 515
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint GLCompute %main "main" %gl_LocalInvocationID %gl_GlobalInvocationID
+ OpExecutionMode %main LocalSize 1 64 1
+ OpSource GLSL 450
+ OpName %main "main"
+ OpName %coordsInBounds_vi2_vi2_ "coordsInBounds(vi2;vi2;"
+ OpName %coord "coord"
+ OpName %shape "shape"
+ OpName %setOutput_i1_f1_ "setOutput(i1;f1;"
+ OpName %flatIndex "flatIndex"
+ OpName %value "value"
+ OpName %getOutputFlatIndex_vi3_ "getOutputFlatIndex(vi3;"
+ OpName %coords "coords"
+ OpName %setOutput_i1_i1_i1_f1_ "setOutput(i1;i1;i1;f1;"
+ OpName %d0 "d0"
+ OpName %d1 "d1"
+ OpName %d2 "d2"
+ OpName %value_0 "value"
+ OpName %mm_matMul_i1_i1_i1_ "mm_matMul(i1;i1;i1;"
+ OpName %dimAOuter "dimAOuter"
+ OpName %dimInner "dimInner"
+ OpName %dimBOuter "dimBOuter"
+ OpName %mm_readA_i1_i1_ "mm_readA(i1;i1;"
+ OpName %row "row"
+ OpName %col "col"
+ OpName %mm_readB_i1_i1_ "mm_readB(i1;i1;"
+ OpName %row_0 "row"
+ OpName %col_0 "col"
+ OpName %mm_write_i1_i1_f1_ "mm_write(i1;i1;f1;"
+ OpName %row_1 "row"
+ OpName %col_1 "col"
+ OpName %value_1 "value"
+ OpName %dimAOuter_0 "dimAOuter"
+ OpName %Uniforms "Uniforms"
+ OpMemberName %Uniforms 0 "NAN"
+ OpMemberName %Uniforms 1 "aShape"
+ OpMemberName %Uniforms 2 "bShape"
+ OpMemberName %Uniforms 3 "outShape"
+ OpMemberName %Uniforms 4 "outShapeStrides"
+ OpName %_ ""
+ OpName %dimInner_0 "dimInner"
+ OpName %dimBOuter_0 "dimBOuter"
+ OpName %ssbOut "ssbOut"
+ OpMemberName %ssbOut 0 "result"
+ OpName %__0 ""
+ OpName %flatIndex_0 "flatIndex"
+ OpName %param "param"
+ OpName %param_0 "param"
+ OpName %param_1 "param"
+ OpName %tileRow "tileRow"
+ OpName %gl_LocalInvocationID "gl_LocalInvocationID"
+ OpName %tileCol "tileCol"
+ OpName %globalRow "globalRow"
+ OpName %gl_GlobalInvocationID "gl_GlobalInvocationID"
+ OpName %globalCol "globalCol"
+ OpName %numTiles "numTiles"
+ OpName %innerRow "innerRow"
+ OpName %innerCol "innerCol"
+ OpName %acc "acc"
+ OpName %tileColA "tileColA"
+ OpName %tileRowB "tileRowB"
+ OpName %t "t"
+ OpName %innerRow_0 "innerRow"
+ OpName %innerCol_0 "innerCol"
+ OpName %inputRow "inputRow"
+ OpName %inputCol "inputCol"
+ OpName %mm_Asub "mm_Asub"
+ OpName %param_2 "param"
+ OpName %param_3 "param"
+ OpName %innerRow_1 "innerRow"
+ OpName %innerCol_1 "innerCol"
+ OpName %inputRow_0 "inputRow"
+ OpName %inputCol_0 "inputCol"
+ OpName %mm_Bsub "mm_Bsub"
+ OpName %param_4 "param"
+ OpName %param_5 "param"
+ OpName %k "k"
+ OpName %inner "inner"
+ OpName %BCached "BCached"
+ OpName %innerRow_2 "innerRow"
+ OpName %ACached "ACached"
+ OpName %innerCol_2 "innerCol"
+ OpName %innerRow_3 "innerRow"
+ OpName %innerCol_3 "innerCol"
+ OpName %param_6 "param"
+ OpName %param_7 "param"
+ OpName %param_8 "param"
+ OpName %batchASize "batchASize"
+ OpName %param_9 "param"
+ OpName %param_10 "param"
+ OpName %ssbA "ssbA"
+ OpMemberName %ssbA 0 "A"
+ OpName %__1 ""
+ OpName %batch "batch"
+ OpName %batchBSize "batchBSize"
+ OpName %param_11 "param"
+ OpName %param_12 "param"
+ OpName %ssbB "ssbB"
+ OpMemberName %ssbB 0 "B"
+ OpName %__2 ""
+ OpName %outCoord "outCoord"
+ OpName %param_13 "param"
+ OpName %param_14 "param"
+ OpName %param_15 "param"
+ OpName %param_16 "param"
+ OpName %param_17 "param"
+ OpName %param_18 "param"
+ OpName %param_19 "param"
+ OpMemberDecorate %Uniforms 0 Offset 0
+ OpMemberDecorate %Uniforms 1 Offset 16
+ OpMemberDecorate %Uniforms 2 Offset 32
+ OpMemberDecorate %Uniforms 3 Offset 48
+ OpMemberDecorate %Uniforms 4 Offset 64
+ OpDecorate %Uniforms Block
+ OpDecorate %_ DescriptorSet 0
+ OpDecorate %_ Binding 3
+ OpDecorate %_runtimearr_float ArrayStride 4
+ OpMemberDecorate %ssbOut 0 NonReadable
+ OpMemberDecorate %ssbOut 0 Offset 0
+ OpDecorate %ssbOut BufferBlock
+ OpDecorate %__0 DescriptorSet 0
+ OpDecorate %__0 Binding 0
+ OpDecorate %gl_LocalInvocationID BuiltIn LocalInvocationId
+ OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
+ OpDecorate %_runtimearr_float_0 ArrayStride 4
+ OpMemberDecorate %ssbA 0 NonWritable
+ OpMemberDecorate %ssbA 0 Offset 0
+ OpDecorate %ssbA BufferBlock
+ OpDecorate %__1 DescriptorSet 0
+ OpDecorate %__1 Binding 1
+ OpDecorate %_runtimearr_float_1 ArrayStride 4
+ OpMemberDecorate %ssbB 0 NonWritable
+ OpMemberDecorate %ssbB 0 Offset 0
+ OpDecorate %ssbB BufferBlock
+ OpDecorate %__2 DescriptorSet 0
+ OpDecorate %__2 Binding 2
+ OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
+ %void = OpTypeVoid
+ %3 = OpTypeFunction %void
+ %int = OpTypeInt 32 1
+ %v2int = OpTypeVector %int 2
+ %_ptr_Function_v2int = OpTypePointer Function %v2int
+ %bool = OpTypeBool
+ %10 = OpTypeFunction %bool %_ptr_Function_v2int %_ptr_Function_v2int
+ %_ptr_Function_int = OpTypePointer Function %int
+ %float = OpTypeFloat 32
+ %_ptr_Function_float = OpTypePointer Function %float
+ %18 = OpTypeFunction %void %_ptr_Function_int %_ptr_Function_float
+ %v3int = OpTypeVector %int 3
+ %_ptr_Function_v3int = OpTypePointer Function %v3int
+ %25 = OpTypeFunction %int %_ptr_Function_v3int
+ %29 = OpTypeFunction %void %_ptr_Function_int %_ptr_Function_int %_ptr_Function_int %_ptr_Function_float
+ %36 = OpTypeFunction %void %_ptr_Function_int %_ptr_Function_int %_ptr_Function_int
+ %42 = OpTypeFunction %float %_ptr_Function_int %_ptr_Function_int
+ %51 = OpTypeFunction %void %_ptr_Function_int %_ptr_Function_int %_ptr_Function_float
+ %_ptr_Private_int = OpTypePointer Private %int
+ %dimAOuter_0 = OpVariable %_ptr_Private_int Private
+ %Uniforms = OpTypeStruct %float %v3int %v3int %v3int %v2int
+ %_ptr_Uniform_Uniforms = OpTypePointer Uniform %Uniforms
+ %_ = OpVariable %_ptr_Uniform_Uniforms Uniform
+ %int_1 = OpConstant %int 1
+ %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+ %_ptr_Uniform_int = OpTypePointer Uniform %int
+ %dimInner_0 = OpVariable %_ptr_Private_int Private
+ %uint_2 = OpConstant %uint 2
+ %dimBOuter_0 = OpVariable %_ptr_Private_int Private
+ %int_2 = OpConstant %int 2
+ %int_0 = OpConstant %int 0
+ %78 = OpConstantComposite %v2int %int_0 %int_0
+ %v2bool = OpTypeVector %bool 2
+ %_runtimearr_float = OpTypeRuntimeArray %float
+ %ssbOut = OpTypeStruct %_runtimearr_float
+ %_ptr_Uniform_ssbOut = OpTypePointer Uniform %ssbOut
+ %__0 = OpVariable %_ptr_Uniform_ssbOut Uniform
+ %_ptr_Uniform_float = OpTypePointer Uniform %float
+ %v3float = OpTypeVector %float 3
+ %int_4 = OpConstant %int 4
+ %uint_0 = OpConstant %uint 0
+ %v3uint = OpTypeVector %uint 3
+ %_ptr_Input_v3uint = OpTypePointer Input %v3uint
+ %gl_LocalInvocationID = OpVariable %_ptr_Input_v3uint Input
+ %_ptr_Input_uint = OpTypePointer Input %uint
+ %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
+ %int_64 = OpConstant %int 64
+ %_arr_float_uint_1 = OpTypeArray %float %uint_1
+ %_arr__arr_float_uint_1_uint_1 = OpTypeArray %_arr_float_uint_1 %uint_1
+ %_ptr_Function__arr__arr_float_uint_1_uint_1 = OpTypePointer Function %_arr__arr_float_uint_1_uint_1
+ %float_0 = OpConstant %float 0
+ %uint_64 = OpConstant %uint 64
+ %_arr_float_uint_64 = OpTypeArray %float %uint_64
+ %_arr__arr_float_uint_64_uint_64 = OpTypeArray %_arr_float_uint_64 %uint_64
+%_ptr_Workgroup__arr__arr_float_uint_64_uint_64 = OpTypePointer Workgroup %_arr__arr_float_uint_64_uint_64
+ %mm_Asub = OpVariable %_ptr_Workgroup__arr__arr_float_uint_64_uint_64 Workgroup
+ %_ptr_Workgroup_float = OpTypePointer Workgroup %float
+ %_arr__arr_float_uint_1_uint_64 = OpTypeArray %_arr_float_uint_1 %uint_64
+ %_ptr_Workgroup__arr__arr_float_uint_1_uint_64 = OpTypePointer Workgroup %_arr__arr_float_uint_1_uint_64
+ %mm_Bsub = OpVariable %_ptr_Workgroup__arr__arr_float_uint_1_uint_64 Workgroup
+ %uint_264 = OpConstant %uint 264
+ %_ptr_Function__arr_float_uint_1 = OpTypePointer Function %_arr_float_uint_1
+ %_runtimearr_float_0 = OpTypeRuntimeArray %float
+ %ssbA = OpTypeStruct %_runtimearr_float_0
+ %_ptr_Uniform_ssbA = OpTypePointer Uniform %ssbA
+ %__1 = OpVariable %_ptr_Uniform_ssbA Uniform
+ %batch = OpVariable %_ptr_Private_int Private
+ %_runtimearr_float_1 = OpTypeRuntimeArray %float
+ %ssbB = OpTypeStruct %_runtimearr_float_1
+ %_ptr_Uniform_ssbB = OpTypePointer Uniform %ssbB
+ %__2 = OpVariable %_ptr_Uniform_ssbB Uniform
+ %gl_WorkGroupSize = OpConstantComposite %v3uint %uint_1 %uint_64 %uint_1
+ %main = OpFunction %void None %3
+ %5 = OpLabel
+ %param_17 = OpVariable %_ptr_Function_int Function
+ %param_18 = OpVariable %_ptr_Function_int Function
+ %param_19 = OpVariable %_ptr_Function_int Function
+ %66 = OpAccessChain %_ptr_Uniform_int %_ %int_1 %uint_1
+ %67 = OpLoad %int %66
+ OpStore %dimAOuter_0 %67
+ %70 = OpAccessChain %_ptr_Uniform_int %_ %int_1 %uint_2
+ %71 = OpLoad %int %70
+ OpStore %dimInner_0 %71
+ %74 = OpAccessChain %_ptr_Uniform_int %_ %int_2 %uint_2
+ %75 = OpLoad %int %74
+ OpStore %dimBOuter_0 %75
+ %504 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_2
+ %505 = OpLoad %uint %504
+ %506 = OpBitcast %int %505
+ OpStore %batch %506
+ %508 = OpLoad %int %dimAOuter_0
+ OpStore %param_17 %508
+ %510 = OpLoad %int %dimInner_0
+ OpStore %param_18 %510
+ %512 = OpLoad %int %dimBOuter_0
+ OpStore %param_19 %512
+ %513 = OpFunctionCall %void %mm_matMul_i1_i1_i1_ %param_17 %param_18 %param_19
+ OpReturn
+ OpFunctionEnd
+ %coordsInBounds_vi2_vi2_ = OpFunction %bool None %10
+ %coord = OpFunctionParameter %_ptr_Function_v2int
+ %shape = OpFunctionParameter %_ptr_Function_v2int
+ %14 = OpLabel
+ %76 = OpLoad %v2int %coord
+ %80 = OpSGreaterThanEqual %v2bool %76 %78
+ %81 = OpAll %bool %80
+ OpSelectionMerge %83 None
+ OpBranchConditional %81 %82 %83
+ %82 = OpLabel
+ %84 = OpLoad %v2int %coord
+ %85 = OpLoad %v2int %shape
+ %86 = OpSLessThan %v2bool %84 %85
+ %87 = OpAll %bool %86
+ OpBranch %83
+ %83 = OpLabel
+ %88 = OpPhi %bool %81 %14 %87 %82
+ OpReturnValue %88
+ OpFunctionEnd
+ %setOutput_i1_f1_ = OpFunction %void None %18
+ %flatIndex = OpFunctionParameter %_ptr_Function_int
+ %value = OpFunctionParameter %_ptr_Function_float
+ %22 = OpLabel
+ %95 = OpLoad %int %flatIndex
+ %96 = OpLoad %float %value
+ %98 = OpAccessChain %_ptr_Uniform_float %__0 %int_0 %95
+ OpStore %98 %96
+ OpReturn
+ OpFunctionEnd
+ %getOutputFlatIndex_vi3_ = OpFunction %int None %25
+ %coords = OpFunctionParameter %_ptr_Function_v3int
+ %28 = OpLabel
+ %99 = OpLoad %v3int %coords
+ %101 = OpConvertSToF %v3float %99
+ %104 = OpAccessChain %_ptr_Uniform_int %_ %int_4 %uint_0
+ %105 = OpLoad %int %104
+ %106 = OpAccessChain %_ptr_Uniform_int %_ %int_4 %uint_1
+ %107 = OpLoad %int %106
+ %108 = OpCompositeConstruct %v3int %105 %107 %int_1
+ %109 = OpConvertSToF %v3float %108
+ %110 = OpDot %float %101 %109
+ %111 = OpConvertFToS %int %110
+ OpReturnValue %111
+ OpFunctionEnd
+ %setOutput_i1_i1_i1_f1_ = OpFunction %void None %29
+ %d0 = OpFunctionParameter %_ptr_Function_int
+ %d1 = OpFunctionParameter %_ptr_Function_int
+ %d2 = OpFunctionParameter %_ptr_Function_int
+ %value_0 = OpFunctionParameter %_ptr_Function_float
+ %35 = OpLabel
+ %flatIndex_0 = OpVariable %_ptr_Function_int Function
+ %param = OpVariable %_ptr_Function_v3int Function
+ %param_0 = OpVariable %_ptr_Function_int Function
+ %param_1 = OpVariable %_ptr_Function_float Function
+ %115 = OpLoad %int %d0
+ %116 = OpLoad %int %d1
+ %117 = OpLoad %int %d2
+ %118 = OpCompositeConstruct %v3int %115 %116 %117
+ OpStore %param %118
+ %120 = OpFunctionCall %int %getOutputFlatIndex_vi3_ %param
+ OpStore %flatIndex_0 %120
+ %122 = OpLoad %int %flatIndex_0
+ OpStore %param_0 %122
+ %124 = OpLoad %float %value_0
+ OpStore %param_1 %124
+ %125 = OpFunctionCall %void %setOutput_i1_f1_ %param_0 %param_1
+ OpReturn
+ OpFunctionEnd
+ %mm_matMul_i1_i1_i1_ = OpFunction %void None %36
+ %dimAOuter = OpFunctionParameter %_ptr_Function_int
+ %dimInner = OpFunctionParameter %_ptr_Function_int
+ %dimBOuter = OpFunctionParameter %_ptr_Function_int
+ %41 = OpLabel
+ %tileRow = OpVariable %_ptr_Function_int Function
+ %tileCol = OpVariable %_ptr_Function_int Function
+ %globalRow = OpVariable %_ptr_Function_int Function
+ %globalCol = OpVariable %_ptr_Function_int Function
+ %numTiles = OpVariable %_ptr_Function_int Function
+ %innerRow = OpVariable %_ptr_Function_int Function
+ %innerCol = OpVariable %_ptr_Function_int Function
+ %acc = OpVariable %_ptr_Function__arr__arr_float_uint_1_uint_1 Function
+ %tileColA = OpVariable %_ptr_Function_int Function
+ %tileRowB = OpVariable %_ptr_Function_int Function
+ %t = OpVariable %_ptr_Function_int Function
+ %innerRow_0 = OpVariable %_ptr_Function_int Function
+ %innerCol_0 = OpVariable %_ptr_Function_int Function
+ %inputRow = OpVariable %_ptr_Function_int Function
+ %inputCol = OpVariable %_ptr_Function_int Function
+ %param_2 = OpVariable %_ptr_Function_int Function
+ %param_3 = OpVariable %_ptr_Function_int Function
+ %innerRow_1 = OpVariable %_ptr_Function_int Function
+ %innerCol_1 = OpVariable %_ptr_Function_int Function
+ %inputRow_0 = OpVariable %_ptr_Function_int Function
+ %inputCol_0 = OpVariable %_ptr_Function_int Function
+ %param_4 = OpVariable %_ptr_Function_int Function
+ %param_5 = OpVariable %_ptr_Function_int Function
+ %k = OpVariable %_ptr_Function_int Function
+ %inner = OpVariable %_ptr_Function_int Function
+ %BCached = OpVariable %_ptr_Function__arr_float_uint_1 Function
+ %innerRow_2 = OpVariable %_ptr_Function_int Function
+ %ACached = OpVariable %_ptr_Function_float Function
+ %innerCol_2 = OpVariable %_ptr_Function_int Function
+ %innerRow_3 = OpVariable %_ptr_Function_int Function
+ %innerCol_3 = OpVariable %_ptr_Function_int Function
+ %param_6 = OpVariable %_ptr_Function_int Function
+ %param_7 = OpVariable %_ptr_Function_int Function
+ %param_8 = OpVariable %_ptr_Function_float Function
+ %131 = OpAccessChain %_ptr_Input_uint %gl_LocalInvocationID %uint_1
+ %132 = OpLoad %uint %131
+ %133 = OpBitcast %int %132
+ %134 = OpIMul %int %133 %int_1
+ OpStore %tileRow %134
+ %136 = OpAccessChain %_ptr_Input_uint %gl_LocalInvocationID %uint_0
+ %137 = OpLoad %uint %136
+ %138 = OpBitcast %int %137
+ %139 = OpIMul %int %138 %int_1
+ OpStore %tileCol %139
+ %142 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_1
+ %143 = OpLoad %uint %142
+ %144 = OpBitcast %int %143
+ %145 = OpIMul %int %144 %int_1
+ OpStore %globalRow %145
+ %147 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0
+ %148 = OpLoad %uint %147
+ %149 = OpBitcast %int %148
+ %150 = OpIMul %int %149 %int_1
+ OpStore %globalCol %150
+ %152 = OpLoad %int %dimInner
+ %153 = OpISub %int %152 %int_1
+ %155 = OpSDiv %int %153 %int_64
+ %156 = OpIAdd %int %155 %int_1
+ OpStore %numTiles %156
+ OpStore %innerRow %int_0
+ OpBranch %158
+ %158 = OpLabel
+ OpLoopMerge %160 %161 None
+ OpBranch %162
+ %162 = OpLabel
+ %163 = OpLoad %int %innerRow
+ %164 = OpSLessThan %bool %163 %int_1
+ OpBranchConditional %164 %159 %160
+ %159 = OpLabel
+ OpStore %innerCol %int_0
+ OpBranch %166
+ %166 = OpLabel
+ OpLoopMerge %168 %169 None
+ OpBranch %170
+ %170 = OpLabel
+ %171 = OpLoad %int %innerCol
+ %172 = OpSLessThan %bool %171 %int_1
+ OpBranchConditional %172 %167 %168
+ %167 = OpLabel
+ %177 = OpLoad %int %innerRow
+ %178 = OpLoad %int %innerCol
+ %180 = OpAccessChain %_ptr_Function_float %acc %177 %178
+ OpStore %180 %float_0
+ OpBranch %169
+ %169 = OpLabel
+ %181 = OpLoad %int %innerCol
+ %182 = OpIAdd %int %181 %int_1
+ OpStore %innerCol %182
+ OpBranch %166
+ %168 = OpLabel
+ OpBranch %161
+ %161 = OpLabel
+ %183 = OpLoad %int %innerRow
+ %184 = OpIAdd %int %183 %int_1
+ OpStore %innerRow %184
+ OpBranch %158
+ %160 = OpLabel
+ %186 = OpAccessChain %_ptr_Input_uint %gl_LocalInvocationID %uint_0
+ %187 = OpLoad %uint %186
+ %188 = OpBitcast %int %187
+ %189 = OpIMul %int %188 %int_64
+ OpStore %tileColA %189
+ %191 = OpAccessChain %_ptr_Input_uint %gl_LocalInvocationID %uint_1
+ %192 = OpLoad %uint %191
+ %193 = OpBitcast %int %192
+ %194 = OpIMul %int %193 %int_1
+ OpStore %tileRowB %194
+ OpStore %t %int_0
+ OpBranch %196
+ %196 = OpLabel
+ OpLoopMerge %198 %199 None
+ OpBranch %200
+ %200 = OpLabel
+ %201 = OpLoad %int %t
+ %202 = OpLoad %int %numTiles
+ %203 = OpSLessThan %bool %201 %202
+ OpBranchConditional %203 %197 %198
+ %197 = OpLabel
+ OpStore %innerRow_0 %int_0
+ OpBranch %205
+ %205 = OpLabel
+ OpLoopMerge %207 %208 None
+ OpBranch %209
+ %209 = OpLabel
+ %210 = OpLoad %int %innerRow_0
+ %211 = OpSLessThan %bool %210 %int_1
+ OpBranchConditional %211 %206 %207
+ %206 = OpLabel
+ OpStore %innerCol_0 %int_0
+ OpBranch %213
+ %213 = OpLabel
+ OpLoopMerge %215 %216 None
+ OpBranch %217
+ %217 = OpLabel
+ %218 = OpLoad %int %innerCol_0
+ %219 = OpSLessThan %bool %218 %int_64
+ OpBranchConditional %219 %214 %215
+ %214 = OpLabel
+ %221 = OpLoad %int %tileRow
+ %222 = OpLoad %int %innerRow_0
+ %223 = OpIAdd %int %221 %222
+ OpStore %inputRow %223
+ %225 = OpLoad %int %tileColA
+ %226 = OpLoad %int %innerCol_0
+ %227 = OpIAdd %int %225 %226
+ OpStore %inputCol %227
+ %233 = OpLoad %int %inputRow
+ %234 = OpLoad %int %inputCol
+ %235 = OpLoad %int %globalRow
+ %236 = OpLoad %int %innerRow_0
+ %237 = OpIAdd %int %235 %236
+ %238 = OpLoad %int %t
+ %239 = OpIMul %int %238 %int_64
+ %240 = OpLoad %int %inputCol
+ %241 = OpIAdd %int %239 %240
+ OpStore %param_2 %237
+ OpStore %param_3 %241
+ %244 = OpFunctionCall %float %mm_readA_i1_i1_ %param_2 %param_3
+ %246 = OpAccessChain %_ptr_Workgroup_float %mm_Asub %233 %234
+ OpStore %246 %244
+ OpBranch %216
+ %216 = OpLabel
+ %247 = OpLoad %int %innerCol_0
+ %248 = OpIAdd %int %247 %int_1
+ OpStore %innerCol_0 %248
+ OpBranch %213
+ %215 = OpLabel
+ OpBranch %208
+ %208 = OpLabel
+ %249 = OpLoad %int %innerRow_0
+ %250 = OpIAdd %int %249 %int_1
+ OpStore %innerRow_0 %250
+ OpBranch %205
+ %207 = OpLabel
+ OpStore %innerRow_1 %int_0
+ OpBranch %252
+ %252 = OpLabel
+ OpLoopMerge %254 %255 None
+ OpBranch %256
+ %256 = OpLabel
+ %257 = OpLoad %int %innerRow_1
+ %258 = OpSLessThan %bool %257 %int_1
+ OpBranchConditional %258 %253 %254
+ %253 = OpLabel
+ OpStore %innerCol_1 %int_0
+ OpBranch %260
+ %260 = OpLabel
+ OpLoopMerge %262 %263 None
+ OpBranch %264
+ %264 = OpLabel
+ %265 = OpLoad %int %innerCol_1
+ %266 = OpSLessThan %bool %265 %int_1
+ OpBranchConditional %266 %261 %262
+ %261 = OpLabel
+ %268 = OpLoad %int %tileRowB
+ %269 = OpLoad %int %innerRow_1
+ %270 = OpIAdd %int %268 %269
+ OpStore %inputRow_0 %270
+ %272 = OpLoad %int %tileCol
+ %273 = OpLoad %int %innerCol_1
+ %274 = OpIAdd %int %272 %273
+ OpStore %inputCol_0 %274
+ %278 = OpLoad %int %inputRow_0
+ %279 = OpLoad %int %inputCol_0
+ %280 = OpLoad %int %t
+ %281 = OpIMul %int %280 %int_64
+ %282 = OpLoad %int %inputRow_0
+ %283 = OpIAdd %int %281 %282
+ %284 = OpLoad %int %globalCol
+ %285 = OpLoad %int %innerCol_1
+ %286 = OpIAdd %int %284 %285
+ OpStore %param_4 %283
+ OpStore %param_5 %286
+ %289 = OpFunctionCall %float %mm_readB_i1_i1_ %param_4 %param_5
+ %290 = OpAccessChain %_ptr_Workgroup_float %mm_Bsub %278 %279
+ OpStore %290 %289
+ OpBranch %263
+ %263 = OpLabel
+ %291 = OpLoad %int %innerCol_1
+ %292 = OpIAdd %int %291 %int_1
+ OpStore %innerCol_1 %292
+ OpBranch %260
+ %262 = OpLabel
+ OpBranch %255
+ %255 = OpLabel
+ %293 = OpLoad %int %innerRow_1
+ %294 = OpIAdd %int %293 %int_1
+ OpStore %innerRow_1 %294
+ OpBranch %252
+ %254 = OpLabel
+ OpControlBarrier %uint_2 %uint_2 %uint_264
+ OpStore %k %int_0
+ OpBranch %297
+ %297 = OpLabel
+ OpLoopMerge %299 %300 None
+ OpBranch %301
+ %301 = OpLabel
+ %302 = OpLoad %int %k
+ %303 = OpSLessThan %bool %302 %int_64
+ OpBranchConditional %303 %298 %299
+ %298 = OpLabel
+ OpStore %inner %int_0
+ OpBranch %305
+ %305 = OpLabel
+ OpLoopMerge %307 %308 None
+ OpBranch %309
+ %309 = OpLabel
+ %310 = OpLoad %int %inner
+ %311 = OpSLessThan %bool %310 %int_1
+ OpBranchConditional %311 %306 %307
+ %306 = OpLabel
+ %314 = OpLoad %int %inner
+ %315 = OpLoad %int %k
+ %316 = OpLoad %int %tileCol
+ %317 = OpLoad %int %inner
+ %318 = OpIAdd %int %316 %317
+ %319 = OpAccessChain %_ptr_Workgroup_float %mm_Bsub %315 %318
+ %320 = OpLoad %float %319
+ %321 = OpAccessChain %_ptr_Function_float %BCached %314
+ OpStore %321 %320
+ OpBranch %308
+ %308 = OpLabel
+ %322 = OpLoad %int %inner
+ %323 = OpIAdd %int %322 %int_1
+ OpStore %inner %323
+ OpBranch %305
+ %307 = OpLabel
+ OpStore %innerRow_2 %int_0
+ OpBranch %325
+ %325 = OpLabel
+ OpLoopMerge %327 %328 None
+ OpBranch %329
+ %329 = OpLabel
+ %330 = OpLoad %int %innerRow_2
+ %331 = OpSLessThan %bool %330 %int_1
+ OpBranchConditional %331 %326 %327
+ %326 = OpLabel
+ %333 = OpLoad %int %tileRow
+ %334 = OpLoad %int %innerRow_2
+ %335 = OpIAdd %int %333 %334
+ %336 = OpLoad %int %k
+ %337 = OpAccessChain %_ptr_Workgroup_float %mm_Asub %335 %336
+ %338 = OpLoad %float %337
+ OpStore %ACached %338
+ OpStore %innerCol_2 %int_0
+ OpBranch %340
+ %340 = OpLabel
+ OpLoopMerge %342 %343 None
+ OpBranch %344
+ %344 = OpLabel
+ %345 = OpLoad %int %innerCol_2
+ %346 = OpSLessThan %bool %345 %int_1
+ OpBranchConditional %346 %341 %342
+ %341 = OpLabel
+ %347 = OpLoad %int %innerRow_2
+ %348 = OpLoad %int %innerCol_2
+ %349 = OpLoad %float %ACached
+ %350 = OpLoad %int %innerCol_2
+ %351 = OpAccessChain %_ptr_Function_float %BCached %350
+ %352 = OpLoad %float %351
+ %353 = OpFMul %float %349 %352
+ %354 = OpAccessChain %_ptr_Function_float %acc %347 %348
+ %355 = OpLoad %float %354
+ %356 = OpFAdd %float %355 %353
+ %357 = OpAccessChain %_ptr_Function_float %acc %347 %348
+ OpStore %357 %356
+ OpBranch %343
+ %343 = OpLabel
+ %358 = OpLoad %int %innerCol_2
+ %359 = OpIAdd %int %358 %int_1
+ OpStore %innerCol_2 %359
+ OpBranch %340
+ %342 = OpLabel
+ OpBranch %328
+ %328 = OpLabel
+ %360 = OpLoad %int %innerRow_2
+ %361 = OpIAdd %int %360 %int_1
+ OpStore %innerRow_2 %361
+ OpBranch %325
+ %327 = OpLabel
+ OpBranch %300
+ %300 = OpLabel
+ %362 = OpLoad %int %k
+ %363 = OpIAdd %int %362 %int_1
+ OpStore %k %363
+ OpBranch %297
+ %299 = OpLabel
+ OpControlBarrier %uint_2 %uint_2 %uint_264
+ OpBranch %199
+ %199 = OpLabel
+ %364 = OpLoad %int %t
+ %365 = OpIAdd %int %364 %int_1
+ OpStore %t %365
+ OpBranch %196
+ %198 = OpLabel
+ OpStore %innerRow_3 %int_0
+ OpBranch %367
+ %367 = OpLabel
+ OpLoopMerge %369 %370 None
+ OpBranch %371
+ %371 = OpLabel
+ %372 = OpLoad %int %innerRow_3
+ %373 = OpSLessThan %bool %372 %int_1
+ OpBranchConditional %373 %368 %369
+ %368 = OpLabel
+ OpStore %innerCol_3 %int_0
+ OpBranch %375
+ %375 = OpLabel
+ OpLoopMerge %377 %378 None
+ OpBranch %379
+ %379 = OpLabel
+ %380 = OpLoad %int %innerCol_3
+ %381 = OpSLessThan %bool %380 %int_1
+ OpBranchConditional %381 %376 %377
+ %376 = OpLabel
+ %382 = OpLoad %int %globalCol
+ %383 = OpLoad %int %innerCol_3
+ %384 = OpIAdd %int %382 %383
+ %385 = OpLoad %int %dimBOuter
+ %386 = OpSLessThan %bool %384 %385
+ OpSelectionMerge %388 None
+ OpBranchConditional %386 %387 %388
+ %387 = OpLabel
+ %389 = OpLoad %int %globalRow
+ %390 = OpLoad %int %innerRow_3
+ %391 = OpIAdd %int %389 %390
+ %392 = OpLoad %int %dimAOuter
+ %393 = OpSLessThan %bool %391 %392
+ OpBranch %388
+ %388 = OpLabel
+ %394 = OpPhi %bool %386 %376 %393 %387
+ OpSelectionMerge %396 None
+ OpBranchConditional %394 %395 %396
+ %395 = OpLabel
+ %397 = OpLoad %int %globalRow
+ %398 = OpLoad %int %innerRow_3
+ %399 = OpIAdd %int %397 %398
+ %400 = OpLoad %int %globalCol
+ %401 = OpLoad %int %innerCol_3
+ %402 = OpIAdd %int %400 %401
+ %403 = OpLoad %int %innerRow_3
+ %404 = OpLoad %int %innerCol_3
+ OpStore %param_6 %399
+ OpStore %param_7 %402
+ %408 = OpAccessChain %_ptr_Function_float %acc %403 %404
+ %409 = OpLoad %float %408
+ OpStore %param_8 %409
+ %410 = OpFunctionCall %void %mm_write_i1_i1_f1_ %param_6 %param_7 %param_8
+ OpBranch %396
+ %396 = OpLabel
+ OpBranch %378
+ %378 = OpLabel
+ %411 = OpLoad %int %innerCol_3
+ %412 = OpIAdd %int %411 %int_1
+ OpStore %innerCol_3 %412
+ OpBranch %375
+ %377 = OpLabel
+ OpBranch %370
+ %370 = OpLabel
+ %413 = OpLoad %int %innerRow_3
+ %414 = OpIAdd %int %413 %int_1
+ OpStore %innerRow_3 %414
+ OpBranch %367
+ %369 = OpLabel
+ OpReturn
+ OpFunctionEnd
+ %mm_readA_i1_i1_ = OpFunction %float None %42
+ %row = OpFunctionParameter %_ptr_Function_int
+ %col = OpFunctionParameter %_ptr_Function_int
+ %46 = OpLabel
+ %batchASize = OpVariable %_ptr_Function_int Function
+ %param_9 = OpVariable %_ptr_Function_v2int Function
+ %param_10 = OpVariable %_ptr_Function_v2int Function
+ %430 = OpVariable %_ptr_Function_float Function
+ %416 = OpAccessChain %_ptr_Uniform_int %_ %int_1 %uint_1
+ %417 = OpLoad %int %416
+ %418 = OpAccessChain %_ptr_Uniform_int %_ %int_1 %uint_2
+ %419 = OpLoad %int %418
+ %420 = OpIMul %int %417 %419
+ OpStore %batchASize %420
+ %421 = OpLoad %int %row
+ %422 = OpLoad %int %col
+ %423 = OpCompositeConstruct %v2int %421 %422
+ %424 = OpLoad %int %dimAOuter_0
+ %425 = OpLoad %int %dimInner_0
+ %426 = OpCompositeConstruct %v2int %424 %425
+ OpStore %param_9 %423
+ OpStore %param_10 %426
+ %429 = OpFunctionCall %bool %coordsInBounds_vi2_vi2_ %param_9 %param_10
+ OpSelectionMerge %432 None
+ OpBranchConditional %429 %431 %449
+ %431 = OpLabel
+ %438 = OpLoad %int %batch
+ %439 = OpLoad %int %batchASize
+ %440 = OpIMul %int %438 %439
+ %441 = OpLoad %int %row
+ %442 = OpLoad %int %dimInner_0
+ %443 = OpIMul %int %441 %442
+ %444 = OpIAdd %int %440 %443
+ %445 = OpLoad %int %col
+ %446 = OpIAdd %int %444 %445
+ %447 = OpAccessChain %_ptr_Uniform_float %__1 %int_0 %446
+ %448 = OpLoad %float %447
+ OpStore %430 %448
+ OpBranch %432
+ %449 = OpLabel
+ OpStore %430 %float_0
+ OpBranch %432
+ %432 = OpLabel
+ %450 = OpLoad %float %430
+ OpReturnValue %450
+ OpFunctionEnd
+ %mm_readB_i1_i1_ = OpFunction %float None %42
+ %row_0 = OpFunctionParameter %_ptr_Function_int
+ %col_0 = OpFunctionParameter %_ptr_Function_int
+ %50 = OpLabel
+ %batchBSize = OpVariable %_ptr_Function_int Function
+ %param_11 = OpVariable %_ptr_Function_v2int Function
+ %param_12 = OpVariable %_ptr_Function_v2int Function
+ %468 = OpVariable %_ptr_Function_float Function
+ %454 = OpAccessChain %_ptr_Uniform_int %_ %int_2 %uint_1
+ %455 = OpLoad %int %454
+ %456 = OpAccessChain %_ptr_Uniform_int %_ %int_2 %uint_2
+ %457 = OpLoad %int %456
+ %458 = OpIMul %int %455 %457
+ OpStore %batchBSize %458
+ %459 = OpLoad %int %row_0
+ %460 = OpLoad %int %col_0
+ %461 = OpCompositeConstruct %v2int %459 %460
+ %462 = OpLoad %int %dimInner_0
+ %463 = OpLoad %int %dimBOuter_0
+ %464 = OpCompositeConstruct %v2int %462 %463
+ OpStore %param_11 %461
+ OpStore %param_12 %464
+ %467 = OpFunctionCall %bool %coordsInBounds_vi2_vi2_ %param_11 %param_12
+ OpSelectionMerge %470 None
+ OpBranchConditional %467 %469 %486
+ %469 = OpLabel
+ %475 = OpLoad %int %batch
+ %476 = OpLoad %int %batchBSize
+ %477 = OpIMul %int %475 %476
+ %478 = OpLoad %int %row_0
+ %479 = OpLoad %int %dimBOuter_0
+ %480 = OpIMul %int %478 %479
+ %481 = OpIAdd %int %477 %480
+ %482 = OpLoad %int %col_0
+ %483 = OpIAdd %int %481 %482
+ %484 = OpAccessChain %_ptr_Uniform_float %__2 %int_0 %483
+ %485 = OpLoad %float %484
+ OpStore %468 %485
+ OpBranch %470
+ %486 = OpLabel
+ OpStore %468 %float_0
+ OpBranch %470
+ %470 = OpLabel
+ %487 = OpLoad %float %468
+ OpReturnValue %487
+ OpFunctionEnd
+ %mm_write_i1_i1_f1_ = OpFunction %void None %51
+ %row_1 = OpFunctionParameter %_ptr_Function_int
+ %col_1 = OpFunctionParameter %_ptr_Function_int
+ %value_1 = OpFunctionParameter %_ptr_Function_float
+ %56 = OpLabel
+ %outCoord = OpVariable %_ptr_Function_v3int Function
+ %param_13 = OpVariable %_ptr_Function_int Function
+ %param_14 = OpVariable %_ptr_Function_int Function
+ %param_15 = OpVariable %_ptr_Function_int Function
+ %param_16 = OpVariable %_ptr_Function_float Function
+ %491 = OpLoad %int %batch
+ %492 = OpLoad %int %row_1
+ %493 = OpLoad %int %col_1
+ %494 = OpCompositeConstruct %v3int %491 %492 %493
+ OpStore %outCoord %494
+ %496 = OpLoad %int %batch
+ OpStore %param_13 %496
+ %498 = OpLoad %int %row_1
+ OpStore %param_14 %498
+ %500 = OpLoad %int %col_1
+ OpStore %param_15 %500
+ %502 = OpLoad %float %value_1
+ OpStore %param_16 %502
+ %503 = OpFunctionCall %void %setOutput_i1_i1_i1_f1_ %param_13 %param_14 %param_15 %param_16
+ OpReturn
+ OpFunctionEnd
diff --git a/test/bug/tint/943.spvasm.expected.hlsl b/test/bug/tint/943.spvasm.expected.hlsl
new file mode 100644
index 0000000..8751dc5
--- /dev/null
+++ b/test/bug/tint/943.spvasm.expected.hlsl
@@ -0,0 +1,512 @@
+static int dimAOuter_1 = 0;
+cbuffer cbuffer_x_48 : register(b3, space0) {
+ uint4 x_48[5];
+};
+static int dimInner_1 = 0;
+static int dimBOuter_1 = 0;
+RWByteAddressBuffer x_54 : register(u0, space0);
+static uint3 gl_LocalInvocationID = uint3(0u, 0u, 0u);
+static uint3 gl_GlobalInvocationID = uint3(0u, 0u, 0u);
+
+struct tint_array_wrapper_1 {
+ float arr[64];
+};
+struct tint_array_wrapper {
+ tint_array_wrapper_1 arr[64];
+};
+
+groupshared tint_array_wrapper mm_Asub;
+
+struct tint_array_wrapper_3 {
+ float arr[1];
+};
+struct tint_array_wrapper_2 {
+ tint_array_wrapper_3 arr[64];
+};
+
+groupshared tint_array_wrapper_2 mm_Bsub;
+ByteAddressBuffer x_165 : register(t1, space0);
+static int batch = 0;
+ByteAddressBuffer x_185 : register(t2, space0);
+
+bool coordsInBounds_vi2_vi2_(inout int2 coord, inout int2 shape) {
+ bool x_87 = false;
+ bool x_88_phi = false;
+ const int2 x_76 = coord;
+ const bool x_81 = all((x_76 >= int2(0, 0)));
+ x_88_phi = x_81;
+ if (x_81) {
+ const int2 x_84 = coord;
+ const int2 x_85 = shape;
+ x_87 = all((x_84 < x_85));
+ x_88_phi = x_87;
+ }
+ const bool x_88 = x_88_phi;
+ return x_88;
+}
+
+float mm_readA_i1_i1_(inout int row, inout int col) {
+ int batchASize = 0;
+ int2 param_10 = int2(0, 0);
+ int2 param_11 = int2(0, 0);
+ float x_430 = 0.0f;
+ const uint scalar_offset = (20u) / 4;
+ const int x_417 = asint(x_48[scalar_offset / 4][scalar_offset % 4]);
+ const uint scalar_offset_1 = (24u) / 4;
+ const int x_419 = asint(x_48[scalar_offset_1 / 4][scalar_offset_1 % 4]);
+ batchASize = (x_417 * x_419);
+ const int x_421 = row;
+ const int x_422 = col;
+ const int x_424 = dimAOuter_1;
+ const int x_425 = dimInner_1;
+ param_10 = int2(x_421, x_422);
+ param_11 = int2(x_424, x_425);
+ const bool x_429 = coordsInBounds_vi2_vi2_(param_10, param_11);
+ if (x_429) {
+ const int x_438 = batch;
+ const int x_439 = batchASize;
+ const int x_441 = row;
+ const int x_442 = dimInner_1;
+ const int x_445 = col;
+ const float x_448 = asfloat(x_165.Load((4u * uint((((x_438 * x_439) + (x_441 * x_442)) + x_445)))));
+ x_430 = x_448;
+ } else {
+ x_430 = 0.0f;
+ }
+ const float x_450 = x_430;
+ return x_450;
+}
+
+float mm_readB_i1_i1_(inout int row_1, inout int col_1) {
+ int batchBSize = 0;
+ int2 param_12 = int2(0, 0);
+ int2 param_13 = int2(0, 0);
+ float x_468 = 0.0f;
+ const uint scalar_offset_2 = (36u) / 4;
+ const int x_455 = asint(x_48[scalar_offset_2 / 4][scalar_offset_2 % 4]);
+ const uint scalar_offset_3 = (40u) / 4;
+ const int x_457 = asint(x_48[scalar_offset_3 / 4][scalar_offset_3 % 4]);
+ batchBSize = (x_455 * x_457);
+ const int x_459 = row_1;
+ const int x_460 = col_1;
+ const int x_462 = dimInner_1;
+ const int x_463 = dimBOuter_1;
+ param_12 = int2(x_459, x_460);
+ param_13 = int2(x_462, x_463);
+ const bool x_467 = coordsInBounds_vi2_vi2_(param_12, param_13);
+ if (x_467) {
+ const int x_475 = batch;
+ const int x_476 = batchBSize;
+ const int x_478 = row_1;
+ const int x_479 = dimBOuter_1;
+ const int x_482 = col_1;
+ const float x_485 = asfloat(x_185.Load((4u * uint((((x_475 * x_476) + (x_478 * x_479)) + x_482)))));
+ x_468 = x_485;
+ } else {
+ x_468 = 0.0f;
+ }
+ const float x_487 = x_468;
+ return x_487;
+}
+
+int getOutputFlatIndex_vi3_(inout int3 coords) {
+ const int3 x_99 = coords;
+ const uint scalar_offset_4 = (64u) / 4;
+ const int x_105 = asint(x_48[scalar_offset_4 / 4][scalar_offset_4 % 4]);
+ const uint scalar_offset_5 = (68u) / 4;
+ const int x_107 = asint(x_48[scalar_offset_5 / 4][scalar_offset_5 % 4]);
+ return int(dot(float3(x_99), float3(int3(x_105, x_107, 1))));
+}
+
+void setOutput_i1_f1_(inout int flatIndex, inout float value) {
+ const int x_95 = flatIndex;
+ const float x_96 = value;
+ x_54.Store((4u * uint(x_95)), asuint(x_96));
+ return;
+}
+
+void setOutput_i1_i1_i1_f1_(inout int d0, inout int d1, inout int d2, inout float value_1) {
+ int flatIndex_1 = 0;
+ int3 param = int3(0, 0, 0);
+ int param_1 = 0;
+ float param_2 = 0.0f;
+ const int x_115 = d0;
+ const int x_116 = d1;
+ const int x_117 = d2;
+ param = int3(x_115, x_116, x_117);
+ const int x_120 = getOutputFlatIndex_vi3_(param);
+ flatIndex_1 = x_120;
+ const int x_122 = flatIndex_1;
+ param_1 = x_122;
+ const float x_124 = value_1;
+ param_2 = x_124;
+ setOutput_i1_f1_(param_1, param_2);
+ return;
+}
+
+void mm_write_i1_i1_f1_(inout int row_2, inout int col_2, inout float value_2) {
+ int3 outCoord = int3(0, 0, 0);
+ int param_14 = 0;
+ int param_15 = 0;
+ int param_16 = 0;
+ float param_17 = 0.0f;
+ const int x_491 = batch;
+ const int x_492 = row_2;
+ const int x_493 = col_2;
+ outCoord = int3(x_491, x_492, x_493);
+ const int x_496 = batch;
+ param_14 = x_496;
+ const int x_498 = row_2;
+ param_15 = x_498;
+ const int x_500 = col_2;
+ param_16 = x_500;
+ const float x_502 = value_2;
+ param_17 = x_502;
+ setOutput_i1_i1_i1_f1_(param_14, param_15, param_16, param_17);
+ return;
+}
+
+struct tint_array_wrapper_4 {
+ tint_array_wrapper_3 arr[1];
+};
+
+void mm_matMul_i1_i1_i1_(inout int dimAOuter, inout int dimInner, inout int dimBOuter) {
+ int tileRow = 0;
+ int tileCol = 0;
+ int globalRow = 0;
+ int globalCol = 0;
+ int numTiles = 0;
+ int innerRow = 0;
+ int innerCol = 0;
+ tint_array_wrapper_4 acc = (tint_array_wrapper_4)0;
+ int tileColA = 0;
+ int tileRowB = 0;
+ int t = 0;
+ int innerRow_1 = 0;
+ int innerCol_1 = 0;
+ int inputRow = 0;
+ int inputCol = 0;
+ int param_3 = 0;
+ int param_4 = 0;
+ int innerRow_2 = 0;
+ int innerCol_2 = 0;
+ int inputRow_1 = 0;
+ int inputCol_1 = 0;
+ int param_5 = 0;
+ int param_6 = 0;
+ int k = 0;
+ int inner = 0;
+ tint_array_wrapper_3 BCached = (tint_array_wrapper_3)0;
+ int innerRow_3 = 0;
+ float ACached = 0.0f;
+ int innerCol_3 = 0;
+ int innerRow_4 = 0;
+ int innerCol_4 = 0;
+ int param_7 = 0;
+ int param_8 = 0;
+ float param_9 = 0.0f;
+ const uint x_132 = gl_LocalInvocationID.y;
+ tileRow = (asint(x_132) * 1);
+ const uint x_137 = gl_LocalInvocationID.x;
+ tileCol = (asint(x_137) * 1);
+ const uint x_143 = gl_GlobalInvocationID.y;
+ globalRow = (asint(x_143) * 1);
+ const uint x_148 = gl_GlobalInvocationID.x;
+ globalCol = (asint(x_148) * 1);
+ const int x_152 = dimInner;
+ numTiles = (((x_152 - 1) / 64) + 1);
+ innerRow = 0;
+ while (true) {
+ const int x_163 = innerRow;
+ if ((x_163 < 1)) {
+ } else {
+ break;
+ }
+ innerCol = 0;
+ while (true) {
+ const int x_171 = innerCol;
+ if ((x_171 < 1)) {
+ } else {
+ break;
+ }
+ const int x_177 = innerRow;
+ const int x_178 = innerCol;
+ acc.arr[x_177].arr[x_178] = 0.0f;
+ {
+ const int x_181 = innerCol;
+ innerCol = (x_181 + 1);
+ }
+ }
+ {
+ const int x_183 = innerRow;
+ innerRow = (x_183 + 1);
+ }
+ }
+ const uint x_187 = gl_LocalInvocationID.x;
+ tileColA = (asint(x_187) * 64);
+ const uint x_192 = gl_LocalInvocationID.y;
+ tileRowB = (asint(x_192) * 1);
+ t = 0;
+ while (true) {
+ const int x_201 = t;
+ const int x_202 = numTiles;
+ if ((x_201 < x_202)) {
+ } else {
+ break;
+ }
+ innerRow_1 = 0;
+ while (true) {
+ const int x_210 = innerRow_1;
+ if ((x_210 < 1)) {
+ } else {
+ break;
+ }
+ innerCol_1 = 0;
+ while (true) {
+ const int x_218 = innerCol_1;
+ if ((x_218 < 64)) {
+ } else {
+ break;
+ }
+ const int x_221 = tileRow;
+ const int x_222 = innerRow_1;
+ inputRow = (x_221 + x_222);
+ const int x_225 = tileColA;
+ const int x_226 = innerCol_1;
+ inputCol = (x_225 + x_226);
+ const int x_233 = inputRow;
+ const int x_234 = inputCol;
+ const int x_235 = globalRow;
+ const int x_236 = innerRow_1;
+ const int x_238 = t;
+ const int x_240 = inputCol;
+ param_3 = (x_235 + x_236);
+ param_4 = ((x_238 * 64) + x_240);
+ const float x_244 = mm_readA_i1_i1_(param_3, param_4);
+ mm_Asub.arr[x_233].arr[x_234] = x_244;
+ {
+ const int x_247 = innerCol_1;
+ innerCol_1 = (x_247 + 1);
+ }
+ }
+ {
+ const int x_249 = innerRow_1;
+ innerRow_1 = (x_249 + 1);
+ }
+ }
+ innerRow_2 = 0;
+ while (true) {
+ const int x_257 = innerRow_2;
+ if ((x_257 < 1)) {
+ } else {
+ break;
+ }
+ innerCol_2 = 0;
+ while (true) {
+ const int x_265 = innerCol_2;
+ if ((x_265 < 1)) {
+ } else {
+ break;
+ }
+ const int x_268 = tileRowB;
+ const int x_269 = innerRow_2;
+ inputRow_1 = (x_268 + x_269);
+ const int x_272 = tileCol;
+ const int x_273 = innerCol_2;
+ inputCol_1 = (x_272 + x_273);
+ const int x_278 = inputRow_1;
+ const int x_279 = inputCol_1;
+ const int x_280 = t;
+ const int x_282 = inputRow_1;
+ const int x_284 = globalCol;
+ const int x_285 = innerCol_2;
+ param_5 = ((x_280 * 64) + x_282);
+ param_6 = (x_284 + x_285);
+ const float x_289 = mm_readB_i1_i1_(param_5, param_6);
+ mm_Bsub.arr[x_278].arr[x_279] = x_289;
+ {
+ const int x_291 = innerCol_2;
+ innerCol_2 = (x_291 + 1);
+ }
+ }
+ {
+ const int x_293 = innerRow_2;
+ innerRow_2 = (x_293 + 1);
+ }
+ }
+ GroupMemoryBarrierWithGroupSync();
+ k = 0;
+ while (true) {
+ const int x_302 = k;
+ if ((x_302 < 64)) {
+ } else {
+ break;
+ }
+ inner = 0;
+ while (true) {
+ const int x_310 = inner;
+ if ((x_310 < 1)) {
+ } else {
+ break;
+ }
+ const int x_314 = inner;
+ const int x_315 = k;
+ const int x_316 = tileCol;
+ const int x_317 = inner;
+ const float x_320 = mm_Bsub.arr[x_315].arr[(x_316 + x_317)];
+ BCached.arr[x_314] = x_320;
+ {
+ const int x_322 = inner;
+ inner = (x_322 + 1);
+ }
+ }
+ innerRow_3 = 0;
+ while (true) {
+ const int x_330 = innerRow_3;
+ if ((x_330 < 1)) {
+ } else {
+ break;
+ }
+ const int x_333 = tileRow;
+ const int x_334 = innerRow_3;
+ const int x_336 = k;
+ const float x_338 = mm_Asub.arr[(x_333 + x_334)].arr[x_336];
+ ACached = x_338;
+ innerCol_3 = 0;
+ while (true) {
+ const int x_345 = innerCol_3;
+ if ((x_345 < 1)) {
+ } else {
+ break;
+ }
+ const int x_347 = innerRow_3;
+ const int x_348 = innerCol_3;
+ const float x_349 = ACached;
+ const int x_350 = innerCol_3;
+ const float x_352 = BCached.arr[x_350];
+ const float x_355 = acc.arr[x_347].arr[x_348];
+ acc.arr[x_347].arr[x_348] = (x_355 + (x_349 * x_352));
+ {
+ const int x_358 = innerCol_3;
+ innerCol_3 = (x_358 + 1);
+ }
+ }
+ {
+ const int x_360 = innerRow_3;
+ innerRow_3 = (x_360 + 1);
+ }
+ }
+ {
+ const int x_362 = k;
+ k = (x_362 + 1);
+ }
+ }
+ GroupMemoryBarrierWithGroupSync();
+ {
+ const int x_364 = t;
+ t = (x_364 + 1);
+ }
+ }
+ innerRow_4 = 0;
+ while (true) {
+ const int x_372 = innerRow_4;
+ if ((x_372 < 1)) {
+ } else {
+ break;
+ }
+ innerCol_4 = 0;
+ while (true) {
+ bool x_393 = false;
+ bool x_394_phi = false;
+ const int x_380 = innerCol_4;
+ if ((x_380 < 1)) {
+ } else {
+ break;
+ }
+ const int x_382 = globalCol;
+ const int x_383 = innerCol_4;
+ const int x_385 = dimBOuter;
+ const bool x_386 = ((x_382 + x_383) < x_385);
+ x_394_phi = x_386;
+ if (x_386) {
+ const int x_389 = globalRow;
+ const int x_390 = innerRow_4;
+ const int x_392 = dimAOuter;
+ x_393 = ((x_389 + x_390) < x_392);
+ x_394_phi = x_393;
+ }
+ const bool x_394 = x_394_phi;
+ if (x_394) {
+ const int x_397 = globalRow;
+ const int x_398 = innerRow_4;
+ const int x_400 = globalCol;
+ const int x_401 = innerCol_4;
+ const int x_403 = innerRow_4;
+ const int x_404 = innerCol_4;
+ param_7 = (x_397 + x_398);
+ param_8 = (x_400 + x_401);
+ const float x_409 = acc.arr[x_403].arr[x_404];
+ param_9 = x_409;
+ mm_write_i1_i1_f1_(param_7, param_8, param_9);
+ }
+ {
+ const int x_411 = innerCol_4;
+ innerCol_4 = (x_411 + 1);
+ }
+ }
+ {
+ const int x_413 = innerRow_4;
+ innerRow_4 = (x_413 + 1);
+ }
+ }
+ return;
+}
+
+void main_1() {
+ int param_18 = 0;
+ int param_19 = 0;
+ int param_20 = 0;
+ const uint scalar_offset_6 = (20u) / 4;
+ const int x_67 = asint(x_48[scalar_offset_6 / 4][scalar_offset_6 % 4]);
+ dimAOuter_1 = x_67;
+ const uint scalar_offset_7 = (24u) / 4;
+ const int x_71 = asint(x_48[scalar_offset_7 / 4][scalar_offset_7 % 4]);
+ dimInner_1 = x_71;
+ const uint scalar_offset_8 = (40u) / 4;
+ const int x_75 = asint(x_48[scalar_offset_8 / 4][scalar_offset_8 % 4]);
+ dimBOuter_1 = x_75;
+ const uint x_505 = gl_GlobalInvocationID.z;
+ batch = asint(x_505);
+ const int x_508 = dimAOuter_1;
+ param_18 = x_508;
+ const int x_510 = dimInner_1;
+ param_19 = x_510;
+ const int x_512 = dimBOuter_1;
+ param_20 = x_512;
+ mm_matMul_i1_i1_i1_(param_18, param_19, param_20);
+ return;
+}
+
+struct tint_symbol_1 {
+ uint3 gl_LocalInvocationID_param : SV_GroupThreadID;
+ uint local_invocation_index : SV_GroupIndex;
+ uint3 gl_GlobalInvocationID_param : SV_DispatchThreadID;
+};
+
+[numthreads(1, 64, 1)]
+void main(tint_symbol_1 tint_symbol) {
+ const uint3 gl_LocalInvocationID_param = tint_symbol.gl_LocalInvocationID_param;
+ const uint3 gl_GlobalInvocationID_param = tint_symbol.gl_GlobalInvocationID_param;
+ const uint local_invocation_index = tint_symbol.local_invocation_index;
+ if ((local_invocation_index == 0u)) {
+ const tint_array_wrapper tint_symbol_6 = {(tint_array_wrapper_1[64])0};
+ mm_Asub = tint_symbol_6;
+ const tint_array_wrapper_2 tint_symbol_7 = {(tint_array_wrapper_3[64])0};
+ mm_Bsub = tint_symbol_7;
+ }
+ GroupMemoryBarrierWithGroupSync();
+ gl_LocalInvocationID = gl_LocalInvocationID_param;
+ gl_GlobalInvocationID = gl_GlobalInvocationID_param;
+ main_1();
+ return;
+}
diff --git a/test/bug/tint/943.spvasm.expected.msl b/test/bug/tint/943.spvasm.expected.msl
new file mode 100644
index 0000000..551f911
--- /dev/null
+++ b/test/bug/tint/943.spvasm.expected.msl
@@ -0,0 +1,32 @@
+SKIP: FAILED
+
+
+
+Validation Failure:
+
+Compilation failed:
+
+program_source:5:22: error: expected parameter declarator
+ /* 0x0000 */ float NAN;
+ ^
+/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/31001/Libraries/lib/clang/31001.189/include/metal/metal_types:214:28: note: expanded from macro 'NAN'
+#define NAN __builtin_nanf("")
+ ^
+program_source:5:22: error: expected ')'
+/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/31001/Libraries/lib/clang/31001.189/include/metal/metal_types:214:28: note: expanded from macro 'NAN'
+#define NAN __builtin_nanf("")
+ ^
+program_source:5:22: note: to match this '('
+/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/31001/Libraries/lib/clang/31001.189/include/metal/metal_types:214:27: note: expanded from macro 'NAN'
+#define NAN __builtin_nanf("")
+ ^
+program_source:494:31: warning: equality comparison with extraneous parentheses
+ if ((local_invocation_index == 0u)) {
+ ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
+program_source:494:31: note: remove extraneous parentheses around the comparison to silence this warning
+ if ((local_invocation_index == 0u)) {
+ ~ ^ ~
+program_source:494:31: note: use '=' to turn this equality comparison into an assignment
+ if ((local_invocation_index == 0u)) {
+ ^~
+ =
diff --git a/test/bug/tint/943.spvasm.expected.spvasm b/test/bug/tint/943.spvasm.expected.spvasm
new file mode 100644
index 0000000..df95d76
--- /dev/null
+++ b/test/bug/tint/943.spvasm.expected.spvasm
@@ -0,0 +1,960 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 609
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint GLCompute %main "main" %tint_symbol_2 %tint_symbol %tint_symbol_1
+ OpExecutionMode %main LocalSize 1 64 1
+ OpName %dimAOuter_1 "dimAOuter_1"
+ OpName %Uniforms "Uniforms"
+ OpMemberName %Uniforms 0 "NAN"
+ OpMemberName %Uniforms 1 "aShape"
+ OpMemberName %Uniforms 2 "bShape"
+ OpMemberName %Uniforms 3 "outShape"
+ OpMemberName %Uniforms 4 "outShapeStrides"
+ OpName %x_48 "x_48"
+ OpName %dimInner_1 "dimInner_1"
+ OpName %dimBOuter_1 "dimBOuter_1"
+ OpName %ssbOut "ssbOut"
+ OpMemberName %ssbOut 0 "result"
+ OpName %x_54 "x_54"
+ OpName %gl_LocalInvocationID "gl_LocalInvocationID"
+ OpName %gl_GlobalInvocationID "gl_GlobalInvocationID"
+ OpName %mm_Asub "mm_Asub"
+ OpName %mm_Bsub "mm_Bsub"
+ OpName %ssbA "ssbA"
+ OpMemberName %ssbA 0 "A"
+ OpName %x_165 "x_165"
+ OpName %batch "batch"
+ OpName %ssbB "ssbB"
+ OpMemberName %ssbB 0 "B"
+ OpName %x_185 "x_185"
+ OpName %tint_symbol "tint_symbol"
+ OpName %tint_symbol_1 "tint_symbol_1"
+ OpName %tint_symbol_2 "tint_symbol_2"
+ OpName %coordsInBounds_vi2_vi2_ "coordsInBounds_vi2_vi2_"
+ OpName %coord "coord"
+ OpName %shape "shape"
+ OpName %x_87 "x_87"
+ OpName %x_88_phi "x_88_phi"
+ OpName %mm_readA_i1_i1_ "mm_readA_i1_i1_"
+ OpName %row "row"
+ OpName %col "col"
+ OpName %batchASize "batchASize"
+ OpName %param_10 "param_10"
+ OpName %param_11 "param_11"
+ OpName %x_430 "x_430"
+ OpName %mm_readB_i1_i1_ "mm_readB_i1_i1_"
+ OpName %row_1 "row_1"
+ OpName %col_1 "col_1"
+ OpName %batchBSize "batchBSize"
+ OpName %param_12 "param_12"
+ OpName %param_13 "param_13"
+ OpName %x_468 "x_468"
+ OpName %getOutputFlatIndex_vi3_ "getOutputFlatIndex_vi3_"
+ OpName %coords "coords"
+ OpName %setOutput_i1_f1_ "setOutput_i1_f1_"
+ OpName %flatIndex "flatIndex"
+ OpName %value "value"
+ OpName %setOutput_i1_i1_i1_f1_ "setOutput_i1_i1_i1_f1_"
+ OpName %d0 "d0"
+ OpName %d1 "d1"
+ OpName %d2 "d2"
+ OpName %value_1 "value_1"
+ OpName %flatIndex_1 "flatIndex_1"
+ OpName %param "param"
+ OpName %param_1 "param_1"
+ OpName %param_2 "param_2"
+ OpName %mm_write_i1_i1_f1_ "mm_write_i1_i1_f1_"
+ OpName %row_2 "row_2"
+ OpName %col_2 "col_2"
+ OpName %value_2 "value_2"
+ OpName %outCoord "outCoord"
+ OpName %param_14 "param_14"
+ OpName %param_15 "param_15"
+ OpName %param_16 "param_16"
+ OpName %param_17 "param_17"
+ OpName %mm_matMul_i1_i1_i1_ "mm_matMul_i1_i1_i1_"
+ OpName %dimAOuter "dimAOuter"
+ OpName %dimInner "dimInner"
+ OpName %dimBOuter "dimBOuter"
+ OpName %tileRow "tileRow"
+ OpName %tileCol "tileCol"
+ OpName %globalRow "globalRow"
+ OpName %globalCol "globalCol"
+ OpName %numTiles "numTiles"
+ OpName %innerRow "innerRow"
+ OpName %innerCol "innerCol"
+ OpName %acc "acc"
+ OpName %tileColA "tileColA"
+ OpName %tileRowB "tileRowB"
+ OpName %t "t"
+ OpName %innerRow_1 "innerRow_1"
+ OpName %innerCol_1 "innerCol_1"
+ OpName %inputRow "inputRow"
+ OpName %inputCol "inputCol"
+ OpName %param_3 "param_3"
+ OpName %param_4 "param_4"
+ OpName %innerRow_2 "innerRow_2"
+ OpName %innerCol_2 "innerCol_2"
+ OpName %inputRow_1 "inputRow_1"
+ OpName %inputCol_1 "inputCol_1"
+ OpName %param_5 "param_5"
+ OpName %param_6 "param_6"
+ OpName %k "k"
+ OpName %inner "inner"
+ OpName %BCached "BCached"
+ OpName %innerRow_3 "innerRow_3"
+ OpName %ACached "ACached"
+ OpName %innerCol_3 "innerCol_3"
+ OpName %innerRow_4 "innerRow_4"
+ OpName %innerCol_4 "innerCol_4"
+ OpName %param_7 "param_7"
+ OpName %param_8 "param_8"
+ OpName %param_9 "param_9"
+ OpName %x_393 "x_393"
+ OpName %x_394_phi "x_394_phi"
+ OpName %main_1 "main_1"
+ OpName %param_18 "param_18"
+ OpName %param_19 "param_19"
+ OpName %param_20 "param_20"
+ OpName %main "main"
+ OpDecorate %Uniforms Block
+ OpMemberDecorate %Uniforms 0 Offset 0
+ OpMemberDecorate %Uniforms 1 Offset 16
+ OpMemberDecorate %Uniforms 2 Offset 32
+ OpMemberDecorate %Uniforms 3 Offset 48
+ OpMemberDecorate %Uniforms 4 Offset 64
+ OpDecorate %x_48 NonWritable
+ OpDecorate %x_48 DescriptorSet 0
+ OpDecorate %x_48 Binding 3
+ OpDecorate %ssbOut Block
+ OpMemberDecorate %ssbOut 0 Offset 0
+ OpDecorate %_runtimearr_float ArrayStride 4
+ OpDecorate %x_54 DescriptorSet 0
+ OpDecorate %x_54 Binding 0
+ OpDecorate %_arr_float_uint_64 ArrayStride 4
+ OpDecorate %_arr__arr_float_uint_64_uint_64 ArrayStride 256
+ OpDecorate %_arr_float_uint_1 ArrayStride 4
+ OpDecorate %_arr__arr_float_uint_1_uint_64 ArrayStride 4
+ OpDecorate %ssbA Block
+ OpMemberDecorate %ssbA 0 Offset 0
+ OpDecorate %x_165 NonWritable
+ OpDecorate %x_165 DescriptorSet 0
+ OpDecorate %x_165 Binding 1
+ OpDecorate %ssbB Block
+ OpMemberDecorate %ssbB 0 Offset 0
+ OpDecorate %x_185 NonWritable
+ OpDecorate %x_185 DescriptorSet 0
+ OpDecorate %x_185 Binding 2
+ OpDecorate %tint_symbol BuiltIn LocalInvocationId
+ OpDecorate %tint_symbol_1 BuiltIn GlobalInvocationId
+ OpDecorate %tint_symbol_2 BuiltIn LocalInvocationIndex
+ OpDecorate %_arr__arr_float_uint_1_uint_1 ArrayStride 4
+ %int = OpTypeInt 32 1
+%_ptr_Private_int = OpTypePointer Private %int
+ %4 = OpConstantNull %int
+%dimAOuter_1 = OpVariable %_ptr_Private_int Private %4
+ %float = OpTypeFloat 32
+ %v3int = OpTypeVector %int 3
+ %v2int = OpTypeVector %int 2
+ %Uniforms = OpTypeStruct %float %v3int %v3int %v3int %v2int
+%_ptr_Uniform_Uniforms = OpTypePointer Uniform %Uniforms
+ %x_48 = OpVariable %_ptr_Uniform_Uniforms Uniform
+ %dimInner_1 = OpVariable %_ptr_Private_int Private %4
+%dimBOuter_1 = OpVariable %_ptr_Private_int Private %4
+%_runtimearr_float = OpTypeRuntimeArray %float
+ %ssbOut = OpTypeStruct %_runtimearr_float
+%_ptr_StorageBuffer_ssbOut = OpTypePointer StorageBuffer %ssbOut
+ %x_54 = OpVariable %_ptr_StorageBuffer_ssbOut StorageBuffer
+ %uint = OpTypeInt 32 0
+ %v3uint = OpTypeVector %uint 3
+%_ptr_Private_v3uint = OpTypePointer Private %v3uint
+ %21 = OpConstantNull %v3uint
+%gl_LocalInvocationID = OpVariable %_ptr_Private_v3uint Private %21
+%gl_GlobalInvocationID = OpVariable %_ptr_Private_v3uint Private %21
+ %uint_64 = OpConstant %uint 64
+%_arr_float_uint_64 = OpTypeArray %float %uint_64
+%_arr__arr_float_uint_64_uint_64 = OpTypeArray %_arr_float_uint_64 %uint_64
+%_ptr_Workgroup__arr__arr_float_uint_64_uint_64 = OpTypePointer Workgroup %_arr__arr_float_uint_64_uint_64
+ %mm_Asub = OpVariable %_ptr_Workgroup__arr__arr_float_uint_64_uint_64 Workgroup
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%_arr__arr_float_uint_1_uint_64 = OpTypeArray %_arr_float_uint_1 %uint_64
+%_ptr_Workgroup__arr__arr_float_uint_1_uint_64 = OpTypePointer Workgroup %_arr__arr_float_uint_1_uint_64
+ %mm_Bsub = OpVariable %_ptr_Workgroup__arr__arr_float_uint_1_uint_64 Workgroup
+ %ssbA = OpTypeStruct %_runtimearr_float
+%_ptr_StorageBuffer_ssbA = OpTypePointer StorageBuffer %ssbA
+ %x_165 = OpVariable %_ptr_StorageBuffer_ssbA StorageBuffer
+ %batch = OpVariable %_ptr_Private_int Private %4
+ %ssbB = OpTypeStruct %_runtimearr_float
+%_ptr_StorageBuffer_ssbB = OpTypePointer StorageBuffer %ssbB
+ %x_185 = OpVariable %_ptr_StorageBuffer_ssbB StorageBuffer
+%_ptr_Input_v3uint = OpTypePointer Input %v3uint
+%tint_symbol = OpVariable %_ptr_Input_v3uint Input
+%tint_symbol_1 = OpVariable %_ptr_Input_v3uint Input
+%_ptr_Input_uint = OpTypePointer Input %uint
+%tint_symbol_2 = OpVariable %_ptr_Input_uint Input
+ %bool = OpTypeBool
+%_ptr_Function_v2int = OpTypePointer Function %v2int
+ %45 = OpTypeFunction %bool %_ptr_Function_v2int %_ptr_Function_v2int
+%_ptr_Function_bool = OpTypePointer Function %bool
+ %54 = OpConstantNull %bool
+ %int_0 = OpConstant %int 0
+ %60 = OpConstantComposite %v2int %int_0 %int_0
+ %v2bool = OpTypeVector %bool 2
+%_ptr_Function_int = OpTypePointer Function %int
+ %73 = OpTypeFunction %float %_ptr_Function_int %_ptr_Function_int
+ %81 = OpConstantNull %v2int
+%_ptr_Function_float = OpTypePointer Function %float
+ %85 = OpConstantNull %float
+%_ptr_Uniform_int = OpTypePointer Uniform %int
+ %uint_2 = OpConstant %uint 2
+ %uint_0 = OpConstant %uint 0
+%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float
+ %float_0 = OpConstant %float 0
+%_ptr_Function_v3int = OpTypePointer Function %v3int
+ %165 = OpTypeFunction %int %_ptr_Function_v3int
+ %uint_4 = OpConstant %uint 4
+ %v3float = OpTypeVector %float 3
+ %int_1 = OpConstant %int 1
+ %void = OpTypeVoid
+ %184 = OpTypeFunction %void %_ptr_Function_int %_ptr_Function_float
+ %195 = OpTypeFunction %void %_ptr_Function_int %_ptr_Function_int %_ptr_Function_int %_ptr_Function_float
+ %204 = OpConstantNull %v3int
+ %222 = OpTypeFunction %void %_ptr_Function_int %_ptr_Function_int %_ptr_Function_float
+ %251 = OpTypeFunction %void %_ptr_Function_int %_ptr_Function_int %_ptr_Function_int
+%_arr__arr_float_uint_1_uint_1 = OpTypeArray %_arr_float_uint_1 %uint_1
+%_ptr_Function__arr__arr_float_uint_1_uint_1 = OpTypePointer Function %_arr__arr_float_uint_1_uint_1
+ %267 = OpConstantNull %_arr__arr_float_uint_1_uint_1
+%_ptr_Function__arr_float_uint_1 = OpTypePointer Function %_arr_float_uint_1
+ %287 = OpConstantNull %_arr_float_uint_1
+%_ptr_Private_uint = OpTypePointer Private %uint
+ %int_64 = OpConstant %int 64
+%_ptr_Workgroup_float = OpTypePointer Workgroup %float
+ %uint_264 = OpConstant %uint 264
+ %575 = OpTypeFunction %void
+ %603 = OpConstantNull %_arr__arr_float_uint_64_uint_64
+ %604 = OpConstantNull %_arr__arr_float_uint_1_uint_64
+%coordsInBounds_vi2_vi2_ = OpFunction %bool None %45
+ %coord = OpFunctionParameter %_ptr_Function_v2int
+ %shape = OpFunctionParameter %_ptr_Function_v2int
+ %51 = OpLabel
+ %x_87 = OpVariable %_ptr_Function_bool Function %54
+ %x_88_phi = OpVariable %_ptr_Function_bool Function %54
+ %57 = OpLoad %v2int %coord
+ %61 = OpSGreaterThanEqual %v2bool %57 %60
+ %58 = OpAll %bool %61
+ OpStore %x_88_phi %58
+ OpSelectionMerge %63 None
+ OpBranchConditional %58 %64 %63
+ %64 = OpLabel
+ %66 = OpLoad %v2int %coord
+ %68 = OpLoad %v2int %shape
+ %70 = OpSLessThan %v2bool %66 %68
+ %69 = OpAll %bool %70
+ OpStore %x_87 %69
+ %71 = OpLoad %bool %x_87
+ OpStore %x_88_phi %71
+ OpBranch %63
+ %63 = OpLabel
+ %72 = OpLoad %bool %x_88_phi
+ OpReturnValue %72
+ OpFunctionEnd
+%mm_readA_i1_i1_ = OpFunction %float None %73
+ %row = OpFunctionParameter %_ptr_Function_int
+ %col = OpFunctionParameter %_ptr_Function_int
+ %78 = OpLabel
+ %batchASize = OpVariable %_ptr_Function_int Function %4
+ %param_10 = OpVariable %_ptr_Function_v2int Function %81
+ %param_11 = OpVariable %_ptr_Function_v2int Function %81
+ %x_430 = OpVariable %_ptr_Function_float Function %85
+ %87 = OpAccessChain %_ptr_Uniform_int %x_48 %uint_1 %uint_1
+ %88 = OpLoad %int %87
+ %90 = OpAccessChain %_ptr_Uniform_int %x_48 %uint_1 %uint_2
+ %91 = OpLoad %int %90
+ %92 = OpIMul %int %88 %91
+ OpStore %batchASize %92
+ %94 = OpLoad %int %row
+ %96 = OpLoad %int %col
+ %97 = OpLoad %int %dimAOuter_1
+ %98 = OpLoad %int %dimInner_1
+ %99 = OpCompositeConstruct %v2int %94 %96
+ OpStore %param_10 %99
+ %100 = OpCompositeConstruct %v2int %97 %98
+ OpStore %param_11 %100
+ %101 = OpFunctionCall %bool %coordsInBounds_vi2_vi2_ %param_10 %param_11
+ OpSelectionMerge %104 None
+ OpBranchConditional %101 %105 %106
+ %105 = OpLabel
+ %107 = OpLoad %int %batch
+ %108 = OpLoad %int %batchASize
+ %110 = OpLoad %int %row
+ %111 = OpLoad %int %dimInner_1
+ %113 = OpLoad %int %col
+ %115 = OpIMul %int %107 %108
+ %116 = OpIMul %int %110 %111
+ %117 = OpIAdd %int %115 %116
+ %118 = OpIAdd %int %117 %113
+ %120 = OpAccessChain %_ptr_StorageBuffer_float %x_165 %uint_0 %118
+ %121 = OpLoad %float %120
+ OpStore %x_430 %121
+ OpBranch %104
+ %106 = OpLabel
+ OpStore %x_430 %float_0
+ OpBranch %104
+ %104 = OpLabel
+ %123 = OpLoad %float %x_430
+ OpReturnValue %123
+ OpFunctionEnd
+%mm_readB_i1_i1_ = OpFunction %float None %73
+ %row_1 = OpFunctionParameter %_ptr_Function_int
+ %col_1 = OpFunctionParameter %_ptr_Function_int
+ %127 = OpLabel
+ %batchBSize = OpVariable %_ptr_Function_int Function %4
+ %param_12 = OpVariable %_ptr_Function_v2int Function %81
+ %param_13 = OpVariable %_ptr_Function_v2int Function %81
+ %x_468 = OpVariable %_ptr_Function_float Function %85
+ %132 = OpAccessChain %_ptr_Uniform_int %x_48 %uint_2 %uint_1
+ %133 = OpLoad %int %132
+ %134 = OpAccessChain %_ptr_Uniform_int %x_48 %uint_2 %uint_2
+ %135 = OpLoad %int %134
+ %136 = OpIMul %int %133 %135
+ OpStore %batchBSize %136
+ %138 = OpLoad %int %row_1
+ %140 = OpLoad %int %col_1
+ %141 = OpLoad %int %dimInner_1
+ %142 = OpLoad %int %dimBOuter_1
+ %143 = OpCompositeConstruct %v2int %138 %140
+ OpStore %param_12 %143
+ %144 = OpCompositeConstruct %v2int %141 %142
+ OpStore %param_13 %144
+ %145 = OpFunctionCall %bool %coordsInBounds_vi2_vi2_ %param_12 %param_13
+ OpSelectionMerge %148 None
+ OpBranchConditional %145 %149 %150
+ %149 = OpLabel
+ %151 = OpLoad %int %batch
+ %152 = OpLoad %int %batchBSize
+ %154 = OpLoad %int %row_1
+ %155 = OpLoad %int %dimBOuter_1
+ %157 = OpLoad %int %col_1
+ %158 = OpIMul %int %151 %152
+ %159 = OpIMul %int %154 %155
+ %160 = OpIAdd %int %158 %159
+ %161 = OpIAdd %int %160 %157
+ %162 = OpAccessChain %_ptr_StorageBuffer_float %x_185 %uint_0 %161
+ %163 = OpLoad %float %162
+ OpStore %x_468 %163
+ OpBranch %148
+ %150 = OpLabel
+ OpStore %x_468 %float_0
+ OpBranch %148
+ %148 = OpLabel
+ %164 = OpLoad %float %x_468
+ OpReturnValue %164
+ OpFunctionEnd
+%getOutputFlatIndex_vi3_ = OpFunction %int None %165
+ %coords = OpFunctionParameter %_ptr_Function_v3int
+ %169 = OpLabel
+ %171 = OpLoad %v3int %coords
+ %173 = OpAccessChain %_ptr_Uniform_int %x_48 %uint_4 %uint_0
+ %174 = OpLoad %int %173
+ %175 = OpAccessChain %_ptr_Uniform_int %x_48 %uint_4 %uint_1
+ %176 = OpLoad %int %175
+ %179 = OpConvertSToF %v3float %171
+ %183 = OpCompositeConstruct %v3int %174 %176 %int_1
+ %181 = OpConvertSToF %v3float %183
+ %178 = OpDot %float %179 %181
+ %177 = OpConvertFToS %int %178
+ OpReturnValue %177
+ OpFunctionEnd
+%setOutput_i1_f1_ = OpFunction %void None %184
+ %flatIndex = OpFunctionParameter %_ptr_Function_int
+ %value = OpFunctionParameter %_ptr_Function_float
+ %189 = OpLabel
+ %191 = OpLoad %int %flatIndex
+ %193 = OpLoad %float %value
+ %194 = OpAccessChain %_ptr_StorageBuffer_float %x_54 %uint_0 %191
+ OpStore %194 %193
+ OpReturn
+ OpFunctionEnd
+%setOutput_i1_i1_i1_f1_ = OpFunction %void None %195
+ %d0 = OpFunctionParameter %_ptr_Function_int
+ %d1 = OpFunctionParameter %_ptr_Function_int
+ %d2 = OpFunctionParameter %_ptr_Function_int
+ %value_1 = OpFunctionParameter %_ptr_Function_float
+ %201 = OpLabel
+%flatIndex_1 = OpVariable %_ptr_Function_int Function %4
+ %param = OpVariable %_ptr_Function_v3int Function %204
+ %param_1 = OpVariable %_ptr_Function_int Function %4
+ %param_2 = OpVariable %_ptr_Function_float Function %85
+ %208 = OpLoad %int %d0
+ %210 = OpLoad %int %d1
+ %212 = OpLoad %int %d2
+ %213 = OpCompositeConstruct %v3int %208 %210 %212
+ OpStore %param %213
+ %214 = OpFunctionCall %int %getOutputFlatIndex_vi3_ %param
+ OpStore %flatIndex_1 %214
+ %216 = OpLoad %int %flatIndex_1
+ OpStore %param_1 %216
+ %218 = OpLoad %float %value_1
+ OpStore %param_2 %218
+ %219 = OpFunctionCall %void %setOutput_i1_f1_ %param_1 %param_2
+ OpReturn
+ OpFunctionEnd
+%mm_write_i1_i1_f1_ = OpFunction %void None %222
+ %row_2 = OpFunctionParameter %_ptr_Function_int
+ %col_2 = OpFunctionParameter %_ptr_Function_int
+ %value_2 = OpFunctionParameter %_ptr_Function_float
+ %227 = OpLabel
+ %outCoord = OpVariable %_ptr_Function_v3int Function %204
+ %param_14 = OpVariable %_ptr_Function_int Function %4
+ %param_15 = OpVariable %_ptr_Function_int Function %4
+ %param_16 = OpVariable %_ptr_Function_int Function %4
+ %param_17 = OpVariable %_ptr_Function_float Function %85
+ %233 = OpLoad %int %batch
+ %235 = OpLoad %int %row_2
+ %237 = OpLoad %int %col_2
+ %238 = OpCompositeConstruct %v3int %233 %235 %237
+ OpStore %outCoord %238
+ %239 = OpLoad %int %batch
+ OpStore %param_14 %239
+ %241 = OpLoad %int %row_2
+ OpStore %param_15 %241
+ %243 = OpLoad %int %col_2
+ OpStore %param_16 %243
+ %245 = OpLoad %float %value_2
+ OpStore %param_17 %245
+ %246 = OpFunctionCall %void %setOutput_i1_i1_i1_f1_ %param_14 %param_15 %param_16 %param_17
+ OpReturn
+ OpFunctionEnd
+%mm_matMul_i1_i1_i1_ = OpFunction %void None %251
+ %dimAOuter = OpFunctionParameter %_ptr_Function_int
+ %dimInner = OpFunctionParameter %_ptr_Function_int
+ %dimBOuter = OpFunctionParameter %_ptr_Function_int
+ %256 = OpLabel
+ %tileRow = OpVariable %_ptr_Function_int Function %4
+ %tileCol = OpVariable %_ptr_Function_int Function %4
+ %globalRow = OpVariable %_ptr_Function_int Function %4
+ %globalCol = OpVariable %_ptr_Function_int Function %4
+ %numTiles = OpVariable %_ptr_Function_int Function %4
+ %innerRow = OpVariable %_ptr_Function_int Function %4
+ %innerCol = OpVariable %_ptr_Function_int Function %4
+ %acc = OpVariable %_ptr_Function__arr__arr_float_uint_1_uint_1 Function %267
+ %tileColA = OpVariable %_ptr_Function_int Function %4
+ %tileRowB = OpVariable %_ptr_Function_int Function %4
+ %t = OpVariable %_ptr_Function_int Function %4
+ %innerRow_1 = OpVariable %_ptr_Function_int Function %4
+ %innerCol_1 = OpVariable %_ptr_Function_int Function %4
+ %inputRow = OpVariable %_ptr_Function_int Function %4
+ %inputCol = OpVariable %_ptr_Function_int Function %4
+ %param_3 = OpVariable %_ptr_Function_int Function %4
+ %param_4 = OpVariable %_ptr_Function_int Function %4
+ %innerRow_2 = OpVariable %_ptr_Function_int Function %4
+ %innerCol_2 = OpVariable %_ptr_Function_int Function %4
+ %inputRow_1 = OpVariable %_ptr_Function_int Function %4
+ %inputCol_1 = OpVariable %_ptr_Function_int Function %4
+ %param_5 = OpVariable %_ptr_Function_int Function %4
+ %param_6 = OpVariable %_ptr_Function_int Function %4
+ %k = OpVariable %_ptr_Function_int Function %4
+ %inner = OpVariable %_ptr_Function_int Function %4
+ %BCached = OpVariable %_ptr_Function__arr_float_uint_1 Function %287
+ %innerRow_3 = OpVariable %_ptr_Function_int Function %4
+ %ACached = OpVariable %_ptr_Function_float Function %85
+ %innerCol_3 = OpVariable %_ptr_Function_int Function %4
+ %innerRow_4 = OpVariable %_ptr_Function_int Function %4
+ %innerCol_4 = OpVariable %_ptr_Function_int Function %4
+ %param_7 = OpVariable %_ptr_Function_int Function %4
+ %param_8 = OpVariable %_ptr_Function_int Function %4
+ %param_9 = OpVariable %_ptr_Function_float Function %85
+ %x_393 = OpVariable %_ptr_Function_bool Function %54
+ %x_394_phi = OpVariable %_ptr_Function_bool Function %54
+ %297 = OpAccessChain %_ptr_Private_uint %gl_LocalInvocationID %uint_1
+ %298 = OpLoad %uint %297
+ %299 = OpBitcast %int %298
+ %300 = OpIMul %int %299 %int_1
+ OpStore %tileRow %300
+ %301 = OpAccessChain %_ptr_Private_uint %gl_LocalInvocationID %uint_0
+ %302 = OpLoad %uint %301
+ %303 = OpBitcast %int %302
+ %304 = OpIMul %int %303 %int_1
+ OpStore %tileCol %304
+ %305 = OpAccessChain %_ptr_Private_uint %gl_GlobalInvocationID %uint_1
+ %306 = OpLoad %uint %305
+ %307 = OpBitcast %int %306
+ %308 = OpIMul %int %307 %int_1
+ OpStore %globalRow %308
+ %309 = OpAccessChain %_ptr_Private_uint %gl_GlobalInvocationID %uint_0
+ %310 = OpLoad %uint %309
+ %311 = OpBitcast %int %310
+ %312 = OpIMul %int %311 %int_1
+ OpStore %globalCol %312
+ %314 = OpLoad %int %dimInner
+ %315 = OpISub %int %314 %int_1
+ %317 = OpSDiv %int %315 %int_64
+ %318 = OpIAdd %int %317 %int_1
+ OpStore %numTiles %318
+ OpStore %innerRow %int_0
+ OpBranch %319
+ %319 = OpLabel
+ OpLoopMerge %320 %321 None
+ OpBranch %322
+ %322 = OpLabel
+ %323 = OpLoad %int %innerRow
+ %324 = OpSLessThan %bool %323 %int_1
+ OpSelectionMerge %325 None
+ OpBranchConditional %324 %326 %327
+ %326 = OpLabel
+ OpBranch %325
+ %327 = OpLabel
+ OpBranch %320
+ %325 = OpLabel
+ OpStore %innerCol %int_0
+ OpBranch %328
+ %328 = OpLabel
+ OpLoopMerge %329 %330 None
+ OpBranch %331
+ %331 = OpLabel
+ %332 = OpLoad %int %innerCol
+ %333 = OpSLessThan %bool %332 %int_1
+ OpSelectionMerge %334 None
+ OpBranchConditional %333 %335 %336
+ %335 = OpLabel
+ OpBranch %334
+ %336 = OpLabel
+ OpBranch %329
+ %334 = OpLabel
+ %337 = OpLoad %int %innerRow
+ %338 = OpLoad %int %innerCol
+ %339 = OpAccessChain %_ptr_Function_float %acc %337 %338
+ OpStore %339 %float_0
+ OpBranch %330
+ %330 = OpLabel
+ %340 = OpLoad %int %innerCol
+ %341 = OpIAdd %int %340 %int_1
+ OpStore %innerCol %341
+ OpBranch %328
+ %329 = OpLabel
+ OpBranch %321
+ %321 = OpLabel
+ %342 = OpLoad %int %innerRow
+ %343 = OpIAdd %int %342 %int_1
+ OpStore %innerRow %343
+ OpBranch %319
+ %320 = OpLabel
+ %344 = OpAccessChain %_ptr_Private_uint %gl_LocalInvocationID %uint_0
+ %345 = OpLoad %uint %344
+ %346 = OpBitcast %int %345
+ %347 = OpIMul %int %346 %int_64
+ OpStore %tileColA %347
+ %348 = OpAccessChain %_ptr_Private_uint %gl_LocalInvocationID %uint_1
+ %349 = OpLoad %uint %348
+ %350 = OpBitcast %int %349
+ %351 = OpIMul %int %350 %int_1
+ OpStore %tileRowB %351
+ OpStore %t %int_0
+ OpBranch %352
+ %352 = OpLabel
+ OpLoopMerge %353 %354 None
+ OpBranch %355
+ %355 = OpLabel
+ %356 = OpLoad %int %t
+ %357 = OpLoad %int %numTiles
+ %358 = OpSLessThan %bool %356 %357
+ OpSelectionMerge %359 None
+ OpBranchConditional %358 %360 %361
+ %360 = OpLabel
+ OpBranch %359
+ %361 = OpLabel
+ OpBranch %353
+ %359 = OpLabel
+ OpStore %innerRow_1 %int_0
+ OpBranch %362
+ %362 = OpLabel
+ OpLoopMerge %363 %364 None
+ OpBranch %365
+ %365 = OpLabel
+ %366 = OpLoad %int %innerRow_1
+ %367 = OpSLessThan %bool %366 %int_1
+ OpSelectionMerge %368 None
+ OpBranchConditional %367 %369 %370
+ %369 = OpLabel
+ OpBranch %368
+ %370 = OpLabel
+ OpBranch %363
+ %368 = OpLabel
+ OpStore %innerCol_1 %int_0
+ OpBranch %371
+ %371 = OpLabel
+ OpLoopMerge %372 %373 None
+ OpBranch %374
+ %374 = OpLabel
+ %375 = OpLoad %int %innerCol_1
+ %376 = OpSLessThan %bool %375 %int_64
+ OpSelectionMerge %377 None
+ OpBranchConditional %376 %378 %379
+ %378 = OpLabel
+ OpBranch %377
+ %379 = OpLabel
+ OpBranch %372
+ %377 = OpLabel
+ %380 = OpLoad %int %tileRow
+ %381 = OpLoad %int %innerRow_1
+ %382 = OpIAdd %int %380 %381
+ OpStore %inputRow %382
+ %383 = OpLoad %int %tileColA
+ %384 = OpLoad %int %innerCol_1
+ %385 = OpIAdd %int %383 %384
+ OpStore %inputCol %385
+ %386 = OpLoad %int %inputRow
+ %387 = OpLoad %int %inputCol
+ %388 = OpLoad %int %globalRow
+ %389 = OpLoad %int %innerRow_1
+ %390 = OpLoad %int %t
+ %391 = OpLoad %int %inputCol
+ %392 = OpIAdd %int %388 %389
+ OpStore %param_3 %392
+ %393 = OpIMul %int %390 %int_64
+ %394 = OpIAdd %int %393 %391
+ OpStore %param_4 %394
+ %395 = OpFunctionCall %float %mm_readA_i1_i1_ %param_3 %param_4
+ %399 = OpAccessChain %_ptr_Workgroup_float %mm_Asub %386 %387
+ OpStore %399 %395
+ OpBranch %373
+ %373 = OpLabel
+ %400 = OpLoad %int %innerCol_1
+ %401 = OpIAdd %int %400 %int_1
+ OpStore %innerCol_1 %401
+ OpBranch %371
+ %372 = OpLabel
+ OpBranch %364
+ %364 = OpLabel
+ %402 = OpLoad %int %innerRow_1
+ %403 = OpIAdd %int %402 %int_1
+ OpStore %innerRow_1 %403
+ OpBranch %362
+ %363 = OpLabel
+ OpStore %innerRow_2 %int_0
+ OpBranch %404
+ %404 = OpLabel
+ OpLoopMerge %405 %406 None
+ OpBranch %407
+ %407 = OpLabel
+ %408 = OpLoad %int %innerRow_2
+ %409 = OpSLessThan %bool %408 %int_1
+ OpSelectionMerge %410 None
+ OpBranchConditional %409 %411 %412
+ %411 = OpLabel
+ OpBranch %410
+ %412 = OpLabel
+ OpBranch %405
+ %410 = OpLabel
+ OpStore %innerCol_2 %int_0
+ OpBranch %413
+ %413 = OpLabel
+ OpLoopMerge %414 %415 None
+ OpBranch %416
+ %416 = OpLabel
+ %417 = OpLoad %int %innerCol_2
+ %418 = OpSLessThan %bool %417 %int_1
+ OpSelectionMerge %419 None
+ OpBranchConditional %418 %420 %421
+ %420 = OpLabel
+ OpBranch %419
+ %421 = OpLabel
+ OpBranch %414
+ %419 = OpLabel
+ %422 = OpLoad %int %tileRowB
+ %423 = OpLoad %int %innerRow_2
+ %424 = OpIAdd %int %422 %423
+ OpStore %inputRow_1 %424
+ %425 = OpLoad %int %tileCol
+ %426 = OpLoad %int %innerCol_2
+ %427 = OpIAdd %int %425 %426
+ OpStore %inputCol_1 %427
+ %428 = OpLoad %int %inputRow_1
+ %429 = OpLoad %int %inputCol_1
+ %430 = OpLoad %int %t
+ %431 = OpLoad %int %inputRow_1
+ %432 = OpLoad %int %globalCol
+ %433 = OpLoad %int %innerCol_2
+ %434 = OpIMul %int %430 %int_64
+ %435 = OpIAdd %int %434 %431
+ OpStore %param_5 %435
+ %436 = OpIAdd %int %432 %433
+ OpStore %param_6 %436
+ %437 = OpFunctionCall %float %mm_readB_i1_i1_ %param_5 %param_6
+ %440 = OpAccessChain %_ptr_Workgroup_float %mm_Bsub %428 %429
+ OpStore %440 %437
+ OpBranch %415
+ %415 = OpLabel
+ %441 = OpLoad %int %innerCol_2
+ %442 = OpIAdd %int %441 %int_1
+ OpStore %innerCol_2 %442
+ OpBranch %413
+ %414 = OpLabel
+ OpBranch %406
+ %406 = OpLabel
+ %443 = OpLoad %int %innerRow_2
+ %444 = OpIAdd %int %443 %int_1
+ OpStore %innerRow_2 %444
+ OpBranch %404
+ %405 = OpLabel
+ OpControlBarrier %uint_2 %uint_2 %uint_264
+ OpStore %k %int_0
+ OpBranch %447
+ %447 = OpLabel
+ OpLoopMerge %448 %449 None
+ OpBranch %450
+ %450 = OpLabel
+ %451 = OpLoad %int %k
+ %452 = OpSLessThan %bool %451 %int_64
+ OpSelectionMerge %453 None
+ OpBranchConditional %452 %454 %455
+ %454 = OpLabel
+ OpBranch %453
+ %455 = OpLabel
+ OpBranch %448
+ %453 = OpLabel
+ OpStore %inner %int_0
+ OpBranch %456
+ %456 = OpLabel
+ OpLoopMerge %457 %458 None
+ OpBranch %459
+ %459 = OpLabel
+ %460 = OpLoad %int %inner
+ %461 = OpSLessThan %bool %460 %int_1
+ OpSelectionMerge %462 None
+ OpBranchConditional %461 %463 %464
+ %463 = OpLabel
+ OpBranch %462
+ %464 = OpLabel
+ OpBranch %457
+ %462 = OpLabel
+ %465 = OpLoad %int %inner
+ %466 = OpLoad %int %k
+ %467 = OpLoad %int %tileCol
+ %468 = OpLoad %int %inner
+ %469 = OpIAdd %int %467 %468
+ %470 = OpAccessChain %_ptr_Workgroup_float %mm_Bsub %466 %469
+ %471 = OpLoad %float %470
+ %472 = OpAccessChain %_ptr_Function_float %BCached %465
+ OpStore %472 %471
+ OpBranch %458
+ %458 = OpLabel
+ %473 = OpLoad %int %inner
+ %474 = OpIAdd %int %473 %int_1
+ OpStore %inner %474
+ OpBranch %456
+ %457 = OpLabel
+ OpStore %innerRow_3 %int_0
+ OpBranch %475
+ %475 = OpLabel
+ OpLoopMerge %476 %477 None
+ OpBranch %478
+ %478 = OpLabel
+ %479 = OpLoad %int %innerRow_3
+ %480 = OpSLessThan %bool %479 %int_1
+ OpSelectionMerge %481 None
+ OpBranchConditional %480 %482 %483
+ %482 = OpLabel
+ OpBranch %481
+ %483 = OpLabel
+ OpBranch %476
+ %481 = OpLabel
+ %484 = OpLoad %int %tileRow
+ %485 = OpLoad %int %innerRow_3
+ %486 = OpLoad %int %k
+ %487 = OpIAdd %int %484 %485
+ %488 = OpAccessChain %_ptr_Workgroup_float %mm_Asub %487 %486
+ %489 = OpLoad %float %488
+ OpStore %ACached %489
+ OpStore %innerCol_3 %int_0
+ OpBranch %490
+ %490 = OpLabel
+ OpLoopMerge %491 %492 None
+ OpBranch %493
+ %493 = OpLabel
+ %494 = OpLoad %int %innerCol_3
+ %495 = OpSLessThan %bool %494 %int_1
+ OpSelectionMerge %496 None
+ OpBranchConditional %495 %497 %498
+ %497 = OpLabel
+ OpBranch %496
+ %498 = OpLabel
+ OpBranch %491
+ %496 = OpLabel
+ %499 = OpLoad %int %innerRow_3
+ %500 = OpLoad %int %innerCol_3
+ %501 = OpLoad %float %ACached
+ %502 = OpLoad %int %innerCol_3
+ %503 = OpAccessChain %_ptr_Function_float %BCached %502
+ %504 = OpLoad %float %503
+ %505 = OpAccessChain %_ptr_Function_float %acc %499 %500
+ %506 = OpLoad %float %505
+ %507 = OpAccessChain %_ptr_Function_float %acc %499 %500
+ %508 = OpFMul %float %501 %504
+ %509 = OpFAdd %float %506 %508
+ OpStore %507 %509
+ OpBranch %492
+ %492 = OpLabel
+ %510 = OpLoad %int %innerCol_3
+ %511 = OpIAdd %int %510 %int_1
+ OpStore %innerCol_3 %511
+ OpBranch %490
+ %491 = OpLabel
+ OpBranch %477
+ %477 = OpLabel
+ %512 = OpLoad %int %innerRow_3
+ %513 = OpIAdd %int %512 %int_1
+ OpStore %innerRow_3 %513
+ OpBranch %475
+ %476 = OpLabel
+ OpBranch %449
+ %449 = OpLabel
+ %514 = OpLoad %int %k
+ %515 = OpIAdd %int %514 %int_1
+ OpStore %k %515
+ OpBranch %447
+ %448 = OpLabel
+ OpControlBarrier %uint_2 %uint_2 %uint_264
+ OpBranch %354
+ %354 = OpLabel
+ %517 = OpLoad %int %t
+ %518 = OpIAdd %int %517 %int_1
+ OpStore %t %518
+ OpBranch %352
+ %353 = OpLabel
+ OpStore %innerRow_4 %int_0
+ OpBranch %519
+ %519 = OpLabel
+ OpLoopMerge %520 %521 None
+ OpBranch %522
+ %522 = OpLabel
+ %523 = OpLoad %int %innerRow_4
+ %524 = OpSLessThan %bool %523 %int_1
+ OpSelectionMerge %525 None
+ OpBranchConditional %524 %526 %527
+ %526 = OpLabel
+ OpBranch %525
+ %527 = OpLabel
+ OpBranch %520
+ %525 = OpLabel
+ OpStore %innerCol_4 %int_0
+ OpBranch %528
+ %528 = OpLabel
+ OpLoopMerge %529 %530 None
+ OpBranch %531
+ %531 = OpLabel
+ %534 = OpLoad %int %innerCol_4
+ %535 = OpSLessThan %bool %534 %int_1
+ OpSelectionMerge %536 None
+ OpBranchConditional %535 %537 %538
+ %537 = OpLabel
+ OpBranch %536
+ %538 = OpLabel
+ OpBranch %529
+ %536 = OpLabel
+ %539 = OpLoad %int %globalCol
+ %540 = OpLoad %int %innerCol_4
+ %542 = OpLoad %int %dimBOuter
+ %543 = OpIAdd %int %539 %540
+ %544 = OpSLessThan %bool %543 %542
+ OpStore %x_394_phi %544
+ OpSelectionMerge %545 None
+ OpBranchConditional %544 %546 %545
+ %546 = OpLabel
+ %547 = OpLoad %int %globalRow
+ %548 = OpLoad %int %innerRow_4
+ %550 = OpLoad %int %dimAOuter
+ %551 = OpIAdd %int %547 %548
+ %552 = OpSLessThan %bool %551 %550
+ OpStore %x_393 %552
+ %553 = OpLoad %bool %x_393
+ OpStore %x_394_phi %553
+ OpBranch %545
+ %545 = OpLabel
+ %554 = OpLoad %bool %x_394_phi
+ OpSelectionMerge %555 None
+ OpBranchConditional %554 %556 %555
+ %556 = OpLabel
+ %557 = OpLoad %int %globalRow
+ %558 = OpLoad %int %innerRow_4
+ %559 = OpLoad %int %globalCol
+ %560 = OpLoad %int %innerCol_4
+ %561 = OpLoad %int %innerRow_4
+ %562 = OpLoad %int %innerCol_4
+ %563 = OpIAdd %int %557 %558
+ OpStore %param_7 %563
+ %564 = OpIAdd %int %559 %560
+ OpStore %param_8 %564
+ %565 = OpAccessChain %_ptr_Function_float %acc %561 %562
+ %566 = OpLoad %float %565
+ OpStore %param_9 %566
+ %567 = OpFunctionCall %void %mm_write_i1_i1_f1_ %param_7 %param_8 %param_9
+ OpBranch %555
+ %555 = OpLabel
+ OpBranch %530
+ %530 = OpLabel
+ %571 = OpLoad %int %innerCol_4
+ %572 = OpIAdd %int %571 %int_1
+ OpStore %innerCol_4 %572
+ OpBranch %528
+ %529 = OpLabel
+ OpBranch %521
+ %521 = OpLabel
+ %573 = OpLoad %int %innerRow_4
+ %574 = OpIAdd %int %573 %int_1
+ OpStore %innerRow_4 %574
+ OpBranch %519
+ %520 = OpLabel
+ OpReturn
+ OpFunctionEnd
+ %main_1 = OpFunction %void None %575
+ %577 = OpLabel
+ %param_18 = OpVariable %_ptr_Function_int Function %4
+ %param_19 = OpVariable %_ptr_Function_int Function %4
+ %param_20 = OpVariable %_ptr_Function_int Function %4
+ %581 = OpAccessChain %_ptr_Uniform_int %x_48 %uint_1 %uint_1
+ %582 = OpLoad %int %581
+ OpStore %dimAOuter_1 %582
+ %583 = OpAccessChain %_ptr_Uniform_int %x_48 %uint_1 %uint_2
+ %584 = OpLoad %int %583
+ OpStore %dimInner_1 %584
+ %585 = OpAccessChain %_ptr_Uniform_int %x_48 %uint_2 %uint_2
+ %586 = OpLoad %int %585
+ OpStore %dimBOuter_1 %586
+ %587 = OpAccessChain %_ptr_Private_uint %gl_GlobalInvocationID %uint_2
+ %588 = OpLoad %uint %587
+ %589 = OpBitcast %int %588
+ OpStore %batch %589
+ %590 = OpLoad %int %dimAOuter_1
+ OpStore %param_18 %590
+ %591 = OpLoad %int %dimInner_1
+ OpStore %param_19 %591
+ %592 = OpLoad %int %dimBOuter_1
+ OpStore %param_20 %592
+ %593 = OpFunctionCall %void %mm_matMul_i1_i1_i1_ %param_18 %param_19 %param_20
+ OpReturn
+ OpFunctionEnd
+ %main = OpFunction %void None %575
+ %598 = OpLabel
+ %599 = OpLoad %uint %tint_symbol_2
+ %600 = OpIEqual %bool %599 %uint_0
+ OpSelectionMerge %601 None
+ OpBranchConditional %600 %602 %601
+ %602 = OpLabel
+ OpStore %mm_Asub %603
+ OpStore %mm_Bsub %604
+ OpBranch %601
+ %601 = OpLabel
+ OpControlBarrier %uint_2 %uint_2 %uint_264
+ %606 = OpLoad %v3uint %tint_symbol
+ OpStore %gl_LocalInvocationID %606
+ %607 = OpLoad %v3uint %tint_symbol_1
+ OpStore %gl_GlobalInvocationID %607
+ %608 = OpFunctionCall %void %main_1
+ OpReturn
+ OpFunctionEnd
diff --git a/test/bug/tint/943.spvasm.expected.wgsl b/test/bug/tint/943.spvasm.expected.wgsl
new file mode 100644
index 0000000..15bdc14
--- /dev/null
+++ b/test/bug/tint/943.spvasm.expected.wgsl
@@ -0,0 +1,526 @@
+[[block]]
+struct Uniforms {
+ NAN : f32;
+ [[size(12)]]
+ padding : u32;
+ aShape : vec3<i32>;
+ [[size(4)]]
+ padding_1 : u32;
+ bShape : vec3<i32>;
+ [[size(4)]]
+ padding_2 : u32;
+ outShape : vec3<i32>;
+ [[size(4)]]
+ padding_3 : u32;
+ outShapeStrides : vec2<i32>;
+};
+
+type RTArr = [[stride(4)]] array<f32>;
+
+type RTArr_1 = [[stride(4)]] array<f32>;
+
+[[block]]
+struct ssbOut {
+ result : RTArr_1;
+};
+
+type RTArr_2 = [[stride(4)]] array<f32>;
+
+[[block]]
+struct ssbA {
+ A : RTArr_1;
+};
+
+[[block]]
+struct ssbB {
+ B : RTArr_1;
+};
+
+var<private> dimAOuter_1 : i32;
+
+[[group(0), binding(3)]] var<uniform> x_48 : Uniforms;
+
+var<private> dimInner_1 : i32;
+
+var<private> dimBOuter_1 : i32;
+
+[[group(0), binding(0)]] var<storage, read_write> x_54 : ssbOut;
+
+var<private> gl_LocalInvocationID : vec3<u32>;
+
+var<private> gl_GlobalInvocationID : vec3<u32>;
+
+var<workgroup> mm_Asub : array<array<f32, 64>, 64>;
+
+var<workgroup> mm_Bsub : array<array<f32, 1>, 64>;
+
+[[group(0), binding(1)]] var<storage, read> x_165 : ssbA;
+
+var<private> batch : i32;
+
+[[group(0), binding(2)]] var<storage, read> x_185 : ssbB;
+
+fn coordsInBounds_vi2_vi2_(coord : ptr<function, vec2<i32>>, shape : ptr<function, vec2<i32>>) -> bool {
+ var x_87 : bool;
+ var x_88_phi : bool;
+ let x_76 : vec2<i32> = *(coord);
+ let x_81 : bool = all((x_76 >= vec2<i32>(0, 0)));
+ x_88_phi = x_81;
+ if (x_81) {
+ let x_84 : vec2<i32> = *(coord);
+ let x_85 : vec2<i32> = *(shape);
+ x_87 = all((x_84 < x_85));
+ x_88_phi = x_87;
+ }
+ let x_88 : bool = x_88_phi;
+ return x_88;
+}
+
+fn mm_readA_i1_i1_(row : ptr<function, i32>, col : ptr<function, i32>) -> f32 {
+ var batchASize : i32;
+ var param_10 : vec2<i32>;
+ var param_11 : vec2<i32>;
+ var x_430 : f32;
+ let x_417 : i32 = x_48.aShape.y;
+ let x_419 : i32 = x_48.aShape.z;
+ batchASize = (x_417 * x_419);
+ let x_421 : i32 = *(row);
+ let x_422 : i32 = *(col);
+ let x_424 : i32 = dimAOuter_1;
+ let x_425 : i32 = dimInner_1;
+ param_10 = vec2<i32>(x_421, x_422);
+ param_11 = vec2<i32>(x_424, x_425);
+ let x_429 : bool = coordsInBounds_vi2_vi2_(&(param_10), &(param_11));
+ if (x_429) {
+ let x_438 : i32 = batch;
+ let x_439 : i32 = batchASize;
+ let x_441 : i32 = *(row);
+ let x_442 : i32 = dimInner_1;
+ let x_445 : i32 = *(col);
+ let x_448 : f32 = x_165.A[(((x_438 * x_439) + (x_441 * x_442)) + x_445)];
+ x_430 = x_448;
+ } else {
+ x_430 = 0.0;
+ }
+ let x_450 : f32 = x_430;
+ return x_450;
+}
+
+fn mm_readB_i1_i1_(row_1 : ptr<function, i32>, col_1 : ptr<function, i32>) -> f32 {
+ var batchBSize : i32;
+ var param_12 : vec2<i32>;
+ var param_13 : vec2<i32>;
+ var x_468 : f32;
+ let x_455 : i32 = x_48.bShape.y;
+ let x_457 : i32 = x_48.bShape.z;
+ batchBSize = (x_455 * x_457);
+ let x_459 : i32 = *(row_1);
+ let x_460 : i32 = *(col_1);
+ let x_462 : i32 = dimInner_1;
+ let x_463 : i32 = dimBOuter_1;
+ param_12 = vec2<i32>(x_459, x_460);
+ param_13 = vec2<i32>(x_462, x_463);
+ let x_467 : bool = coordsInBounds_vi2_vi2_(&(param_12), &(param_13));
+ if (x_467) {
+ let x_475 : i32 = batch;
+ let x_476 : i32 = batchBSize;
+ let x_478 : i32 = *(row_1);
+ let x_479 : i32 = dimBOuter_1;
+ let x_482 : i32 = *(col_1);
+ let x_485 : f32 = x_185.B[(((x_475 * x_476) + (x_478 * x_479)) + x_482)];
+ x_468 = x_485;
+ } else {
+ x_468 = 0.0;
+ }
+ let x_487 : f32 = x_468;
+ return x_487;
+}
+
+fn getOutputFlatIndex_vi3_(coords : ptr<function, vec3<i32>>) -> i32 {
+ let x_99 : vec3<i32> = *(coords);
+ let x_105 : i32 = x_48.outShapeStrides.x;
+ let x_107 : i32 = x_48.outShapeStrides.y;
+ return i32(dot(vec3<f32>(x_99), vec3<f32>(vec3<i32>(x_105, x_107, 1))));
+}
+
+fn setOutput_i1_f1_(flatIndex : ptr<function, i32>, value : ptr<function, f32>) {
+ let x_95 : i32 = *(flatIndex);
+ let x_96 : f32 = *(value);
+ x_54.result[x_95] = x_96;
+ return;
+}
+
+fn setOutput_i1_i1_i1_f1_(d0 : ptr<function, i32>, d1 : ptr<function, i32>, d2 : ptr<function, i32>, value_1 : ptr<function, f32>) {
+ var flatIndex_1 : i32;
+ var param : vec3<i32>;
+ var param_1 : i32;
+ var param_2 : f32;
+ let x_115 : i32 = *(d0);
+ let x_116 : i32 = *(d1);
+ let x_117 : i32 = *(d2);
+ param = vec3<i32>(x_115, x_116, x_117);
+ let x_120 : i32 = getOutputFlatIndex_vi3_(&(param));
+ flatIndex_1 = x_120;
+ let x_122 : i32 = flatIndex_1;
+ param_1 = x_122;
+ let x_124 : f32 = *(value_1);
+ param_2 = x_124;
+ setOutput_i1_f1_(&(param_1), &(param_2));
+ return;
+}
+
+fn mm_write_i1_i1_f1_(row_2 : ptr<function, i32>, col_2 : ptr<function, i32>, value_2 : ptr<function, f32>) {
+ var outCoord : vec3<i32>;
+ var param_14 : i32;
+ var param_15 : i32;
+ var param_16 : i32;
+ var param_17 : f32;
+ let x_491 : i32 = batch;
+ let x_492 : i32 = *(row_2);
+ let x_493 : i32 = *(col_2);
+ outCoord = vec3<i32>(x_491, x_492, x_493);
+ let x_496 : i32 = batch;
+ param_14 = x_496;
+ let x_498 : i32 = *(row_2);
+ param_15 = x_498;
+ let x_500 : i32 = *(col_2);
+ param_16 = x_500;
+ let x_502 : f32 = *(value_2);
+ param_17 = x_502;
+ setOutput_i1_i1_i1_f1_(&(param_14), &(param_15), &(param_16), &(param_17));
+ return;
+}
+
+fn mm_matMul_i1_i1_i1_(dimAOuter : ptr<function, i32>, dimInner : ptr<function, i32>, dimBOuter : ptr<function, i32>) {
+ var tileRow : i32;
+ var tileCol : i32;
+ var globalRow : i32;
+ var globalCol : i32;
+ var numTiles : i32;
+ var innerRow : i32;
+ var innerCol : i32;
+ var acc : array<array<f32, 1>, 1>;
+ var tileColA : i32;
+ var tileRowB : i32;
+ var t : i32;
+ var innerRow_1 : i32;
+ var innerCol_1 : i32;
+ var inputRow : i32;
+ var inputCol : i32;
+ var param_3 : i32;
+ var param_4 : i32;
+ var innerRow_2 : i32;
+ var innerCol_2 : i32;
+ var inputRow_1 : i32;
+ var inputCol_1 : i32;
+ var param_5 : i32;
+ var param_6 : i32;
+ var k : i32;
+ var inner : i32;
+ var BCached : array<f32, 1>;
+ var innerRow_3 : i32;
+ var ACached : f32;
+ var innerCol_3 : i32;
+ var innerRow_4 : i32;
+ var innerCol_4 : i32;
+ var param_7 : i32;
+ var param_8 : i32;
+ var param_9 : f32;
+ let x_132 : u32 = gl_LocalInvocationID.y;
+ tileRow = (bitcast<i32>(x_132) * 1);
+ let x_137 : u32 = gl_LocalInvocationID.x;
+ tileCol = (bitcast<i32>(x_137) * 1);
+ let x_143 : u32 = gl_GlobalInvocationID.y;
+ globalRow = (bitcast<i32>(x_143) * 1);
+ let x_148 : u32 = gl_GlobalInvocationID.x;
+ globalCol = (bitcast<i32>(x_148) * 1);
+ let x_152 : i32 = *(dimInner);
+ numTiles = (((x_152 - 1) / 64) + 1);
+ innerRow = 0;
+ loop {
+ let x_163 : i32 = innerRow;
+ if ((x_163 < 1)) {
+ } else {
+ break;
+ }
+ innerCol = 0;
+ loop {
+ let x_171 : i32 = innerCol;
+ if ((x_171 < 1)) {
+ } else {
+ break;
+ }
+ let x_177 : i32 = innerRow;
+ let x_178 : i32 = innerCol;
+ acc[x_177][x_178] = 0.0;
+
+ continuing {
+ let x_181 : i32 = innerCol;
+ innerCol = (x_181 + 1);
+ }
+ }
+
+ continuing {
+ let x_183 : i32 = innerRow;
+ innerRow = (x_183 + 1);
+ }
+ }
+ let x_187 : u32 = gl_LocalInvocationID.x;
+ tileColA = (bitcast<i32>(x_187) * 64);
+ let x_192 : u32 = gl_LocalInvocationID.y;
+ tileRowB = (bitcast<i32>(x_192) * 1);
+ t = 0;
+ loop {
+ let x_201 : i32 = t;
+ let x_202 : i32 = numTiles;
+ if ((x_201 < x_202)) {
+ } else {
+ break;
+ }
+ innerRow_1 = 0;
+ loop {
+ let x_210 : i32 = innerRow_1;
+ if ((x_210 < 1)) {
+ } else {
+ break;
+ }
+ innerCol_1 = 0;
+ loop {
+ let x_218 : i32 = innerCol_1;
+ if ((x_218 < 64)) {
+ } else {
+ break;
+ }
+ let x_221 : i32 = tileRow;
+ let x_222 : i32 = innerRow_1;
+ inputRow = (x_221 + x_222);
+ let x_225 : i32 = tileColA;
+ let x_226 : i32 = innerCol_1;
+ inputCol = (x_225 + x_226);
+ let x_233 : i32 = inputRow;
+ let x_234 : i32 = inputCol;
+ let x_235 : i32 = globalRow;
+ let x_236 : i32 = innerRow_1;
+ let x_238 : i32 = t;
+ let x_240 : i32 = inputCol;
+ param_3 = (x_235 + x_236);
+ param_4 = ((x_238 * 64) + x_240);
+ let x_244 : f32 = mm_readA_i1_i1_(&(param_3), &(param_4));
+ mm_Asub[x_233][x_234] = x_244;
+
+ continuing {
+ let x_247 : i32 = innerCol_1;
+ innerCol_1 = (x_247 + 1);
+ }
+ }
+
+ continuing {
+ let x_249 : i32 = innerRow_1;
+ innerRow_1 = (x_249 + 1);
+ }
+ }
+ innerRow_2 = 0;
+ loop {
+ let x_257 : i32 = innerRow_2;
+ if ((x_257 < 1)) {
+ } else {
+ break;
+ }
+ innerCol_2 = 0;
+ loop {
+ let x_265 : i32 = innerCol_2;
+ if ((x_265 < 1)) {
+ } else {
+ break;
+ }
+ let x_268 : i32 = tileRowB;
+ let x_269 : i32 = innerRow_2;
+ inputRow_1 = (x_268 + x_269);
+ let x_272 : i32 = tileCol;
+ let x_273 : i32 = innerCol_2;
+ inputCol_1 = (x_272 + x_273);
+ let x_278 : i32 = inputRow_1;
+ let x_279 : i32 = inputCol_1;
+ let x_280 : i32 = t;
+ let x_282 : i32 = inputRow_1;
+ let x_284 : i32 = globalCol;
+ let x_285 : i32 = innerCol_2;
+ param_5 = ((x_280 * 64) + x_282);
+ param_6 = (x_284 + x_285);
+ let x_289 : f32 = mm_readB_i1_i1_(&(param_5), &(param_6));
+ mm_Bsub[x_278][x_279] = x_289;
+
+ continuing {
+ let x_291 : i32 = innerCol_2;
+ innerCol_2 = (x_291 + 1);
+ }
+ }
+
+ continuing {
+ let x_293 : i32 = innerRow_2;
+ innerRow_2 = (x_293 + 1);
+ }
+ }
+ workgroupBarrier();
+ k = 0;
+ loop {
+ let x_302 : i32 = k;
+ if ((x_302 < 64)) {
+ } else {
+ break;
+ }
+ inner = 0;
+ loop {
+ let x_310 : i32 = inner;
+ if ((x_310 < 1)) {
+ } else {
+ break;
+ }
+ let x_314 : i32 = inner;
+ let x_315 : i32 = k;
+ let x_316 : i32 = tileCol;
+ let x_317 : i32 = inner;
+ let x_320 : f32 = mm_Bsub[x_315][(x_316 + x_317)];
+ BCached[x_314] = x_320;
+
+ continuing {
+ let x_322 : i32 = inner;
+ inner = (x_322 + 1);
+ }
+ }
+ innerRow_3 = 0;
+ loop {
+ let x_330 : i32 = innerRow_3;
+ if ((x_330 < 1)) {
+ } else {
+ break;
+ }
+ let x_333 : i32 = tileRow;
+ let x_334 : i32 = innerRow_3;
+ let x_336 : i32 = k;
+ let x_338 : f32 = mm_Asub[(x_333 + x_334)][x_336];
+ ACached = x_338;
+ innerCol_3 = 0;
+ loop {
+ let x_345 : i32 = innerCol_3;
+ if ((x_345 < 1)) {
+ } else {
+ break;
+ }
+ let x_347 : i32 = innerRow_3;
+ let x_348 : i32 = innerCol_3;
+ let x_349 : f32 = ACached;
+ let x_350 : i32 = innerCol_3;
+ let x_352 : f32 = BCached[x_350];
+ let x_355 : f32 = acc[x_347][x_348];
+ acc[x_347][x_348] = (x_355 + (x_349 * x_352));
+
+ continuing {
+ let x_358 : i32 = innerCol_3;
+ innerCol_3 = (x_358 + 1);
+ }
+ }
+
+ continuing {
+ let x_360 : i32 = innerRow_3;
+ innerRow_3 = (x_360 + 1);
+ }
+ }
+
+ continuing {
+ let x_362 : i32 = k;
+ k = (x_362 + 1);
+ }
+ }
+ workgroupBarrier();
+
+ continuing {
+ let x_364 : i32 = t;
+ t = (x_364 + 1);
+ }
+ }
+ innerRow_4 = 0;
+ loop {
+ let x_372 : i32 = innerRow_4;
+ if ((x_372 < 1)) {
+ } else {
+ break;
+ }
+ innerCol_4 = 0;
+ loop {
+ var x_393 : bool;
+ var x_394_phi : bool;
+ let x_380 : i32 = innerCol_4;
+ if ((x_380 < 1)) {
+ } else {
+ break;
+ }
+ let x_382 : i32 = globalCol;
+ let x_383 : i32 = innerCol_4;
+ let x_385 : i32 = *(dimBOuter);
+ let x_386 : bool = ((x_382 + x_383) < x_385);
+ x_394_phi = x_386;
+ if (x_386) {
+ let x_389 : i32 = globalRow;
+ let x_390 : i32 = innerRow_4;
+ let x_392 : i32 = *(dimAOuter);
+ x_393 = ((x_389 + x_390) < x_392);
+ x_394_phi = x_393;
+ }
+ let x_394 : bool = x_394_phi;
+ if (x_394) {
+ let x_397 : i32 = globalRow;
+ let x_398 : i32 = innerRow_4;
+ let x_400 : i32 = globalCol;
+ let x_401 : i32 = innerCol_4;
+ let x_403 : i32 = innerRow_4;
+ let x_404 : i32 = innerCol_4;
+ param_7 = (x_397 + x_398);
+ param_8 = (x_400 + x_401);
+ let x_409 : f32 = acc[x_403][x_404];
+ param_9 = x_409;
+ mm_write_i1_i1_f1_(&(param_7), &(param_8), &(param_9));
+ }
+
+ continuing {
+ let x_411 : i32 = innerCol_4;
+ innerCol_4 = (x_411 + 1);
+ }
+ }
+
+ continuing {
+ let x_413 : i32 = innerRow_4;
+ innerRow_4 = (x_413 + 1);
+ }
+ }
+ return;
+}
+
+fn main_1() {
+ var param_18 : i32;
+ var param_19 : i32;
+ var param_20 : i32;
+ let x_67 : i32 = x_48.aShape.y;
+ dimAOuter_1 = x_67;
+ let x_71 : i32 = x_48.aShape.z;
+ dimInner_1 = x_71;
+ let x_75 : i32 = x_48.bShape.z;
+ dimBOuter_1 = x_75;
+ let x_505 : u32 = gl_GlobalInvocationID.z;
+ batch = bitcast<i32>(x_505);
+ let x_508 : i32 = dimAOuter_1;
+ param_18 = x_508;
+ let x_510 : i32 = dimInner_1;
+ param_19 = x_510;
+ let x_512 : i32 = dimBOuter_1;
+ param_20 = x_512;
+ mm_matMul_i1_i1_i1_(&(param_18), &(param_19), &(param_20));
+ return;
+}
+
+[[stage(compute), workgroup_size(1, 64, 1)]]
+fn main([[builtin(local_invocation_id)]] gl_LocalInvocationID_param : vec3<u32>, [[builtin(global_invocation_id)]] gl_GlobalInvocationID_param : vec3<u32>) {
+ gl_LocalInvocationID = gl_LocalInvocationID_param;
+ gl_GlobalInvocationID = gl_GlobalInvocationID_param;
+ main_1();
+}
diff --git a/test/bug/tint/948.wgsl b/test/bug/tint/948.wgsl
new file mode 100644
index 0000000..3654f57
--- /dev/null
+++ b/test/bug/tint/948.wgsl
@@ -0,0 +1,229 @@
+[[block]]
+struct LeftOver {
+ time : f32;
+ [[size(12)]]
+ padding : u32;
+ worldViewProjection : mat4x4<f32>;
+ outputSize : vec2<f32>;
+ stageSize : vec2<f32>;
+ spriteMapSize : vec2<f32>;
+ stageScale : f32;
+ spriteCount : f32;
+ colorMul : vec3<f32>;
+};
+
+[[group(2), binding(9)]] var<uniform> x_20 : LeftOver;
+
+[[group(2), binding(3)]] var frameMapTexture : texture_2d<f32>;
+
+[[group(2), binding(2)]] var frameMapSampler : sampler;
+
+var<private> tUV : vec2<f32>;
+
+[[group(2), binding(5)]] var tileMapsTexture0 : texture_2d<f32>;
+
+[[group(2), binding(4)]] var tileMapsSampler : sampler;
+
+[[group(2), binding(6)]] var tileMapsTexture1 : texture_2d<f32>;
+
+[[group(2), binding(8)]] var animationMapTexture : texture_2d<f32>;
+
+[[group(2), binding(7)]] var animationMapSampler : sampler;
+
+var<private> mt : f32;
+
+[[group(2), binding(1)]] var spriteSheetTexture : texture_2d<f32>;
+
+[[group(2), binding(0)]] var spriteSheetSampler : sampler;
+
+var<private> glFragColor : vec4<f32>;
+
+var<private> tileID_1 : vec2<f32>;
+
+var<private> levelUnits : vec2<f32>;
+
+var<private> stageUnits_1 : vec2<f32>;
+
+var<private> vPosition : vec3<f32>;
+
+var<private> vUV : vec2<f32>;
+
+fn getFrameData_f1_(frameID : ptr<function, f32>) -> mat4x4<f32> {
+ var fX : f32;
+ let x_15 : f32 = *(frameID);
+ let x_25 : f32 = x_20.spriteCount;
+ fX = (x_15 / x_25);
+ let x_37 : f32 = fX;
+ let x_40 : vec4<f32> = textureSampleBias(frameMapTexture, frameMapSampler, vec2<f32>(x_37, 0.0), 0.0);
+ let x_44 : f32 = fX;
+ let x_47 : vec4<f32> = textureSampleBias(frameMapTexture, frameMapSampler, vec2<f32>(x_44, 0.25), 0.0);
+ let x_51 : f32 = fX;
+ let x_54 : vec4<f32> = textureSampleBias(frameMapTexture, frameMapSampler, vec2<f32>(x_51, 0.5), 0.0);
+ return mat4x4<f32>(vec4<f32>(x_40.x, x_40.y, x_40.z, x_40.w), vec4<f32>(x_47.x, x_47.y, x_47.z, x_47.w), vec4<f32>(x_54.x, x_54.y, x_54.z, x_54.w), vec4<f32>(vec4<f32>(0.0, 0.0, 0.0, 0.0).x, vec4<f32>(0.0, 0.0, 0.0, 0.0).y, vec4<f32>(0.0, 0.0, 0.0, 0.0).z, vec4<f32>(0.0, 0.0, 0.0, 0.0).w));
+}
+
+fn main_1() {
+ var color : vec4<f32>;
+ var tileUV : vec2<f32>;
+ var tileID : vec2<f32>;
+ var sheetUnits : vec2<f32>;
+ var spriteUnits : f32;
+ var stageUnits : vec2<f32>;
+ var i : i32;
+ var frameID_1 : f32;
+ var animationData : vec4<f32>;
+ var f : f32;
+ var frameData : mat4x4<f32>;
+ var param : f32;
+ var frameSize : vec2<f32>;
+ var offset_1 : vec2<f32>;
+ var ratio : vec2<f32>;
+ var nc : vec4<f32>;
+ var alpha : f32;
+ var mixed : vec3<f32>;
+ color = vec4<f32>(0.0, 0.0, 0.0, 0.0);
+ let x_86 : vec2<f32> = tUV;
+ tileUV = fract(x_86);
+ let x_91 : f32 = tileUV.y;
+ tileUV.y = (1.0 - x_91);
+ let x_95 : vec2<f32> = tUV;
+ tileID = floor(x_95);
+ let x_101 : vec2<f32> = x_20.spriteMapSize;
+ sheetUnits = (vec2<f32>(1.0, 1.0) / x_101);
+ let x_106 : f32 = x_20.spriteCount;
+ spriteUnits = (1.0 / x_106);
+ let x_111 : vec2<f32> = x_20.stageSize;
+ stageUnits = (vec2<f32>(1.0, 1.0) / x_111);
+ i = 0;
+ loop {
+ let x_122 : i32 = i;
+ if ((x_122 < 2)) {
+ } else {
+ break;
+ }
+ let x_126 : i32 = i;
+ switch(x_126) {
+ case 1: {
+ let x_150 : vec2<f32> = tileID;
+ let x_154 : vec2<f32> = x_20.stageSize;
+ let x_156 : vec4<f32> = textureSampleBias(tileMapsTexture1, tileMapsSampler, ((x_150 + vec2<f32>(0.5, 0.5)) / x_154), 0.0);
+ frameID_1 = x_156.x;
+ }
+ case 0: {
+ let x_136 : vec2<f32> = tileID;
+ let x_140 : vec2<f32> = x_20.stageSize;
+ let x_142 : vec4<f32> = textureSampleBias(tileMapsTexture0, tileMapsSampler, ((x_136 + vec2<f32>(0.5, 0.5)) / x_140), 0.0);
+ frameID_1 = x_142.x;
+ }
+ default: {
+ }
+ }
+ let x_166 : f32 = frameID_1;
+ let x_169 : f32 = x_20.spriteCount;
+ let x_172 : vec4<f32> = textureSampleBias(animationMapTexture, animationMapSampler, vec2<f32>(((x_166 + 0.5) / x_169), 0.0), 0.0);
+ animationData = x_172;
+ let x_174 : f32 = animationData.y;
+ if ((x_174 > 0.0)) {
+ let x_181 : f32 = x_20.time;
+ let x_184 : f32 = animationData.z;
+ mt = ((x_181 * x_184) % 1.0);
+ f = 0.0;
+ loop {
+ let x_193 : f32 = f;
+ if ((x_193 < 8.0)) {
+ } else {
+ break;
+ }
+ let x_197 : f32 = animationData.y;
+ let x_198 : f32 = mt;
+ if ((x_197 > x_198)) {
+ let x_203 : f32 = animationData.x;
+ frameID_1 = x_203;
+ break;
+ }
+ let x_208 : f32 = frameID_1;
+ let x_211 : f32 = x_20.spriteCount;
+ let x_214 : f32 = f;
+ let x_217 : vec4<f32> = textureSampleBias(animationMapTexture, animationMapSampler, vec2<f32>(((x_208 + 0.5) / x_211), (0.125 * x_214)), 0.0);
+ animationData = x_217;
+
+ continuing {
+ let x_218 : f32 = f;
+ f = (x_218 + 1.0);
+ }
+ }
+ }
+ let x_222 : f32 = frameID_1;
+ param = (x_222 + 0.5);
+ let x_225 : mat4x4<f32> = getFrameData_f1_(&(param));
+ frameData = x_225;
+ let x_228 : vec4<f32> = frameData[0];
+ let x_231 : vec2<f32> = x_20.spriteMapSize;
+ frameSize = (vec2<f32>(x_228.w, x_228.z) / x_231);
+ let x_235 : vec4<f32> = frameData[0];
+ let x_237 : vec2<f32> = sheetUnits;
+ offset_1 = (vec2<f32>(x_235.x, x_235.y) * x_237);
+ let x_241 : vec4<f32> = frameData[2];
+ let x_244 : vec4<f32> = frameData[0];
+ ratio = (vec2<f32>(x_241.x, x_241.y) / vec2<f32>(x_244.w, x_244.z));
+ let x_248 : f32 = frameData[2].z;
+ if ((x_248 == 1.0)) {
+ let x_252 : vec2<f32> = tileUV;
+ tileUV = vec2<f32>(x_252.y, x_252.x);
+ }
+ let x_254 : i32 = i;
+ if ((x_254 == 0)) {
+ let x_263 : vec2<f32> = tileUV;
+ let x_264 : vec2<f32> = frameSize;
+ let x_266 : vec2<f32> = offset_1;
+ let x_268 : vec4<f32> = textureSample(spriteSheetTexture, spriteSheetSampler, ((x_263 * x_264) + x_266));
+ color = x_268;
+ } else {
+ let x_274 : vec2<f32> = tileUV;
+ let x_275 : vec2<f32> = frameSize;
+ let x_277 : vec2<f32> = offset_1;
+ let x_279 : vec4<f32> = textureSample(spriteSheetTexture, spriteSheetSampler, ((x_274 * x_275) + x_277));
+ nc = x_279;
+ let x_283 : f32 = color.w;
+ let x_285 : f32 = nc.w;
+ alpha = min((x_283 + x_285), 1.0);
+ let x_290 : vec4<f32> = color;
+ let x_292 : vec4<f32> = nc;
+ let x_295 : f32 = nc.w;
+ mixed = mix(vec3<f32>(x_290.x, x_290.y, x_290.z), vec3<f32>(x_292.x, x_292.y, x_292.z), vec3<f32>(x_295, x_295, x_295));
+ let x_298 : vec3<f32> = mixed;
+ let x_299 : f32 = alpha;
+ color = vec4<f32>(x_298.x, x_298.y, x_298.z, x_299);
+ }
+
+ continuing {
+ let x_304 : i32 = i;
+ i = (x_304 + 1);
+ }
+ }
+ let x_310 : vec3<f32> = x_20.colorMul;
+ let x_311 : vec4<f32> = color;
+ let x_313 : vec3<f32> = (vec3<f32>(x_311.x, x_311.y, x_311.z) * x_310);
+ let x_314 : vec4<f32> = color;
+ color = vec4<f32>(x_313.x, x_313.y, x_313.z, x_314.w);
+ let x_318 : vec4<f32> = color;
+ glFragColor = x_318;
+ return;
+}
+
+struct main_out {
+ [[location(0)]]
+ glFragColor_1 : vec4<f32>;
+};
+
+[[stage(fragment)]]
+fn main([[location(2)]] tUV_param : vec2<f32>, [[location(5)]] tileID_1_param : vec2<f32>, [[location(4)]] levelUnits_param : vec2<f32>, [[location(3)]] stageUnits_1_param : vec2<f32>, [[location(0)]] vPosition_param : vec3<f32>, [[location(1)]] vUV_param : vec2<f32>) -> main_out {
+ tUV = tUV_param;
+ tileID_1 = tileID_1_param;
+ levelUnits = levelUnits_param;
+ stageUnits_1 = stageUnits_1_param;
+ vPosition = vPosition_param;
+ vUV = vUV_param;
+ main_1();
+ return main_out(glFragColor);
+}
\ No newline at end of file
diff --git a/test/bug/tint/948.wgsl.expected.hlsl b/test/bug/tint/948.wgsl.expected.hlsl
new file mode 100644
index 0000000..f852d43
--- /dev/null
+++ b/test/bug/tint/948.wgsl.expected.hlsl
@@ -0,0 +1,234 @@
+cbuffer cbuffer_x_20 : register(b9, space2) {
+ uint4 x_20[8];
+};
+Texture2D<float4> frameMapTexture : register(t3, space2);
+SamplerState frameMapSampler : register(s2, space2);
+static float2 tUV = float2(0.0f, 0.0f);
+Texture2D<float4> tileMapsTexture0 : register(t5, space2);
+SamplerState tileMapsSampler : register(s4, space2);
+Texture2D<float4> tileMapsTexture1 : register(t6, space2);
+Texture2D<float4> animationMapTexture : register(t8, space2);
+SamplerState animationMapSampler : register(s7, space2);
+static float mt = 0.0f;
+Texture2D<float4> spriteSheetTexture : register(t1, space2);
+SamplerState spriteSheetSampler : register(s0, space2);
+static float4 glFragColor = float4(0.0f, 0.0f, 0.0f, 0.0f);
+static float2 tileID_1 = float2(0.0f, 0.0f);
+static float2 levelUnits = float2(0.0f, 0.0f);
+static float2 stageUnits_1 = float2(0.0f, 0.0f);
+static float3 vPosition = float3(0.0f, 0.0f, 0.0f);
+static float2 vUV = float2(0.0f, 0.0f);
+
+float4x4 getFrameData_f1_(inout float frameID) {
+ float fX = 0.0f;
+ const float x_15 = frameID;
+ const uint scalar_offset = (108u) / 4;
+ const float x_25 = asfloat(x_20[scalar_offset / 4][scalar_offset % 4]);
+ fX = (x_15 / x_25);
+ const float x_37 = fX;
+ const float4 x_40 = frameMapTexture.SampleBias(frameMapSampler, float2(x_37, 0.0f), 0.0f);
+ const float x_44 = fX;
+ const float4 x_47 = frameMapTexture.SampleBias(frameMapSampler, float2(x_44, 0.25f), 0.0f);
+ const float x_51 = fX;
+ const float4 x_54 = frameMapTexture.SampleBias(frameMapSampler, float2(x_51, 0.5f), 0.0f);
+ return float4x4(float4(x_40.x, x_40.y, x_40.z, x_40.w), float4(x_47.x, x_47.y, x_47.z, x_47.w), float4(x_54.x, x_54.y, x_54.z, x_54.w), float4(float4(0.0f, 0.0f, 0.0f, 0.0f).x, float4(0.0f, 0.0f, 0.0f, 0.0f).y, float4(0.0f, 0.0f, 0.0f, 0.0f).z, float4(0.0f, 0.0f, 0.0f, 0.0f).w));
+}
+
+void main_1() {
+ float4 color = float4(0.0f, 0.0f, 0.0f, 0.0f);
+ float2 tileUV = float2(0.0f, 0.0f);
+ float2 tileID = float2(0.0f, 0.0f);
+ float2 sheetUnits = float2(0.0f, 0.0f);
+ float spriteUnits = 0.0f;
+ float2 stageUnits = float2(0.0f, 0.0f);
+ int i = 0;
+ float frameID_1 = 0.0f;
+ float4 animationData = float4(0.0f, 0.0f, 0.0f, 0.0f);
+ float f = 0.0f;
+ float4x4 frameData = float4x4(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
+ float param = 0.0f;
+ float2 frameSize = float2(0.0f, 0.0f);
+ float2 offset_1 = float2(0.0f, 0.0f);
+ float2 ratio = float2(0.0f, 0.0f);
+ float4 nc = float4(0.0f, 0.0f, 0.0f, 0.0f);
+ float alpha = 0.0f;
+ float3 mixed = float3(0.0f, 0.0f, 0.0f);
+ color = float4(0.0f, 0.0f, 0.0f, 0.0f);
+ const float2 x_86 = tUV;
+ tileUV = frac(x_86);
+ const float x_91 = tileUV.y;
+ tileUV.y = (1.0f - x_91);
+ const float2 x_95 = tUV;
+ tileID = floor(x_95);
+ const uint scalar_offset_1 = (96u) / 4;
+ uint4 ubo_load = x_20[scalar_offset_1 / 4];
+ const float2 x_101 = asfloat(((scalar_offset_1 & 2) ? ubo_load.zw : ubo_load.xy));
+ sheetUnits = (float2(1.0f, 1.0f) / x_101);
+ const uint scalar_offset_2 = (108u) / 4;
+ const float x_106 = asfloat(x_20[scalar_offset_2 / 4][scalar_offset_2 % 4]);
+ spriteUnits = (1.0f / x_106);
+ const uint scalar_offset_3 = (88u) / 4;
+ uint4 ubo_load_1 = x_20[scalar_offset_3 / 4];
+ const float2 x_111 = asfloat(((scalar_offset_3 & 2) ? ubo_load_1.zw : ubo_load_1.xy));
+ stageUnits = (float2(1.0f, 1.0f) / x_111);
+ i = 0;
+ while (true) {
+ const int x_122 = i;
+ if ((x_122 < 2)) {
+ } else {
+ break;
+ }
+ const int x_126 = i;
+ switch(x_126) {
+ case 1: {
+ const float2 x_150 = tileID;
+ const uint scalar_offset_4 = (88u) / 4;
+ uint4 ubo_load_2 = x_20[scalar_offset_4 / 4];
+ const float2 x_154 = asfloat(((scalar_offset_4 & 2) ? ubo_load_2.zw : ubo_load_2.xy));
+ const float4 x_156 = tileMapsTexture1.SampleBias(tileMapsSampler, ((x_150 + float2(0.5f, 0.5f)) / x_154), 0.0f);
+ frameID_1 = x_156.x;
+ break;
+ }
+ case 0: {
+ const float2 x_136 = tileID;
+ const uint scalar_offset_5 = (88u) / 4;
+ uint4 ubo_load_3 = x_20[scalar_offset_5 / 4];
+ const float2 x_140 = asfloat(((scalar_offset_5 & 2) ? ubo_load_3.zw : ubo_load_3.xy));
+ const float4 x_142 = tileMapsTexture0.SampleBias(tileMapsSampler, ((x_136 + float2(0.5f, 0.5f)) / x_140), 0.0f);
+ frameID_1 = x_142.x;
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+ const float x_166 = frameID_1;
+ const uint scalar_offset_6 = (108u) / 4;
+ const float x_169 = asfloat(x_20[scalar_offset_6 / 4][scalar_offset_6 % 4]);
+ const float4 x_172 = animationMapTexture.SampleBias(animationMapSampler, float2(((x_166 + 0.5f) / x_169), 0.0f), 0.0f);
+ animationData = x_172;
+ const float x_174 = animationData.y;
+ if ((x_174 > 0.0f)) {
+ const uint scalar_offset_7 = (0u) / 4;
+ const float x_181 = asfloat(x_20[scalar_offset_7 / 4][scalar_offset_7 % 4]);
+ const float x_184 = animationData.z;
+ mt = ((x_181 * x_184) % 1.0f);
+ f = 0.0f;
+ while (true) {
+ const float x_193 = f;
+ if ((x_193 < 8.0f)) {
+ } else {
+ break;
+ }
+ const float x_197 = animationData.y;
+ const float x_198 = mt;
+ if ((x_197 > x_198)) {
+ const float x_203 = animationData.x;
+ frameID_1 = x_203;
+ break;
+ }
+ const float x_208 = frameID_1;
+ const uint scalar_offset_8 = (108u) / 4;
+ const float x_211 = asfloat(x_20[scalar_offset_8 / 4][scalar_offset_8 % 4]);
+ const float x_214 = f;
+ const float4 x_217 = animationMapTexture.SampleBias(animationMapSampler, float2(((x_208 + 0.5f) / x_211), (0.125f * x_214)), 0.0f);
+ animationData = x_217;
+ {
+ const float x_218 = f;
+ f = (x_218 + 1.0f);
+ }
+ }
+ }
+ const float x_222 = frameID_1;
+ param = (x_222 + 0.5f);
+ const float4x4 x_225 = getFrameData_f1_(param);
+ frameData = x_225;
+ const float4 x_228 = frameData[0];
+ const uint scalar_offset_9 = (96u) / 4;
+ uint4 ubo_load_4 = x_20[scalar_offset_9 / 4];
+ const float2 x_231 = asfloat(((scalar_offset_9 & 2) ? ubo_load_4.zw : ubo_load_4.xy));
+ frameSize = (float2(x_228.w, x_228.z) / x_231);
+ const float4 x_235 = frameData[0];
+ const float2 x_237 = sheetUnits;
+ offset_1 = (float2(x_235.x, x_235.y) * x_237);
+ const float4 x_241 = frameData[2];
+ const float4 x_244 = frameData[0];
+ ratio = (float2(x_241.x, x_241.y) / float2(x_244.w, x_244.z));
+ const float x_248 = frameData[2].z;
+ if ((x_248 == 1.0f)) {
+ const float2 x_252 = tileUV;
+ tileUV = float2(x_252.y, x_252.x);
+ }
+ const int x_254 = i;
+ if ((x_254 == 0)) {
+ const float2 x_263 = tileUV;
+ const float2 x_264 = frameSize;
+ const float2 x_266 = offset_1;
+ const float4 x_268 = spriteSheetTexture.Sample(spriteSheetSampler, ((x_263 * x_264) + x_266));
+ color = x_268;
+ } else {
+ const float2 x_274 = tileUV;
+ const float2 x_275 = frameSize;
+ const float2 x_277 = offset_1;
+ const float4 x_279 = spriteSheetTexture.Sample(spriteSheetSampler, ((x_274 * x_275) + x_277));
+ nc = x_279;
+ const float x_283 = color.w;
+ const float x_285 = nc.w;
+ alpha = min((x_283 + x_285), 1.0f);
+ const float4 x_290 = color;
+ const float4 x_292 = nc;
+ const float x_295 = nc.w;
+ mixed = lerp(float3(x_290.x, x_290.y, x_290.z), float3(x_292.x, x_292.y, x_292.z), float3(x_295, x_295, x_295));
+ const float3 x_298 = mixed;
+ const float x_299 = alpha;
+ color = float4(x_298.x, x_298.y, x_298.z, x_299);
+ }
+ {
+ const int x_304 = i;
+ i = (x_304 + 1);
+ }
+ }
+ const uint scalar_offset_10 = (112u) / 4;
+ const float3 x_310 = asfloat(x_20[scalar_offset_10 / 4].xyz);
+ const float4 x_311 = color;
+ const float3 x_313 = (float3(x_311.x, x_311.y, x_311.z) * x_310);
+ const float4 x_314 = color;
+ color = float4(x_313.x, x_313.y, x_313.z, x_314.w);
+ const float4 x_318 = color;
+ glFragColor = x_318;
+ return;
+}
+
+struct main_out {
+ float4 glFragColor_1;
+};
+struct tint_symbol_1 {
+ float3 vPosition_param : TEXCOORD0;
+ float2 vUV_param : TEXCOORD1;
+ float2 tUV_param : TEXCOORD2;
+ float2 stageUnits_1_param : TEXCOORD3;
+ float2 levelUnits_param : TEXCOORD4;
+ float2 tileID_1_param : TEXCOORD5;
+};
+struct tint_symbol_2 {
+ float4 glFragColor_1 : SV_Target0;
+};
+
+tint_symbol_2 main(tint_symbol_1 tint_symbol) {
+ const float2 tUV_param = tint_symbol.tUV_param;
+ const float2 tileID_1_param = tint_symbol.tileID_1_param;
+ const float2 levelUnits_param = tint_symbol.levelUnits_param;
+ const float2 stageUnits_1_param = tint_symbol.stageUnits_1_param;
+ const float3 vPosition_param = tint_symbol.vPosition_param;
+ const float2 vUV_param = tint_symbol.vUV_param;
+ tUV = tUV_param;
+ tileID_1 = tileID_1_param;
+ levelUnits = levelUnits_param;
+ stageUnits_1 = stageUnits_1_param;
+ vPosition = vPosition_param;
+ vUV = vUV_param;
+ main_1();
+ const main_out tint_symbol_3 = {glFragColor};
+ const tint_symbol_2 tint_symbol_7 = {tint_symbol_3.glFragColor_1};
+ return tint_symbol_7;
+}
diff --git a/test/bug/tint/948.wgsl.expected.msl b/test/bug/tint/948.wgsl.expected.msl
new file mode 100644
index 0000000..55d9052
--- /dev/null
+++ b/test/bug/tint/948.wgsl.expected.msl
@@ -0,0 +1,11 @@
+SKIP: FAILED
+
+
+
+Validation Failure:
+
+Compilation failed:
+
+program_source:113:44: error: invalid operands to binary expression ('float' and 'float')
+ *(tint_symbol_14) = ((x_181 * x_184) % 1.0f);
+ ~~~~~~~~~~~~~~~ ^ ~~~~
diff --git a/test/bug/tint/948.wgsl.expected.spvasm b/test/bug/tint/948.wgsl.expected.spvasm
new file mode 100644
index 0000000..f4c18cf
--- /dev/null
+++ b/test/bug/tint/948.wgsl.expected.spvasm
@@ -0,0 +1,572 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 381
+; Schema: 0
+ OpCapability Shader
+ %138 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Fragment %main "main" %tint_symbol %tint_symbol_1 %tint_symbol_2 %tint_symbol_3 %tint_symbol_4 %tint_symbol_5 %tint_symbol_7
+ OpExecutionMode %main OriginUpperLeft
+ OpName %LeftOver "LeftOver"
+ OpMemberName %LeftOver 0 "time"
+ OpMemberName %LeftOver 1 "padding"
+ OpMemberName %LeftOver 2 "worldViewProjection"
+ OpMemberName %LeftOver 3 "outputSize"
+ OpMemberName %LeftOver 4 "stageSize"
+ OpMemberName %LeftOver 5 "spriteMapSize"
+ OpMemberName %LeftOver 6 "stageScale"
+ OpMemberName %LeftOver 7 "spriteCount"
+ OpMemberName %LeftOver 8 "colorMul"
+ OpName %x_20 "x_20"
+ OpName %frameMapTexture "frameMapTexture"
+ OpName %frameMapSampler "frameMapSampler"
+ OpName %tUV "tUV"
+ OpName %tileMapsTexture0 "tileMapsTexture0"
+ OpName %tileMapsSampler "tileMapsSampler"
+ OpName %tileMapsTexture1 "tileMapsTexture1"
+ OpName %animationMapTexture "animationMapTexture"
+ OpName %animationMapSampler "animationMapSampler"
+ OpName %mt "mt"
+ OpName %spriteSheetTexture "spriteSheetTexture"
+ OpName %spriteSheetSampler "spriteSheetSampler"
+ OpName %glFragColor "glFragColor"
+ OpName %tileID_1 "tileID_1"
+ OpName %levelUnits "levelUnits"
+ OpName %stageUnits_1 "stageUnits_1"
+ OpName %vPosition "vPosition"
+ OpName %vUV "vUV"
+ OpName %tint_symbol "tint_symbol"
+ OpName %tint_symbol_1 "tint_symbol_1"
+ OpName %tint_symbol_2 "tint_symbol_2"
+ OpName %tint_symbol_3 "tint_symbol_3"
+ OpName %tint_symbol_4 "tint_symbol_4"
+ OpName %tint_symbol_5 "tint_symbol_5"
+ OpName %tint_symbol_7 "tint_symbol_7"
+ OpName %getFrameData_f1_ "getFrameData_f1_"
+ OpName %frameID "frameID"
+ OpName %fX "fX"
+ OpName %main_1 "main_1"
+ OpName %color "color"
+ OpName %tileUV "tileUV"
+ OpName %tileID "tileID"
+ OpName %sheetUnits "sheetUnits"
+ OpName %spriteUnits "spriteUnits"
+ OpName %stageUnits "stageUnits"
+ OpName %i "i"
+ OpName %frameID_1 "frameID_1"
+ OpName %animationData "animationData"
+ OpName %f "f"
+ OpName %frameData "frameData"
+ OpName %param "param"
+ OpName %frameSize "frameSize"
+ OpName %offset_1 "offset_1"
+ OpName %ratio "ratio"
+ OpName %nc "nc"
+ OpName %alpha "alpha"
+ OpName %mixed "mixed"
+ OpName %main_out "main_out"
+ OpMemberName %main_out 0 "glFragColor_1"
+ OpName %tint_symbol_8 "tint_symbol_8"
+ OpName %tint_symbol_6 "tint_symbol_6"
+ OpName %main "main"
+ OpDecorate %LeftOver Block
+ OpMemberDecorate %LeftOver 0 Offset 0
+ OpMemberDecorate %LeftOver 1 Offset 4
+ OpMemberDecorate %LeftOver 2 Offset 16
+ OpMemberDecorate %LeftOver 2 ColMajor
+ OpMemberDecorate %LeftOver 2 MatrixStride 16
+ OpMemberDecorate %LeftOver 3 Offset 80
+ OpMemberDecorate %LeftOver 4 Offset 88
+ OpMemberDecorate %LeftOver 5 Offset 96
+ OpMemberDecorate %LeftOver 6 Offset 104
+ OpMemberDecorate %LeftOver 7 Offset 108
+ OpMemberDecorate %LeftOver 8 Offset 112
+ OpDecorate %x_20 NonWritable
+ OpDecorate %x_20 DescriptorSet 2
+ OpDecorate %x_20 Binding 9
+ OpDecorate %frameMapTexture DescriptorSet 2
+ OpDecorate %frameMapTexture Binding 3
+ OpDecorate %frameMapSampler DescriptorSet 2
+ OpDecorate %frameMapSampler Binding 2
+ OpDecorate %tileMapsTexture0 DescriptorSet 2
+ OpDecorate %tileMapsTexture0 Binding 5
+ OpDecorate %tileMapsSampler DescriptorSet 2
+ OpDecorate %tileMapsSampler Binding 4
+ OpDecorate %tileMapsTexture1 DescriptorSet 2
+ OpDecorate %tileMapsTexture1 Binding 6
+ OpDecorate %animationMapTexture DescriptorSet 2
+ OpDecorate %animationMapTexture Binding 8
+ OpDecorate %animationMapSampler DescriptorSet 2
+ OpDecorate %animationMapSampler Binding 7
+ OpDecorate %spriteSheetTexture DescriptorSet 2
+ OpDecorate %spriteSheetTexture Binding 1
+ OpDecorate %spriteSheetSampler DescriptorSet 2
+ OpDecorate %spriteSheetSampler Binding 0
+ OpDecorate %tint_symbol Location 2
+ OpDecorate %tint_symbol_1 Location 5
+ OpDecorate %tint_symbol_2 Location 4
+ OpDecorate %tint_symbol_3 Location 3
+ OpDecorate %tint_symbol_4 Location 0
+ OpDecorate %tint_symbol_5 Location 1
+ OpDecorate %tint_symbol_7 Location 0
+ OpMemberDecorate %main_out 0 Offset 0
+ %float = OpTypeFloat 32
+ %uint = OpTypeInt 32 0
+ %v4float = OpTypeVector %float 4
+%mat4v4float = OpTypeMatrix %v4float 4
+ %v2float = OpTypeVector %float 2
+ %v3float = OpTypeVector %float 3
+ %LeftOver = OpTypeStruct %float %uint %mat4v4float %v2float %v2float %v2float %float %float %v3float
+%_ptr_Uniform_LeftOver = OpTypePointer Uniform %LeftOver
+ %x_20 = OpVariable %_ptr_Uniform_LeftOver Uniform
+ %12 = OpTypeImage %float 2D 0 0 0 1 Unknown
+%_ptr_UniformConstant_12 = OpTypePointer UniformConstant %12
+%frameMapTexture = OpVariable %_ptr_UniformConstant_12 UniformConstant
+ %15 = OpTypeSampler
+%_ptr_UniformConstant_15 = OpTypePointer UniformConstant %15
+%frameMapSampler = OpVariable %_ptr_UniformConstant_15 UniformConstant
+%_ptr_Private_v2float = OpTypePointer Private %v2float
+ %18 = OpConstantNull %v2float
+ %tUV = OpVariable %_ptr_Private_v2float Private %18
+%tileMapsTexture0 = OpVariable %_ptr_UniformConstant_12 UniformConstant
+%tileMapsSampler = OpVariable %_ptr_UniformConstant_15 UniformConstant
+%tileMapsTexture1 = OpVariable %_ptr_UniformConstant_12 UniformConstant
+%animationMapTexture = OpVariable %_ptr_UniformConstant_12 UniformConstant
+%animationMapSampler = OpVariable %_ptr_UniformConstant_15 UniformConstant
+%_ptr_Private_float = OpTypePointer Private %float
+ %26 = OpConstantNull %float
+ %mt = OpVariable %_ptr_Private_float Private %26
+%spriteSheetTexture = OpVariable %_ptr_UniformConstant_12 UniformConstant
+%spriteSheetSampler = OpVariable %_ptr_UniformConstant_15 UniformConstant
+%_ptr_Private_v4float = OpTypePointer Private %v4float
+ %31 = OpConstantNull %v4float
+%glFragColor = OpVariable %_ptr_Private_v4float Private %31
+ %tileID_1 = OpVariable %_ptr_Private_v2float Private %18
+ %levelUnits = OpVariable %_ptr_Private_v2float Private %18
+%stageUnits_1 = OpVariable %_ptr_Private_v2float Private %18
+%_ptr_Private_v3float = OpTypePointer Private %v3float
+ %37 = OpConstantNull %v3float
+ %vPosition = OpVariable %_ptr_Private_v3float Private %37
+ %vUV = OpVariable %_ptr_Private_v2float Private %18
+%_ptr_Input_v2float = OpTypePointer Input %v2float
+%tint_symbol = OpVariable %_ptr_Input_v2float Input
+%tint_symbol_1 = OpVariable %_ptr_Input_v2float Input
+%tint_symbol_2 = OpVariable %_ptr_Input_v2float Input
+%tint_symbol_3 = OpVariable %_ptr_Input_v2float Input
+%_ptr_Input_v3float = OpTypePointer Input %v3float
+%tint_symbol_4 = OpVariable %_ptr_Input_v3float Input
+%tint_symbol_5 = OpVariable %_ptr_Input_v2float Input
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+%tint_symbol_7 = OpVariable %_ptr_Output_v4float Output %31
+%_ptr_Function_float = OpTypePointer Function %float
+ %49 = OpTypeFunction %mat4v4float %_ptr_Function_float
+ %uint_7 = OpConstant %uint 7
+%_ptr_Uniform_float = OpTypePointer Uniform %float
+ %66 = OpTypeSampledImage %12
+ %float_0 = OpConstant %float 0
+ %float_0_25 = OpConstant %float 0.25
+ %float_0_5 = OpConstant %float 0.5
+ %99 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
+ %void = OpTypeVoid
+ %106 = OpTypeFunction %void
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+ %int = OpTypeInt 32 1
+%_ptr_Function_int = OpTypePointer Function %int
+ %121 = OpConstantNull %int
+%_ptr_Function_mat4v4float = OpTypePointer Function %mat4v4float
+ %127 = OpConstantNull %mat4v4float
+%_ptr_Function_v3float = OpTypePointer Function %v3float
+ %uint_1 = OpConstant %uint 1
+ %float_1 = OpConstant %float 1
+ %uint_5 = OpConstant %uint 5
+%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
+ %151 = OpConstantComposite %v2float %float_1 %float_1
+ %uint_4 = OpConstant %uint 4
+ %int_0 = OpConstant %int 0
+ %int_2 = OpConstant %int 2
+ %bool = OpTypeBool
+ %184 = OpConstantComposite %v2float %float_0_5 %float_0_5
+ %uint_0 = OpConstant %uint 0
+ %uint_2 = OpConstant %uint 2
+ %float_8 = OpConstant %float 8
+%float_0_125 = OpConstant %float 0.125
+ %uint_3 = OpConstant %uint 3
+ %int_1 = OpConstant %int 1
+ %uint_8 = OpConstant %uint 8
+%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float
+ %main_out = OpTypeStruct %v4float
+ %363 = OpTypeFunction %void %main_out
+%getFrameData_f1_ = OpFunction %mat4v4float None %49
+ %frameID = OpFunctionParameter %_ptr_Function_float
+ %53 = OpLabel
+ %fX = OpVariable %_ptr_Function_float Function %26
+ %56 = OpLoad %float %frameID
+ %59 = OpAccessChain %_ptr_Uniform_float %x_20 %uint_7
+ %60 = OpLoad %float %59
+ %61 = OpFDiv %float %56 %60
+ OpStore %fX %61
+ %62 = OpLoad %float %fX
+ %64 = OpLoad %15 %frameMapSampler
+ %65 = OpLoad %12 %frameMapTexture
+ %67 = OpSampledImage %66 %65 %64
+ %69 = OpCompositeConstruct %v2float %62 %float_0
+ %63 = OpImageSampleImplicitLod %v4float %67 %69 Bias %float_0
+ %70 = OpLoad %float %fX
+ %72 = OpLoad %15 %frameMapSampler
+ %73 = OpLoad %12 %frameMapTexture
+ %74 = OpSampledImage %66 %73 %72
+ %76 = OpCompositeConstruct %v2float %70 %float_0_25
+ %71 = OpImageSampleImplicitLod %v4float %74 %76 Bias %float_0
+ %77 = OpLoad %float %fX
+ %79 = OpLoad %15 %frameMapSampler
+ %80 = OpLoad %12 %frameMapTexture
+ %81 = OpSampledImage %66 %80 %79
+ %83 = OpCompositeConstruct %v2float %77 %float_0_5
+ %78 = OpImageSampleImplicitLod %v4float %81 %83 Bias %float_0
+ %84 = OpCompositeExtract %float %63 0
+ %85 = OpCompositeExtract %float %63 1
+ %86 = OpCompositeExtract %float %63 2
+ %87 = OpCompositeExtract %float %63 3
+ %88 = OpCompositeConstruct %v4float %84 %85 %86 %87
+ %89 = OpCompositeExtract %float %71 0
+ %90 = OpCompositeExtract %float %71 1
+ %91 = OpCompositeExtract %float %71 2
+ %92 = OpCompositeExtract %float %71 3
+ %93 = OpCompositeConstruct %v4float %89 %90 %91 %92
+ %94 = OpCompositeExtract %float %78 0
+ %95 = OpCompositeExtract %float %78 1
+ %96 = OpCompositeExtract %float %78 2
+ %97 = OpCompositeExtract %float %78 3
+ %98 = OpCompositeConstruct %v4float %94 %95 %96 %97
+ %100 = OpCompositeExtract %float %99 0
+ %101 = OpCompositeExtract %float %99 1
+ %102 = OpCompositeExtract %float %99 2
+ %103 = OpCompositeExtract %float %99 3
+ %104 = OpCompositeConstruct %v4float %100 %101 %102 %103
+ %105 = OpCompositeConstruct %mat4v4float %88 %93 %98 %104
+ OpReturnValue %105
+ OpFunctionEnd
+ %main_1 = OpFunction %void None %106
+ %109 = OpLabel
+ %color = OpVariable %_ptr_Function_v4float Function %31
+ %tileUV = OpVariable %_ptr_Function_v2float Function %18
+ %tileID = OpVariable %_ptr_Function_v2float Function %18
+ %sheetUnits = OpVariable %_ptr_Function_v2float Function %18
+%spriteUnits = OpVariable %_ptr_Function_float Function %26
+ %stageUnits = OpVariable %_ptr_Function_v2float Function %18
+ %i = OpVariable %_ptr_Function_int Function %121
+ %frameID_1 = OpVariable %_ptr_Function_float Function %26
+%animationData = OpVariable %_ptr_Function_v4float Function %31
+ %f = OpVariable %_ptr_Function_float Function %26
+ %frameData = OpVariable %_ptr_Function_mat4v4float Function %127
+ %param = OpVariable %_ptr_Function_float Function %26
+ %frameSize = OpVariable %_ptr_Function_v2float Function %18
+ %offset_1 = OpVariable %_ptr_Function_v2float Function %18
+ %ratio = OpVariable %_ptr_Function_v2float Function %18
+ %nc = OpVariable %_ptr_Function_v4float Function %31
+ %alpha = OpVariable %_ptr_Function_float Function %26
+ %mixed = OpVariable %_ptr_Function_v3float Function %37
+ OpStore %color %99
+ %136 = OpLoad %v2float %tUV
+ %137 = OpExtInst %v2float %138 Fract %136
+ OpStore %tileUV %137
+ %140 = OpAccessChain %_ptr_Function_float %tileUV %uint_1
+ %141 = OpLoad %float %140
+ %142 = OpAccessChain %_ptr_Function_float %tileUV %uint_1
+ %144 = OpFSub %float %float_1 %141
+ OpStore %142 %144
+ %145 = OpLoad %v2float %tUV
+ %146 = OpExtInst %v2float %138 Floor %145
+ OpStore %tileID %146
+ %149 = OpAccessChain %_ptr_Uniform_v2float %x_20 %uint_5
+ %150 = OpLoad %v2float %149
+ %152 = OpFDiv %v2float %151 %150
+ OpStore %sheetUnits %152
+ %153 = OpAccessChain %_ptr_Uniform_float %x_20 %uint_7
+ %154 = OpLoad %float %153
+ %155 = OpFDiv %float %float_1 %154
+ OpStore %spriteUnits %155
+ %157 = OpAccessChain %_ptr_Uniform_v2float %x_20 %uint_4
+ %158 = OpLoad %v2float %157
+ %159 = OpFDiv %v2float %151 %158
+ OpStore %stageUnits %159
+ OpStore %i %int_0
+ OpBranch %161
+ %161 = OpLabel
+ OpLoopMerge %162 %163 None
+ OpBranch %164
+ %164 = OpLabel
+ %165 = OpLoad %int %i
+ %167 = OpSLessThan %bool %165 %int_2
+ OpSelectionMerge %169 None
+ OpBranchConditional %167 %170 %171
+ %170 = OpLabel
+ OpBranch %169
+ %171 = OpLabel
+ OpBranch %162
+ %169 = OpLabel
+ %172 = OpLoad %int %i
+ OpSelectionMerge %173 None
+ OpSwitch %172 %174 1 %175 0 %176
+ %175 = OpLabel
+ %177 = OpLoad %v2float %tileID
+ %178 = OpAccessChain %_ptr_Uniform_v2float %x_20 %uint_4
+ %179 = OpLoad %v2float %178
+ %181 = OpLoad %15 %tileMapsSampler
+ %182 = OpLoad %12 %tileMapsTexture1
+ %183 = OpSampledImage %66 %182 %181
+ %185 = OpFAdd %v2float %177 %184
+ %186 = OpFDiv %v2float %185 %179
+ %180 = OpImageSampleImplicitLod %v4float %183 %186 Bias %float_0
+ %187 = OpCompositeExtract %float %180 0
+ OpStore %frameID_1 %187
+ OpBranch %173
+ %176 = OpLabel
+ %188 = OpLoad %v2float %tileID
+ %189 = OpAccessChain %_ptr_Uniform_v2float %x_20 %uint_4
+ %190 = OpLoad %v2float %189
+ %192 = OpLoad %15 %tileMapsSampler
+ %193 = OpLoad %12 %tileMapsTexture0
+ %194 = OpSampledImage %66 %193 %192
+ %195 = OpFAdd %v2float %188 %184
+ %196 = OpFDiv %v2float %195 %190
+ %191 = OpImageSampleImplicitLod %v4float %194 %196 Bias %float_0
+ %197 = OpCompositeExtract %float %191 0
+ OpStore %frameID_1 %197
+ OpBranch %173
+ %174 = OpLabel
+ OpBranch %173
+ %173 = OpLabel
+ %198 = OpLoad %float %frameID_1
+ %199 = OpAccessChain %_ptr_Uniform_float %x_20 %uint_7
+ %200 = OpLoad %float %199
+ %202 = OpLoad %15 %animationMapSampler
+ %203 = OpLoad %12 %animationMapTexture
+ %204 = OpSampledImage %66 %203 %202
+ %205 = OpFAdd %float %198 %float_0_5
+ %206 = OpFDiv %float %205 %200
+ %207 = OpCompositeConstruct %v2float %206 %float_0
+ %201 = OpImageSampleImplicitLod %v4float %204 %207 Bias %float_0
+ OpStore %animationData %201
+ %208 = OpAccessChain %_ptr_Function_float %animationData %uint_1
+ %209 = OpLoad %float %208
+ %210 = OpFOrdGreaterThan %bool %209 %float_0
+ OpSelectionMerge %211 None
+ OpBranchConditional %210 %212 %211
+ %212 = OpLabel
+ %214 = OpAccessChain %_ptr_Uniform_float %x_20 %uint_0
+ %215 = OpLoad %float %214
+ %217 = OpAccessChain %_ptr_Function_float %animationData %uint_2
+ %218 = OpLoad %float %217
+ %219 = OpFMul %float %215 %218
+ %220 = OpFMod %float %219 %float_1
+ OpStore %mt %220
+ OpStore %f %float_0
+ OpBranch %221
+ %221 = OpLabel
+ OpLoopMerge %222 %223 None
+ OpBranch %224
+ %224 = OpLabel
+ %225 = OpLoad %float %f
+ %227 = OpFOrdLessThan %bool %225 %float_8
+ OpSelectionMerge %228 None
+ OpBranchConditional %227 %229 %230
+ %229 = OpLabel
+ OpBranch %228
+ %230 = OpLabel
+ OpBranch %222
+ %228 = OpLabel
+ %231 = OpAccessChain %_ptr_Function_float %animationData %uint_1
+ %232 = OpLoad %float %231
+ %233 = OpLoad %float %mt
+ %234 = OpFOrdGreaterThan %bool %232 %233
+ OpSelectionMerge %235 None
+ OpBranchConditional %234 %236 %235
+ %236 = OpLabel
+ %237 = OpAccessChain %_ptr_Function_float %animationData %uint_0
+ %238 = OpLoad %float %237
+ OpStore %frameID_1 %238
+ OpBranch %222
+ %235 = OpLabel
+ %239 = OpLoad %float %frameID_1
+ %240 = OpAccessChain %_ptr_Uniform_float %x_20 %uint_7
+ %241 = OpLoad %float %240
+ %242 = OpLoad %float %f
+ %244 = OpLoad %15 %animationMapSampler
+ %245 = OpLoad %12 %animationMapTexture
+ %246 = OpSampledImage %66 %245 %244
+ %247 = OpFAdd %float %239 %float_0_5
+ %248 = OpFDiv %float %247 %241
+ %250 = OpFMul %float %float_0_125 %242
+ %251 = OpCompositeConstruct %v2float %248 %250
+ %243 = OpImageSampleImplicitLod %v4float %246 %251 Bias %float_0
+ OpStore %animationData %243
+ OpBranch %223
+ %223 = OpLabel
+ %252 = OpLoad %float %f
+ %253 = OpFAdd %float %252 %float_1
+ OpStore %f %253
+ OpBranch %221
+ %222 = OpLabel
+ OpBranch %211
+ %211 = OpLabel
+ %254 = OpLoad %float %frameID_1
+ %255 = OpFAdd %float %254 %float_0_5
+ OpStore %param %255
+ %256 = OpFunctionCall %mat4v4float %getFrameData_f1_ %param
+ OpStore %frameData %256
+ %258 = OpAccessChain %_ptr_Function_v4float %frameData %int_0
+ %259 = OpLoad %v4float %258
+ %260 = OpAccessChain %_ptr_Uniform_v2float %x_20 %uint_5
+ %261 = OpLoad %v2float %260
+ %262 = OpCompositeExtract %float %259 3
+ %263 = OpCompositeExtract %float %259 2
+ %264 = OpCompositeConstruct %v2float %262 %263
+ %265 = OpFDiv %v2float %264 %261
+ OpStore %frameSize %265
+ %266 = OpAccessChain %_ptr_Function_v4float %frameData %int_0
+ %267 = OpLoad %v4float %266
+ %268 = OpLoad %v2float %sheetUnits
+ %269 = OpCompositeExtract %float %267 0
+ %270 = OpCompositeExtract %float %267 1
+ %271 = OpCompositeConstruct %v2float %269 %270
+ %272 = OpFMul %v2float %271 %268
+ OpStore %offset_1 %272
+ %273 = OpAccessChain %_ptr_Function_v4float %frameData %int_2
+ %274 = OpLoad %v4float %273
+ %275 = OpAccessChain %_ptr_Function_v4float %frameData %int_0
+ %276 = OpLoad %v4float %275
+ %277 = OpCompositeExtract %float %274 0
+ %278 = OpCompositeExtract %float %274 1
+ %279 = OpCompositeConstruct %v2float %277 %278
+ %280 = OpCompositeExtract %float %276 3
+ %281 = OpCompositeExtract %float %276 2
+ %282 = OpCompositeConstruct %v2float %280 %281
+ %283 = OpFDiv %v2float %279 %282
+ OpStore %ratio %283
+ %284 = OpAccessChain %_ptr_Function_float %frameData %int_2 %uint_2
+ %285 = OpLoad %float %284
+ %286 = OpFOrdEqual %bool %285 %float_1
+ OpSelectionMerge %287 None
+ OpBranchConditional %286 %288 %287
+ %288 = OpLabel
+ %289 = OpLoad %v2float %tileUV
+ %290 = OpCompositeExtract %float %289 1
+ %291 = OpCompositeExtract %float %289 0
+ %292 = OpCompositeConstruct %v2float %290 %291
+ OpStore %tileUV %292
+ OpBranch %287
+ %287 = OpLabel
+ %293 = OpLoad %int %i
+ %294 = OpIEqual %bool %293 %int_0
+ OpSelectionMerge %295 None
+ OpBranchConditional %294 %296 %297
+ %296 = OpLabel
+ %298 = OpLoad %v2float %tileUV
+ %299 = OpLoad %v2float %frameSize
+ %300 = OpLoad %v2float %offset_1
+ %302 = OpLoad %15 %spriteSheetSampler
+ %303 = OpLoad %12 %spriteSheetTexture
+ %304 = OpSampledImage %66 %303 %302
+ %305 = OpFMul %v2float %298 %299
+ %306 = OpFAdd %v2float %305 %300
+ %301 = OpImageSampleImplicitLod %v4float %304 %306
+ OpStore %color %301
+ OpBranch %295
+ %297 = OpLabel
+ %307 = OpLoad %v2float %tileUV
+ %308 = OpLoad %v2float %frameSize
+ %309 = OpLoad %v2float %offset_1
+ %311 = OpLoad %15 %spriteSheetSampler
+ %312 = OpLoad %12 %spriteSheetTexture
+ %313 = OpSampledImage %66 %312 %311
+ %314 = OpFMul %v2float %307 %308
+ %315 = OpFAdd %v2float %314 %309
+ %310 = OpImageSampleImplicitLod %v4float %313 %315
+ OpStore %nc %310
+ %317 = OpAccessChain %_ptr_Function_float %color %uint_3
+ %318 = OpLoad %float %317
+ %319 = OpAccessChain %_ptr_Function_float %nc %uint_3
+ %320 = OpLoad %float %319
+ %322 = OpFAdd %float %318 %320
+ %321 = OpExtInst %float %138 NMin %322 %float_1
+ OpStore %alpha %321
+ %323 = OpLoad %v4float %color
+ %324 = OpLoad %v4float %nc
+ %325 = OpAccessChain %_ptr_Function_float %nc %uint_3
+ %326 = OpLoad %float %325
+ %328 = OpCompositeExtract %float %323 0
+ %329 = OpCompositeExtract %float %323 1
+ %330 = OpCompositeExtract %float %323 2
+ %331 = OpCompositeConstruct %v3float %328 %329 %330
+ %332 = OpCompositeExtract %float %324 0
+ %333 = OpCompositeExtract %float %324 1
+ %334 = OpCompositeExtract %float %324 2
+ %335 = OpCompositeConstruct %v3float %332 %333 %334
+ %336 = OpCompositeConstruct %v3float %326 %326 %326
+ %327 = OpExtInst %v3float %138 FMix %331 %335 %336
+ OpStore %mixed %327
+ %337 = OpLoad %v3float %mixed
+ %338 = OpLoad %float %alpha
+ %339 = OpCompositeExtract %float %337 0
+ %340 = OpCompositeExtract %float %337 1
+ %341 = OpCompositeExtract %float %337 2
+ %342 = OpCompositeConstruct %v4float %339 %340 %341 %338
+ OpStore %color %342
+ OpBranch %295
+ %295 = OpLabel
+ OpBranch %163
+ %163 = OpLabel
+ %343 = OpLoad %int %i
+ %345 = OpIAdd %int %343 %int_1
+ OpStore %i %345
+ OpBranch %161
+ %162 = OpLabel
+ %348 = OpAccessChain %_ptr_Uniform_v3float %x_20 %uint_8
+ %349 = OpLoad %v3float %348
+ %350 = OpLoad %v4float %color
+ %351 = OpCompositeExtract %float %350 0
+ %352 = OpCompositeExtract %float %350 1
+ %353 = OpCompositeExtract %float %350 2
+ %354 = OpCompositeConstruct %v3float %351 %352 %353
+ %355 = OpFMul %v3float %354 %349
+ %356 = OpLoad %v4float %color
+ %357 = OpCompositeExtract %float %355 0
+ %358 = OpCompositeExtract %float %355 1
+ %359 = OpCompositeExtract %float %355 2
+ %360 = OpCompositeExtract %float %356 3
+ %361 = OpCompositeConstruct %v4float %357 %358 %359 %360
+ OpStore %color %361
+ %362 = OpLoad %v4float %color
+ OpStore %glFragColor %362
+ OpReturn
+ OpFunctionEnd
+%tint_symbol_8 = OpFunction %void None %363
+%tint_symbol_6 = OpFunctionParameter %main_out
+ %367 = OpLabel
+ %368 = OpCompositeExtract %v4float %tint_symbol_6 0
+ OpStore %tint_symbol_7 %368
+ OpReturn
+ OpFunctionEnd
+ %main = OpFunction %void None %106
+ %370 = OpLabel
+ %371 = OpLoad %v2float %tint_symbol
+ OpStore %tUV %371
+ %372 = OpLoad %v2float %tint_symbol_1
+ OpStore %tileID_1 %372
+ %373 = OpLoad %v2float %tint_symbol_2
+ OpStore %levelUnits %373
+ %374 = OpLoad %v2float %tint_symbol_3
+ OpStore %stageUnits_1 %374
+ %375 = OpLoad %v3float %tint_symbol_4
+ OpStore %vPosition %375
+ %376 = OpLoad %v2float %tint_symbol_5
+ OpStore %vUV %376
+ %377 = OpFunctionCall %void %main_1
+ %379 = OpLoad %v4float %glFragColor
+ %380 = OpCompositeConstruct %main_out %379
+ %378 = OpFunctionCall %void %tint_symbol_8 %380
+ OpReturn
+ OpFunctionEnd
diff --git a/test/bug/tint/948.wgsl.expected.wgsl b/test/bug/tint/948.wgsl.expected.wgsl
new file mode 100644
index 0000000..9a337f7
--- /dev/null
+++ b/test/bug/tint/948.wgsl.expected.wgsl
@@ -0,0 +1,229 @@
+[[block]]
+struct LeftOver {
+ time : f32;
+ [[size(12)]]
+ padding : u32;
+ worldViewProjection : mat4x4<f32>;
+ outputSize : vec2<f32>;
+ stageSize : vec2<f32>;
+ spriteMapSize : vec2<f32>;
+ stageScale : f32;
+ spriteCount : f32;
+ colorMul : vec3<f32>;
+};
+
+[[group(2), binding(9)]] var<uniform> x_20 : LeftOver;
+
+[[group(2), binding(3)]] var frameMapTexture : texture_2d<f32>;
+
+[[group(2), binding(2)]] var frameMapSampler : sampler;
+
+var<private> tUV : vec2<f32>;
+
+[[group(2), binding(5)]] var tileMapsTexture0 : texture_2d<f32>;
+
+[[group(2), binding(4)]] var tileMapsSampler : sampler;
+
+[[group(2), binding(6)]] var tileMapsTexture1 : texture_2d<f32>;
+
+[[group(2), binding(8)]] var animationMapTexture : texture_2d<f32>;
+
+[[group(2), binding(7)]] var animationMapSampler : sampler;
+
+var<private> mt : f32;
+
+[[group(2), binding(1)]] var spriteSheetTexture : texture_2d<f32>;
+
+[[group(2), binding(0)]] var spriteSheetSampler : sampler;
+
+var<private> glFragColor : vec4<f32>;
+
+var<private> tileID_1 : vec2<f32>;
+
+var<private> levelUnits : vec2<f32>;
+
+var<private> stageUnits_1 : vec2<f32>;
+
+var<private> vPosition : vec3<f32>;
+
+var<private> vUV : vec2<f32>;
+
+fn getFrameData_f1_(frameID : ptr<function, f32>) -> mat4x4<f32> {
+ var fX : f32;
+ let x_15 : f32 = *(frameID);
+ let x_25 : f32 = x_20.spriteCount;
+ fX = (x_15 / x_25);
+ let x_37 : f32 = fX;
+ let x_40 : vec4<f32> = textureSampleBias(frameMapTexture, frameMapSampler, vec2<f32>(x_37, 0.0), 0.0);
+ let x_44 : f32 = fX;
+ let x_47 : vec4<f32> = textureSampleBias(frameMapTexture, frameMapSampler, vec2<f32>(x_44, 0.25), 0.0);
+ let x_51 : f32 = fX;
+ let x_54 : vec4<f32> = textureSampleBias(frameMapTexture, frameMapSampler, vec2<f32>(x_51, 0.5), 0.0);
+ return mat4x4<f32>(vec4<f32>(x_40.x, x_40.y, x_40.z, x_40.w), vec4<f32>(x_47.x, x_47.y, x_47.z, x_47.w), vec4<f32>(x_54.x, x_54.y, x_54.z, x_54.w), vec4<f32>(vec4<f32>(0.0, 0.0, 0.0, 0.0).x, vec4<f32>(0.0, 0.0, 0.0, 0.0).y, vec4<f32>(0.0, 0.0, 0.0, 0.0).z, vec4<f32>(0.0, 0.0, 0.0, 0.0).w));
+}
+
+fn main_1() {
+ var color : vec4<f32>;
+ var tileUV : vec2<f32>;
+ var tileID : vec2<f32>;
+ var sheetUnits : vec2<f32>;
+ var spriteUnits : f32;
+ var stageUnits : vec2<f32>;
+ var i : i32;
+ var frameID_1 : f32;
+ var animationData : vec4<f32>;
+ var f : f32;
+ var frameData : mat4x4<f32>;
+ var param : f32;
+ var frameSize : vec2<f32>;
+ var offset_1 : vec2<f32>;
+ var ratio : vec2<f32>;
+ var nc : vec4<f32>;
+ var alpha : f32;
+ var mixed : vec3<f32>;
+ color = vec4<f32>(0.0, 0.0, 0.0, 0.0);
+ let x_86 : vec2<f32> = tUV;
+ tileUV = fract(x_86);
+ let x_91 : f32 = tileUV.y;
+ tileUV.y = (1.0 - x_91);
+ let x_95 : vec2<f32> = tUV;
+ tileID = floor(x_95);
+ let x_101 : vec2<f32> = x_20.spriteMapSize;
+ sheetUnits = (vec2<f32>(1.0, 1.0) / x_101);
+ let x_106 : f32 = x_20.spriteCount;
+ spriteUnits = (1.0 / x_106);
+ let x_111 : vec2<f32> = x_20.stageSize;
+ stageUnits = (vec2<f32>(1.0, 1.0) / x_111);
+ i = 0;
+ loop {
+ let x_122 : i32 = i;
+ if ((x_122 < 2)) {
+ } else {
+ break;
+ }
+ let x_126 : i32 = i;
+ switch(x_126) {
+ case 1: {
+ let x_150 : vec2<f32> = tileID;
+ let x_154 : vec2<f32> = x_20.stageSize;
+ let x_156 : vec4<f32> = textureSampleBias(tileMapsTexture1, tileMapsSampler, ((x_150 + vec2<f32>(0.5, 0.5)) / x_154), 0.0);
+ frameID_1 = x_156.x;
+ }
+ case 0: {
+ let x_136 : vec2<f32> = tileID;
+ let x_140 : vec2<f32> = x_20.stageSize;
+ let x_142 : vec4<f32> = textureSampleBias(tileMapsTexture0, tileMapsSampler, ((x_136 + vec2<f32>(0.5, 0.5)) / x_140), 0.0);
+ frameID_1 = x_142.x;
+ }
+ default: {
+ }
+ }
+ let x_166 : f32 = frameID_1;
+ let x_169 : f32 = x_20.spriteCount;
+ let x_172 : vec4<f32> = textureSampleBias(animationMapTexture, animationMapSampler, vec2<f32>(((x_166 + 0.5) / x_169), 0.0), 0.0);
+ animationData = x_172;
+ let x_174 : f32 = animationData.y;
+ if ((x_174 > 0.0)) {
+ let x_181 : f32 = x_20.time;
+ let x_184 : f32 = animationData.z;
+ mt = ((x_181 * x_184) % 1.0);
+ f = 0.0;
+ loop {
+ let x_193 : f32 = f;
+ if ((x_193 < 8.0)) {
+ } else {
+ break;
+ }
+ let x_197 : f32 = animationData.y;
+ let x_198 : f32 = mt;
+ if ((x_197 > x_198)) {
+ let x_203 : f32 = animationData.x;
+ frameID_1 = x_203;
+ break;
+ }
+ let x_208 : f32 = frameID_1;
+ let x_211 : f32 = x_20.spriteCount;
+ let x_214 : f32 = f;
+ let x_217 : vec4<f32> = textureSampleBias(animationMapTexture, animationMapSampler, vec2<f32>(((x_208 + 0.5) / x_211), (0.125 * x_214)), 0.0);
+ animationData = x_217;
+
+ continuing {
+ let x_218 : f32 = f;
+ f = (x_218 + 1.0);
+ }
+ }
+ }
+ let x_222 : f32 = frameID_1;
+ param = (x_222 + 0.5);
+ let x_225 : mat4x4<f32> = getFrameData_f1_(&(param));
+ frameData = x_225;
+ let x_228 : vec4<f32> = frameData[0];
+ let x_231 : vec2<f32> = x_20.spriteMapSize;
+ frameSize = (vec2<f32>(x_228.w, x_228.z) / x_231);
+ let x_235 : vec4<f32> = frameData[0];
+ let x_237 : vec2<f32> = sheetUnits;
+ offset_1 = (vec2<f32>(x_235.x, x_235.y) * x_237);
+ let x_241 : vec4<f32> = frameData[2];
+ let x_244 : vec4<f32> = frameData[0];
+ ratio = (vec2<f32>(x_241.x, x_241.y) / vec2<f32>(x_244.w, x_244.z));
+ let x_248 : f32 = frameData[2].z;
+ if ((x_248 == 1.0)) {
+ let x_252 : vec2<f32> = tileUV;
+ tileUV = vec2<f32>(x_252.y, x_252.x);
+ }
+ let x_254 : i32 = i;
+ if ((x_254 == 0)) {
+ let x_263 : vec2<f32> = tileUV;
+ let x_264 : vec2<f32> = frameSize;
+ let x_266 : vec2<f32> = offset_1;
+ let x_268 : vec4<f32> = textureSample(spriteSheetTexture, spriteSheetSampler, ((x_263 * x_264) + x_266));
+ color = x_268;
+ } else {
+ let x_274 : vec2<f32> = tileUV;
+ let x_275 : vec2<f32> = frameSize;
+ let x_277 : vec2<f32> = offset_1;
+ let x_279 : vec4<f32> = textureSample(spriteSheetTexture, spriteSheetSampler, ((x_274 * x_275) + x_277));
+ nc = x_279;
+ let x_283 : f32 = color.w;
+ let x_285 : f32 = nc.w;
+ alpha = min((x_283 + x_285), 1.0);
+ let x_290 : vec4<f32> = color;
+ let x_292 : vec4<f32> = nc;
+ let x_295 : f32 = nc.w;
+ mixed = mix(vec3<f32>(x_290.x, x_290.y, x_290.z), vec3<f32>(x_292.x, x_292.y, x_292.z), vec3<f32>(x_295, x_295, x_295));
+ let x_298 : vec3<f32> = mixed;
+ let x_299 : f32 = alpha;
+ color = vec4<f32>(x_298.x, x_298.y, x_298.z, x_299);
+ }
+
+ continuing {
+ let x_304 : i32 = i;
+ i = (x_304 + 1);
+ }
+ }
+ let x_310 : vec3<f32> = x_20.colorMul;
+ let x_311 : vec4<f32> = color;
+ let x_313 : vec3<f32> = (vec3<f32>(x_311.x, x_311.y, x_311.z) * x_310);
+ let x_314 : vec4<f32> = color;
+ color = vec4<f32>(x_313.x, x_313.y, x_313.z, x_314.w);
+ let x_318 : vec4<f32> = color;
+ glFragColor = x_318;
+ return;
+}
+
+struct main_out {
+ [[location(0)]]
+ glFragColor_1 : vec4<f32>;
+};
+
+[[stage(fragment)]]
+fn main([[location(2)]] tUV_param : vec2<f32>, [[location(5)]] tileID_1_param : vec2<f32>, [[location(4)]] levelUnits_param : vec2<f32>, [[location(3)]] stageUnits_1_param : vec2<f32>, [[location(0)]] vPosition_param : vec3<f32>, [[location(1)]] vUV_param : vec2<f32>) -> main_out {
+ tUV = tUV_param;
+ tileID_1 = tileID_1_param;
+ levelUnits = levelUnits_param;
+ stageUnits_1 = stageUnits_1_param;
+ vPosition = vPosition_param;
+ vUV = vUV_param;
+ main_1();
+ return main_out(glFragColor);
+}
diff --git a/test/bug/tint/949.wgsl b/test/bug/tint/949.wgsl
new file mode 100644
index 0000000..41be7ed
--- /dev/null
+++ b/test/bug/tint/949.wgsl
@@ -0,0 +1,455 @@
+// Dumped generated WGSL
+struct lightingInfo {
+ diffuse : vec3<f32>;
+ specular : vec3<f32>;
+};
+
+[[block]]
+struct LeftOver {
+ u_World : mat4x4<f32>;
+ u_ViewProjection : mat4x4<f32>;
+ u_bumpStrength : f32;
+ [[size(12)]]
+ padding : u32;
+ u_cameraPosition : vec3<f32>;
+ u_parallaxScale : f32;
+ textureInfoName : f32;
+ [[size(4)]]
+ padding_1 : u32;
+ tangentSpaceParameter0 : vec2<f32>;
+};
+
+[[block]]
+struct Light0 {
+ vLightData : vec4<f32>;
+ vLightDiffuse : vec4<f32>;
+ vLightSpecular : vec4<f32>;
+ vLightGround : vec3<f32>;
+ [[size(4)]]
+ padding_2 : u32;
+ shadowsInfo : vec4<f32>;
+ depthValues : vec2<f32>;
+};
+
+var<private> u_Float : f32;
+
+var<private> u_Color : vec3<f32>;
+
+[[group(2), binding(1)]] var TextureSamplerTexture : texture_2d<f32>;
+
+[[group(2), binding(0)]] var TextureSamplerSampler : sampler;
+
+var<private> vMainuv : vec2<f32>;
+
+[[group(2), binding(6)]] var<uniform> x_269 : LeftOver;
+
+var<private> v_output1 : vec4<f32>;
+
+var<private> gl_FrontFacing : bool;
+
+var<private> v_uv : vec2<f32>;
+
+var<private> v_output2 : vec4<f32>;
+
+[[group(2), binding(3)]] var TextureSampler1Texture : texture_2d<f32>;
+
+[[group(2), binding(2)]] var TextureSampler1Sampler : sampler;
+
+[[group(0), binding(5)]] var<uniform> light0 : Light0;
+
+var<private> glFragColor : vec4<f32>;
+
+[[group(2), binding(4)]] var bumpSamplerSampler : sampler;
+
+[[group(2), binding(5)]] var bumpSamplerTexture : texture_2d<f32>;
+
+fn cotangent_frame_vf3_vf3_vf2_vf2_(normal_1 : ptr<function, vec3<f32>>, p : ptr<function, vec3<f32>>, uv : ptr<function, vec2<f32>>, tangentSpaceParams : ptr<function, vec2<f32>>) -> mat3x3<f32> {
+ var dp1 : vec3<f32>;
+ var dp2 : vec3<f32>;
+ var duv1 : vec2<f32>;
+ var duv2 : vec2<f32>;
+ var dp2perp : vec3<f32>;
+ var dp1perp : vec3<f32>;
+ var tangent : vec3<f32>;
+ var bitangent : vec3<f32>;
+ var invmax : f32;
+ let x_133 : vec3<f32> = *(p);
+ dp1 = dpdx(x_133);
+ let x_136 : vec3<f32> = *(p);
+ dp2 = dpdy(x_136);
+ let x_139 : vec2<f32> = *(uv);
+ duv1 = dpdx(x_139);
+ let x_142 : vec2<f32> = *(uv);
+ duv2 = dpdy(x_142);
+ let x_145 : vec3<f32> = dp2;
+ let x_146 : vec3<f32> = *(normal_1);
+ dp2perp = cross(x_145, x_146);
+ let x_149 : vec3<f32> = *(normal_1);
+ let x_150 : vec3<f32> = dp1;
+ dp1perp = cross(x_149, x_150);
+ let x_153 : vec3<f32> = dp2perp;
+ let x_155 : f32 = duv1.x;
+ let x_157 : vec3<f32> = dp1perp;
+ let x_159 : f32 = duv2.x;
+ tangent = ((x_153 * x_155) + (x_157 * x_159));
+ let x_163 : vec3<f32> = dp2perp;
+ let x_165 : f32 = duv1.y;
+ let x_167 : vec3<f32> = dp1perp;
+ let x_169 : f32 = duv2.y;
+ bitangent = ((x_163 * x_165) + (x_167 * x_169));
+ let x_173 : f32 = (*(tangentSpaceParams)).x;
+ let x_174 : vec3<f32> = tangent;
+ tangent = (x_174 * x_173);
+ let x_177 : f32 = (*(tangentSpaceParams)).y;
+ let x_178 : vec3<f32> = bitangent;
+ bitangent = (x_178 * x_177);
+ let x_181 : vec3<f32> = tangent;
+ let x_182 : vec3<f32> = tangent;
+ let x_184 : vec3<f32> = bitangent;
+ let x_185 : vec3<f32> = bitangent;
+ invmax = inverseSqrt(max(dot(x_181, x_182), dot(x_184, x_185)));
+ let x_189 : vec3<f32> = tangent;
+ let x_190 : f32 = invmax;
+ let x_191 : vec3<f32> = (x_189 * x_190);
+ let x_192 : vec3<f32> = bitangent;
+ let x_193 : f32 = invmax;
+ let x_194 : vec3<f32> = (x_192 * x_193);
+ let x_195 : vec3<f32> = *(normal_1);
+ return mat3x3<f32>(vec3<f32>(x_191.x, x_191.y, x_191.z), vec3<f32>(x_194.x, x_194.y, x_194.z), vec3<f32>(x_195.x, x_195.y, x_195.z));
+}
+
+fn transposeMat3_mf33_(inMatrix : ptr<function, mat3x3<f32>>) -> mat3x3<f32> {
+ var i0 : vec3<f32>;
+ var i1 : vec3<f32>;
+ var i2 : vec3<f32>;
+ var outMatrix : mat3x3<f32>;
+ let x_60 : vec3<f32> = (*(inMatrix))[0];
+ i0 = x_60;
+ let x_64 : vec3<f32> = (*(inMatrix))[1];
+ i1 = x_64;
+ let x_68 : vec3<f32> = (*(inMatrix))[2];
+ i2 = x_68;
+ let x_73 : f32 = i0.x;
+ let x_75 : f32 = i1.x;
+ let x_77 : f32 = i2.x;
+ let x_78 : vec3<f32> = vec3<f32>(x_73, x_75, x_77);
+ let x_81 : f32 = i0.y;
+ let x_83 : f32 = i1.y;
+ let x_85 : f32 = i2.y;
+ let x_86 : vec3<f32> = vec3<f32>(x_81, x_83, x_85);
+ let x_89 : f32 = i0.z;
+ let x_91 : f32 = i1.z;
+ let x_93 : f32 = i2.z;
+ let x_94 : vec3<f32> = vec3<f32>(x_89, x_91, x_93);
+ outMatrix = mat3x3<f32>(vec3<f32>(x_78.x, x_78.y, x_78.z), vec3<f32>(x_86.x, x_86.y, x_86.z), vec3<f32>(x_94.x, x_94.y, x_94.z));
+ let x_110 : mat3x3<f32> = outMatrix;
+ return x_110;
+}
+
+fn perturbNormalBase_mf33_vf3_f1_(cotangentFrame : ptr<function, mat3x3<f32>>, normal : ptr<function, vec3<f32>>, scale : ptr<function, f32>) -> vec3<f32> {
+ let x_113 : mat3x3<f32> = *(cotangentFrame);
+ let x_114 : vec3<f32> = *(normal);
+ return normalize((x_113 * x_114));
+}
+
+fn perturbNormal_mf33_vf3_f1_(cotangentFrame_1 : ptr<function, mat3x3<f32>>, textureSample : ptr<function, vec3<f32>>, scale_1 : ptr<function, f32>) -> vec3<f32> {
+ var param : mat3x3<f32>;
+ var param_1 : vec3<f32>;
+ var param_2 : f32;
+ let x_119 : vec3<f32> = *(textureSample);
+ let x_125 : mat3x3<f32> = *(cotangentFrame_1);
+ param = x_125;
+ param_1 = ((x_119 * 2.0) - vec3<f32>(1.0, 1.0, 1.0));
+ let x_128 : f32 = *(scale_1);
+ param_2 = x_128;
+ let x_129 : vec3<f32> = perturbNormalBase_mf33_vf3_f1_(&(param), &(param_1), &(param_2));
+ return x_129;
+}
+
+fn computeHemisphericLighting_vf3_vf3_vf4_vf3_vf3_vf3_f1_(viewDirectionW : ptr<function, vec3<f32>>, vNormal : ptr<function, vec3<f32>>, lightData : ptr<function, vec4<f32>>, diffuseColor : ptr<function, vec3<f32>>, specularColor : ptr<function, vec3<f32>>, groundColor : ptr<function, vec3<f32>>, glossiness : ptr<function, f32>) -> lightingInfo {
+ var ndl : f32;
+ var result : lightingInfo;
+ var angleW : vec3<f32>;
+ var specComp : f32;
+ let x_212 : vec3<f32> = *(vNormal);
+ let x_213 : vec4<f32> = *(lightData);
+ ndl = ((dot(x_212, vec3<f32>(x_213.x, x_213.y, x_213.z)) * 0.5) + 0.5);
+ let x_220 : vec3<f32> = *(groundColor);
+ let x_221 : vec3<f32> = *(diffuseColor);
+ let x_222 : f32 = ndl;
+ result.diffuse = mix(x_220, x_221, vec3<f32>(x_222, x_222, x_222));
+ let x_227 : vec3<f32> = *(viewDirectionW);
+ let x_228 : vec4<f32> = *(lightData);
+ angleW = normalize((x_227 + vec3<f32>(x_228.x, x_228.y, x_228.z)));
+ let x_233 : vec3<f32> = *(vNormal);
+ let x_234 : vec3<f32> = angleW;
+ specComp = max(0.0, dot(x_233, x_234));
+ let x_237 : f32 = specComp;
+ let x_238 : f32 = *(glossiness);
+ specComp = pow(x_237, max(1.0, x_238));
+ let x_241 : f32 = specComp;
+ let x_242 : vec3<f32> = *(specularColor);
+ result.specular = (x_242 * x_241);
+ let x_245 : lightingInfo = result;
+ return x_245;
+}
+
+fn main_1() {
+ var tempTextureRead : vec4<f32>;
+ var rgb : vec3<f32>;
+ var output5 : vec3<f32>;
+ var output4 : vec4<f32>;
+ var uvOffset : vec2<f32>;
+ var normalScale : f32;
+ var TBNUV : vec2<f32>;
+ var x_299 : vec2<f32>;
+ var TBN : mat3x3<f32>;
+ var param_3 : vec3<f32>;
+ var param_4 : vec3<f32>;
+ var param_5 : vec2<f32>;
+ var param_6 : vec2<f32>;
+ var invTBN : mat3x3<f32>;
+ var param_7 : mat3x3<f32>;
+ var parallaxLimit : f32;
+ var vOffsetDir : vec2<f32>;
+ var vMaxOffset : vec2<f32>;
+ var numSamples : f32;
+ var stepSize : f32;
+ var currRayHeight : f32;
+ var vCurrOffset : vec2<f32>;
+ var vLastOffset : vec2<f32>;
+ var lastSampledHeight : f32;
+ var currSampledHeight : f32;
+ var i : i32;
+ var delta1 : f32;
+ var delta2 : f32;
+ var ratio : f32;
+ var parallaxOcclusion_0 : vec2<f32>;
+ var param_8 : mat3x3<f32>;
+ var param_9 : vec3<f32>;
+ var param_10 : f32;
+ var output6 : vec2<f32>;
+ var tempTextureRead1 : vec4<f32>;
+ var rgb1 : vec3<f32>;
+ var viewDirectionW_1 : vec3<f32>;
+ var shadow : f32;
+ var glossiness_1 : f32;
+ var diffuseBase : vec3<f32>;
+ var specularBase : vec3<f32>;
+ var normalW : vec3<f32>;
+ var info : lightingInfo;
+ var param_11 : vec3<f32>;
+ var param_12 : vec3<f32>;
+ var param_13 : vec4<f32>;
+ var param_14 : vec3<f32>;
+ var param_15 : vec3<f32>;
+ var param_16 : vec3<f32>;
+ var param_17 : f32;
+ var diffuseOutput : vec3<f32>;
+ var specularOutput : vec3<f32>;
+ var output3 : vec3<f32>;
+ u_Float = 100.0;
+ u_Color = vec3<f32>(0.5, 0.5, 0.5);
+ let x_261 : vec2<f32> = vMainuv;
+ let x_262 : vec4<f32> = textureSample(TextureSamplerTexture, TextureSamplerSampler, x_261);
+ tempTextureRead = x_262;
+ let x_264 : vec4<f32> = tempTextureRead;
+ let x_273 : f32 = x_269.textureInfoName;
+ rgb = (vec3<f32>(x_264.x, x_264.y, x_264.z) * x_273);
+ let x_279 : vec3<f32> = x_269.u_cameraPosition;
+ let x_282 : vec4<f32> = v_output1;
+ output5 = normalize((x_279 - vec3<f32>(x_282.x, x_282.y, x_282.z)));
+ output4 = vec4<f32>(0.0, 0.0, 0.0, 0.0);
+ uvOffset = vec2<f32>(0.0, 0.0);
+ let x_292 : f32 = x_269.u_bumpStrength;
+ normalScale = (1.0 / x_292);
+ let x_298 : bool = gl_FrontFacing;
+ if (x_298) {
+ let x_303 : vec2<f32> = v_uv;
+ x_299 = x_303;
+ } else {
+ let x_305 : vec2<f32> = v_uv;
+ x_299 = -(x_305);
+ }
+ let x_307 : vec2<f32> = x_299;
+ TBNUV = x_307;
+ let x_310 : vec4<f32> = v_output2;
+ let x_312 : f32 = normalScale;
+ param_3 = (vec3<f32>(x_310.x, x_310.y, x_310.z) * x_312);
+ let x_317 : vec4<f32> = v_output1;
+ param_4 = vec3<f32>(x_317.x, x_317.y, x_317.z);
+ let x_320 : vec2<f32> = TBNUV;
+ param_5 = x_320;
+ let x_324 : vec2<f32> = x_269.tangentSpaceParameter0;
+ param_6 = x_324;
+ let x_325 : mat3x3<f32> = cotangent_frame_vf3_vf3_vf2_vf2_(&(param_3), &(param_4), &(param_5), &(param_6));
+ TBN = x_325;
+ let x_328 : mat3x3<f32> = TBN;
+ param_7 = x_328;
+ let x_329 : mat3x3<f32> = transposeMat3_mf33_(&(param_7));
+ invTBN = x_329;
+ let x_331 : mat3x3<f32> = invTBN;
+ let x_332 : vec3<f32> = output5;
+ let x_334 : vec3<f32> = (x_331 * -(x_332));
+ let x_337 : mat3x3<f32> = invTBN;
+ let x_338 : vec3<f32> = output5;
+ parallaxLimit = (length(vec2<f32>(x_334.x, x_334.y)) / ((x_337 * -(x_338))).z);
+ let x_345 : f32 = x_269.u_parallaxScale;
+ let x_346 : f32 = parallaxLimit;
+ parallaxLimit = (x_346 * x_345);
+ let x_349 : mat3x3<f32> = invTBN;
+ let x_350 : vec3<f32> = output5;
+ let x_352 : vec3<f32> = (x_349 * -(x_350));
+ vOffsetDir = normalize(vec2<f32>(x_352.x, x_352.y));
+ let x_356 : vec2<f32> = vOffsetDir;
+ let x_357 : f32 = parallaxLimit;
+ vMaxOffset = (x_356 * x_357);
+ let x_361 : mat3x3<f32> = invTBN;
+ let x_362 : vec3<f32> = output5;
+ let x_365 : mat3x3<f32> = invTBN;
+ let x_366 : vec4<f32> = v_output2;
+ numSamples = (15.0 + (dot((x_361 * -(x_362)), (x_365 * vec3<f32>(x_366.x, x_366.y, x_366.z))) * -11.0));
+ let x_374 : f32 = numSamples;
+ stepSize = (1.0 / x_374);
+ currRayHeight = 1.0;
+ vCurrOffset = vec2<f32>(0.0, 0.0);
+ vLastOffset = vec2<f32>(0.0, 0.0);
+ lastSampledHeight = 1.0;
+ currSampledHeight = 1.0;
+ i = 0;
+ loop {
+ let x_388 : i32 = i;
+ if ((x_388 < 15)) {
+ } else {
+ break;
+ }
+ let x_394 : vec2<f32> = v_uv;
+ let x_395 : vec2<f32> = vCurrOffset;
+ let x_397 : vec4<f32> = textureSample(TextureSamplerTexture, TextureSamplerSampler, (x_394 + x_395));
+ currSampledHeight = x_397.w;
+ let x_400 : f32 = currSampledHeight;
+ let x_401 : f32 = currRayHeight;
+ if ((x_400 > x_401)) {
+ let x_406 : f32 = currSampledHeight;
+ let x_407 : f32 = currRayHeight;
+ delta1 = (x_406 - x_407);
+ let x_410 : f32 = currRayHeight;
+ let x_411 : f32 = stepSize;
+ let x_413 : f32 = lastSampledHeight;
+ delta2 = ((x_410 + x_411) - x_413);
+ let x_416 : f32 = delta1;
+ let x_417 : f32 = delta1;
+ let x_418 : f32 = delta2;
+ ratio = (x_416 / (x_417 + x_418));
+ let x_421 : f32 = ratio;
+ let x_422 : vec2<f32> = vLastOffset;
+ let x_424 : f32 = ratio;
+ let x_426 : vec2<f32> = vCurrOffset;
+ vCurrOffset = ((x_422 * x_421) + (x_426 * (1.0 - x_424)));
+ break;
+ } else {
+ let x_431 : f32 = stepSize;
+ let x_432 : f32 = currRayHeight;
+ currRayHeight = (x_432 - x_431);
+ let x_434 : vec2<f32> = vCurrOffset;
+ vLastOffset = x_434;
+ let x_435 : f32 = stepSize;
+ let x_436 : vec2<f32> = vMaxOffset;
+ let x_438 : vec2<f32> = vCurrOffset;
+ vCurrOffset = (x_438 + (x_436 * x_435));
+ let x_440 : f32 = currSampledHeight;
+ lastSampledHeight = x_440;
+ }
+
+ continuing {
+ let x_441 : i32 = i;
+ i = (x_441 + 1);
+ }
+ }
+ let x_444 : vec2<f32> = vCurrOffset;
+ parallaxOcclusion_0 = x_444;
+ let x_445 : vec2<f32> = parallaxOcclusion_0;
+ uvOffset = x_445;
+ let x_449 : vec2<f32> = v_uv;
+ let x_450 : vec2<f32> = uvOffset;
+ let x_452 : vec4<f32> = textureSample(TextureSamplerTexture, TextureSamplerSampler, (x_449 + x_450));
+ let x_454 : f32 = x_269.u_bumpStrength;
+ let x_457 : mat3x3<f32> = TBN;
+ param_8 = x_457;
+ param_9 = vec3<f32>(x_452.x, x_452.y, x_452.z);
+ param_10 = (1.0 / x_454);
+ let x_461 : vec3<f32> = perturbNormal_mf33_vf3_f1_(&(param_8), &(param_9), &(param_10));
+ let x_462 : vec4<f32> = output4;
+ output4 = vec4<f32>(x_461.x, x_461.y, x_461.z, x_462.w);
+ let x_465 : vec2<f32> = v_uv;
+ let x_466 : vec2<f32> = uvOffset;
+ output6 = (x_465 + x_466);
+ let x_474 : vec2<f32> = output6;
+ let x_475 : vec4<f32> = textureSample(TextureSampler1Texture, TextureSampler1Sampler, x_474);
+ tempTextureRead1 = x_475;
+ let x_477 : vec4<f32> = tempTextureRead1;
+ rgb1 = vec3<f32>(x_477.x, x_477.y, x_477.z);
+ let x_481 : vec3<f32> = x_269.u_cameraPosition;
+ let x_482 : vec4<f32> = v_output1;
+ viewDirectionW_1 = normalize((x_481 - vec3<f32>(x_482.x, x_482.y, x_482.z)));
+ shadow = 1.0;
+ let x_488 : f32 = u_Float;
+ glossiness_1 = (1.0 * x_488);
+ diffuseBase = vec3<f32>(0.0, 0.0, 0.0);
+ specularBase = vec3<f32>(0.0, 0.0, 0.0);
+ let x_494 : vec4<f32> = output4;
+ normalW = vec3<f32>(x_494.x, x_494.y, x_494.z);
+ let x_501 : vec3<f32> = viewDirectionW_1;
+ param_11 = x_501;
+ let x_503 : vec3<f32> = normalW;
+ param_12 = x_503;
+ let x_507 : vec4<f32> = light0.vLightData;
+ param_13 = x_507;
+ let x_510 : vec4<f32> = light0.vLightDiffuse;
+ param_14 = vec3<f32>(x_510.x, x_510.y, x_510.z);
+ let x_514 : vec4<f32> = light0.vLightSpecular;
+ param_15 = vec3<f32>(x_514.x, x_514.y, x_514.z);
+ let x_518 : vec3<f32> = light0.vLightGround;
+ param_16 = x_518;
+ let x_520 : f32 = glossiness_1;
+ param_17 = x_520;
+ let x_521 : lightingInfo = computeHemisphericLighting_vf3_vf3_vf4_vf3_vf3_vf3_f1_(&(param_11), &(param_12), &(param_13), &(param_14), &(param_15), &(param_16), &(param_17));
+ info = x_521;
+ shadow = 1.0;
+ let x_523 : vec3<f32> = info.diffuse;
+ let x_524 : f32 = shadow;
+ let x_526 : vec3<f32> = diffuseBase;
+ diffuseBase = (x_526 + (x_523 * x_524));
+ let x_529 : vec3<f32> = info.specular;
+ let x_530 : f32 = shadow;
+ let x_532 : vec3<f32> = specularBase;
+ specularBase = (x_532 + (x_529 * x_530));
+ let x_535 : vec3<f32> = diffuseBase;
+ let x_536 : vec3<f32> = rgb1;
+ diffuseOutput = (x_535 * x_536);
+ let x_539 : vec3<f32> = specularBase;
+ let x_540 : vec3<f32> = u_Color;
+ specularOutput = (x_539 * x_540);
+ let x_543 : vec3<f32> = diffuseOutput;
+ let x_544 : vec3<f32> = specularOutput;
+ output3 = (x_543 + x_544);
+ let x_548 : vec3<f32> = output3;
+ glFragColor = vec4<f32>(x_548.x, x_548.y, x_548.z, 1.0);
+ return;
+}
+
+struct main_out {
+ [[location(0)]]
+ glFragColor_1 : vec4<f32>;
+};
+
+[[stage(fragment)]]
+fn main([[location(1)]] vMainuv_param : vec2<f32>, [[location(0)]] v_output1_param : vec4<f32>, [[builtin(front_facing)]] gl_FrontFacing_param : bool, [[location(3)]] v_uv_param : vec2<f32>, [[location(2)]] v_output2_param : vec4<f32>) -> main_out {
+ vMainuv = vMainuv_param;
+ v_output1 = v_output1_param;
+ gl_FrontFacing = gl_FrontFacing_param;
+ v_uv = v_uv_param;
+ v_output2 = v_output2_param;
+ main_1();
+ return main_out(glFragColor);
+}
\ No newline at end of file
diff --git a/test/bug/tint/949.wgsl.expected.hlsl b/test/bug/tint/949.wgsl.expected.hlsl
new file mode 100644
index 0000000..d4aee55
--- /dev/null
+++ b/test/bug/tint/949.wgsl.expected.hlsl
@@ -0,0 +1,442 @@
+struct lightingInfo {
+ float3 diffuse;
+ float3 specular;
+};
+
+static float u_Float = 0.0f;
+static float3 u_Color = float3(0.0f, 0.0f, 0.0f);
+Texture2D<float4> TextureSamplerTexture : register(t1, space2);
+SamplerState TextureSamplerSampler : register(s0, space2);
+static float2 vMainuv = float2(0.0f, 0.0f);
+cbuffer cbuffer_x_269 : register(b6, space2) {
+ uint4 x_269[11];
+};
+static float4 v_output1 = float4(0.0f, 0.0f, 0.0f, 0.0f);
+static bool gl_FrontFacing = false;
+static float2 v_uv = float2(0.0f, 0.0f);
+static float4 v_output2 = float4(0.0f, 0.0f, 0.0f, 0.0f);
+Texture2D<float4> TextureSampler1Texture : register(t3, space2);
+SamplerState TextureSampler1Sampler : register(s2, space2);
+cbuffer cbuffer_light0 : register(b5, space0) {
+ uint4 light0[6];
+};
+static float4 glFragColor = float4(0.0f, 0.0f, 0.0f, 0.0f);
+SamplerState bumpSamplerSampler : register(s4, space2);
+Texture2D<float4> bumpSamplerTexture : register(t5, space2);
+
+float3x3 cotangent_frame_vf3_vf3_vf2_vf2_(inout float3 normal_1, inout float3 p, inout float2 uv, inout float2 tangentSpaceParams) {
+ float3 dp1 = float3(0.0f, 0.0f, 0.0f);
+ float3 dp2 = float3(0.0f, 0.0f, 0.0f);
+ float2 duv1 = float2(0.0f, 0.0f);
+ float2 duv2 = float2(0.0f, 0.0f);
+ float3 dp2perp = float3(0.0f, 0.0f, 0.0f);
+ float3 dp1perp = float3(0.0f, 0.0f, 0.0f);
+ float3 tangent = float3(0.0f, 0.0f, 0.0f);
+ float3 bitangent = float3(0.0f, 0.0f, 0.0f);
+ float invmax = 0.0f;
+ const float3 x_133 = p;
+ dp1 = ddx(x_133);
+ const float3 x_136 = p;
+ dp2 = ddy(x_136);
+ const float2 x_139 = uv;
+ duv1 = ddx(x_139);
+ const float2 x_142 = uv;
+ duv2 = ddy(x_142);
+ const float3 x_145 = dp2;
+ const float3 x_146 = normal_1;
+ dp2perp = cross(x_145, x_146);
+ const float3 x_149 = normal_1;
+ const float3 x_150 = dp1;
+ dp1perp = cross(x_149, x_150);
+ const float3 x_153 = dp2perp;
+ const float x_155 = duv1.x;
+ const float3 x_157 = dp1perp;
+ const float x_159 = duv2.x;
+ tangent = ((x_153 * x_155) + (x_157 * x_159));
+ const float3 x_163 = dp2perp;
+ const float x_165 = duv1.y;
+ const float3 x_167 = dp1perp;
+ const float x_169 = duv2.y;
+ bitangent = ((x_163 * x_165) + (x_167 * x_169));
+ const float x_173 = tangentSpaceParams.x;
+ const float3 x_174 = tangent;
+ tangent = (x_174 * x_173);
+ const float x_177 = tangentSpaceParams.y;
+ const float3 x_178 = bitangent;
+ bitangent = (x_178 * x_177);
+ const float3 x_181 = tangent;
+ const float3 x_182 = tangent;
+ const float3 x_184 = bitangent;
+ const float3 x_185 = bitangent;
+ invmax = rsqrt(max(dot(x_181, x_182), dot(x_184, x_185)));
+ const float3 x_189 = tangent;
+ const float x_190 = invmax;
+ const float3 x_191 = (x_189 * x_190);
+ const float3 x_192 = bitangent;
+ const float x_193 = invmax;
+ const float3 x_194 = (x_192 * x_193);
+ const float3 x_195 = normal_1;
+ return float3x3(float3(x_191.x, x_191.y, x_191.z), float3(x_194.x, x_194.y, x_194.z), float3(x_195.x, x_195.y, x_195.z));
+}
+
+float3x3 transposeMat3_mf33_(inout float3x3 inMatrix) {
+ float3 i0 = float3(0.0f, 0.0f, 0.0f);
+ float3 i1 = float3(0.0f, 0.0f, 0.0f);
+ float3 i2 = float3(0.0f, 0.0f, 0.0f);
+ float3x3 outMatrix = float3x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
+ const float3 x_60 = inMatrix[0];
+ i0 = x_60;
+ const float3 x_64 = inMatrix[1];
+ i1 = x_64;
+ const float3 x_68 = inMatrix[2];
+ i2 = x_68;
+ const float x_73 = i0.x;
+ const float x_75 = i1.x;
+ const float x_77 = i2.x;
+ const float3 x_78 = float3(x_73, x_75, x_77);
+ const float x_81 = i0.y;
+ const float x_83 = i1.y;
+ const float x_85 = i2.y;
+ const float3 x_86 = float3(x_81, x_83, x_85);
+ const float x_89 = i0.z;
+ const float x_91 = i1.z;
+ const float x_93 = i2.z;
+ const float3 x_94 = float3(x_89, x_91, x_93);
+ outMatrix = float3x3(float3(x_78.x, x_78.y, x_78.z), float3(x_86.x, x_86.y, x_86.z), float3(x_94.x, x_94.y, x_94.z));
+ const float3x3 x_110 = outMatrix;
+ return x_110;
+}
+
+float3 perturbNormalBase_mf33_vf3_f1_(inout float3x3 cotangentFrame, inout float3 normal, inout float scale) {
+ const float3x3 x_113 = cotangentFrame;
+ const float3 x_114 = normal;
+ return normalize(mul(x_114, x_113));
+}
+
+float3 perturbNormal_mf33_vf3_f1_(inout float3x3 cotangentFrame_1, inout float3 textureSample, inout float scale_1) {
+ float3x3 param = float3x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
+ float3 param_1 = float3(0.0f, 0.0f, 0.0f);
+ float param_2 = 0.0f;
+ const float3 x_119 = textureSample;
+ const float3x3 x_125 = cotangentFrame_1;
+ param = x_125;
+ param_1 = ((x_119 * 2.0f) - float3(1.0f, 1.0f, 1.0f));
+ const float x_128 = scale_1;
+ param_2 = x_128;
+ const float3 x_129 = perturbNormalBase_mf33_vf3_f1_(param, param_1, param_2);
+ return x_129;
+}
+
+lightingInfo computeHemisphericLighting_vf3_vf3_vf4_vf3_vf3_vf3_f1_(inout float3 viewDirectionW, inout float3 vNormal, inout float4 lightData, inout float3 diffuseColor, inout float3 specularColor, inout float3 groundColor, inout float glossiness) {
+ float ndl = 0.0f;
+ lightingInfo result = (lightingInfo)0;
+ float3 angleW = float3(0.0f, 0.0f, 0.0f);
+ float specComp = 0.0f;
+ const float3 x_212 = vNormal;
+ const float4 x_213 = lightData;
+ ndl = ((dot(x_212, float3(x_213.x, x_213.y, x_213.z)) * 0.5f) + 0.5f);
+ const float3 x_220 = groundColor;
+ const float3 x_221 = diffuseColor;
+ const float x_222 = ndl;
+ result.diffuse = lerp(x_220, x_221, float3(x_222, x_222, x_222));
+ const float3 x_227 = viewDirectionW;
+ const float4 x_228 = lightData;
+ angleW = normalize((x_227 + float3(x_228.x, x_228.y, x_228.z)));
+ const float3 x_233 = vNormal;
+ const float3 x_234 = angleW;
+ specComp = max(0.0f, dot(x_233, x_234));
+ const float x_237 = specComp;
+ const float x_238 = glossiness;
+ specComp = pow(x_237, max(1.0f, x_238));
+ const float x_241 = specComp;
+ const float3 x_242 = specularColor;
+ result.specular = (x_242 * x_241);
+ const lightingInfo x_245 = result;
+ return x_245;
+}
+
+void main_1() {
+ float4 tempTextureRead = float4(0.0f, 0.0f, 0.0f, 0.0f);
+ float3 rgb = float3(0.0f, 0.0f, 0.0f);
+ float3 output5 = float3(0.0f, 0.0f, 0.0f);
+ float4 output4 = float4(0.0f, 0.0f, 0.0f, 0.0f);
+ float2 uvOffset = float2(0.0f, 0.0f);
+ float normalScale = 0.0f;
+ float2 TBNUV = float2(0.0f, 0.0f);
+ float2 x_299 = float2(0.0f, 0.0f);
+ float3x3 TBN = float3x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
+ float3 param_3 = float3(0.0f, 0.0f, 0.0f);
+ float3 param_4 = float3(0.0f, 0.0f, 0.0f);
+ float2 param_5 = float2(0.0f, 0.0f);
+ float2 param_6 = float2(0.0f, 0.0f);
+ float3x3 invTBN = float3x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
+ float3x3 param_7 = float3x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
+ float parallaxLimit = 0.0f;
+ float2 vOffsetDir = float2(0.0f, 0.0f);
+ float2 vMaxOffset = float2(0.0f, 0.0f);
+ float numSamples = 0.0f;
+ float stepSize = 0.0f;
+ float currRayHeight = 0.0f;
+ float2 vCurrOffset = float2(0.0f, 0.0f);
+ float2 vLastOffset = float2(0.0f, 0.0f);
+ float lastSampledHeight = 0.0f;
+ float currSampledHeight = 0.0f;
+ int i = 0;
+ float delta1 = 0.0f;
+ float delta2 = 0.0f;
+ float ratio = 0.0f;
+ float2 parallaxOcclusion_0 = float2(0.0f, 0.0f);
+ float3x3 param_8 = float3x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
+ float3 param_9 = float3(0.0f, 0.0f, 0.0f);
+ float param_10 = 0.0f;
+ float2 output6 = float2(0.0f, 0.0f);
+ float4 tempTextureRead1 = float4(0.0f, 0.0f, 0.0f, 0.0f);
+ float3 rgb1 = float3(0.0f, 0.0f, 0.0f);
+ float3 viewDirectionW_1 = float3(0.0f, 0.0f, 0.0f);
+ float shadow = 0.0f;
+ float glossiness_1 = 0.0f;
+ float3 diffuseBase = float3(0.0f, 0.0f, 0.0f);
+ float3 specularBase = float3(0.0f, 0.0f, 0.0f);
+ float3 normalW = float3(0.0f, 0.0f, 0.0f);
+ lightingInfo info = (lightingInfo)0;
+ float3 param_11 = float3(0.0f, 0.0f, 0.0f);
+ float3 param_12 = float3(0.0f, 0.0f, 0.0f);
+ float4 param_13 = float4(0.0f, 0.0f, 0.0f, 0.0f);
+ float3 param_14 = float3(0.0f, 0.0f, 0.0f);
+ float3 param_15 = float3(0.0f, 0.0f, 0.0f);
+ float3 param_16 = float3(0.0f, 0.0f, 0.0f);
+ float param_17 = 0.0f;
+ float3 diffuseOutput = float3(0.0f, 0.0f, 0.0f);
+ float3 specularOutput = float3(0.0f, 0.0f, 0.0f);
+ float3 output3 = float3(0.0f, 0.0f, 0.0f);
+ u_Float = 100.0f;
+ u_Color = float3(0.5f, 0.5f, 0.5f);
+ const float2 x_261 = vMainuv;
+ const float4 x_262 = TextureSamplerTexture.Sample(TextureSamplerSampler, x_261);
+ tempTextureRead = x_262;
+ const float4 x_264 = tempTextureRead;
+ const uint scalar_offset = (160u) / 4;
+ const float x_273 = asfloat(x_269[scalar_offset / 4][scalar_offset % 4]);
+ rgb = (float3(x_264.x, x_264.y, x_264.z) * x_273);
+ const uint scalar_offset_1 = (144u) / 4;
+ const float3 x_279 = asfloat(x_269[scalar_offset_1 / 4].xyz);
+ const float4 x_282 = v_output1;
+ output5 = normalize((x_279 - float3(x_282.x, x_282.y, x_282.z)));
+ output4 = float4(0.0f, 0.0f, 0.0f, 0.0f);
+ uvOffset = float2(0.0f, 0.0f);
+ const uint scalar_offset_2 = (128u) / 4;
+ const float x_292 = asfloat(x_269[scalar_offset_2 / 4][scalar_offset_2 % 4]);
+ normalScale = (1.0f / x_292);
+ const bool x_298 = gl_FrontFacing;
+ if (x_298) {
+ const float2 x_303 = v_uv;
+ x_299 = x_303;
+ } else {
+ const float2 x_305 = v_uv;
+ x_299 = -(x_305);
+ }
+ const float2 x_307 = x_299;
+ TBNUV = x_307;
+ const float4 x_310 = v_output2;
+ const float x_312 = normalScale;
+ param_3 = (float3(x_310.x, x_310.y, x_310.z) * x_312);
+ const float4 x_317 = v_output1;
+ param_4 = float3(x_317.x, x_317.y, x_317.z);
+ const float2 x_320 = TBNUV;
+ param_5 = x_320;
+ const uint scalar_offset_3 = (168u) / 4;
+ uint4 ubo_load = x_269[scalar_offset_3 / 4];
+ const float2 x_324 = asfloat(((scalar_offset_3 & 2) ? ubo_load.zw : ubo_load.xy));
+ param_6 = x_324;
+ const float3x3 x_325 = cotangent_frame_vf3_vf3_vf2_vf2_(param_3, param_4, param_5, param_6);
+ TBN = x_325;
+ const float3x3 x_328 = TBN;
+ param_7 = x_328;
+ const float3x3 x_329 = transposeMat3_mf33_(param_7);
+ invTBN = x_329;
+ const float3x3 x_331 = invTBN;
+ const float3 x_332 = output5;
+ const float3 x_334 = mul(-(x_332), x_331);
+ const float3x3 x_337 = invTBN;
+ const float3 x_338 = output5;
+ parallaxLimit = (length(float2(x_334.x, x_334.y)) / mul(-(x_338), x_337).z);
+ const uint scalar_offset_4 = (156u) / 4;
+ const float x_345 = asfloat(x_269[scalar_offset_4 / 4][scalar_offset_4 % 4]);
+ const float x_346 = parallaxLimit;
+ parallaxLimit = (x_346 * x_345);
+ const float3x3 x_349 = invTBN;
+ const float3 x_350 = output5;
+ const float3 x_352 = mul(-(x_350), x_349);
+ vOffsetDir = normalize(float2(x_352.x, x_352.y));
+ const float2 x_356 = vOffsetDir;
+ const float x_357 = parallaxLimit;
+ vMaxOffset = (x_356 * x_357);
+ const float3x3 x_361 = invTBN;
+ const float3 x_362 = output5;
+ const float3x3 x_365 = invTBN;
+ const float4 x_366 = v_output2;
+ numSamples = (15.0f + (dot(mul(-(x_362), x_361), mul(float3(x_366.x, x_366.y, x_366.z), x_365)) * -11.0f));
+ const float x_374 = numSamples;
+ stepSize = (1.0f / x_374);
+ currRayHeight = 1.0f;
+ vCurrOffset = float2(0.0f, 0.0f);
+ vLastOffset = float2(0.0f, 0.0f);
+ lastSampledHeight = 1.0f;
+ currSampledHeight = 1.0f;
+ i = 0;
+ while (true) {
+ const int x_388 = i;
+ if ((x_388 < 15)) {
+ } else {
+ break;
+ }
+ const float2 x_394 = v_uv;
+ const float2 x_395 = vCurrOffset;
+ const float4 x_397 = TextureSamplerTexture.Sample(TextureSamplerSampler, (x_394 + x_395));
+ currSampledHeight = x_397.w;
+ const float x_400 = currSampledHeight;
+ const float x_401 = currRayHeight;
+ if ((x_400 > x_401)) {
+ const float x_406 = currSampledHeight;
+ const float x_407 = currRayHeight;
+ delta1 = (x_406 - x_407);
+ const float x_410 = currRayHeight;
+ const float x_411 = stepSize;
+ const float x_413 = lastSampledHeight;
+ delta2 = ((x_410 + x_411) - x_413);
+ const float x_416 = delta1;
+ const float x_417 = delta1;
+ const float x_418 = delta2;
+ ratio = (x_416 / (x_417 + x_418));
+ const float x_421 = ratio;
+ const float2 x_422 = vLastOffset;
+ const float x_424 = ratio;
+ const float2 x_426 = vCurrOffset;
+ vCurrOffset = ((x_422 * x_421) + (x_426 * (1.0f - x_424)));
+ break;
+ } else {
+ const float x_431 = stepSize;
+ const float x_432 = currRayHeight;
+ currRayHeight = (x_432 - x_431);
+ const float2 x_434 = vCurrOffset;
+ vLastOffset = x_434;
+ const float x_435 = stepSize;
+ const float2 x_436 = vMaxOffset;
+ const float2 x_438 = vCurrOffset;
+ vCurrOffset = (x_438 + (x_436 * x_435));
+ const float x_440 = currSampledHeight;
+ lastSampledHeight = x_440;
+ }
+ {
+ const int x_441 = i;
+ i = (x_441 + 1);
+ }
+ }
+ const float2 x_444 = vCurrOffset;
+ parallaxOcclusion_0 = x_444;
+ const float2 x_445 = parallaxOcclusion_0;
+ uvOffset = x_445;
+ const float2 x_449 = v_uv;
+ const float2 x_450 = uvOffset;
+ const float4 x_452 = TextureSamplerTexture.Sample(TextureSamplerSampler, (x_449 + x_450));
+ const uint scalar_offset_5 = (128u) / 4;
+ const float x_454 = asfloat(x_269[scalar_offset_5 / 4][scalar_offset_5 % 4]);
+ const float3x3 x_457 = TBN;
+ param_8 = x_457;
+ param_9 = float3(x_452.x, x_452.y, x_452.z);
+ param_10 = (1.0f / x_454);
+ const float3 x_461 = perturbNormal_mf33_vf3_f1_(param_8, param_9, param_10);
+ const float4 x_462 = output4;
+ output4 = float4(x_461.x, x_461.y, x_461.z, x_462.w);
+ const float2 x_465 = v_uv;
+ const float2 x_466 = uvOffset;
+ output6 = (x_465 + x_466);
+ const float2 x_474 = output6;
+ const float4 x_475 = TextureSampler1Texture.Sample(TextureSampler1Sampler, x_474);
+ tempTextureRead1 = x_475;
+ const float4 x_477 = tempTextureRead1;
+ rgb1 = float3(x_477.x, x_477.y, x_477.z);
+ const uint scalar_offset_6 = (144u) / 4;
+ const float3 x_481 = asfloat(x_269[scalar_offset_6 / 4].xyz);
+ const float4 x_482 = v_output1;
+ viewDirectionW_1 = normalize((x_481 - float3(x_482.x, x_482.y, x_482.z)));
+ shadow = 1.0f;
+ const float x_488 = u_Float;
+ glossiness_1 = (1.0f * x_488);
+ diffuseBase = float3(0.0f, 0.0f, 0.0f);
+ specularBase = float3(0.0f, 0.0f, 0.0f);
+ const float4 x_494 = output4;
+ normalW = float3(x_494.x, x_494.y, x_494.z);
+ const float3 x_501 = viewDirectionW_1;
+ param_11 = x_501;
+ const float3 x_503 = normalW;
+ param_12 = x_503;
+ const uint scalar_offset_7 = (0u) / 4;
+ const float4 x_507 = asfloat(light0[scalar_offset_7 / 4]);
+ param_13 = x_507;
+ const uint scalar_offset_8 = (16u) / 4;
+ const float4 x_510 = asfloat(light0[scalar_offset_8 / 4]);
+ param_14 = float3(x_510.x, x_510.y, x_510.z);
+ const uint scalar_offset_9 = (32u) / 4;
+ const float4 x_514 = asfloat(light0[scalar_offset_9 / 4]);
+ param_15 = float3(x_514.x, x_514.y, x_514.z);
+ const uint scalar_offset_10 = (48u) / 4;
+ const float3 x_518 = asfloat(light0[scalar_offset_10 / 4].xyz);
+ param_16 = x_518;
+ const float x_520 = glossiness_1;
+ param_17 = x_520;
+ const lightingInfo x_521 = computeHemisphericLighting_vf3_vf3_vf4_vf3_vf3_vf3_f1_(param_11, param_12, param_13, param_14, param_15, param_16, param_17);
+ info = x_521;
+ shadow = 1.0f;
+ const float3 x_523 = info.diffuse;
+ const float x_524 = shadow;
+ const float3 x_526 = diffuseBase;
+ diffuseBase = (x_526 + (x_523 * x_524));
+ const float3 x_529 = info.specular;
+ const float x_530 = shadow;
+ const float3 x_532 = specularBase;
+ specularBase = (x_532 + (x_529 * x_530));
+ const float3 x_535 = diffuseBase;
+ const float3 x_536 = rgb1;
+ diffuseOutput = (x_535 * x_536);
+ const float3 x_539 = specularBase;
+ const float3 x_540 = u_Color;
+ specularOutput = (x_539 * x_540);
+ const float3 x_543 = diffuseOutput;
+ const float3 x_544 = specularOutput;
+ output3 = (x_543 + x_544);
+ const float3 x_548 = output3;
+ glFragColor = float4(x_548.x, x_548.y, x_548.z, 1.0f);
+ return;
+}
+
+struct main_out {
+ float4 glFragColor_1;
+};
+struct tint_symbol_1 {
+ float4 v_output1_param : TEXCOORD0;
+ float2 vMainuv_param : TEXCOORD1;
+ float4 v_output2_param : TEXCOORD2;
+ float2 v_uv_param : TEXCOORD3;
+ bool gl_FrontFacing_param : SV_IsFrontFace;
+};
+struct tint_symbol_2 {
+ float4 glFragColor_1 : SV_Target0;
+};
+
+tint_symbol_2 main(tint_symbol_1 tint_symbol) {
+ const float2 vMainuv_param = tint_symbol.vMainuv_param;
+ const float4 v_output1_param = tint_symbol.v_output1_param;
+ const bool gl_FrontFacing_param = tint_symbol.gl_FrontFacing_param;
+ const float2 v_uv_param = tint_symbol.v_uv_param;
+ const float4 v_output2_param = tint_symbol.v_output2_param;
+ vMainuv = vMainuv_param;
+ v_output1 = v_output1_param;
+ gl_FrontFacing = gl_FrontFacing_param;
+ v_uv = v_uv_param;
+ v_output2 = v_output2_param;
+ main_1();
+ const main_out tint_symbol_3 = {glFragColor};
+ const tint_symbol_2 tint_symbol_9 = {tint_symbol_3.glFragColor_1};
+ return tint_symbol_9;
+}
diff --git a/test/bug/tint/949.wgsl.expected.msl b/test/bug/tint/949.wgsl.expected.msl
new file mode 100644
index 0000000..75eef87
--- /dev/null
+++ b/test/bug/tint/949.wgsl.expected.msl
@@ -0,0 +1,440 @@
+#include <metal_stdlib>
+
+using namespace metal;
+struct lightingInfo {
+ float3 diffuse;
+ float3 specular;
+};
+struct LeftOver {
+ /* 0x0000 */ float4x4 u_World;
+ /* 0x0040 */ float4x4 u_ViewProjection;
+ /* 0x0080 */ float u_bumpStrength;
+ /* 0x0084 */ uint padding;
+ /* 0x0088 */ int8_t tint_pad[8];
+ /* 0x0090 */ packed_float3 u_cameraPosition;
+ /* 0x009c */ float u_parallaxScale;
+ /* 0x00a0 */ float textureInfoName;
+ /* 0x00a4 */ uint padding_1;
+ /* 0x00a8 */ packed_float2 tangentSpaceParameter0;
+};
+struct Light0 {
+ /* 0x0000 */ packed_float4 vLightData;
+ /* 0x0010 */ packed_float4 vLightDiffuse;
+ /* 0x0020 */ packed_float4 vLightSpecular;
+ /* 0x0030 */ packed_float3 vLightGround;
+ /* 0x003c */ uint padding_2;
+ /* 0x0040 */ packed_float4 shadowsInfo;
+ /* 0x0050 */ packed_float2 depthValues;
+ /* 0x0058 */ int8_t tint_pad_1[8];
+};
+struct main_out {
+ float4 glFragColor_1;
+};
+struct tint_symbol_2 {
+ float4 v_output1_param [[user(locn0)]];
+ float2 vMainuv_param [[user(locn1)]];
+ float4 v_output2_param [[user(locn2)]];
+ float2 v_uv_param [[user(locn3)]];
+};
+struct tint_symbol_3 {
+ float4 glFragColor_1 [[color(0)]];
+};
+
+float3x3 cotangent_frame_vf3_vf3_vf2_vf2_(thread float3* const normal_1, thread float3* const p, thread float2* const uv, thread float2* const tangentSpaceParams) {
+ float3 dp1 = 0.0f;
+ float3 dp2 = 0.0f;
+ float2 duv1 = 0.0f;
+ float2 duv2 = 0.0f;
+ float3 dp2perp = 0.0f;
+ float3 dp1perp = 0.0f;
+ float3 tangent = 0.0f;
+ float3 bitangent = 0.0f;
+ float invmax = 0.0f;
+ float3 const x_133 = *(p);
+ dp1 = dfdx(x_133);
+ float3 const x_136 = *(p);
+ dp2 = dfdy(x_136);
+ float2 const x_139 = *(uv);
+ duv1 = dfdx(x_139);
+ float2 const x_142 = *(uv);
+ duv2 = dfdy(x_142);
+ float3 const x_145 = dp2;
+ float3 const x_146 = *(normal_1);
+ dp2perp = cross(x_145, x_146);
+ float3 const x_149 = *(normal_1);
+ float3 const x_150 = dp1;
+ dp1perp = cross(x_149, x_150);
+ float3 const x_153 = dp2perp;
+ float const x_155 = duv1.x;
+ float3 const x_157 = dp1perp;
+ float const x_159 = duv2.x;
+ tangent = ((x_153 * x_155) + (x_157 * x_159));
+ float3 const x_163 = dp2perp;
+ float const x_165 = duv1.y;
+ float3 const x_167 = dp1perp;
+ float const x_169 = duv2.y;
+ bitangent = ((x_163 * x_165) + (x_167 * x_169));
+ float const x_173 = (*(tangentSpaceParams)).x;
+ float3 const x_174 = tangent;
+ tangent = (x_174 * x_173);
+ float const x_177 = (*(tangentSpaceParams)).y;
+ float3 const x_178 = bitangent;
+ bitangent = (x_178 * x_177);
+ float3 const x_181 = tangent;
+ float3 const x_182 = tangent;
+ float3 const x_184 = bitangent;
+ float3 const x_185 = bitangent;
+ invmax = rsqrt(fmax(dot(x_181, x_182), dot(x_184, x_185)));
+ float3 const x_189 = tangent;
+ float const x_190 = invmax;
+ float3 const x_191 = (x_189 * x_190);
+ float3 const x_192 = bitangent;
+ float const x_193 = invmax;
+ float3 const x_194 = (x_192 * x_193);
+ float3 const x_195 = *(normal_1);
+ return float3x3(float3(x_191.x, x_191.y, x_191.z), float3(x_194.x, x_194.y, x_194.z), float3(x_195.x, x_195.y, x_195.z));
+}
+
+float3x3 transposeMat3_mf33_(thread float3x3* const inMatrix) {
+ float3 i0 = 0.0f;
+ float3 i1 = 0.0f;
+ float3 i2 = 0.0f;
+ float3x3 outMatrix = float3x3(0.0f);
+ float3 const x_60 = (*(inMatrix))[0];
+ i0 = x_60;
+ float3 const x_64 = (*(inMatrix))[1];
+ i1 = x_64;
+ float3 const x_68 = (*(inMatrix))[2];
+ i2 = x_68;
+ float const x_73 = i0.x;
+ float const x_75 = i1.x;
+ float const x_77 = i2.x;
+ float3 const x_78 = float3(x_73, x_75, x_77);
+ float const x_81 = i0.y;
+ float const x_83 = i1.y;
+ float const x_85 = i2.y;
+ float3 const x_86 = float3(x_81, x_83, x_85);
+ float const x_89 = i0.z;
+ float const x_91 = i1.z;
+ float const x_93 = i2.z;
+ float3 const x_94 = float3(x_89, x_91, x_93);
+ outMatrix = float3x3(float3(x_78.x, x_78.y, x_78.z), float3(x_86.x, x_86.y, x_86.z), float3(x_94.x, x_94.y, x_94.z));
+ float3x3 const x_110 = outMatrix;
+ return x_110;
+}
+
+float3 perturbNormalBase_mf33_vf3_f1_(thread float3x3* const cotangentFrame, thread float3* const normal, thread float* const scale) {
+ float3x3 const x_113 = *(cotangentFrame);
+ float3 const x_114 = *(normal);
+ return normalize((x_113 * x_114));
+}
+
+float3 perturbNormal_mf33_vf3_f1_(thread float3x3* const cotangentFrame_1, thread float3* const textureSample, thread float* const scale_1) {
+ float3x3 param = float3x3(0.0f);
+ float3 param_1 = 0.0f;
+ float param_2 = 0.0f;
+ float3 const x_119 = *(textureSample);
+ float3x3 const x_125 = *(cotangentFrame_1);
+ param = x_125;
+ param_1 = ((x_119 * 2.0f) - float3(1.0f, 1.0f, 1.0f));
+ float const x_128 = *(scale_1);
+ param_2 = x_128;
+ float3 const x_129 = perturbNormalBase_mf33_vf3_f1_(&(param), &(param_1), &(param_2));
+ return x_129;
+}
+
+lightingInfo computeHemisphericLighting_vf3_vf3_vf4_vf3_vf3_vf3_f1_(thread float3* const viewDirectionW, thread float3* const vNormal, thread float4* const lightData, thread float3* const diffuseColor, thread float3* const specularColor, thread float3* const groundColor, thread float* const glossiness) {
+ float ndl = 0.0f;
+ lightingInfo result = {};
+ float3 angleW = 0.0f;
+ float specComp = 0.0f;
+ float3 const x_212 = *(vNormal);
+ float4 const x_213 = *(lightData);
+ ndl = ((dot(x_212, float3(x_213.x, x_213.y, x_213.z)) * 0.5f) + 0.5f);
+ float3 const x_220 = *(groundColor);
+ float3 const x_221 = *(diffuseColor);
+ float const x_222 = ndl;
+ result.diffuse = mix(x_220, x_221, float3(x_222, x_222, x_222));
+ float3 const x_227 = *(viewDirectionW);
+ float4 const x_228 = *(lightData);
+ angleW = normalize((x_227 + float3(x_228.x, x_228.y, x_228.z)));
+ float3 const x_233 = *(vNormal);
+ float3 const x_234 = angleW;
+ specComp = fmax(0.0f, dot(x_233, x_234));
+ float const x_237 = specComp;
+ float const x_238 = *(glossiness);
+ specComp = pow(x_237, fmax(1.0f, x_238));
+ float const x_241 = specComp;
+ float3 const x_242 = *(specularColor);
+ result.specular = (x_242 * x_241);
+ lightingInfo const x_245 = result;
+ return x_245;
+}
+
+void main_1(constant LeftOver& x_269, constant Light0& light0, thread float* const tint_symbol_6, thread float3* const tint_symbol_7, thread float2* const tint_symbol_8, texture2d<float, access::sample> tint_symbol_9, sampler tint_symbol_10, thread float4* const tint_symbol_11, thread bool* const tint_symbol_12, thread float2* const tint_symbol_13, thread float4* const tint_symbol_14, texture2d<float, access::sample> tint_symbol_15, sampler tint_symbol_16, thread float4* const tint_symbol_17) {
+ float4 tempTextureRead = 0.0f;
+ float3 rgb = 0.0f;
+ float3 output5 = 0.0f;
+ float4 output4 = 0.0f;
+ float2 uvOffset = 0.0f;
+ float normalScale = 0.0f;
+ float2 TBNUV = 0.0f;
+ float2 x_299 = 0.0f;
+ float3x3 TBN = float3x3(0.0f);
+ float3 param_3 = 0.0f;
+ float3 param_4 = 0.0f;
+ float2 param_5 = 0.0f;
+ float2 param_6 = 0.0f;
+ float3x3 invTBN = float3x3(0.0f);
+ float3x3 param_7 = float3x3(0.0f);
+ float parallaxLimit = 0.0f;
+ float2 vOffsetDir = 0.0f;
+ float2 vMaxOffset = 0.0f;
+ float numSamples = 0.0f;
+ float stepSize = 0.0f;
+ float currRayHeight = 0.0f;
+ float2 vCurrOffset = 0.0f;
+ float2 vLastOffset = 0.0f;
+ float lastSampledHeight = 0.0f;
+ float currSampledHeight = 0.0f;
+ int i = 0;
+ float delta1 = 0.0f;
+ float delta2 = 0.0f;
+ float ratio = 0.0f;
+ float2 parallaxOcclusion_0 = 0.0f;
+ float3x3 param_8 = float3x3(0.0f);
+ float3 param_9 = 0.0f;
+ float param_10 = 0.0f;
+ float2 output6 = 0.0f;
+ float4 tempTextureRead1 = 0.0f;
+ float3 rgb1 = 0.0f;
+ float3 viewDirectionW_1 = 0.0f;
+ float shadow = 0.0f;
+ float glossiness_1 = 0.0f;
+ float3 diffuseBase = 0.0f;
+ float3 specularBase = 0.0f;
+ float3 normalW = 0.0f;
+ lightingInfo info = {};
+ float3 param_11 = 0.0f;
+ float3 param_12 = 0.0f;
+ float4 param_13 = 0.0f;
+ float3 param_14 = 0.0f;
+ float3 param_15 = 0.0f;
+ float3 param_16 = 0.0f;
+ float param_17 = 0.0f;
+ float3 diffuseOutput = 0.0f;
+ float3 specularOutput = 0.0f;
+ float3 output3 = 0.0f;
+ *(tint_symbol_6) = 100.0f;
+ *(tint_symbol_7) = float3(0.5f, 0.5f, 0.5f);
+ float2 const x_261 = *(tint_symbol_8);
+ float4 const x_262 = tint_symbol_9.sample(tint_symbol_10, x_261);
+ tempTextureRead = x_262;
+ float4 const x_264 = tempTextureRead;
+ float const x_273 = x_269.textureInfoName;
+ rgb = (float3(x_264.x, x_264.y, x_264.z) * x_273);
+ float3 const x_279 = x_269.u_cameraPosition;
+ float4 const x_282 = *(tint_symbol_11);
+ output5 = normalize((x_279 - float3(x_282.x, x_282.y, x_282.z)));
+ output4 = float4(0.0f, 0.0f, 0.0f, 0.0f);
+ uvOffset = float2(0.0f, 0.0f);
+ float const x_292 = x_269.u_bumpStrength;
+ normalScale = (1.0f / x_292);
+ bool const x_298 = *(tint_symbol_12);
+ if (x_298) {
+ float2 const x_303 = *(tint_symbol_13);
+ x_299 = x_303;
+ } else {
+ float2 const x_305 = *(tint_symbol_13);
+ x_299 = -(x_305);
+ }
+ float2 const x_307 = x_299;
+ TBNUV = x_307;
+ float4 const x_310 = *(tint_symbol_14);
+ float const x_312 = normalScale;
+ param_3 = (float3(x_310.x, x_310.y, x_310.z) * x_312);
+ float4 const x_317 = *(tint_symbol_11);
+ param_4 = float3(x_317.x, x_317.y, x_317.z);
+ float2 const x_320 = TBNUV;
+ param_5 = x_320;
+ float2 const x_324 = x_269.tangentSpaceParameter0;
+ param_6 = x_324;
+ float3x3 const x_325 = cotangent_frame_vf3_vf3_vf2_vf2_(&(param_3), &(param_4), &(param_5), &(param_6));
+ TBN = x_325;
+ float3x3 const x_328 = TBN;
+ param_7 = x_328;
+ float3x3 const x_329 = transposeMat3_mf33_(&(param_7));
+ invTBN = x_329;
+ float3x3 const x_331 = invTBN;
+ float3 const x_332 = output5;
+ float3 const x_334 = (x_331 * -(x_332));
+ float3x3 const x_337 = invTBN;
+ float3 const x_338 = output5;
+ parallaxLimit = (length(float2(x_334.x, x_334.y)) / ((x_337 * -(x_338))).z);
+ float const x_345 = x_269.u_parallaxScale;
+ float const x_346 = parallaxLimit;
+ parallaxLimit = (x_346 * x_345);
+ float3x3 const x_349 = invTBN;
+ float3 const x_350 = output5;
+ float3 const x_352 = (x_349 * -(x_350));
+ vOffsetDir = normalize(float2(x_352.x, x_352.y));
+ float2 const x_356 = vOffsetDir;
+ float const x_357 = parallaxLimit;
+ vMaxOffset = (x_356 * x_357);
+ float3x3 const x_361 = invTBN;
+ float3 const x_362 = output5;
+ float3x3 const x_365 = invTBN;
+ float4 const x_366 = *(tint_symbol_14);
+ numSamples = (15.0f + (dot((x_361 * -(x_362)), (x_365 * float3(x_366.x, x_366.y, x_366.z))) * -11.0f));
+ float const x_374 = numSamples;
+ stepSize = (1.0f / x_374);
+ currRayHeight = 1.0f;
+ vCurrOffset = float2(0.0f, 0.0f);
+ vLastOffset = float2(0.0f, 0.0f);
+ lastSampledHeight = 1.0f;
+ currSampledHeight = 1.0f;
+ i = 0;
+ while (true) {
+ int const x_388 = i;
+ if ((x_388 < 15)) {
+ } else {
+ break;
+ }
+ float2 const x_394 = *(tint_symbol_13);
+ float2 const x_395 = vCurrOffset;
+ float4 const x_397 = tint_symbol_9.sample(tint_symbol_10, (x_394 + x_395));
+ currSampledHeight = x_397.w;
+ float const x_400 = currSampledHeight;
+ float const x_401 = currRayHeight;
+ if ((x_400 > x_401)) {
+ float const x_406 = currSampledHeight;
+ float const x_407 = currRayHeight;
+ delta1 = (x_406 - x_407);
+ float const x_410 = currRayHeight;
+ float const x_411 = stepSize;
+ float const x_413 = lastSampledHeight;
+ delta2 = ((x_410 + x_411) - x_413);
+ float const x_416 = delta1;
+ float const x_417 = delta1;
+ float const x_418 = delta2;
+ ratio = (x_416 / (x_417 + x_418));
+ float const x_421 = ratio;
+ float2 const x_422 = vLastOffset;
+ float const x_424 = ratio;
+ float2 const x_426 = vCurrOffset;
+ vCurrOffset = ((x_422 * x_421) + (x_426 * (1.0f - x_424)));
+ break;
+ } else {
+ float const x_431 = stepSize;
+ float const x_432 = currRayHeight;
+ currRayHeight = (x_432 - x_431);
+ float2 const x_434 = vCurrOffset;
+ vLastOffset = x_434;
+ float const x_435 = stepSize;
+ float2 const x_436 = vMaxOffset;
+ float2 const x_438 = vCurrOffset;
+ vCurrOffset = (x_438 + (x_436 * x_435));
+ float const x_440 = currSampledHeight;
+ lastSampledHeight = x_440;
+ }
+ {
+ int const x_441 = i;
+ i = (x_441 + 1);
+ }
+ }
+ float2 const x_444 = vCurrOffset;
+ parallaxOcclusion_0 = x_444;
+ float2 const x_445 = parallaxOcclusion_0;
+ uvOffset = x_445;
+ float2 const x_449 = *(tint_symbol_13);
+ float2 const x_450 = uvOffset;
+ float4 const x_452 = tint_symbol_9.sample(tint_symbol_10, (x_449 + x_450));
+ float const x_454 = x_269.u_bumpStrength;
+ float3x3 const x_457 = TBN;
+ param_8 = x_457;
+ param_9 = float3(x_452.x, x_452.y, x_452.z);
+ param_10 = (1.0f / x_454);
+ float3 const x_461 = perturbNormal_mf33_vf3_f1_(&(param_8), &(param_9), &(param_10));
+ float4 const x_462 = output4;
+ output4 = float4(x_461.x, x_461.y, x_461.z, x_462.w);
+ float2 const x_465 = *(tint_symbol_13);
+ float2 const x_466 = uvOffset;
+ output6 = (x_465 + x_466);
+ float2 const x_474 = output6;
+ float4 const x_475 = tint_symbol_15.sample(tint_symbol_16, x_474);
+ tempTextureRead1 = x_475;
+ float4 const x_477 = tempTextureRead1;
+ rgb1 = float3(x_477.x, x_477.y, x_477.z);
+ float3 const x_481 = x_269.u_cameraPosition;
+ float4 const x_482 = *(tint_symbol_11);
+ viewDirectionW_1 = normalize((x_481 - float3(x_482.x, x_482.y, x_482.z)));
+ shadow = 1.0f;
+ float const x_488 = *(tint_symbol_6);
+ glossiness_1 = (1.0f * x_488);
+ diffuseBase = float3(0.0f, 0.0f, 0.0f);
+ specularBase = float3(0.0f, 0.0f, 0.0f);
+ float4 const x_494 = output4;
+ normalW = float3(x_494.x, x_494.y, x_494.z);
+ float3 const x_501 = viewDirectionW_1;
+ param_11 = x_501;
+ float3 const x_503 = normalW;
+ param_12 = x_503;
+ float4 const x_507 = light0.vLightData;
+ param_13 = x_507;
+ float4 const x_510 = light0.vLightDiffuse;
+ param_14 = float3(x_510.x, x_510.y, x_510.z);
+ float4 const x_514 = light0.vLightSpecular;
+ param_15 = float3(x_514.x, x_514.y, x_514.z);
+ float3 const x_518 = light0.vLightGround;
+ param_16 = x_518;
+ float const x_520 = glossiness_1;
+ param_17 = x_520;
+ lightingInfo const x_521 = computeHemisphericLighting_vf3_vf3_vf4_vf3_vf3_vf3_f1_(&(param_11), &(param_12), &(param_13), &(param_14), &(param_15), &(param_16), &(param_17));
+ info = x_521;
+ shadow = 1.0f;
+ float3 const x_523 = info.diffuse;
+ float const x_524 = shadow;
+ float3 const x_526 = diffuseBase;
+ diffuseBase = (x_526 + (x_523 * x_524));
+ float3 const x_529 = info.specular;
+ float const x_530 = shadow;
+ float3 const x_532 = specularBase;
+ specularBase = (x_532 + (x_529 * x_530));
+ float3 const x_535 = diffuseBase;
+ float3 const x_536 = rgb1;
+ diffuseOutput = (x_535 * x_536);
+ float3 const x_539 = specularBase;
+ float3 const x_540 = *(tint_symbol_7);
+ specularOutput = (x_539 * x_540);
+ float3 const x_543 = diffuseOutput;
+ float3 const x_544 = specularOutput;
+ output3 = (x_543 + x_544);
+ float3 const x_548 = output3;
+ *(tint_symbol_17) = float4(x_548.x, x_548.y, x_548.z, 1.0f);
+ return;
+}
+
+fragment tint_symbol_3 tint_symbol(texture2d<float, access::sample> tint_symbol_25 [[texture(1)]], sampler tint_symbol_26 [[sampler(0)]], texture2d<float, access::sample> tint_symbol_27 [[texture(3)]], sampler tint_symbol_28 [[sampler(2)]], bool gl_FrontFacing_param [[front_facing]], tint_symbol_2 tint_symbol_1 [[stage_in]], constant LeftOver& x_269 [[buffer(6)]], constant Light0& light0 [[buffer(5)]]) {
+ thread float2 tint_symbol_18 = 0.0f;
+ thread float4 tint_symbol_19 = 0.0f;
+ thread bool tint_symbol_20 = false;
+ thread float2 tint_symbol_21 = 0.0f;
+ thread float4 tint_symbol_22 = 0.0f;
+ thread float tint_symbol_23 = 0.0f;
+ thread float3 tint_symbol_24 = 0.0f;
+ thread float4 tint_symbol_29 = 0.0f;
+ float2 const vMainuv_param = tint_symbol_1.vMainuv_param;
+ float4 const v_output1_param = tint_symbol_1.v_output1_param;
+ float2 const v_uv_param = tint_symbol_1.v_uv_param;
+ float4 const v_output2_param = tint_symbol_1.v_output2_param;
+ tint_symbol_18 = vMainuv_param;
+ tint_symbol_19 = v_output1_param;
+ tint_symbol_20 = gl_FrontFacing_param;
+ tint_symbol_21 = v_uv_param;
+ tint_symbol_22 = v_output2_param;
+ main_1(x_269, light0, &(tint_symbol_23), &(tint_symbol_24), &(tint_symbol_18), tint_symbol_25, tint_symbol_26, &(tint_symbol_19), &(tint_symbol_20), &(tint_symbol_21), &(tint_symbol_22), tint_symbol_27, tint_symbol_28, &(tint_symbol_29));
+ main_out const tint_symbol_4 = {.glFragColor_1=tint_symbol_29};
+ tint_symbol_3 const tint_symbol_5 = {.glFragColor_1=tint_symbol_4.glFragColor_1};
+ return tint_symbol_5;
+}
+
diff --git a/test/bug/tint/949.wgsl.expected.spvasm b/test/bug/tint/949.wgsl.expected.spvasm
new file mode 100644
index 0000000..1d55ece
--- /dev/null
+++ b/test/bug/tint/949.wgsl.expected.spvasm
@@ -0,0 +1,962 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 671
+; Schema: 0
+ OpCapability Shader
+ %88 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Fragment %main "main" %tint_symbol %tint_symbol_1 %tint_symbol_2 %tint_symbol_3 %tint_symbol_4 %tint_symbol_6
+ OpExecutionMode %main OriginUpperLeft
+ OpName %u_Float "u_Float"
+ OpName %u_Color "u_Color"
+ OpName %TextureSamplerTexture "TextureSamplerTexture"
+ OpName %TextureSamplerSampler "TextureSamplerSampler"
+ OpName %vMainuv "vMainuv"
+ OpName %LeftOver "LeftOver"
+ OpMemberName %LeftOver 0 "u_World"
+ OpMemberName %LeftOver 1 "u_ViewProjection"
+ OpMemberName %LeftOver 2 "u_bumpStrength"
+ OpMemberName %LeftOver 3 "padding"
+ OpMemberName %LeftOver 4 "u_cameraPosition"
+ OpMemberName %LeftOver 5 "u_parallaxScale"
+ OpMemberName %LeftOver 6 "textureInfoName"
+ OpMemberName %LeftOver 7 "padding_1"
+ OpMemberName %LeftOver 8 "tangentSpaceParameter0"
+ OpName %x_269 "x_269"
+ OpName %v_output1 "v_output1"
+ OpName %gl_FrontFacing "gl_FrontFacing"
+ OpName %v_uv "v_uv"
+ OpName %v_output2 "v_output2"
+ OpName %TextureSampler1Texture "TextureSampler1Texture"
+ OpName %TextureSampler1Sampler "TextureSampler1Sampler"
+ OpName %Light0 "Light0"
+ OpMemberName %Light0 0 "vLightData"
+ OpMemberName %Light0 1 "vLightDiffuse"
+ OpMemberName %Light0 2 "vLightSpecular"
+ OpMemberName %Light0 3 "vLightGround"
+ OpMemberName %Light0 4 "padding_2"
+ OpMemberName %Light0 5 "shadowsInfo"
+ OpMemberName %Light0 6 "depthValues"
+ OpName %light0 "light0"
+ OpName %glFragColor "glFragColor"
+ OpName %bumpSamplerSampler "bumpSamplerSampler"
+ OpName %bumpSamplerTexture "bumpSamplerTexture"
+ OpName %tint_symbol "tint_symbol"
+ OpName %tint_symbol_1 "tint_symbol_1"
+ OpName %tint_symbol_2 "tint_symbol_2"
+ OpName %tint_symbol_3 "tint_symbol_3"
+ OpName %tint_symbol_4 "tint_symbol_4"
+ OpName %tint_symbol_6 "tint_symbol_6"
+ OpName %cotangent_frame_vf3_vf3_vf2_vf2_ "cotangent_frame_vf3_vf3_vf2_vf2_"
+ OpName %normal_1 "normal_1"
+ OpName %p "p"
+ OpName %uv "uv"
+ OpName %tangentSpaceParams "tangentSpaceParams"
+ OpName %dp1 "dp1"
+ OpName %dp2 "dp2"
+ OpName %duv1 "duv1"
+ OpName %duv2 "duv2"
+ OpName %dp2perp "dp2perp"
+ OpName %dp1perp "dp1perp"
+ OpName %tangent "tangent"
+ OpName %bitangent "bitangent"
+ OpName %invmax "invmax"
+ OpName %transposeMat3_mf33_ "transposeMat3_mf33_"
+ OpName %inMatrix "inMatrix"
+ OpName %i0 "i0"
+ OpName %i1 "i1"
+ OpName %i2 "i2"
+ OpName %outMatrix "outMatrix"
+ OpName %perturbNormalBase_mf33_vf3_f1_ "perturbNormalBase_mf33_vf3_f1_"
+ OpName %cotangentFrame "cotangentFrame"
+ OpName %normal "normal"
+ OpName %scale "scale"
+ OpName %perturbNormal_mf33_vf3_f1_ "perturbNormal_mf33_vf3_f1_"
+ OpName %cotangentFrame_1 "cotangentFrame_1"
+ OpName %textureSample "textureSample"
+ OpName %scale_1 "scale_1"
+ OpName %param "param"
+ OpName %param_1 "param_1"
+ OpName %param_2 "param_2"
+ OpName %lightingInfo "lightingInfo"
+ OpMemberName %lightingInfo 0 "diffuse"
+ OpMemberName %lightingInfo 1 "specular"
+ OpName %computeHemisphericLighting_vf3_vf3_vf4_vf3_vf3_vf3_f1_ "computeHemisphericLighting_vf3_vf3_vf4_vf3_vf3_vf3_f1_"
+ OpName %viewDirectionW "viewDirectionW"
+ OpName %vNormal "vNormal"
+ OpName %lightData "lightData"
+ OpName %diffuseColor "diffuseColor"
+ OpName %specularColor "specularColor"
+ OpName %groundColor "groundColor"
+ OpName %glossiness "glossiness"
+ OpName %ndl "ndl"
+ OpName %result "result"
+ OpName %angleW "angleW"
+ OpName %specComp "specComp"
+ OpName %main_1 "main_1"
+ OpName %tempTextureRead "tempTextureRead"
+ OpName %rgb "rgb"
+ OpName %output5 "output5"
+ OpName %output4 "output4"
+ OpName %uvOffset "uvOffset"
+ OpName %normalScale "normalScale"
+ OpName %TBNUV "TBNUV"
+ OpName %x_299 "x_299"
+ OpName %TBN "TBN"
+ OpName %param_3 "param_3"
+ OpName %param_4 "param_4"
+ OpName %param_5 "param_5"
+ OpName %param_6 "param_6"
+ OpName %invTBN "invTBN"
+ OpName %param_7 "param_7"
+ OpName %parallaxLimit "parallaxLimit"
+ OpName %vOffsetDir "vOffsetDir"
+ OpName %vMaxOffset "vMaxOffset"
+ OpName %numSamples "numSamples"
+ OpName %stepSize "stepSize"
+ OpName %currRayHeight "currRayHeight"
+ OpName %vCurrOffset "vCurrOffset"
+ OpName %vLastOffset "vLastOffset"
+ OpName %lastSampledHeight "lastSampledHeight"
+ OpName %currSampledHeight "currSampledHeight"
+ OpName %i "i"
+ OpName %delta1 "delta1"
+ OpName %delta2 "delta2"
+ OpName %ratio "ratio"
+ OpName %parallaxOcclusion_0 "parallaxOcclusion_0"
+ OpName %param_8 "param_8"
+ OpName %param_9 "param_9"
+ OpName %param_10 "param_10"
+ OpName %output6 "output6"
+ OpName %tempTextureRead1 "tempTextureRead1"
+ OpName %rgb1 "rgb1"
+ OpName %viewDirectionW_1 "viewDirectionW_1"
+ OpName %shadow "shadow"
+ OpName %glossiness_1 "glossiness_1"
+ OpName %diffuseBase "diffuseBase"
+ OpName %specularBase "specularBase"
+ OpName %normalW "normalW"
+ OpName %info "info"
+ OpName %param_11 "param_11"
+ OpName %param_12 "param_12"
+ OpName %param_13 "param_13"
+ OpName %param_14 "param_14"
+ OpName %param_15 "param_15"
+ OpName %param_16 "param_16"
+ OpName %param_17 "param_17"
+ OpName %diffuseOutput "diffuseOutput"
+ OpName %specularOutput "specularOutput"
+ OpName %output3 "output3"
+ OpName %main_out "main_out"
+ OpMemberName %main_out 0 "glFragColor_1"
+ OpName %tint_symbol_7 "tint_symbol_7"
+ OpName %tint_symbol_5 "tint_symbol_5"
+ OpName %main "main"
+ OpDecorate %TextureSamplerTexture DescriptorSet 2
+ OpDecorate %TextureSamplerTexture Binding 1
+ OpDecorate %TextureSamplerSampler DescriptorSet 2
+ OpDecorate %TextureSamplerSampler Binding 0
+ OpDecorate %LeftOver Block
+ OpMemberDecorate %LeftOver 0 Offset 0
+ OpMemberDecorate %LeftOver 0 ColMajor
+ OpMemberDecorate %LeftOver 0 MatrixStride 16
+ OpMemberDecorate %LeftOver 1 Offset 64
+ OpMemberDecorate %LeftOver 1 ColMajor
+ OpMemberDecorate %LeftOver 1 MatrixStride 16
+ OpMemberDecorate %LeftOver 2 Offset 128
+ OpMemberDecorate %LeftOver 3 Offset 132
+ OpMemberDecorate %LeftOver 4 Offset 144
+ OpMemberDecorate %LeftOver 5 Offset 156
+ OpMemberDecorate %LeftOver 6 Offset 160
+ OpMemberDecorate %LeftOver 7 Offset 164
+ OpMemberDecorate %LeftOver 8 Offset 168
+ OpDecorate %x_269 NonWritable
+ OpDecorate %x_269 DescriptorSet 2
+ OpDecorate %x_269 Binding 6
+ OpDecorate %TextureSampler1Texture DescriptorSet 2
+ OpDecorate %TextureSampler1Texture Binding 3
+ OpDecorate %TextureSampler1Sampler DescriptorSet 2
+ OpDecorate %TextureSampler1Sampler Binding 2
+ OpDecorate %Light0 Block
+ OpMemberDecorate %Light0 0 Offset 0
+ OpMemberDecorate %Light0 1 Offset 16
+ OpMemberDecorate %Light0 2 Offset 32
+ OpMemberDecorate %Light0 3 Offset 48
+ OpMemberDecorate %Light0 4 Offset 60
+ OpMemberDecorate %Light0 5 Offset 64
+ OpMemberDecorate %Light0 6 Offset 80
+ OpDecorate %light0 NonWritable
+ OpDecorate %light0 DescriptorSet 0
+ OpDecorate %light0 Binding 5
+ OpDecorate %bumpSamplerSampler DescriptorSet 2
+ OpDecorate %bumpSamplerSampler Binding 4
+ OpDecorate %bumpSamplerTexture DescriptorSet 2
+ OpDecorate %bumpSamplerTexture Binding 5
+ OpDecorate %tint_symbol Location 1
+ OpDecorate %tint_symbol_1 Location 0
+ OpDecorate %tint_symbol_2 BuiltIn FrontFacing
+ OpDecorate %tint_symbol_3 Location 3
+ OpDecorate %tint_symbol_4 Location 2
+ OpDecorate %tint_symbol_6 Location 0
+ OpMemberDecorate %lightingInfo 0 Offset 0
+ OpMemberDecorate %lightingInfo 1 Offset 16
+ OpMemberDecorate %main_out 0 Offset 0
+ %float = OpTypeFloat 32
+%_ptr_Private_float = OpTypePointer Private %float
+ %4 = OpConstantNull %float
+ %u_Float = OpVariable %_ptr_Private_float Private %4
+ %v3float = OpTypeVector %float 3
+%_ptr_Private_v3float = OpTypePointer Private %v3float
+ %8 = OpConstantNull %v3float
+ %u_Color = OpVariable %_ptr_Private_v3float Private %8
+ %11 = OpTypeImage %float 2D 0 0 0 1 Unknown
+%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
+%TextureSamplerTexture = OpVariable %_ptr_UniformConstant_11 UniformConstant
+ %14 = OpTypeSampler
+%_ptr_UniformConstant_14 = OpTypePointer UniformConstant %14
+%TextureSamplerSampler = OpVariable %_ptr_UniformConstant_14 UniformConstant
+ %v2float = OpTypeVector %float 2
+%_ptr_Private_v2float = OpTypePointer Private %v2float
+ %18 = OpConstantNull %v2float
+ %vMainuv = OpVariable %_ptr_Private_v2float Private %18
+ %v4float = OpTypeVector %float 4
+%mat4v4float = OpTypeMatrix %v4float 4
+ %uint = OpTypeInt 32 0
+ %LeftOver = OpTypeStruct %mat4v4float %mat4v4float %float %uint %v3float %float %float %uint %v2float
+%_ptr_Uniform_LeftOver = OpTypePointer Uniform %LeftOver
+ %x_269 = OpVariable %_ptr_Uniform_LeftOver Uniform
+%_ptr_Private_v4float = OpTypePointer Private %v4float
+ %27 = OpConstantNull %v4float
+ %v_output1 = OpVariable %_ptr_Private_v4float Private %27
+ %bool = OpTypeBool
+%_ptr_Private_bool = OpTypePointer Private %bool
+ %31 = OpConstantNull %bool
+%gl_FrontFacing = OpVariable %_ptr_Private_bool Private %31
+ %v_uv = OpVariable %_ptr_Private_v2float Private %18
+ %v_output2 = OpVariable %_ptr_Private_v4float Private %27
+%TextureSampler1Texture = OpVariable %_ptr_UniformConstant_11 UniformConstant
+%TextureSampler1Sampler = OpVariable %_ptr_UniformConstant_14 UniformConstant
+ %Light0 = OpTypeStruct %v4float %v4float %v4float %v3float %uint %v4float %v2float
+%_ptr_Uniform_Light0 = OpTypePointer Uniform %Light0
+ %light0 = OpVariable %_ptr_Uniform_Light0 Uniform
+%glFragColor = OpVariable %_ptr_Private_v4float Private %27
+%bumpSamplerSampler = OpVariable %_ptr_UniformConstant_14 UniformConstant
+%bumpSamplerTexture = OpVariable %_ptr_UniformConstant_11 UniformConstant
+%_ptr_Input_v2float = OpTypePointer Input %v2float
+%tint_symbol = OpVariable %_ptr_Input_v2float Input
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%tint_symbol_1 = OpVariable %_ptr_Input_v4float Input
+%_ptr_Input_bool = OpTypePointer Input %bool
+%tint_symbol_2 = OpVariable %_ptr_Input_bool Input
+%tint_symbol_3 = OpVariable %_ptr_Input_v2float Input
+%tint_symbol_4 = OpVariable %_ptr_Input_v4float Input
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+%tint_symbol_6 = OpVariable %_ptr_Output_v4float Output %27
+%mat3v3float = OpTypeMatrix %v3float 3
+%_ptr_Function_v3float = OpTypePointer Function %v3float
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+ %52 = OpTypeFunction %mat3v3float %_ptr_Function_v3float %_ptr_Function_v3float %_ptr_Function_v2float %_ptr_Function_v2float
+%_ptr_Function_float = OpTypePointer Function %float
+ %uint_0 = OpConstant %uint 0
+ %uint_1 = OpConstant %uint 1
+%_ptr_Function_mat3v3float = OpTypePointer Function %mat3v3float
+ %152 = OpTypeFunction %mat3v3float %_ptr_Function_mat3v3float
+ %161 = OpConstantNull %mat3v3float
+ %int = OpTypeInt 32 1
+ %int_0 = OpConstant %int 0
+ %int_1 = OpConstant %int 1
+ %int_2 = OpConstant %int 2
+ %uint_2 = OpConstant %uint 2
+ %211 = OpTypeFunction %v3float %_ptr_Function_mat3v3float %_ptr_Function_v3float %_ptr_Function_float
+ %float_2 = OpConstant %float 2
+ %float_1 = OpConstant %float 1
+ %238 = OpConstantComposite %v3float %float_1 %float_1 %float_1
+%lightingInfo = OpTypeStruct %v3float %v3float
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+ %246 = OpTypeFunction %lightingInfo %_ptr_Function_v3float %_ptr_Function_v3float %_ptr_Function_v4float %_ptr_Function_v3float %_ptr_Function_v3float %_ptr_Function_v3float %_ptr_Function_float
+%_ptr_Function_lightingInfo = OpTypePointer Function %lightingInfo
+ %261 = OpConstantNull %lightingInfo
+ %float_0_5 = OpConstant %float 0.5
+ %float_0 = OpConstant %float 0
+ %void = OpTypeVoid
+ %311 = OpTypeFunction %void
+%_ptr_Function_int = OpTypePointer Function %int
+ %342 = OpConstantNull %int
+ %float_100 = OpConstant %float 100
+ %371 = OpConstantComposite %v3float %float_0_5 %float_0_5 %float_0_5
+ %376 = OpTypeSampledImage %11
+ %uint_6 = OpConstant %uint 6
+%_ptr_Uniform_float = OpTypePointer Uniform %float
+ %uint_4 = OpConstant %uint 4
+%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float
+ %399 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
+ %400 = OpConstantComposite %v2float %float_0 %float_0
+ %uint_8 = OpConstant %uint 8
+%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
+ %uint_5 = OpConstant %uint 5
+ %float_15 = OpConstant %float 15
+ %float_n11 = OpConstant %float -11
+ %int_15 = OpConstant %int 15
+ %593 = OpConstantComposite %v3float %float_0 %float_0 %float_0
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+ %uint_3 = OpConstant %uint 3
+ %main_out = OpTypeStruct %v4float
+ %654 = OpTypeFunction %void %main_out
+%cotangent_frame_vf3_vf3_vf2_vf2_ = OpFunction %mat3v3float None %52
+ %normal_1 = OpFunctionParameter %_ptr_Function_v3float
+ %p = OpFunctionParameter %_ptr_Function_v3float
+ %uv = OpFunctionParameter %_ptr_Function_v2float
+%tangentSpaceParams = OpFunctionParameter %_ptr_Function_v2float
+ %61 = OpLabel
+ %dp1 = OpVariable %_ptr_Function_v3float Function %8
+ %dp2 = OpVariable %_ptr_Function_v3float Function %8
+ %duv1 = OpVariable %_ptr_Function_v2float Function %18
+ %duv2 = OpVariable %_ptr_Function_v2float Function %18
+ %dp2perp = OpVariable %_ptr_Function_v3float Function %8
+ %dp1perp = OpVariable %_ptr_Function_v3float Function %8
+ %tangent = OpVariable %_ptr_Function_v3float Function %8
+ %bitangent = OpVariable %_ptr_Function_v3float Function %8
+ %invmax = OpVariable %_ptr_Function_float Function %4
+ %73 = OpLoad %v3float %p
+ %74 = OpDPdx %v3float %73
+ OpStore %dp1 %74
+ %76 = OpLoad %v3float %p
+ %77 = OpDPdy %v3float %76
+ OpStore %dp2 %77
+ %79 = OpLoad %v2float %uv
+ %80 = OpDPdx %v2float %79
+ OpStore %duv1 %80
+ %82 = OpLoad %v2float %uv
+ %83 = OpDPdy %v2float %82
+ OpStore %duv2 %83
+ %84 = OpLoad %v3float %dp2
+ %86 = OpLoad %v3float %normal_1
+ %87 = OpExtInst %v3float %88 Cross %84 %86
+ OpStore %dp2perp %87
+ %90 = OpLoad %v3float %normal_1
+ %91 = OpLoad %v3float %dp1
+ %92 = OpExtInst %v3float %88 Cross %90 %91
+ OpStore %dp1perp %92
+ %93 = OpLoad %v3float %dp2perp
+ %95 = OpAccessChain %_ptr_Function_float %duv1 %uint_0
+ %96 = OpLoad %float %95
+ %97 = OpLoad %v3float %dp1perp
+ %98 = OpAccessChain %_ptr_Function_float %duv2 %uint_0
+ %99 = OpLoad %float %98
+ %100 = OpVectorTimesScalar %v3float %93 %96
+ %101 = OpVectorTimesScalar %v3float %97 %99
+ %102 = OpFAdd %v3float %100 %101
+ OpStore %tangent %102
+ %103 = OpLoad %v3float %dp2perp
+ %105 = OpAccessChain %_ptr_Function_float %duv1 %uint_1
+ %106 = OpLoad %float %105
+ %107 = OpLoad %v3float %dp1perp
+ %108 = OpAccessChain %_ptr_Function_float %duv2 %uint_1
+ %109 = OpLoad %float %108
+ %110 = OpVectorTimesScalar %v3float %103 %106
+ %111 = OpVectorTimesScalar %v3float %107 %109
+ %112 = OpFAdd %v3float %110 %111
+ OpStore %bitangent %112
+ %114 = OpAccessChain %_ptr_Function_float %tangentSpaceParams %uint_0
+ %115 = OpLoad %float %114
+ %116 = OpLoad %v3float %tangent
+ %117 = OpVectorTimesScalar %v3float %116 %115
+ OpStore %tangent %117
+ %119 = OpAccessChain %_ptr_Function_float %tangentSpaceParams %uint_1
+ %120 = OpLoad %float %119
+ %121 = OpLoad %v3float %bitangent
+ %122 = OpVectorTimesScalar %v3float %121 %120
+ OpStore %bitangent %122
+ %123 = OpLoad %v3float %tangent
+ %124 = OpLoad %v3float %tangent
+ %125 = OpLoad %v3float %bitangent
+ %126 = OpLoad %v3float %bitangent
+ %129 = OpDot %float %123 %124
+ %130 = OpDot %float %125 %126
+ %128 = OpExtInst %float %88 NMax %129 %130
+ %127 = OpExtInst %float %88 InverseSqrt %128
+ OpStore %invmax %127
+ %131 = OpLoad %v3float %tangent
+ %132 = OpLoad %float %invmax
+ %133 = OpVectorTimesScalar %v3float %131 %132
+ %134 = OpLoad %v3float %bitangent
+ %135 = OpLoad %float %invmax
+ %136 = OpVectorTimesScalar %v3float %134 %135
+ %138 = OpLoad %v3float %normal_1
+ %139 = OpCompositeExtract %float %133 0
+ %140 = OpCompositeExtract %float %133 1
+ %141 = OpCompositeExtract %float %133 2
+ %142 = OpCompositeConstruct %v3float %139 %140 %141
+ %143 = OpCompositeExtract %float %136 0
+ %144 = OpCompositeExtract %float %136 1
+ %145 = OpCompositeExtract %float %136 2
+ %146 = OpCompositeConstruct %v3float %143 %144 %145
+ %147 = OpCompositeExtract %float %138 0
+ %148 = OpCompositeExtract %float %138 1
+ %149 = OpCompositeExtract %float %138 2
+ %150 = OpCompositeConstruct %v3float %147 %148 %149
+ %151 = OpCompositeConstruct %mat3v3float %142 %146 %150
+ OpReturnValue %151
+ OpFunctionEnd
+%transposeMat3_mf33_ = OpFunction %mat3v3float None %152
+ %inMatrix = OpFunctionParameter %_ptr_Function_mat3v3float
+ %156 = OpLabel
+ %i0 = OpVariable %_ptr_Function_v3float Function %8
+ %i1 = OpVariable %_ptr_Function_v3float Function %8
+ %i2 = OpVariable %_ptr_Function_v3float Function %8
+ %outMatrix = OpVariable %_ptr_Function_mat3v3float Function %161
+ %165 = OpAccessChain %_ptr_Function_v3float %inMatrix %int_0
+ %166 = OpLoad %v3float %165
+ OpStore %i0 %166
+ %169 = OpAccessChain %_ptr_Function_v3float %inMatrix %int_1
+ %170 = OpLoad %v3float %169
+ OpStore %i1 %170
+ %173 = OpAccessChain %_ptr_Function_v3float %inMatrix %int_2
+ %174 = OpLoad %v3float %173
+ OpStore %i2 %174
+ %175 = OpAccessChain %_ptr_Function_float %i0 %uint_0
+ %176 = OpLoad %float %175
+ %177 = OpAccessChain %_ptr_Function_float %i1 %uint_0
+ %178 = OpLoad %float %177
+ %179 = OpAccessChain %_ptr_Function_float %i2 %uint_0
+ %180 = OpLoad %float %179
+ %181 = OpCompositeConstruct %v3float %176 %178 %180
+ %182 = OpAccessChain %_ptr_Function_float %i0 %uint_1
+ %183 = OpLoad %float %182
+ %184 = OpAccessChain %_ptr_Function_float %i1 %uint_1
+ %185 = OpLoad %float %184
+ %186 = OpAccessChain %_ptr_Function_float %i2 %uint_1
+ %187 = OpLoad %float %186
+ %188 = OpCompositeConstruct %v3float %183 %185 %187
+ %190 = OpAccessChain %_ptr_Function_float %i0 %uint_2
+ %191 = OpLoad %float %190
+ %192 = OpAccessChain %_ptr_Function_float %i1 %uint_2
+ %193 = OpLoad %float %192
+ %194 = OpAccessChain %_ptr_Function_float %i2 %uint_2
+ %195 = OpLoad %float %194
+ %196 = OpCompositeConstruct %v3float %191 %193 %195
+ %197 = OpCompositeExtract %float %181 0
+ %198 = OpCompositeExtract %float %181 1
+ %199 = OpCompositeExtract %float %181 2
+ %200 = OpCompositeConstruct %v3float %197 %198 %199
+ %201 = OpCompositeExtract %float %188 0
+ %202 = OpCompositeExtract %float %188 1
+ %203 = OpCompositeExtract %float %188 2
+ %204 = OpCompositeConstruct %v3float %201 %202 %203
+ %205 = OpCompositeExtract %float %196 0
+ %206 = OpCompositeExtract %float %196 1
+ %207 = OpCompositeExtract %float %196 2
+ %208 = OpCompositeConstruct %v3float %205 %206 %207
+ %209 = OpCompositeConstruct %mat3v3float %200 %204 %208
+ OpStore %outMatrix %209
+ %210 = OpLoad %mat3v3float %outMatrix
+ OpReturnValue %210
+ OpFunctionEnd
+%perturbNormalBase_mf33_vf3_f1_ = OpFunction %v3float None %211
+%cotangentFrame = OpFunctionParameter %_ptr_Function_mat3v3float
+ %normal = OpFunctionParameter %_ptr_Function_v3float
+ %scale = OpFunctionParameter %_ptr_Function_float
+ %216 = OpLabel
+ %218 = OpLoad %mat3v3float %cotangentFrame
+ %220 = OpLoad %v3float %normal
+ %222 = OpMatrixTimesVector %v3float %218 %220
+ %221 = OpExtInst %v3float %88 Normalize %222
+ OpReturnValue %221
+ OpFunctionEnd
+%perturbNormal_mf33_vf3_f1_ = OpFunction %v3float None %211
+%cotangentFrame_1 = OpFunctionParameter %_ptr_Function_mat3v3float
+%textureSample = OpFunctionParameter %_ptr_Function_v3float
+ %scale_1 = OpFunctionParameter %_ptr_Function_float
+ %227 = OpLabel
+ %param = OpVariable %_ptr_Function_mat3v3float Function %161
+ %param_1 = OpVariable %_ptr_Function_v3float Function %8
+ %param_2 = OpVariable %_ptr_Function_float Function %4
+ %232 = OpLoad %v3float %textureSample
+ %234 = OpLoad %mat3v3float %cotangentFrame_1
+ OpStore %param %234
+ %236 = OpVectorTimesScalar %v3float %232 %float_2
+ %239 = OpFSub %v3float %236 %238
+ OpStore %param_1 %239
+ %241 = OpLoad %float %scale_1
+ OpStore %param_2 %241
+ %242 = OpFunctionCall %v3float %perturbNormalBase_mf33_vf3_f1_ %param %param_1 %param_2
+ OpReturnValue %242
+ OpFunctionEnd
+%computeHemisphericLighting_vf3_vf3_vf4_vf3_vf3_vf3_f1_ = OpFunction %lightingInfo None %246
+%viewDirectionW = OpFunctionParameter %_ptr_Function_v3float
+ %vNormal = OpFunctionParameter %_ptr_Function_v3float
+ %lightData = OpFunctionParameter %_ptr_Function_v4float
+%diffuseColor = OpFunctionParameter %_ptr_Function_v3float
+%specularColor = OpFunctionParameter %_ptr_Function_v3float
+%groundColor = OpFunctionParameter %_ptr_Function_v3float
+ %glossiness = OpFunctionParameter %_ptr_Function_float
+ %257 = OpLabel
+ %ndl = OpVariable %_ptr_Function_float Function %4
+ %result = OpVariable %_ptr_Function_lightingInfo Function %261
+ %angleW = OpVariable %_ptr_Function_v3float Function %8
+ %specComp = OpVariable %_ptr_Function_float Function %4
+ %265 = OpLoad %v3float %vNormal
+ %267 = OpLoad %v4float %lightData
+ %269 = OpCompositeExtract %float %267 0
+ %270 = OpCompositeExtract %float %267 1
+ %271 = OpCompositeExtract %float %267 2
+ %272 = OpCompositeConstruct %v3float %269 %270 %271
+ %268 = OpDot %float %265 %272
+ %274 = OpFMul %float %268 %float_0_5
+ %275 = OpFAdd %float %274 %float_0_5
+ OpStore %ndl %275
+ %277 = OpLoad %v3float %groundColor
+ %279 = OpLoad %v3float %diffuseColor
+ %280 = OpLoad %float %ndl
+ %281 = OpAccessChain %_ptr_Function_v3float %result %uint_0
+ %283 = OpCompositeConstruct %v3float %280 %280 %280
+ %282 = OpExtInst %v3float %88 FMix %277 %279 %283
+ OpStore %281 %282
+ %285 = OpLoad %v3float %viewDirectionW
+ %287 = OpLoad %v4float %lightData
+ %289 = OpCompositeExtract %float %287 0
+ %290 = OpCompositeExtract %float %287 1
+ %291 = OpCompositeExtract %float %287 2
+ %292 = OpCompositeConstruct %v3float %289 %290 %291
+ %293 = OpFAdd %v3float %285 %292
+ %288 = OpExtInst %v3float %88 Normalize %293
+ OpStore %angleW %288
+ %295 = OpLoad %v3float %vNormal
+ %296 = OpLoad %v3float %angleW
+ %299 = OpDot %float %295 %296
+ %297 = OpExtInst %float %88 NMax %float_0 %299
+ OpStore %specComp %297
+ %300 = OpLoad %float %specComp
+ %302 = OpLoad %float %glossiness
+ %304 = OpExtInst %float %88 NMax %float_1 %302
+ %303 = OpExtInst %float %88 Pow %300 %304
+ OpStore %specComp %303
+ %305 = OpLoad %float %specComp
+ %307 = OpLoad %v3float %specularColor
+ %308 = OpAccessChain %_ptr_Function_v3float %result %uint_1
+ %309 = OpVectorTimesScalar %v3float %307 %305
+ OpStore %308 %309
+ %310 = OpLoad %lightingInfo %result
+ OpReturnValue %310
+ OpFunctionEnd
+ %main_1 = OpFunction %void None %311
+ %314 = OpLabel
+%tempTextureRead = OpVariable %_ptr_Function_v4float Function %27
+ %rgb = OpVariable %_ptr_Function_v3float Function %8
+ %output5 = OpVariable %_ptr_Function_v3float Function %8
+ %output4 = OpVariable %_ptr_Function_v4float Function %27
+ %uvOffset = OpVariable %_ptr_Function_v2float Function %18
+%normalScale = OpVariable %_ptr_Function_float Function %4
+ %TBNUV = OpVariable %_ptr_Function_v2float Function %18
+ %x_299 = OpVariable %_ptr_Function_v2float Function %18
+ %TBN = OpVariable %_ptr_Function_mat3v3float Function %161
+ %param_3 = OpVariable %_ptr_Function_v3float Function %8
+ %param_4 = OpVariable %_ptr_Function_v3float Function %8
+ %param_5 = OpVariable %_ptr_Function_v2float Function %18
+ %param_6 = OpVariable %_ptr_Function_v2float Function %18
+ %invTBN = OpVariable %_ptr_Function_mat3v3float Function %161
+ %param_7 = OpVariable %_ptr_Function_mat3v3float Function %161
+%parallaxLimit = OpVariable %_ptr_Function_float Function %4
+ %vOffsetDir = OpVariable %_ptr_Function_v2float Function %18
+ %vMaxOffset = OpVariable %_ptr_Function_v2float Function %18
+ %numSamples = OpVariable %_ptr_Function_float Function %4
+ %stepSize = OpVariable %_ptr_Function_float Function %4
+%currRayHeight = OpVariable %_ptr_Function_float Function %4
+%vCurrOffset = OpVariable %_ptr_Function_v2float Function %18
+%vLastOffset = OpVariable %_ptr_Function_v2float Function %18
+%lastSampledHeight = OpVariable %_ptr_Function_float Function %4
+%currSampledHeight = OpVariable %_ptr_Function_float Function %4
+ %i = OpVariable %_ptr_Function_int Function %342
+ %delta1 = OpVariable %_ptr_Function_float Function %4
+ %delta2 = OpVariable %_ptr_Function_float Function %4
+ %ratio = OpVariable %_ptr_Function_float Function %4
+%parallaxOcclusion_0 = OpVariable %_ptr_Function_v2float Function %18
+ %param_8 = OpVariable %_ptr_Function_mat3v3float Function %161
+ %param_9 = OpVariable %_ptr_Function_v3float Function %8
+ %param_10 = OpVariable %_ptr_Function_float Function %4
+ %output6 = OpVariable %_ptr_Function_v2float Function %18
+%tempTextureRead1 = OpVariable %_ptr_Function_v4float Function %27
+ %rgb1 = OpVariable %_ptr_Function_v3float Function %8
+%viewDirectionW_1 = OpVariable %_ptr_Function_v3float Function %8
+ %shadow = OpVariable %_ptr_Function_float Function %4
+%glossiness_1 = OpVariable %_ptr_Function_float Function %4
+%diffuseBase = OpVariable %_ptr_Function_v3float Function %8
+%specularBase = OpVariable %_ptr_Function_v3float Function %8
+ %normalW = OpVariable %_ptr_Function_v3float Function %8
+ %info = OpVariable %_ptr_Function_lightingInfo Function %261
+ %param_11 = OpVariable %_ptr_Function_v3float Function %8
+ %param_12 = OpVariable %_ptr_Function_v3float Function %8
+ %param_13 = OpVariable %_ptr_Function_v4float Function %27
+ %param_14 = OpVariable %_ptr_Function_v3float Function %8
+ %param_15 = OpVariable %_ptr_Function_v3float Function %8
+ %param_16 = OpVariable %_ptr_Function_v3float Function %8
+ %param_17 = OpVariable %_ptr_Function_float Function %4
+%diffuseOutput = OpVariable %_ptr_Function_v3float Function %8
+%specularOutput = OpVariable %_ptr_Function_v3float Function %8
+ %output3 = OpVariable %_ptr_Function_v3float Function %8
+ OpStore %u_Float %float_100
+ OpStore %u_Color %371
+ %372 = OpLoad %v2float %vMainuv
+ %374 = OpLoad %14 %TextureSamplerSampler
+ %375 = OpLoad %11 %TextureSamplerTexture
+ %377 = OpSampledImage %376 %375 %374
+ %373 = OpImageSampleImplicitLod %v4float %377 %372
+ OpStore %tempTextureRead %373
+ %378 = OpLoad %v4float %tempTextureRead
+ %381 = OpAccessChain %_ptr_Uniform_float %x_269 %uint_6
+ %382 = OpLoad %float %381
+ %383 = OpCompositeExtract %float %378 0
+ %384 = OpCompositeExtract %float %378 1
+ %385 = OpCompositeExtract %float %378 2
+ %386 = OpCompositeConstruct %v3float %383 %384 %385
+ %387 = OpVectorTimesScalar %v3float %386 %382
+ OpStore %rgb %387
+ %390 = OpAccessChain %_ptr_Uniform_v3float %x_269 %uint_4
+ %391 = OpLoad %v3float %390
+ %392 = OpLoad %v4float %v_output1
+ %394 = OpCompositeExtract %float %392 0
+ %395 = OpCompositeExtract %float %392 1
+ %396 = OpCompositeExtract %float %392 2
+ %397 = OpCompositeConstruct %v3float %394 %395 %396
+ %398 = OpFSub %v3float %391 %397
+ %393 = OpExtInst %v3float %88 Normalize %398
+ OpStore %output5 %393
+ OpStore %output4 %399
+ OpStore %uvOffset %400
+ %401 = OpAccessChain %_ptr_Uniform_float %x_269 %uint_2
+ %402 = OpLoad %float %401
+ %403 = OpFDiv %float %float_1 %402
+ OpStore %normalScale %403
+ %404 = OpLoad %bool %gl_FrontFacing
+ OpSelectionMerge %405 None
+ OpBranchConditional %404 %406 %407
+ %406 = OpLabel
+ %408 = OpLoad %v2float %v_uv
+ OpStore %x_299 %408
+ OpBranch %405
+ %407 = OpLabel
+ %409 = OpLoad %v2float %v_uv
+ %410 = OpFNegate %v2float %409
+ OpStore %x_299 %410
+ OpBranch %405
+ %405 = OpLabel
+ %411 = OpLoad %v2float %x_299
+ OpStore %TBNUV %411
+ %412 = OpLoad %v4float %v_output2
+ %413 = OpLoad %float %normalScale
+ %414 = OpCompositeExtract %float %412 0
+ %415 = OpCompositeExtract %float %412 1
+ %416 = OpCompositeExtract %float %412 2
+ %417 = OpCompositeConstruct %v3float %414 %415 %416
+ %418 = OpVectorTimesScalar %v3float %417 %413
+ OpStore %param_3 %418
+ %419 = OpLoad %v4float %v_output1
+ %420 = OpCompositeExtract %float %419 0
+ %421 = OpCompositeExtract %float %419 1
+ %422 = OpCompositeExtract %float %419 2
+ %423 = OpCompositeConstruct %v3float %420 %421 %422
+ OpStore %param_4 %423
+ %424 = OpLoad %v2float %TBNUV
+ OpStore %param_5 %424
+ %427 = OpAccessChain %_ptr_Uniform_v2float %x_269 %uint_8
+ %428 = OpLoad %v2float %427
+ OpStore %param_6 %428
+ %429 = OpFunctionCall %mat3v3float %cotangent_frame_vf3_vf3_vf2_vf2_ %param_3 %param_4 %param_5 %param_6
+ OpStore %TBN %429
+ %434 = OpLoad %mat3v3float %TBN
+ OpStore %param_7 %434
+ %435 = OpFunctionCall %mat3v3float %transposeMat3_mf33_ %param_7
+ OpStore %invTBN %435
+ %437 = OpLoad %mat3v3float %invTBN
+ %438 = OpLoad %v3float %output5
+ %439 = OpFNegate %v3float %438
+ %440 = OpMatrixTimesVector %v3float %437 %439
+ %441 = OpLoad %mat3v3float %invTBN
+ %442 = OpLoad %v3float %output5
+ %444 = OpCompositeExtract %float %440 0
+ %445 = OpCompositeExtract %float %440 1
+ %446 = OpCompositeConstruct %v2float %444 %445
+ %443 = OpExtInst %float %88 Length %446
+ %447 = OpFNegate %v3float %442
+ %448 = OpMatrixTimesVector %v3float %441 %447
+ %449 = OpCompositeExtract %float %448 2
+ %450 = OpFDiv %float %443 %449
+ OpStore %parallaxLimit %450
+ %452 = OpAccessChain %_ptr_Uniform_float %x_269 %uint_5
+ %453 = OpLoad %float %452
+ %454 = OpLoad %float %parallaxLimit
+ %455 = OpFMul %float %454 %453
+ OpStore %parallaxLimit %455
+ %456 = OpLoad %mat3v3float %invTBN
+ %457 = OpLoad %v3float %output5
+ %458 = OpFNegate %v3float %457
+ %459 = OpMatrixTimesVector %v3float %456 %458
+ %461 = OpCompositeExtract %float %459 0
+ %462 = OpCompositeExtract %float %459 1
+ %463 = OpCompositeConstruct %v2float %461 %462
+ %460 = OpExtInst %v2float %88 Normalize %463
+ OpStore %vOffsetDir %460
+ %464 = OpLoad %v2float %vOffsetDir
+ %465 = OpLoad %float %parallaxLimit
+ %466 = OpVectorTimesScalar %v2float %464 %465
+ OpStore %vMaxOffset %466
+ %467 = OpLoad %mat3v3float %invTBN
+ %468 = OpLoad %v3float %output5
+ %469 = OpLoad %mat3v3float %invTBN
+ %470 = OpLoad %v4float %v_output2
+ %473 = OpFNegate %v3float %468
+ %474 = OpMatrixTimesVector %v3float %467 %473
+ %475 = OpCompositeExtract %float %470 0
+ %476 = OpCompositeExtract %float %470 1
+ %477 = OpCompositeExtract %float %470 2
+ %478 = OpCompositeConstruct %v3float %475 %476 %477
+ %479 = OpMatrixTimesVector %v3float %469 %478
+ %472 = OpDot %float %474 %479
+ %481 = OpFMul %float %472 %float_n11
+ %482 = OpFAdd %float %float_15 %481
+ OpStore %numSamples %482
+ %483 = OpLoad %float %numSamples
+ %484 = OpFDiv %float %float_1 %483
+ OpStore %stepSize %484
+ OpStore %currRayHeight %float_1
+ OpStore %vCurrOffset %400
+ OpStore %vLastOffset %400
+ OpStore %lastSampledHeight %float_1
+ OpStore %currSampledHeight %float_1
+ OpStore %i %int_0
+ OpBranch %485
+ %485 = OpLabel
+ OpLoopMerge %486 %487 None
+ OpBranch %488
+ %488 = OpLabel
+ %489 = OpLoad %int %i
+ %491 = OpSLessThan %bool %489 %int_15
+ OpSelectionMerge %492 None
+ OpBranchConditional %491 %493 %494
+ %493 = OpLabel
+ OpBranch %492
+ %494 = OpLabel
+ OpBranch %486
+ %492 = OpLabel
+ %495 = OpLoad %v2float %v_uv
+ %496 = OpLoad %v2float %vCurrOffset
+ %498 = OpLoad %14 %TextureSamplerSampler
+ %499 = OpLoad %11 %TextureSamplerTexture
+ %500 = OpSampledImage %376 %499 %498
+ %501 = OpFAdd %v2float %495 %496
+ %497 = OpImageSampleImplicitLod %v4float %500 %501
+ %502 = OpCompositeExtract %float %497 3
+ OpStore %currSampledHeight %502
+ %503 = OpLoad %float %currSampledHeight
+ %504 = OpLoad %float %currRayHeight
+ %505 = OpFOrdGreaterThan %bool %503 %504
+ OpSelectionMerge %506 None
+ OpBranchConditional %505 %507 %508
+ %507 = OpLabel
+ %509 = OpLoad %float %currSampledHeight
+ %510 = OpLoad %float %currRayHeight
+ %511 = OpFSub %float %509 %510
+ OpStore %delta1 %511
+ %512 = OpLoad %float %currRayHeight
+ %513 = OpLoad %float %stepSize
+ %514 = OpLoad %float %lastSampledHeight
+ %515 = OpFAdd %float %512 %513
+ %516 = OpFSub %float %515 %514
+ OpStore %delta2 %516
+ %517 = OpLoad %float %delta1
+ %518 = OpLoad %float %delta1
+ %519 = OpLoad %float %delta2
+ %520 = OpFAdd %float %518 %519
+ %521 = OpFDiv %float %517 %520
+ OpStore %ratio %521
+ %522 = OpLoad %float %ratio
+ %523 = OpLoad %v2float %vLastOffset
+ %524 = OpLoad %float %ratio
+ %525 = OpLoad %v2float %vCurrOffset
+ %526 = OpVectorTimesScalar %v2float %523 %522
+ %527 = OpFSub %float %float_1 %524
+ %528 = OpVectorTimesScalar %v2float %525 %527
+ %529 = OpFAdd %v2float %526 %528
+ OpStore %vCurrOffset %529
+ OpBranch %486
+ %508 = OpLabel
+ %530 = OpLoad %float %stepSize
+ %531 = OpLoad %float %currRayHeight
+ %532 = OpFSub %float %531 %530
+ OpStore %currRayHeight %532
+ %533 = OpLoad %v2float %vCurrOffset
+ OpStore %vLastOffset %533
+ %534 = OpLoad %float %stepSize
+ %535 = OpLoad %v2float %vMaxOffset
+ %536 = OpLoad %v2float %vCurrOffset
+ %537 = OpVectorTimesScalar %v2float %535 %534
+ %538 = OpFAdd %v2float %536 %537
+ OpStore %vCurrOffset %538
+ %539 = OpLoad %float %currSampledHeight
+ OpStore %lastSampledHeight %539
+ OpBranch %506
+ %506 = OpLabel
+ OpBranch %487
+ %487 = OpLabel
+ %540 = OpLoad %int %i
+ %541 = OpIAdd %int %540 %int_1
+ OpStore %i %541
+ OpBranch %485
+ %486 = OpLabel
+ %542 = OpLoad %v2float %vCurrOffset
+ OpStore %parallaxOcclusion_0 %542
+ %543 = OpLoad %v2float %parallaxOcclusion_0
+ OpStore %uvOffset %543
+ %544 = OpLoad %v2float %v_uv
+ %545 = OpLoad %v2float %uvOffset
+ %547 = OpLoad %14 %TextureSamplerSampler
+ %548 = OpLoad %11 %TextureSamplerTexture
+ %549 = OpSampledImage %376 %548 %547
+ %550 = OpFAdd %v2float %544 %545
+ %546 = OpImageSampleImplicitLod %v4float %549 %550
+ %551 = OpAccessChain %_ptr_Uniform_float %x_269 %uint_2
+ %552 = OpLoad %float %551
+ %553 = OpLoad %mat3v3float %TBN
+ OpStore %param_8 %553
+ %554 = OpCompositeExtract %float %546 0
+ %555 = OpCompositeExtract %float %546 1
+ %556 = OpCompositeExtract %float %546 2
+ %557 = OpCompositeConstruct %v3float %554 %555 %556
+ OpStore %param_9 %557
+ %558 = OpFDiv %float %float_1 %552
+ OpStore %param_10 %558
+ %559 = OpFunctionCall %v3float %perturbNormal_mf33_vf3_f1_ %param_8 %param_9 %param_10
+ %563 = OpLoad %v4float %output4
+ %564 = OpCompositeExtract %float %559 0
+ %565 = OpCompositeExtract %float %559 1
+ %566 = OpCompositeExtract %float %559 2
+ %567 = OpCompositeExtract %float %563 3
+ %568 = OpCompositeConstruct %v4float %564 %565 %566 %567
+ OpStore %output4 %568
+ %569 = OpLoad %v2float %v_uv
+ %570 = OpLoad %v2float %uvOffset
+ %571 = OpFAdd %v2float %569 %570
+ OpStore %output6 %571
+ %572 = OpLoad %v2float %output6
+ %574 = OpLoad %14 %TextureSampler1Sampler
+ %575 = OpLoad %11 %TextureSampler1Texture
+ %576 = OpSampledImage %376 %575 %574
+ %573 = OpImageSampleImplicitLod %v4float %576 %572
+ OpStore %tempTextureRead1 %573
+ %577 = OpLoad %v4float %tempTextureRead1
+ %578 = OpCompositeExtract %float %577 0
+ %579 = OpCompositeExtract %float %577 1
+ %580 = OpCompositeExtract %float %577 2
+ %581 = OpCompositeConstruct %v3float %578 %579 %580
+ OpStore %rgb1 %581
+ %582 = OpAccessChain %_ptr_Uniform_v3float %x_269 %uint_4
+ %583 = OpLoad %v3float %582
+ %584 = OpLoad %v4float %v_output1
+ %586 = OpCompositeExtract %float %584 0
+ %587 = OpCompositeExtract %float %584 1
+ %588 = OpCompositeExtract %float %584 2
+ %589 = OpCompositeConstruct %v3float %586 %587 %588
+ %590 = OpFSub %v3float %583 %589
+ %585 = OpExtInst %v3float %88 Normalize %590
+ OpStore %viewDirectionW_1 %585
+ OpStore %shadow %float_1
+ %591 = OpLoad %float %u_Float
+ %592 = OpFMul %float %float_1 %591
+ OpStore %glossiness_1 %592
+ OpStore %diffuseBase %593
+ OpStore %specularBase %593
+ %594 = OpLoad %v4float %output4
+ %595 = OpCompositeExtract %float %594 0
+ %596 = OpCompositeExtract %float %594 1
+ %597 = OpCompositeExtract %float %594 2
+ %598 = OpCompositeConstruct %v3float %595 %596 %597
+ OpStore %normalW %598
+ %599 = OpLoad %v3float %viewDirectionW_1
+ OpStore %param_11 %599
+ %600 = OpLoad %v3float %normalW
+ OpStore %param_12 %600
+ %602 = OpAccessChain %_ptr_Uniform_v4float %light0 %uint_0
+ %603 = OpLoad %v4float %602
+ OpStore %param_13 %603
+ %604 = OpAccessChain %_ptr_Uniform_v4float %light0 %uint_1
+ %605 = OpLoad %v4float %604
+ %606 = OpCompositeExtract %float %605 0
+ %607 = OpCompositeExtract %float %605 1
+ %608 = OpCompositeExtract %float %605 2
+ %609 = OpCompositeConstruct %v3float %606 %607 %608
+ OpStore %param_14 %609
+ %610 = OpAccessChain %_ptr_Uniform_v4float %light0 %uint_2
+ %611 = OpLoad %v4float %610
+ %612 = OpCompositeExtract %float %611 0
+ %613 = OpCompositeExtract %float %611 1
+ %614 = OpCompositeExtract %float %611 2
+ %615 = OpCompositeConstruct %v3float %612 %613 %614
+ OpStore %param_15 %615
+ %617 = OpAccessChain %_ptr_Uniform_v3float %light0 %uint_3
+ %618 = OpLoad %v3float %617
+ OpStore %param_16 %618
+ %619 = OpLoad %float %glossiness_1
+ OpStore %param_17 %619
+ %620 = OpFunctionCall %lightingInfo %computeHemisphericLighting_vf3_vf3_vf4_vf3_vf3_vf3_f1_ %param_11 %param_12 %param_13 %param_14 %param_15 %param_16 %param_17
+ OpStore %info %620
+ OpStore %shadow %float_1
+ %628 = OpAccessChain %_ptr_Function_v3float %info %uint_0
+ %629 = OpLoad %v3float %628
+ %630 = OpLoad %float %shadow
+ %631 = OpLoad %v3float %diffuseBase
+ %632 = OpVectorTimesScalar %v3float %629 %630
+ %633 = OpFAdd %v3float %631 %632
+ OpStore %diffuseBase %633
+ %634 = OpAccessChain %_ptr_Function_v3float %info %uint_1
+ %635 = OpLoad %v3float %634
+ %636 = OpLoad %float %shadow
+ %637 = OpLoad %v3float %specularBase
+ %638 = OpVectorTimesScalar %v3float %635 %636
+ %639 = OpFAdd %v3float %637 %638
+ OpStore %specularBase %639
+ %640 = OpLoad %v3float %diffuseBase
+ %641 = OpLoad %v3float %rgb1
+ %642 = OpFMul %v3float %640 %641
+ OpStore %diffuseOutput %642
+ %643 = OpLoad %v3float %specularBase
+ %644 = OpLoad %v3float %u_Color
+ %645 = OpFMul %v3float %643 %644
+ OpStore %specularOutput %645
+ %646 = OpLoad %v3float %diffuseOutput
+ %647 = OpLoad %v3float %specularOutput
+ %648 = OpFAdd %v3float %646 %647
+ OpStore %output3 %648
+ %649 = OpLoad %v3float %output3
+ %650 = OpCompositeExtract %float %649 0
+ %651 = OpCompositeExtract %float %649 1
+ %652 = OpCompositeExtract %float %649 2
+ %653 = OpCompositeConstruct %v4float %650 %651 %652 %float_1
+ OpStore %glFragColor %653
+ OpReturn
+ OpFunctionEnd
+%tint_symbol_7 = OpFunction %void None %654
+%tint_symbol_5 = OpFunctionParameter %main_out
+ %658 = OpLabel
+ %659 = OpCompositeExtract %v4float %tint_symbol_5 0
+ OpStore %tint_symbol_6 %659
+ OpReturn
+ OpFunctionEnd
+ %main = OpFunction %void None %311
+ %661 = OpLabel
+ %662 = OpLoad %v2float %tint_symbol
+ OpStore %vMainuv %662
+ %663 = OpLoad %v4float %tint_symbol_1
+ OpStore %v_output1 %663
+ %664 = OpLoad %bool %tint_symbol_2
+ OpStore %gl_FrontFacing %664
+ %665 = OpLoad %v2float %tint_symbol_3
+ OpStore %v_uv %665
+ %666 = OpLoad %v4float %tint_symbol_4
+ OpStore %v_output2 %666
+ %667 = OpFunctionCall %void %main_1
+ %669 = OpLoad %v4float %glFragColor
+ %670 = OpCompositeConstruct %main_out %669
+ %668 = OpFunctionCall %void %tint_symbol_7 %670
+ OpReturn
+ OpFunctionEnd
diff --git a/test/bug/tint/949.wgsl.expected.wgsl b/test/bug/tint/949.wgsl.expected.wgsl
new file mode 100644
index 0000000..73b74ea
--- /dev/null
+++ b/test/bug/tint/949.wgsl.expected.wgsl
@@ -0,0 +1,454 @@
+struct lightingInfo {
+ diffuse : vec3<f32>;
+ specular : vec3<f32>;
+};
+
+[[block]]
+struct LeftOver {
+ u_World : mat4x4<f32>;
+ u_ViewProjection : mat4x4<f32>;
+ u_bumpStrength : f32;
+ [[size(12)]]
+ padding : u32;
+ u_cameraPosition : vec3<f32>;
+ u_parallaxScale : f32;
+ textureInfoName : f32;
+ [[size(4)]]
+ padding_1 : u32;
+ tangentSpaceParameter0 : vec2<f32>;
+};
+
+[[block]]
+struct Light0 {
+ vLightData : vec4<f32>;
+ vLightDiffuse : vec4<f32>;
+ vLightSpecular : vec4<f32>;
+ vLightGround : vec3<f32>;
+ [[size(4)]]
+ padding_2 : u32;
+ shadowsInfo : vec4<f32>;
+ depthValues : vec2<f32>;
+};
+
+var<private> u_Float : f32;
+
+var<private> u_Color : vec3<f32>;
+
+[[group(2), binding(1)]] var TextureSamplerTexture : texture_2d<f32>;
+
+[[group(2), binding(0)]] var TextureSamplerSampler : sampler;
+
+var<private> vMainuv : vec2<f32>;
+
+[[group(2), binding(6)]] var<uniform> x_269 : LeftOver;
+
+var<private> v_output1 : vec4<f32>;
+
+var<private> gl_FrontFacing : bool;
+
+var<private> v_uv : vec2<f32>;
+
+var<private> v_output2 : vec4<f32>;
+
+[[group(2), binding(3)]] var TextureSampler1Texture : texture_2d<f32>;
+
+[[group(2), binding(2)]] var TextureSampler1Sampler : sampler;
+
+[[group(0), binding(5)]] var<uniform> light0 : Light0;
+
+var<private> glFragColor : vec4<f32>;
+
+[[group(2), binding(4)]] var bumpSamplerSampler : sampler;
+
+[[group(2), binding(5)]] var bumpSamplerTexture : texture_2d<f32>;
+
+fn cotangent_frame_vf3_vf3_vf2_vf2_(normal_1 : ptr<function, vec3<f32>>, p : ptr<function, vec3<f32>>, uv : ptr<function, vec2<f32>>, tangentSpaceParams : ptr<function, vec2<f32>>) -> mat3x3<f32> {
+ var dp1 : vec3<f32>;
+ var dp2 : vec3<f32>;
+ var duv1 : vec2<f32>;
+ var duv2 : vec2<f32>;
+ var dp2perp : vec3<f32>;
+ var dp1perp : vec3<f32>;
+ var tangent : vec3<f32>;
+ var bitangent : vec3<f32>;
+ var invmax : f32;
+ let x_133 : vec3<f32> = *(p);
+ dp1 = dpdx(x_133);
+ let x_136 : vec3<f32> = *(p);
+ dp2 = dpdy(x_136);
+ let x_139 : vec2<f32> = *(uv);
+ duv1 = dpdx(x_139);
+ let x_142 : vec2<f32> = *(uv);
+ duv2 = dpdy(x_142);
+ let x_145 : vec3<f32> = dp2;
+ let x_146 : vec3<f32> = *(normal_1);
+ dp2perp = cross(x_145, x_146);
+ let x_149 : vec3<f32> = *(normal_1);
+ let x_150 : vec3<f32> = dp1;
+ dp1perp = cross(x_149, x_150);
+ let x_153 : vec3<f32> = dp2perp;
+ let x_155 : f32 = duv1.x;
+ let x_157 : vec3<f32> = dp1perp;
+ let x_159 : f32 = duv2.x;
+ tangent = ((x_153 * x_155) + (x_157 * x_159));
+ let x_163 : vec3<f32> = dp2perp;
+ let x_165 : f32 = duv1.y;
+ let x_167 : vec3<f32> = dp1perp;
+ let x_169 : f32 = duv2.y;
+ bitangent = ((x_163 * x_165) + (x_167 * x_169));
+ let x_173 : f32 = (*(tangentSpaceParams)).x;
+ let x_174 : vec3<f32> = tangent;
+ tangent = (x_174 * x_173);
+ let x_177 : f32 = (*(tangentSpaceParams)).y;
+ let x_178 : vec3<f32> = bitangent;
+ bitangent = (x_178 * x_177);
+ let x_181 : vec3<f32> = tangent;
+ let x_182 : vec3<f32> = tangent;
+ let x_184 : vec3<f32> = bitangent;
+ let x_185 : vec3<f32> = bitangent;
+ invmax = inverseSqrt(max(dot(x_181, x_182), dot(x_184, x_185)));
+ let x_189 : vec3<f32> = tangent;
+ let x_190 : f32 = invmax;
+ let x_191 : vec3<f32> = (x_189 * x_190);
+ let x_192 : vec3<f32> = bitangent;
+ let x_193 : f32 = invmax;
+ let x_194 : vec3<f32> = (x_192 * x_193);
+ let x_195 : vec3<f32> = *(normal_1);
+ return mat3x3<f32>(vec3<f32>(x_191.x, x_191.y, x_191.z), vec3<f32>(x_194.x, x_194.y, x_194.z), vec3<f32>(x_195.x, x_195.y, x_195.z));
+}
+
+fn transposeMat3_mf33_(inMatrix : ptr<function, mat3x3<f32>>) -> mat3x3<f32> {
+ var i0 : vec3<f32>;
+ var i1 : vec3<f32>;
+ var i2 : vec3<f32>;
+ var outMatrix : mat3x3<f32>;
+ let x_60 : vec3<f32> = (*(inMatrix))[0];
+ i0 = x_60;
+ let x_64 : vec3<f32> = (*(inMatrix))[1];
+ i1 = x_64;
+ let x_68 : vec3<f32> = (*(inMatrix))[2];
+ i2 = x_68;
+ let x_73 : f32 = i0.x;
+ let x_75 : f32 = i1.x;
+ let x_77 : f32 = i2.x;
+ let x_78 : vec3<f32> = vec3<f32>(x_73, x_75, x_77);
+ let x_81 : f32 = i0.y;
+ let x_83 : f32 = i1.y;
+ let x_85 : f32 = i2.y;
+ let x_86 : vec3<f32> = vec3<f32>(x_81, x_83, x_85);
+ let x_89 : f32 = i0.z;
+ let x_91 : f32 = i1.z;
+ let x_93 : f32 = i2.z;
+ let x_94 : vec3<f32> = vec3<f32>(x_89, x_91, x_93);
+ outMatrix = mat3x3<f32>(vec3<f32>(x_78.x, x_78.y, x_78.z), vec3<f32>(x_86.x, x_86.y, x_86.z), vec3<f32>(x_94.x, x_94.y, x_94.z));
+ let x_110 : mat3x3<f32> = outMatrix;
+ return x_110;
+}
+
+fn perturbNormalBase_mf33_vf3_f1_(cotangentFrame : ptr<function, mat3x3<f32>>, normal : ptr<function, vec3<f32>>, scale : ptr<function, f32>) -> vec3<f32> {
+ let x_113 : mat3x3<f32> = *(cotangentFrame);
+ let x_114 : vec3<f32> = *(normal);
+ return normalize((x_113 * x_114));
+}
+
+fn perturbNormal_mf33_vf3_f1_(cotangentFrame_1 : ptr<function, mat3x3<f32>>, textureSample : ptr<function, vec3<f32>>, scale_1 : ptr<function, f32>) -> vec3<f32> {
+ var param : mat3x3<f32>;
+ var param_1 : vec3<f32>;
+ var param_2 : f32;
+ let x_119 : vec3<f32> = *(textureSample);
+ let x_125 : mat3x3<f32> = *(cotangentFrame_1);
+ param = x_125;
+ param_1 = ((x_119 * 2.0) - vec3<f32>(1.0, 1.0, 1.0));
+ let x_128 : f32 = *(scale_1);
+ param_2 = x_128;
+ let x_129 : vec3<f32> = perturbNormalBase_mf33_vf3_f1_(&(param), &(param_1), &(param_2));
+ return x_129;
+}
+
+fn computeHemisphericLighting_vf3_vf3_vf4_vf3_vf3_vf3_f1_(viewDirectionW : ptr<function, vec3<f32>>, vNormal : ptr<function, vec3<f32>>, lightData : ptr<function, vec4<f32>>, diffuseColor : ptr<function, vec3<f32>>, specularColor : ptr<function, vec3<f32>>, groundColor : ptr<function, vec3<f32>>, glossiness : ptr<function, f32>) -> lightingInfo {
+ var ndl : f32;
+ var result : lightingInfo;
+ var angleW : vec3<f32>;
+ var specComp : f32;
+ let x_212 : vec3<f32> = *(vNormal);
+ let x_213 : vec4<f32> = *(lightData);
+ ndl = ((dot(x_212, vec3<f32>(x_213.x, x_213.y, x_213.z)) * 0.5) + 0.5);
+ let x_220 : vec3<f32> = *(groundColor);
+ let x_221 : vec3<f32> = *(diffuseColor);
+ let x_222 : f32 = ndl;
+ result.diffuse = mix(x_220, x_221, vec3<f32>(x_222, x_222, x_222));
+ let x_227 : vec3<f32> = *(viewDirectionW);
+ let x_228 : vec4<f32> = *(lightData);
+ angleW = normalize((x_227 + vec3<f32>(x_228.x, x_228.y, x_228.z)));
+ let x_233 : vec3<f32> = *(vNormal);
+ let x_234 : vec3<f32> = angleW;
+ specComp = max(0.0, dot(x_233, x_234));
+ let x_237 : f32 = specComp;
+ let x_238 : f32 = *(glossiness);
+ specComp = pow(x_237, max(1.0, x_238));
+ let x_241 : f32 = specComp;
+ let x_242 : vec3<f32> = *(specularColor);
+ result.specular = (x_242 * x_241);
+ let x_245 : lightingInfo = result;
+ return x_245;
+}
+
+fn main_1() {
+ var tempTextureRead : vec4<f32>;
+ var rgb : vec3<f32>;
+ var output5 : vec3<f32>;
+ var output4 : vec4<f32>;
+ var uvOffset : vec2<f32>;
+ var normalScale : f32;
+ var TBNUV : vec2<f32>;
+ var x_299 : vec2<f32>;
+ var TBN : mat3x3<f32>;
+ var param_3 : vec3<f32>;
+ var param_4 : vec3<f32>;
+ var param_5 : vec2<f32>;
+ var param_6 : vec2<f32>;
+ var invTBN : mat3x3<f32>;
+ var param_7 : mat3x3<f32>;
+ var parallaxLimit : f32;
+ var vOffsetDir : vec2<f32>;
+ var vMaxOffset : vec2<f32>;
+ var numSamples : f32;
+ var stepSize : f32;
+ var currRayHeight : f32;
+ var vCurrOffset : vec2<f32>;
+ var vLastOffset : vec2<f32>;
+ var lastSampledHeight : f32;
+ var currSampledHeight : f32;
+ var i : i32;
+ var delta1 : f32;
+ var delta2 : f32;
+ var ratio : f32;
+ var parallaxOcclusion_0 : vec2<f32>;
+ var param_8 : mat3x3<f32>;
+ var param_9 : vec3<f32>;
+ var param_10 : f32;
+ var output6 : vec2<f32>;
+ var tempTextureRead1 : vec4<f32>;
+ var rgb1 : vec3<f32>;
+ var viewDirectionW_1 : vec3<f32>;
+ var shadow : f32;
+ var glossiness_1 : f32;
+ var diffuseBase : vec3<f32>;
+ var specularBase : vec3<f32>;
+ var normalW : vec3<f32>;
+ var info : lightingInfo;
+ var param_11 : vec3<f32>;
+ var param_12 : vec3<f32>;
+ var param_13 : vec4<f32>;
+ var param_14 : vec3<f32>;
+ var param_15 : vec3<f32>;
+ var param_16 : vec3<f32>;
+ var param_17 : f32;
+ var diffuseOutput : vec3<f32>;
+ var specularOutput : vec3<f32>;
+ var output3 : vec3<f32>;
+ u_Float = 100.0;
+ u_Color = vec3<f32>(0.5, 0.5, 0.5);
+ let x_261 : vec2<f32> = vMainuv;
+ let x_262 : vec4<f32> = textureSample(TextureSamplerTexture, TextureSamplerSampler, x_261);
+ tempTextureRead = x_262;
+ let x_264 : vec4<f32> = tempTextureRead;
+ let x_273 : f32 = x_269.textureInfoName;
+ rgb = (vec3<f32>(x_264.x, x_264.y, x_264.z) * x_273);
+ let x_279 : vec3<f32> = x_269.u_cameraPosition;
+ let x_282 : vec4<f32> = v_output1;
+ output5 = normalize((x_279 - vec3<f32>(x_282.x, x_282.y, x_282.z)));
+ output4 = vec4<f32>(0.0, 0.0, 0.0, 0.0);
+ uvOffset = vec2<f32>(0.0, 0.0);
+ let x_292 : f32 = x_269.u_bumpStrength;
+ normalScale = (1.0 / x_292);
+ let x_298 : bool = gl_FrontFacing;
+ if (x_298) {
+ let x_303 : vec2<f32> = v_uv;
+ x_299 = x_303;
+ } else {
+ let x_305 : vec2<f32> = v_uv;
+ x_299 = -(x_305);
+ }
+ let x_307 : vec2<f32> = x_299;
+ TBNUV = x_307;
+ let x_310 : vec4<f32> = v_output2;
+ let x_312 : f32 = normalScale;
+ param_3 = (vec3<f32>(x_310.x, x_310.y, x_310.z) * x_312);
+ let x_317 : vec4<f32> = v_output1;
+ param_4 = vec3<f32>(x_317.x, x_317.y, x_317.z);
+ let x_320 : vec2<f32> = TBNUV;
+ param_5 = x_320;
+ let x_324 : vec2<f32> = x_269.tangentSpaceParameter0;
+ param_6 = x_324;
+ let x_325 : mat3x3<f32> = cotangent_frame_vf3_vf3_vf2_vf2_(&(param_3), &(param_4), &(param_5), &(param_6));
+ TBN = x_325;
+ let x_328 : mat3x3<f32> = TBN;
+ param_7 = x_328;
+ let x_329 : mat3x3<f32> = transposeMat3_mf33_(&(param_7));
+ invTBN = x_329;
+ let x_331 : mat3x3<f32> = invTBN;
+ let x_332 : vec3<f32> = output5;
+ let x_334 : vec3<f32> = (x_331 * -(x_332));
+ let x_337 : mat3x3<f32> = invTBN;
+ let x_338 : vec3<f32> = output5;
+ parallaxLimit = (length(vec2<f32>(x_334.x, x_334.y)) / ((x_337 * -(x_338))).z);
+ let x_345 : f32 = x_269.u_parallaxScale;
+ let x_346 : f32 = parallaxLimit;
+ parallaxLimit = (x_346 * x_345);
+ let x_349 : mat3x3<f32> = invTBN;
+ let x_350 : vec3<f32> = output5;
+ let x_352 : vec3<f32> = (x_349 * -(x_350));
+ vOffsetDir = normalize(vec2<f32>(x_352.x, x_352.y));
+ let x_356 : vec2<f32> = vOffsetDir;
+ let x_357 : f32 = parallaxLimit;
+ vMaxOffset = (x_356 * x_357);
+ let x_361 : mat3x3<f32> = invTBN;
+ let x_362 : vec3<f32> = output5;
+ let x_365 : mat3x3<f32> = invTBN;
+ let x_366 : vec4<f32> = v_output2;
+ numSamples = (15.0 + (dot((x_361 * -(x_362)), (x_365 * vec3<f32>(x_366.x, x_366.y, x_366.z))) * -11.0));
+ let x_374 : f32 = numSamples;
+ stepSize = (1.0 / x_374);
+ currRayHeight = 1.0;
+ vCurrOffset = vec2<f32>(0.0, 0.0);
+ vLastOffset = vec2<f32>(0.0, 0.0);
+ lastSampledHeight = 1.0;
+ currSampledHeight = 1.0;
+ i = 0;
+ loop {
+ let x_388 : i32 = i;
+ if ((x_388 < 15)) {
+ } else {
+ break;
+ }
+ let x_394 : vec2<f32> = v_uv;
+ let x_395 : vec2<f32> = vCurrOffset;
+ let x_397 : vec4<f32> = textureSample(TextureSamplerTexture, TextureSamplerSampler, (x_394 + x_395));
+ currSampledHeight = x_397.w;
+ let x_400 : f32 = currSampledHeight;
+ let x_401 : f32 = currRayHeight;
+ if ((x_400 > x_401)) {
+ let x_406 : f32 = currSampledHeight;
+ let x_407 : f32 = currRayHeight;
+ delta1 = (x_406 - x_407);
+ let x_410 : f32 = currRayHeight;
+ let x_411 : f32 = stepSize;
+ let x_413 : f32 = lastSampledHeight;
+ delta2 = ((x_410 + x_411) - x_413);
+ let x_416 : f32 = delta1;
+ let x_417 : f32 = delta1;
+ let x_418 : f32 = delta2;
+ ratio = (x_416 / (x_417 + x_418));
+ let x_421 : f32 = ratio;
+ let x_422 : vec2<f32> = vLastOffset;
+ let x_424 : f32 = ratio;
+ let x_426 : vec2<f32> = vCurrOffset;
+ vCurrOffset = ((x_422 * x_421) + (x_426 * (1.0 - x_424)));
+ break;
+ } else {
+ let x_431 : f32 = stepSize;
+ let x_432 : f32 = currRayHeight;
+ currRayHeight = (x_432 - x_431);
+ let x_434 : vec2<f32> = vCurrOffset;
+ vLastOffset = x_434;
+ let x_435 : f32 = stepSize;
+ let x_436 : vec2<f32> = vMaxOffset;
+ let x_438 : vec2<f32> = vCurrOffset;
+ vCurrOffset = (x_438 + (x_436 * x_435));
+ let x_440 : f32 = currSampledHeight;
+ lastSampledHeight = x_440;
+ }
+
+ continuing {
+ let x_441 : i32 = i;
+ i = (x_441 + 1);
+ }
+ }
+ let x_444 : vec2<f32> = vCurrOffset;
+ parallaxOcclusion_0 = x_444;
+ let x_445 : vec2<f32> = parallaxOcclusion_0;
+ uvOffset = x_445;
+ let x_449 : vec2<f32> = v_uv;
+ let x_450 : vec2<f32> = uvOffset;
+ let x_452 : vec4<f32> = textureSample(TextureSamplerTexture, TextureSamplerSampler, (x_449 + x_450));
+ let x_454 : f32 = x_269.u_bumpStrength;
+ let x_457 : mat3x3<f32> = TBN;
+ param_8 = x_457;
+ param_9 = vec3<f32>(x_452.x, x_452.y, x_452.z);
+ param_10 = (1.0 / x_454);
+ let x_461 : vec3<f32> = perturbNormal_mf33_vf3_f1_(&(param_8), &(param_9), &(param_10));
+ let x_462 : vec4<f32> = output4;
+ output4 = vec4<f32>(x_461.x, x_461.y, x_461.z, x_462.w);
+ let x_465 : vec2<f32> = v_uv;
+ let x_466 : vec2<f32> = uvOffset;
+ output6 = (x_465 + x_466);
+ let x_474 : vec2<f32> = output6;
+ let x_475 : vec4<f32> = textureSample(TextureSampler1Texture, TextureSampler1Sampler, x_474);
+ tempTextureRead1 = x_475;
+ let x_477 : vec4<f32> = tempTextureRead1;
+ rgb1 = vec3<f32>(x_477.x, x_477.y, x_477.z);
+ let x_481 : vec3<f32> = x_269.u_cameraPosition;
+ let x_482 : vec4<f32> = v_output1;
+ viewDirectionW_1 = normalize((x_481 - vec3<f32>(x_482.x, x_482.y, x_482.z)));
+ shadow = 1.0;
+ let x_488 : f32 = u_Float;
+ glossiness_1 = (1.0 * x_488);
+ diffuseBase = vec3<f32>(0.0, 0.0, 0.0);
+ specularBase = vec3<f32>(0.0, 0.0, 0.0);
+ let x_494 : vec4<f32> = output4;
+ normalW = vec3<f32>(x_494.x, x_494.y, x_494.z);
+ let x_501 : vec3<f32> = viewDirectionW_1;
+ param_11 = x_501;
+ let x_503 : vec3<f32> = normalW;
+ param_12 = x_503;
+ let x_507 : vec4<f32> = light0.vLightData;
+ param_13 = x_507;
+ let x_510 : vec4<f32> = light0.vLightDiffuse;
+ param_14 = vec3<f32>(x_510.x, x_510.y, x_510.z);
+ let x_514 : vec4<f32> = light0.vLightSpecular;
+ param_15 = vec3<f32>(x_514.x, x_514.y, x_514.z);
+ let x_518 : vec3<f32> = light0.vLightGround;
+ param_16 = x_518;
+ let x_520 : f32 = glossiness_1;
+ param_17 = x_520;
+ let x_521 : lightingInfo = computeHemisphericLighting_vf3_vf3_vf4_vf3_vf3_vf3_f1_(&(param_11), &(param_12), &(param_13), &(param_14), &(param_15), &(param_16), &(param_17));
+ info = x_521;
+ shadow = 1.0;
+ let x_523 : vec3<f32> = info.diffuse;
+ let x_524 : f32 = shadow;
+ let x_526 : vec3<f32> = diffuseBase;
+ diffuseBase = (x_526 + (x_523 * x_524));
+ let x_529 : vec3<f32> = info.specular;
+ let x_530 : f32 = shadow;
+ let x_532 : vec3<f32> = specularBase;
+ specularBase = (x_532 + (x_529 * x_530));
+ let x_535 : vec3<f32> = diffuseBase;
+ let x_536 : vec3<f32> = rgb1;
+ diffuseOutput = (x_535 * x_536);
+ let x_539 : vec3<f32> = specularBase;
+ let x_540 : vec3<f32> = u_Color;
+ specularOutput = (x_539 * x_540);
+ let x_543 : vec3<f32> = diffuseOutput;
+ let x_544 : vec3<f32> = specularOutput;
+ output3 = (x_543 + x_544);
+ let x_548 : vec3<f32> = output3;
+ glFragColor = vec4<f32>(x_548.x, x_548.y, x_548.z, 1.0);
+ return;
+}
+
+struct main_out {
+ [[location(0)]]
+ glFragColor_1 : vec4<f32>;
+};
+
+[[stage(fragment)]]
+fn main([[location(1)]] vMainuv_param : vec2<f32>, [[location(0)]] v_output1_param : vec4<f32>, [[builtin(front_facing)]] gl_FrontFacing_param : bool, [[location(3)]] v_uv_param : vec2<f32>, [[location(2)]] v_output2_param : vec4<f32>) -> main_out {
+ vMainuv = vMainuv_param;
+ v_output1 = v_output1_param;
+ gl_FrontFacing = gl_FrontFacing_param;
+ v_uv = v_uv_param;
+ v_output2 = v_output2_param;
+ main_1();
+ return main_out(glFragColor);
+}