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

443 lines
17 KiB
Plaintext

#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_5, thread float3* const tint_symbol_6, thread float2* const tint_symbol_7, texture2d<float, access::sample> tint_symbol_8, sampler tint_symbol_9, thread float4* const tint_symbol_10, thread bool* const tint_symbol_11, thread float2* const tint_symbol_12, thread float4* const tint_symbol_13, texture2d<float, access::sample> tint_symbol_14, sampler tint_symbol_15, thread float4* const tint_symbol_16) {
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 = 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_10);
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_11);
if (x_298) {
float2 const x_303 = *(tint_symbol_12);
x_299 = x_303;
} else {
float2 const x_305 = *(tint_symbol_12);
x_299 = -(x_305);
}
float2 const x_307 = x_299;
TBNUV = x_307;
float4 const x_310 = *(tint_symbol_13);
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_10);
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_13);
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_12);
float2 const x_395 = vCurrOffset;
float4 const x_397 = tint_symbol_8.sample(tint_symbol_9, (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 = 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_12);
float2 const x_450 = uvOffset;
float4 const x_452 = tint_symbol_8.sample(tint_symbol_9, (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_12);
float2 const x_466 = uvOffset;
output6 = (x_465 + x_466);
float2 const x_474 = output6;
float4 const x_475 = tint_symbol_14.sample(tint_symbol_15, 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_10);
viewDirectionW_1 = normalize((x_481 - float3(x_482.x, x_482.y, x_482.z)));
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.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_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_16) = float4(x_548.x, x_548.y, x_548.z, 1.0f);
return;
}
main_out tint_symbol_inner(constant LeftOver& x_269, constant Light0& light0, float2 vMainuv_param, float4 v_output1_param, bool gl_FrontFacing_param, float2 v_uv_param, float4 v_output2_param, thread float2* const tint_symbol_17, thread float4* const tint_symbol_18, thread bool* const tint_symbol_19, thread float2* const tint_symbol_20, thread float4* const tint_symbol_21, thread float* const tint_symbol_22, thread float3* const tint_symbol_23, texture2d<float, access::sample> tint_symbol_24, sampler tint_symbol_25, texture2d<float, access::sample> tint_symbol_26, sampler tint_symbol_27, thread float4* const tint_symbol_28) {
*(tint_symbol_17) = vMainuv_param;
*(tint_symbol_18) = v_output1_param;
*(tint_symbol_19) = gl_FrontFacing_param;
*(tint_symbol_20) = v_uv_param;
*(tint_symbol_21) = v_output2_param;
main_1(x_269, light0, tint_symbol_22, tint_symbol_23, tint_symbol_17, tint_symbol_24, tint_symbol_25, tint_symbol_18, tint_symbol_19, tint_symbol_20, tint_symbol_21, tint_symbol_26, tint_symbol_27, tint_symbol_28);
main_out const tint_symbol_4 = {.glFragColor_1=*(tint_symbol_28)};
return tint_symbol_4;
}
fragment tint_symbol_3 tint_symbol(texture2d<float, access::sample> tint_symbol_36 [[texture(1)]], sampler tint_symbol_37 [[sampler(0)]], texture2d<float, access::sample> tint_symbol_38 [[texture(3)]], sampler tint_symbol_39 [[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_29 = 0.0f;
thread float4 tint_symbol_30 = 0.0f;
thread bool tint_symbol_31 = false;
thread float2 tint_symbol_32 = 0.0f;
thread float4 tint_symbol_33 = 0.0f;
thread float tint_symbol_34 = 0.0f;
thread float3 tint_symbol_35 = 0.0f;
thread float4 tint_symbol_40 = 0.0f;
main_out const inner_result = tint_symbol_inner(x_269, light0, 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_29), &(tint_symbol_30), &(tint_symbol_31), &(tint_symbol_32), &(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_3 wrapper_result = {};
wrapper_result.glFragColor_1 = inner_result.glFragColor_1;
return wrapper_result;
}