cemu_graphic_packs/Resolutions/XenobladeX_Resolution/1f915b133a255dab_0000000000000000_vs.txt
Crementif 306da0b802
Update every graphic pack to V4
Since it's not possible to update 300+ shaders manually and automation was possible, I thought that I'd take the honor and create a script that's able to automatically convert all of the shaders to be cross-compatible with Vulkan. And change the graphic pack versions to version 4 of course.

Also, the script has some nifty testing code which compiled every shader as OpenGL and Vulkan, but for that see the details that I've written below.

**Here's the script that I've made to do all of this. No manual edits were needed:**
https://gist.github.com/Crementif/8d98a855b95f219d95298fb3db99deae
2019-11-29 04:36:05 +01:00

234 lines
13 KiB
Plaintext

#version 420
#extension GL_ARB_texture_gather : enable
#extension GL_ARB_shading_language_packing : enable
#ifdef VULKAN
#define ATTR_LAYOUT(__vkSet, __location) layout(set = __vkSet, location = __location)
#define UNIFORM_BUFFER_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(set = __vkSet, binding = __vkLocation, std140)
#define TEXTURE_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(set = __vkSet, binding = __vkLocation)
#define SET_POSITION(_v) gl_Position = _v; gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0
#define GET_FRAGCOORD() vec4(gl_FragCoord.xy*uf_fragCoordScale.xy,gl_FragCoord.zw)
#define gl_VertexID gl_VertexIndex
#define gl_InstanceID gl_InstanceIndex
#else
#define ATTR_LAYOUT(__vkSet, __location) layout(location = __location)
#define UNIFORM_BUFFER_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(binding = __glLocation, std140)
#define TEXTURE_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(binding = __glLocation)
#define SET_POSITION(_v) gl_Position = _v
#define GET_FRAGCOORD() vec4(gl_FragCoord.xy*uf_fragCoordScale,gl_FragCoord.zw)
#endif
// This shaders was auto-converted from OpenGL to Cemu so expect weird code and possible errors.
// shader 1f915b133a255dab
//battle graph, dumped
#ifdef VULKAN
layout(set = 0, binding = 0) uniform ufBlock
{
uniform ivec4 uf_uniformRegisterVS[256];
uniform vec2 uf_windowSpaceToClipSpaceTransform;
uniform float uf_alphaTestRef;
};
#else
uniform ivec4 uf_uniformRegisterVS[256];
uniform vec2 uf_windowSpaceToClipSpaceTransform;
uniform float uf_alphaTestRef;
#endif
ATTR_LAYOUT(0, 0) in uvec4 attrDataSem0;
out gl_PerVertex
{
vec4 gl_Position;
float gl_PointSize;
};
layout(location = 0) out vec4 passParameterSem0;
layout(location = 1) out vec4 passParameterSem1;
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 min(a*b,min(abs(a)*3.40282347E+38F,abs(b)*3.40282347E+38F)); }
void main()
{
ivec4 R0i = ivec4(0);
ivec4 R1i = ivec4(0);
ivec4 R2i = ivec4(0);
ivec4 R123i = ivec4(0);
ivec4 R124i = ivec4(0);
ivec4 R125i = ivec4(0);
ivec4 R126i = ivec4(0);
ivec4 R127i = ivec4(0);
uvec4 attrDecoder;
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;
vec3 cubeMapSTM;
int cubeMapFaceId;
R0i = ivec4(gl_VertexID, 0, 0, gl_InstanceID);
attrDecoder.xyz = attrDataSem0.xyz;
attrDecoder.xyz = (attrDecoder.xyz>>24)|((attrDecoder.xyz>>8)&0xFF00)|((attrDecoder.xyz<<8)&0xFF0000)|((attrDecoder.xyz<<24));
attrDecoder.w = 0;
R1i = ivec4(int(attrDecoder.x), int(attrDecoder.y), int(attrDecoder.z), floatBitsToInt(1.0));
// 0
R127i.x = floatBitsToInt(intBitsToFloat(uf_uniformRegisterVS[27].w) * 1.0);
R127i.y = floatBitsToInt(intBitsToFloat(uf_uniformRegisterVS[27].z) * 1.0);
R127i.z = floatBitsToInt(intBitsToFloat(uf_uniformRegisterVS[27].y) * 1.0);
R127i.w = floatBitsToInt(intBitsToFloat(uf_uniformRegisterVS[27].x) * 1.0);
PS0i = int(intBitsToFloat(R1i.z));
// 1
R126i.x = floatBitsToInt(intBitsToFloat(uf_uniformRegisterVS[15].w) * 1.0);
R125i.y = floatBitsToInt(intBitsToFloat(uf_uniformRegisterVS[15].z) * 1.0);
R125i.z = floatBitsToInt(intBitsToFloat(uf_uniformRegisterVS[15].y) * 1.0);
R125i.w = floatBitsToInt(intBitsToFloat(uf_uniformRegisterVS[15].x) * 1.0);
R124i.x = floatBitsToInt(float(PS0i));
PS1i = R124i.x;
// 2
tempResultf = intBitsToFloat(PS1i);
tempResultf = floor(tempResultf);
tempResultf = clamp(tempResultf, -256.0, 255.0);
ARi.x = int(tempResultf);
PV0i.x = floatBitsToInt(tempResultf);
R124i.y = floatBitsToInt(intBitsToFloat(uf_uniformRegisterVS[19].z) * 1.0);
R124i.z = floatBitsToInt(intBitsToFloat(uf_uniformRegisterVS[19].y) * 1.0);
R124i.w = floatBitsToInt(intBitsToFloat(uf_uniformRegisterVS[19].x) * 1.0);
R125i.x = floatBitsToInt(intBitsToFloat(uf_uniformRegisterVS[19].w) * 1.0);
PS0i = R125i.x;
// 3
R123i.x = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+4].z) * intBitsToFloat(uf_uniformRegisterVS[26].w) + intBitsToFloat(R127i.x)));
PV1i.x = R123i.x;
R123i.y = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+4].z) * intBitsToFloat(uf_uniformRegisterVS[26].z) + intBitsToFloat(R127i.y)));
PV1i.y = R123i.y;
// 4
R127i.x = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+4].y) * intBitsToFloat(uf_uniformRegisterVS[25].w) + intBitsToFloat(PV1i.x)));
R127i.y = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+4].y) * intBitsToFloat(uf_uniformRegisterVS[25].z) + intBitsToFloat(PV1i.y)));
// 5
backupReg0i = R127i.z;
backupReg1i = R127i.w;
R127i.z = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+4].z) * intBitsToFloat(uf_uniformRegisterVS[26].y) + intBitsToFloat(backupReg0i)));
R127i.w = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+4].z) * intBitsToFloat(uf_uniformRegisterVS[26].x) + intBitsToFloat(backupReg1i)));
// 6
backupReg0i = R127i.x;
R127i.x = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+4].x) * intBitsToFloat(uf_uniformRegisterVS[24].w) + intBitsToFloat(backupReg0i)));
R126i.y = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+4].x) * intBitsToFloat(uf_uniformRegisterVS[24].z) + intBitsToFloat(R127i.y)));
// 7
backupReg0i = R127i.z;
backupReg1i = R127i.w;
R127i.z = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+4].y) * intBitsToFloat(uf_uniformRegisterVS[25].y) + intBitsToFloat(backupReg0i)));
R127i.w = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+4].y) * intBitsToFloat(uf_uniformRegisterVS[25].x) + intBitsToFloat(backupReg1i)));
// 8
backupReg0i = R127i.x;
backupReg0i = R127i.x;
backupReg0i = R127i.x;
backupReg0i = R127i.x;
R127i.x = floatBitsToInt(intBitsToFloat(backupReg0i) * intBitsToFloat(uf_uniformRegisterVS[23].w));
R127i.y = floatBitsToInt(intBitsToFloat(backupReg0i) * intBitsToFloat(uf_uniformRegisterVS[23].z));
R126i.z = floatBitsToInt(intBitsToFloat(backupReg0i) * intBitsToFloat(uf_uniformRegisterVS[23].y));
R126i.w = floatBitsToInt(intBitsToFloat(backupReg0i) * intBitsToFloat(uf_uniformRegisterVS[23].x));
// 9
backupReg0i = R127i.z;
backupReg1i = R127i.w;
R127i.z = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+4].x) * intBitsToFloat(uf_uniformRegisterVS[24].y) + intBitsToFloat(backupReg0i)));
R127i.w = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+4].x) * intBitsToFloat(uf_uniformRegisterVS[24].x) + intBitsToFloat(backupReg1i)));
// 10
R123i.x = floatBitsToInt((intBitsToFloat(R126i.y) * intBitsToFloat(uf_uniformRegisterVS[22].w) + intBitsToFloat(R127i.x)));
PV0i.x = R123i.x;
R123i.y = floatBitsToInt((intBitsToFloat(R126i.y) * intBitsToFloat(uf_uniformRegisterVS[22].z) + intBitsToFloat(R127i.y)));
PV0i.y = R123i.y;
R123i.z = floatBitsToInt((intBitsToFloat(R126i.y) * intBitsToFloat(uf_uniformRegisterVS[22].y) + intBitsToFloat(R126i.z)));
PV0i.z = R123i.z;
R123i.w = floatBitsToInt((intBitsToFloat(R126i.y) * intBitsToFloat(uf_uniformRegisterVS[22].x) + intBitsToFloat(R126i.w)));
PV0i.w = R123i.w;
// 11
R123i.x = floatBitsToInt((intBitsToFloat(R127i.z) * intBitsToFloat(uf_uniformRegisterVS[21].w) + intBitsToFloat(PV0i.x)));
PV1i.x = R123i.x;
R123i.y = floatBitsToInt((intBitsToFloat(R127i.z) * intBitsToFloat(uf_uniformRegisterVS[21].z) + intBitsToFloat(PV0i.y)));
PV1i.y = R123i.y;
R123i.z = floatBitsToInt((intBitsToFloat(R127i.z) * intBitsToFloat(uf_uniformRegisterVS[21].y) + intBitsToFloat(PV0i.z)));
PV1i.z = R123i.z;
R123i.w = floatBitsToInt((intBitsToFloat(R127i.z) * intBitsToFloat(uf_uniformRegisterVS[21].x) + intBitsToFloat(PV0i.w)));
PV1i.w = R123i.w;
// 12
backupReg0i = R127i.w;
R123i.x = floatBitsToInt((intBitsToFloat(R127i.w) * intBitsToFloat(uf_uniformRegisterVS[20].w) + intBitsToFloat(PV1i.x)));
PV0i.x = R123i.x;
R127i.y = floatBitsToInt((intBitsToFloat(R127i.w) * intBitsToFloat(uf_uniformRegisterVS[20].z) + intBitsToFloat(PV1i.y)));
R127i.z = floatBitsToInt((intBitsToFloat(R127i.w) * intBitsToFloat(uf_uniformRegisterVS[20].y) + intBitsToFloat(PV1i.z)));
R127i.w = floatBitsToInt((intBitsToFloat(backupReg0i) * intBitsToFloat(uf_uniformRegisterVS[20].x) + intBitsToFloat(PV1i.w)));
// 13
PV1i.x = floatBitsToInt(intBitsToFloat(PV0i.x) * intBitsToFloat(uf_uniformRegisterVS[3].w));
PV1i.y = floatBitsToInt(intBitsToFloat(PV0i.x) * intBitsToFloat(uf_uniformRegisterVS[3].z));
PV1i.z = floatBitsToInt(intBitsToFloat(PV0i.x) * intBitsToFloat(uf_uniformRegisterVS[3].y));
PV1i.w = floatBitsToInt(intBitsToFloat(PV0i.x) * intBitsToFloat(uf_uniformRegisterVS[3].x));
// 14
R123i.x = floatBitsToInt((intBitsToFloat(R127i.y) * intBitsToFloat(uf_uniformRegisterVS[2].w) + intBitsToFloat(PV1i.x)));
PV0i.x = R123i.x;
R123i.y = floatBitsToInt((intBitsToFloat(R127i.y) * intBitsToFloat(uf_uniformRegisterVS[2].z) + intBitsToFloat(PV1i.y)));
PV0i.y = R123i.y;
R123i.z = floatBitsToInt((intBitsToFloat(R127i.y) * intBitsToFloat(uf_uniformRegisterVS[2].y) + intBitsToFloat(PV1i.z)));
PV0i.z = R123i.z;
R123i.w = floatBitsToInt((intBitsToFloat(R127i.y) * intBitsToFloat(uf_uniformRegisterVS[2].x) + intBitsToFloat(PV1i.w)));
PV0i.w = R123i.w;
// 15
R123i.x = floatBitsToInt((intBitsToFloat(R127i.z) * intBitsToFloat(uf_uniformRegisterVS[1].w) + intBitsToFloat(PV0i.x)));
PV1i.x = R123i.x;
R123i.y = floatBitsToInt((intBitsToFloat(R127i.z) * intBitsToFloat(uf_uniformRegisterVS[1].z) + intBitsToFloat(PV0i.y)));
PV1i.y = R123i.y;
R123i.z = floatBitsToInt((intBitsToFloat(R127i.z) * intBitsToFloat(uf_uniformRegisterVS[1].y) + intBitsToFloat(PV0i.z)));
PV1i.z = R123i.z;
R123i.w = floatBitsToInt((intBitsToFloat(R127i.z) * intBitsToFloat(uf_uniformRegisterVS[1].x) + intBitsToFloat(PV0i.w)));
PV1i.w = R123i.w;
// 16
R1i.x = floatBitsToInt((intBitsToFloat(R127i.w) * intBitsToFloat(uf_uniformRegisterVS[0].x) + intBitsToFloat(PV1i.w)));
R1i.y = floatBitsToInt((intBitsToFloat(R127i.w) * intBitsToFloat(uf_uniformRegisterVS[0].y) + intBitsToFloat(PV1i.z)));
R1i.z = floatBitsToInt((intBitsToFloat(R127i.w) * intBitsToFloat(uf_uniformRegisterVS[0].z) + intBitsToFloat(PV1i.y)));
R1i.w = floatBitsToInt((intBitsToFloat(R127i.w) * intBitsToFloat(uf_uniformRegisterVS[0].w) + intBitsToFloat(PV1i.x)));
// 17
backupReg0i = R125i.z;
backupReg1i = R125i.w;
R125i.z = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].y) * intBitsToFloat(uf_uniformRegisterVS[13].y) + intBitsToFloat(backupReg0i)));
R125i.w = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].y) * intBitsToFloat(uf_uniformRegisterVS[13].x) + intBitsToFloat(backupReg1i)));
// 18
backupReg0i = R126i.x;
backupReg1i = R125i.y;
R126i.x = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].y) * intBitsToFloat(uf_uniformRegisterVS[13].w) + intBitsToFloat(backupReg0i)));
R125i.y = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].y) * intBitsToFloat(uf_uniformRegisterVS[13].z) + intBitsToFloat(backupReg1i)));
// 19
backupReg0i = R124i.z;
backupReg1i = R124i.w;
R124i.z = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].w) * intBitsToFloat(uf_uniformRegisterVS[17].y) + intBitsToFloat(backupReg0i)));
R124i.w = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].w) * intBitsToFloat(uf_uniformRegisterVS[17].x) + intBitsToFloat(backupReg1i)));
// 20
backupReg0i = R125i.x;
backupReg1i = R124i.y;
R125i.x = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].w) * intBitsToFloat(uf_uniformRegisterVS[17].w) + intBitsToFloat(backupReg0i)));
R124i.y = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].w) * intBitsToFloat(uf_uniformRegisterVS[17].z) + intBitsToFloat(backupReg1i)));
// 21
R0i.x = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].x) * intBitsToFloat(uf_uniformRegisterVS[12].x) + intBitsToFloat(R125i.w)));
R0i.y = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].x) * intBitsToFloat(uf_uniformRegisterVS[12].y) + intBitsToFloat(R125i.z)));
// 22
R0i.z = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].x) * intBitsToFloat(uf_uniformRegisterVS[12].z) + intBitsToFloat(R125i.y)));
R0i.w = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].x) * intBitsToFloat(uf_uniformRegisterVS[12].w) + intBitsToFloat(R126i.x)));
// 23
R2i.x = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].z) * intBitsToFloat(uf_uniformRegisterVS[16].x) + intBitsToFloat(R124i.w)));
R2i.y = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].z) * intBitsToFloat(uf_uniformRegisterVS[16].y) + intBitsToFloat(R124i.z)));
// 24
R2i.z = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].z) * intBitsToFloat(uf_uniformRegisterVS[16].z) + intBitsToFloat(R124i.y)));
R2i.w = floatBitsToInt((intBitsToFloat(uf_uniformRegisterVS[ARi.x+8].z) * intBitsToFloat(uf_uniformRegisterVS[16].w) + intBitsToFloat(R125i.x)));
// export
float origRatio = (float(1280)/float(720));
float newRatio = (float($width)/float($height)) ;
// *(origRatio / newRatio)
SET_POSITION(vec4(intBitsToFloat(R1i.x)*(origRatio / newRatio), intBitsToFloat(R1i.y), intBitsToFloat(R1i.z), intBitsToFloat(R1i.w)));
// export
passParameterSem0 = vec4(intBitsToFloat(R0i.x), intBitsToFloat(R0i.y), intBitsToFloat(R0i.z), intBitsToFloat(R0i.w));
// export
passParameterSem1 = vec4(intBitsToFloat(R2i.x), intBitsToFloat(R2i.y), intBitsToFloat(R2i.z), intBitsToFloat(R2i.w));
// 0
}