cemu_graphic_packs/Resolutions/Bayonetta2_Resolution/284b1bf9010d4e57_0000000000000079_ps.txt
Crementif 077f4f8f27
Fix shader errors and shader cleanup
Since I wanted to make sure that I didn't broke the shaders after converting the shaders to Vulkan, we need to check if all the shaders weren't broken. Since we're talking about like 400 shaders checking all of them is pretty much impossible and even then, 

So, the obvious solution was to automate the checking. Not as simple as you'd think, because in 300 of our shaders we use preset variables which without replacing the value like Cemu does, will make the shader error regardless. So I also implemented some functionality that would read the preset values and types out of the rules.txt file and replace them in the shaders using that information. And then we use Khronos' glslang to compile the shaders, using both OpenGL and Vulkan.

The result was that glslang found quite a few errors in some of the shaders, which I fixed in this commit. I'm considering adding this rules.txt parsing and automated shader compilation testing to the build process.

Also, I fixed Clarity's name and description since Monochromia isn't available anymore and Xenoblade's resolution pack had a lot of weird blank lines before their #version declaration, which my converter didn't like.
2019-11-29 00:51:00 +01:00

129 lines
5.0 KiB
Plaintext

#version 420
#extension GL_ARB_texture_gather : enable
#extension GL_ARB_separate_shader_objects : enable
// shader 284b1bf9010d4e57
layout(binding = 0) uniform sampler2D textureUnitPS0;// Tex0 addr 0xf489f800 res 1280x720x1 dim 1 tm: 4 format 001a compSel: 0 1 2 3 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x1) Sampler0 ClampX/Y/Z: 2 2 2 border: 0
layout(location = 0) in vec4 passParameterSem133;
layout(location = 0) out vec4 passPixelColor0;
uniform vec2 uf_fragCoordScale;
float scaleFactor = uf_fragCoordScale.x;
int clampFI32(int v)
{
if( v == 0x7FFFFFFF )
return floatBitsToInt(1.0);
else if( v == 0xFFFFFFFF )
return floatBitsToInt(0.0);
return floatBitsToInt(clamp(intBitsToFloat(v), 0.0, 1.0));
}
float mul_nonIEEE(float a, float b){return mix(0.0, a*b, (a != 0.0) && (b != 0.0));}
void main()
{
ivec4 R0i = ivec4(0);
ivec4 R1i = ivec4(0);
ivec4 R2i = ivec4(0);
ivec4 R3i = ivec4(0);
ivec4 R4i = ivec4(0);
ivec4 R123i = ivec4(0);
int backupReg0i, backupReg1i, backupReg2i, backupReg3i, backupReg4i;
ivec4 PV0i = ivec4(0), PV1i = ivec4(0);
int PS0i = 0, PS1i = 0;
ivec4 tempi = ivec4(0);
float tempResultf;
int tempResulti;
ivec4 ARi = ivec4(0);
bool predResult = true;
bool activeMaskStack[2];
bool activeMaskStackC[3];
activeMaskStack[0] = false;
activeMaskStackC[0] = false;
activeMaskStackC[1] = false;
activeMaskStack[0] = true;
activeMaskStackC[0] = true;
activeMaskStackC[1] = true;
vec3 cubeMapSTM;
int cubeMapFaceId;
R0i = floatBitsToInt(passParameterSem133);
if( activeMaskStackC[1] == true ) {
// 0
R1i.x = floatBitsToInt(intBitsToFloat(R0i.x) + intBitsToFloat(0xba4ccccd)*scaleFactor);
R1i.y = floatBitsToInt(intBitsToFloat(R0i.y) + 0.0);
R0i.z = floatBitsToInt(intBitsToFloat(R0i.x) + intBitsToFloat(0x3a4ccccd)*scaleFactor);
R0i.w = floatBitsToInt(intBitsToFloat(R0i.y) + 0.0);
R2i.x = floatBitsToInt(intBitsToFloat(R0i.x) + 0.0);
PS0i = R2i.x;
// 1
R3i.x = floatBitsToInt(intBitsToFloat(R0i.x) + 0.0);
R2i.y = floatBitsToInt(intBitsToFloat(R0i.y) + intBitsToFloat(0xbab60b61)*scaleFactor);
R3i.zwy = floatBitsToInt(vec3(intBitsToFloat(R0i.y),intBitsToFloat(R0i.x),intBitsToFloat(R0i.y)) + vec3(intBitsToFloat(0x3ab60b61)*scaleFactor,0.0,0.0));
PS1i = R3i.y;
}
if( activeMaskStackC[1] == true ) {
R1i.xyz = floatBitsToInt(texture(textureUnitPS0, intBitsToFloat(R1i.xy)).xyz);
R0i.xyz = floatBitsToInt(texture(textureUnitPS0, intBitsToFloat(R0i.zw)).xyz);
R2i.xyz = floatBitsToInt(texture(textureUnitPS0, intBitsToFloat(R2i.xy)).xyz);
R4i.xyz = floatBitsToInt(texture(textureUnitPS0, intBitsToFloat(R3i.xz)).xyz);
R3i.xyz = floatBitsToInt(texture(textureUnitPS0, intBitsToFloat(R3i.wy)).xyz);
}
if( activeMaskStackC[1] == true ) {
activeMaskStack[1] = activeMaskStack[0];
activeMaskStackC[2] = activeMaskStackC[1];
// 0
backupReg0i = R0i.x;
backupReg1i = R0i.z;
PV0i.x = floatBitsToInt(intBitsToFloat(R1i.y) + intBitsToFloat(R0i.y));
PV0i.y = floatBitsToInt(intBitsToFloat(R1i.x) + intBitsToFloat(backupReg0i));
PV0i.z = floatBitsToInt(intBitsToFloat(R1i.z) + intBitsToFloat(backupReg1i));
// 1
PV1i.x = floatBitsToInt(intBitsToFloat(R2i.z) + intBitsToFloat(PV0i.z));
PV1i.y = floatBitsToInt(intBitsToFloat(R2i.y) + intBitsToFloat(PV0i.x));
PV1i.w = floatBitsToInt(intBitsToFloat(R2i.x) + intBitsToFloat(PV0i.y));
// 2
PV0i.y = floatBitsToInt(intBitsToFloat(R4i.z) + intBitsToFloat(PV1i.x));
PV0i.z = floatBitsToInt(intBitsToFloat(R4i.x) + intBitsToFloat(PV1i.w));
PV0i.w = floatBitsToInt(intBitsToFloat(R4i.y) + intBitsToFloat(PV1i.y));
// 3
R123i.x = floatBitsToInt((-(intBitsToFloat(R3i.x)) * 4.0 + intBitsToFloat(PV0i.z)));
PV1i.x = R123i.x;
R123i.z = floatBitsToInt((-(intBitsToFloat(R3i.y)) * 4.0 + intBitsToFloat(PV0i.w)));
PV1i.z = R123i.z;
R123i.w = floatBitsToInt((-(intBitsToFloat(R3i.z)) * 4.0 + intBitsToFloat(PV0i.y)));
PV1i.w = R123i.w;
// 4
PV0i.x = floatBitsToInt(max(intBitsToFloat(PV1i.x), -(intBitsToFloat(PV1i.x))));
PV0i.x = floatBitsToInt(intBitsToFloat(PV0i.x) * 4.0);
PV0i.y = floatBitsToInt(max(intBitsToFloat(PV1i.z), -(intBitsToFloat(PV1i.z))));
PV0i.y = floatBitsToInt(intBitsToFloat(PV0i.y) * 4.0);
PV0i.z = floatBitsToInt(max(intBitsToFloat(PV1i.w), -(intBitsToFloat(PV1i.w))));
PV0i.z = floatBitsToInt(intBitsToFloat(PV0i.z) * 4.0);
// 5
R0i.x = floatBitsToInt(dot(vec4(intBitsToFloat(PV0i.x),intBitsToFloat(PV0i.y),intBitsToFloat(PV0i.z),-0.0),vec4(intBitsToFloat(0x3eaa7efa)*scaleFactor,intBitsToFloat(0x3eab020c)*scaleFactor,intBitsToFloat(0x3eaa7efa)*scaleFactor,0.0)));
PV1i.x = R0i.x;
PV1i.y = R0i.x;
PV1i.z = R0i.x;
PV1i.w = R0i.x;
// 6
R0i.y = floatBitsToInt(intBitsToFloat(PV1i.x) + -(0.5));
// 7
predResult = (0.0 > intBitsToFloat(R0i.y));
activeMaskStack[1] = predResult;
activeMaskStackC[2] = predResult == true && activeMaskStackC[1] == true;
}
else {
activeMaskStack[1] = false;
activeMaskStackC[2] = false;
}
if( activeMaskStackC[2] == true ) {
// 0
if( (0 == 0)) discard;
}
activeMaskStackC[1] = activeMaskStack[0] == true && activeMaskStackC[0] == true;
if( activeMaskStackC[1] == true ) {
// 0
R3i.w = R0i.x;
}
// export
passPixelColor0 = vec4(intBitsToFloat(R3i.x), intBitsToFloat(R3i.y), intBitsToFloat(R3i.z), intBitsToFloat(R3i.w));
}