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

459 lines
18 KiB
Plaintext
Raw Normal View History

#include <metal_stdlib>
using namespace metal;
template<typename T, int N, int M>
inline vec<T, M> 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 vec<T, N> operator*(packed_vec<T, M> lhs, matrix<T, N, M> rhs) {
return vec<T, M>(lhs) * rhs;
}
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 */ float2 tangentSpaceParameter0;
};
struct Light0 {
/* 0x0000 */ float4 vLightData;
/* 0x0010 */ float4 vLightDiffuse;
/* 0x0020 */ float4 vLightSpecular;
/* 0x0030 */ packed_float3 vLightGround;
/* 0x003c */ uint padding_2;
/* 0x0040 */ float4 shadowsInfo;
/* 0x0050 */ float2 depthValues;
/* 0x0058 */ int8_t tint_pad_1[8];
};
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[0];
float3 const x_157 = dp1perp;
float const x_159 = duv2[0];
tangent = ((x_153 * x_155) + (x_157 * x_159));
float3 const x_163 = dp2perp;
float const x_165 = duv1[1];
float3 const x_167 = dp1perp;
float const x_169 = duv2[1];
bitangent = ((x_163 * x_165) + (x_167 * x_169));
float const x_173 = (*(tangentSpaceParams))[0];
float3 const x_174 = tangent;
tangent = (x_174 * x_173);
float const x_177 = (*(tangentSpaceParams))[1];
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[0], x_191[1], x_191[2]), float3(x_194[0], x_194[1], x_194[2]), float3(x_195[0], x_195[1], x_195[2]));
}
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[0];
float const x_75 = i1[0];
float const x_77 = i2[0];
float3 const x_78 = float3(x_73, x_75, x_77);
float const x_81 = i0[1];
float const x_83 = i1[1];
float const x_85 = i2[1];
float3 const x_86 = float3(x_81, x_83, x_85);
float const x_89 = i0[2];
float const x_91 = i1[2];
float const x_93 = i2[2];
float3 const x_94 = float3(x_89, x_91, x_93);
outMatrix = float3x3(float3(x_78[0], x_78[1], x_78[2]), float3(x_86[0], x_86[1], x_86[2]), float3(x_94[0], x_94[1], x_94[2]));
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[0], x_213[1], x_213[2])) * 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[0], x_228[1], x_228[2])));
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(thread float* const tint_symbol_5, thread float3* const tint_symbol_6, thread float2* const tint_symbol_7, texture2d<float, access::sample> tint_symbol_8, sampler tint_symbol_9, const constant LeftOver* const 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, const constant Light0* const tint_symbol_17, thread float4* const tint_symbol_18) {
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_5) = 100.0f;
*(tint_symbol_6) = float3(0.5f, 0.5f, 0.5f);
float2 const x_261 = *(tint_symbol_7);
float4 const x_262 = tint_symbol_8.sample(tint_symbol_9, x_261);
tempTextureRead = x_262;
float4 const x_264 = tempTextureRead;
float const x_273 = (*(tint_symbol_10)).textureInfoName;
rgb = (float3(x_264[0], x_264[1], x_264[2]) * x_273);
float3 const x_279 = (*(tint_symbol_10)).u_cameraPosition;
float4 const x_282 = *(tint_symbol_11);
output5 = normalize((x_279 - float3(x_282[0], x_282[1], x_282[2])));
output4 = float4(0.0f, 0.0f, 0.0f, 0.0f);
uvOffset = float2(0.0f, 0.0f);
float const x_292 = (*(tint_symbol_10)).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[0], x_310[1], x_310[2]) * x_312);
float4 const x_317 = *(tint_symbol_11);
param_4 = float3(x_317[0], x_317[1], x_317[2]);
float2 const x_320 = TBNUV;
param_5 = x_320;
float2 const x_324 = (*(tint_symbol_10)).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[0], x_334[1])) / ((x_337 * -(x_338)))[2]);
float const x_345 = (*(tint_symbol_10)).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[0], x_352[1]));
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[0], x_366[1], x_366[2]))) * -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_8.sample(tint_symbol_9, (x_394 + x_395));
currSampledHeight = x_397[3];
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 = as_type<int>((as_type<uint>(x_441) + as_type<uint>(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_8.sample(tint_symbol_9, (x_449 + x_450));
float const x_454 = (*(tint_symbol_10)).u_bumpStrength;
float3x3 const x_457 = TBN;
param_8 = x_457;
param_9 = float3(x_452[0], x_452[1], x_452[2]);
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[0], x_461[1], x_461[2], x_462[3]);
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[0], x_477[1], x_477[2]);
float3 const x_481 = (*(tint_symbol_10)).u_cameraPosition;
float4 const x_482 = *(tint_symbol_11);
viewDirectionW_1 = normalize((x_481 - float3(x_482[0], x_482[1], x_482[2])));
shadow = 1.0f;
float const x_488 = *(tint_symbol_5);
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[0], x_494[1], x_494[2]);
float3 const x_501 = viewDirectionW_1;
param_11 = x_501;
float3 const x_503 = normalW;
param_12 = x_503;
float4 const x_507 = (*(tint_symbol_17)).vLightData;
param_13 = x_507;
float4 const x_510 = (*(tint_symbol_17)).vLightDiffuse;
param_14 = float3(x_510[0], x_510[1], x_510[2]);
float4 const x_514 = (*(tint_symbol_17)).vLightSpecular;
param_15 = float3(x_514[0], x_514[1], x_514[2]);
float3 const x_518 = (*(tint_symbol_17)).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_6);
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_18) = float4(x_548[0], x_548[1], x_548[2], 1.0f);
return;
}
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)]];
};
main_out tint_symbol_inner(float2 vMainuv_param, float4 v_output1_param, bool gl_FrontFacing_param, float2 v_uv_param, float4 v_output2_param, thread float2* const tint_symbol_19, thread float4* const tint_symbol_20, thread bool* const tint_symbol_21, thread float2* const tint_symbol_22, thread float4* const tint_symbol_23, thread float* const tint_symbol_24, thread float3* const tint_symbol_25, texture2d<float, access::sample> tint_symbol_26, sampler tint_symbol_27, const constant LeftOver* const tint_symbol_28, texture2d<float, access::sample> tint_symbol_29, sampler tint_symbol_30, const constant Light0* const tint_symbol_31, thread float4* const tint_symbol_32) {
*(tint_symbol_19) = vMainuv_param;
*(tint_symbol_20) = v_output1_param;
*(tint_symbol_21) = gl_FrontFacing_param;
*(tint_symbol_22) = v_uv_param;
*(tint_symbol_23) = v_output2_param;
main_1(tint_symbol_24, tint_symbol_25, tint_symbol_19, tint_symbol_26, tint_symbol_27, tint_symbol_28, tint_symbol_20, tint_symbol_21, tint_symbol_22, tint_symbol_23, tint_symbol_29, tint_symbol_30, tint_symbol_31, tint_symbol_32);
main_out const tint_symbol_4 = {.glFragColor_1=*(tint_symbol_32)};
return tint_symbol_4;
}
fragment tint_symbol_3 tint_symbol(texture2d<float, access::sample> tint_symbol_40 [[texture(0)]], sampler tint_symbol_41 [[sampler(0)]], const constant LeftOver* tint_symbol_42 [[buffer(0)]], texture2d<float, access::sample> tint_symbol_43 [[texture(1)]], sampler tint_symbol_44 [[sampler(1)]], const constant Light0* tint_symbol_45 [[buffer(1)]], bool gl_FrontFacing_param [[front_facing]], tint_symbol_2 tint_symbol_1 [[stage_in]]) {
thread float2 tint_symbol_33 = 0.0f;
thread float4 tint_symbol_34 = 0.0f;
thread bool tint_symbol_35 = false;
thread float2 tint_symbol_36 = 0.0f;
thread float4 tint_symbol_37 = 0.0f;
thread float tint_symbol_38 = 0.0f;
thread float3 tint_symbol_39 = 0.0f;
thread float4 tint_symbol_46 = 0.0f;
main_out const inner_result = tint_symbol_inner(tint_symbol_1.vMainuv_param, tint_symbol_1.v_output1_param, gl_FrontFacing_param, tint_symbol_1.v_uv_param, tint_symbol_1.v_output2_param, &(tint_symbol_33), &(tint_symbol_34), &(tint_symbol_35), &(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_3 wrapper_result = {};
wrapper_result.glFragColor_1 = inner_result.glFragColor_1;
return wrapper_result;
}