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

443 lines
16 KiB
HLSL

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;
}