dawn-cmake/test/bug/tint/948.wgsl.expected.msl

234 lines
10 KiB
Plaintext

#include <metal_stdlib>
using namespace metal;
template<typename T, int N, int M>
inline auto operator*(matrix<T, N, M> lhs, packed_vec<T, N> rhs) {
return lhs * vec<T, N>(rhs);
}
template<typename T, int N, int M>
inline auto operator*(packed_vec<T, M> lhs, matrix<T, N, M> rhs) {
return vec<T, M>(lhs) * rhs;
}
struct LeftOver {
/* 0x0000 */ float time;
/* 0x0004 */ uint padding;
/* 0x0008 */ int8_t tint_pad[8];
/* 0x0010 */ float4x4 worldViewProjection;
/* 0x0050 */ float2 outputSize;
/* 0x0058 */ float2 stageSize;
/* 0x0060 */ float2 spriteMapSize;
/* 0x0068 */ float stageScale;
/* 0x006c */ float spriteCount;
/* 0x0070 */ packed_float3 colorMul;
/* 0x007c */ int8_t tint_pad_1[4];
};
struct main_out {
float4 glFragColor_1;
};
struct tint_symbol_2 {
float3 vPosition_param [[user(locn0)]];
float2 vUV_param [[user(locn1)]];
float2 tUV_param [[user(locn2)]];
float2 stageUnits_1_param [[user(locn3)]];
float2 levelUnits_param [[user(locn4)]];
float2 tileID_1_param [[user(locn5)]];
};
struct tint_symbol_3 {
float4 glFragColor_1 [[color(0)]];
};
float4x4 getFrameData_f1_(constant LeftOver& x_20, thread float* const frameID, texture2d<float, access::sample> tint_symbol_5, sampler tint_symbol_6) {
float fX = 0.0f;
float const x_15 = *(frameID);
float const x_25 = x_20.spriteCount;
fX = (x_15 / x_25);
float const x_37 = fX;
float4 const x_40 = tint_symbol_5.sample(tint_symbol_6, float2(x_37, 0.0f), bias(0.0f));
float const x_44 = fX;
float4 const x_47 = tint_symbol_5.sample(tint_symbol_6, float2(x_44, 0.25f), bias(0.0f));
float const x_51 = fX;
float4 const x_54 = tint_symbol_5.sample(tint_symbol_6, float2(x_51, 0.5f), bias(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(constant LeftOver& x_20, thread float2* const tint_symbol_7, texture2d<float, access::sample> tint_symbol_8, sampler tint_symbol_9, texture2d<float, access::sample> tint_symbol_10, texture2d<float, access::sample> tint_symbol_11, sampler tint_symbol_12, thread float* const tint_symbol_13, texture2d<float, access::sample> tint_symbol_14, sampler tint_symbol_15, texture2d<float, access::sample> tint_symbol_16, sampler tint_symbol_17, thread float4* const tint_symbol_18) {
float4 color = 0.0f;
float2 tileUV = 0.0f;
float2 tileID = 0.0f;
float2 sheetUnits = 0.0f;
float spriteUnits = 0.0f;
float2 stageUnits = 0.0f;
int i = 0;
float frameID_1 = 0.0f;
float4 animationData = 0.0f;
float f = 0.0f;
float4x4 frameData = float4x4(0.0f);
float param = 0.0f;
float2 frameSize = 0.0f;
float2 offset_1 = 0.0f;
float2 ratio = 0.0f;
float4 nc = 0.0f;
float alpha = 0.0f;
float3 mixed = 0.0f;
color = float4(0.0f, 0.0f, 0.0f, 0.0f);
float2 const x_86 = *(tint_symbol_7);
tileUV = fract(x_86);
float const x_91 = tileUV.y;
tileUV.y = (1.0f - x_91);
float2 const x_95 = *(tint_symbol_7);
tileID = floor(x_95);
float2 const x_101 = x_20.spriteMapSize;
sheetUnits = (float2(1.0f, 1.0f) / x_101);
float const x_106 = x_20.spriteCount;
spriteUnits = (1.0f / x_106);
float2 const x_111 = x_20.stageSize;
stageUnits = (float2(1.0f, 1.0f) / x_111);
i = 0;
while (true) {
int const x_122 = i;
if ((x_122 < 2)) {
} else {
break;
}
int const x_126 = i;
switch(x_126) {
case 1: {
float2 const x_150 = tileID;
float2 const x_154 = x_20.stageSize;
float4 const x_156 = tint_symbol_8.sample(tint_symbol_9, ((x_150 + float2(0.5f, 0.5f)) / x_154), bias(0.0f));
frameID_1 = x_156.x;
break;
}
case 0: {
float2 const x_136 = tileID;
float2 const x_140 = x_20.stageSize;
float4 const x_142 = tint_symbol_10.sample(tint_symbol_9, ((x_136 + float2(0.5f, 0.5f)) / x_140), bias(0.0f));
frameID_1 = x_142.x;
break;
}
default: {
break;
}
}
float const x_166 = frameID_1;
float const x_169 = x_20.spriteCount;
float4 const x_172 = tint_symbol_11.sample(tint_symbol_12, float2(((x_166 + 0.5f) / x_169), 0.0f), bias(0.0f));
animationData = x_172;
float const x_174 = animationData.y;
if ((x_174 > 0.0f)) {
float const x_181 = x_20.time;
float const x_184 = animationData.z;
*(tint_symbol_13) = fmod((x_181 * x_184), 1.0f);
f = 0.0f;
while (true) {
float const x_193 = f;
if ((x_193 < 8.0f)) {
} else {
break;
}
float const x_197 = animationData.y;
float const x_198 = *(tint_symbol_13);
if ((x_197 > x_198)) {
float const x_203 = animationData.x;
frameID_1 = x_203;
break;
}
float const x_208 = frameID_1;
float const x_211 = x_20.spriteCount;
float const x_214 = f;
float4 const x_217 = tint_symbol_11.sample(tint_symbol_12, float2(((x_208 + 0.5f) / x_211), (0.125f * x_214)), bias(0.0f));
animationData = x_217;
{
float const x_218 = f;
f = (x_218 + 1.0f);
}
}
}
float const x_222 = frameID_1;
param = (x_222 + 0.5f);
float4x4 const x_225 = getFrameData_f1_(x_20, &(param), tint_symbol_14, tint_symbol_15);
frameData = x_225;
float4 const x_228 = frameData[0];
float2 const x_231 = x_20.spriteMapSize;
frameSize = (float2(x_228.w, x_228.z) / x_231);
float4 const x_235 = frameData[0];
float2 const x_237 = sheetUnits;
offset_1 = (float2(x_235.x, x_235.y) * x_237);
float4 const x_241 = frameData[2];
float4 const x_244 = frameData[0];
ratio = (float2(x_241.x, x_241.y) / float2(x_244.w, x_244.z));
float const x_248 = frameData[2].z;
if ((x_248 == 1.0f)) {
float2 const x_252 = tileUV;
tileUV = float2(x_252.y, x_252.x);
}
int const x_254 = i;
if ((x_254 == 0)) {
float2 const x_263 = tileUV;
float2 const x_264 = frameSize;
float2 const x_266 = offset_1;
float4 const x_268 = tint_symbol_16.sample(tint_symbol_17, ((x_263 * x_264) + x_266));
color = x_268;
} else {
float2 const x_274 = tileUV;
float2 const x_275 = frameSize;
float2 const x_277 = offset_1;
float4 const x_279 = tint_symbol_16.sample(tint_symbol_17, ((x_274 * x_275) + x_277));
nc = x_279;
float const x_283 = color.w;
float const x_285 = nc.w;
alpha = fmin((x_283 + x_285), 1.0f);
float4 const x_290 = color;
float4 const x_292 = nc;
float const x_295 = nc.w;
mixed = mix(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));
float3 const x_298 = mixed;
float const x_299 = alpha;
color = float4(x_298.x, x_298.y, x_298.z, x_299);
}
{
int const x_304 = i;
i = as_type<int>((as_type<uint>(x_304) + as_type<uint>(1)));
}
}
float3 const x_310 = x_20.colorMul;
float4 const x_311 = color;
float3 const x_313 = (float3(x_311.x, x_311.y, x_311.z) * x_310);
float4 const x_314 = color;
color = float4(x_313.x, x_313.y, x_313.z, x_314.w);
float4 const x_318 = color;
*(tint_symbol_18) = x_318;
return;
}
main_out tint_symbol_inner(constant LeftOver& x_20, float2 tUV_param, float2 tileID_1_param, float2 levelUnits_param, float2 stageUnits_1_param, float3 vPosition_param, float2 vUV_param, thread float2* const tint_symbol_19, thread float2* const tint_symbol_20, thread float2* const tint_symbol_21, thread float2* const tint_symbol_22, thread float3* const tint_symbol_23, thread float2* const tint_symbol_24, texture2d<float, access::sample> tint_symbol_25, sampler tint_symbol_26, texture2d<float, access::sample> tint_symbol_27, texture2d<float, access::sample> tint_symbol_28, sampler tint_symbol_29, thread float* const tint_symbol_30, texture2d<float, access::sample> tint_symbol_31, sampler tint_symbol_32, texture2d<float, access::sample> tint_symbol_33, sampler tint_symbol_34, thread float4* const tint_symbol_35) {
*(tint_symbol_19) = tUV_param;
*(tint_symbol_20) = tileID_1_param;
*(tint_symbol_21) = levelUnits_param;
*(tint_symbol_22) = stageUnits_1_param;
*(tint_symbol_23) = vPosition_param;
*(tint_symbol_24) = vUV_param;
main_1(x_20, tint_symbol_19, tint_symbol_25, tint_symbol_26, tint_symbol_27, tint_symbol_28, tint_symbol_29, tint_symbol_30, tint_symbol_31, tint_symbol_32, tint_symbol_33, tint_symbol_34, tint_symbol_35);
main_out const tint_symbol_4 = {.glFragColor_1=*(tint_symbol_35)};
return tint_symbol_4;
}
fragment tint_symbol_3 tint_symbol(texture2d<float, access::sample> tint_symbol_42 [[texture(0)]], sampler tint_symbol_43 [[sampler(0)]], texture2d<float, access::sample> tint_symbol_44 [[texture(1)]], texture2d<float, access::sample> tint_symbol_45 [[texture(2)]], sampler tint_symbol_46 [[sampler(1)]], texture2d<float, access::sample> tint_symbol_48 [[texture(3)]], sampler tint_symbol_49 [[sampler(2)]], texture2d<float, access::sample> tint_symbol_50 [[texture(4)]], sampler tint_symbol_51 [[sampler(3)]], tint_symbol_2 tint_symbol_1 [[stage_in]], constant LeftOver& x_20 [[buffer(0)]]) {
thread float2 tint_symbol_36 = 0.0f;
thread float2 tint_symbol_37 = 0.0f;
thread float2 tint_symbol_38 = 0.0f;
thread float2 tint_symbol_39 = 0.0f;
thread float3 tint_symbol_40 = 0.0f;
thread float2 tint_symbol_41 = 0.0f;
thread float tint_symbol_47 = 0.0f;
thread float4 tint_symbol_52 = 0.0f;
main_out const inner_result = tint_symbol_inner(x_20, tint_symbol_1.tUV_param, tint_symbol_1.tileID_1_param, tint_symbol_1.levelUnits_param, tint_symbol_1.stageUnits_1_param, tint_symbol_1.vPosition_param, tint_symbol_1.vUV_param, &(tint_symbol_36), &(tint_symbol_37), &(tint_symbol_38), &(tint_symbol_39), &(tint_symbol_40), &(tint_symbol_41), tint_symbol_42, tint_symbol_43, tint_symbol_44, tint_symbol_45, tint_symbol_46, &(tint_symbol_47), tint_symbol_48, tint_symbol_49, tint_symbol_50, tint_symbol_51, &(tint_symbol_52));
tint_symbol_3 wrapper_result = {};
wrapper_result.glFragColor_1 = inner_result.glFragColor_1;
return wrapper_result;
}