Update gles.patch

This commit is contained in:
offtkp 2024-07-18 04:05:58 +03:00
parent 4e7185a058
commit 301895a9d2

66
.github/gles.patch vendored
View file

@ -21,7 +21,7 @@ index 990e2f80..2e7842ac 100644
void main() {
diff --git a/src/host_shaders/opengl_fragment_shader.frag b/src/host_shaders/opengl_fragment_shader.frag
index 23c5c4cb..a9851a8b 100644
index d622b97e..8aa434f2 100644
--- a/src/host_shaders/opengl_fragment_shader.frag
+++ b/src/host_shaders/opengl_fragment_shader.frag
@@ -1,4 +1,5 @@
@ -31,7 +31,7 @@ index 23c5c4cb..a9851a8b 100644
in vec4 v_quaternion;
in vec4 v_colour;
@@ -189,11 +190,17 @@ float lutLookup(uint lut, int index) {
@@ -164,11 +165,17 @@ float lutLookup(uint lut, int index) {
return texelFetch(u_tex_lighting_lut, ivec2(index, lut), 0).r;
}
@ -50,8 +50,8 @@ index 23c5c4cb..a9851a8b 100644
}
// Convert an arbitrary-width floating point literal to an f32
@@ -257,16 +264,16 @@ float lightLutLookup(uint environment_id, uint lut_id, uint light_id, vec3 light
// If RR is enabled but not RG or RB, the output of RR is used for the three components; Red, Green and Blue.
@@ -208,16 +215,16 @@ float lightLutLookup(uint environment_id, uint lut_id, uint light_id, vec3 light
bool current_sampler_enabled = isSamplerEnabled(environment_id, lut_id); // 7 luts per environment
- if (!current_sampler_enabled || (bitfieldExtract(GPUREG_LIGHTING_CONFIG1, bit_in_config1, 1) != 0u)) {
@ -70,26 +70,23 @@ index 23c5c4cb..a9851a8b 100644
switch (input_id) {
case 0u: {
delta = dot(normal, normalize(half_vector));
@@ -285,14 +292,14 @@ float lightLutLookup(uint environment_id, uint lut_id, uint light_id, vec3 light
break;
}
case 4u: {
- // These are ints so that bitfieldExtract sign extends for us
+ // These are ints so that bitfieldExtractCompat sign extends for us
int GPUREG_LIGHTi_SPOTDIR_LOW = int(readPicaReg(0x0146u + (light_id << 4u)));
int GPUREG_LIGHTi_SPOTDIR_HIGH = int(readPicaReg(0x0147u + (light_id << 4u)));
@@ -239,11 +246,11 @@ float lightLutLookup(uint environment_id, uint lut_id, uint light_id, vec3 light
uint GPUREG_LIGHTi_SPOTDIR_LOW = readPicaReg(0x0146u + (light_id << 4u));
uint GPUREG_LIGHTi_SPOTDIR_HIGH = readPicaReg(0x0147u + (light_id << 4u));
// These are fixed point 1.1.11 values, so we need to convert them to float
- float x = float(bitfieldExtract(GPUREG_LIGHTi_SPOTDIR_LOW, 0, 13)) / 2047.0;
- float y = float(bitfieldExtract(GPUREG_LIGHTi_SPOTDIR_LOW, 16, 13)) / 2047.0;
- float z = float(bitfieldExtract(GPUREG_LIGHTi_SPOTDIR_HIGH, 0, 13)) / 2047.0;
+ float x = float(bitfieldExtractCompat(GPUREG_LIGHTi_SPOTDIR_LOW, 0, 13)) / 2047.0;
+ float y = float(bitfieldExtractCompat(GPUREG_LIGHTi_SPOTDIR_LOW, 16, 13)) / 2047.0;
+ float z = float(bitfieldExtractCompat(GPUREG_LIGHTi_SPOTDIR_HIGH, 0, 13)) / 2047.0;
vec3 spotlight_vector = vec3(x, y, z);
delta = dot(light_vector, spotlight_vector); // spotlight direction is negated so we don't negate light_vector
break;
@@ -310,9 +317,9 @@ float lightLutLookup(uint environment_id, uint lut_id, uint light_id, vec3 light
- // Sign extend them. Normally bitfieldExtract would do that but it's missing on some versions
+ // Sign extend them. Normally bitfieldExtractCompat would do that but it's missing on some versions
// of GLSL so we do it manually
- int se_x = bitfieldExtract(GPUREG_LIGHTi_SPOTDIR_LOW, 0, 13);
- int se_y = bitfieldExtract(GPUREG_LIGHTi_SPOTDIR_LOW, 16, 13);
- int se_z = bitfieldExtract(GPUREG_LIGHTi_SPOTDIR_HIGH, 0, 13);
+ int se_x = bitfieldExtractCompat(GPUREG_LIGHTi_SPOTDIR_LOW, 0, 13);
+ int se_y = bitfieldExtractCompat(GPUREG_LIGHTi_SPOTDIR_LOW, 16, 13);
+ int se_z = bitfieldExtractCompat(GPUREG_LIGHTi_SPOTDIR_HIGH, 0, 13);
if (se_x & 0x1000) se_x |= 0xffffe000;
if (se_y & 0x1000) se_y |= 0xffffe000;
@@ -270,9 +277,9 @@ float lightLutLookup(uint environment_id, uint lut_id, uint light_id, vec3 light
}
// 0 = enabled
@ -101,7 +98,7 @@ index 23c5c4cb..a9851a8b 100644
delta = max(delta, 0.0);
} else {
delta = abs(delta);
@@ -339,7 +346,7 @@ void calcLighting(out vec4 primary_color, out vec4 secondary_color) {
@@ -299,7 +306,7 @@ void calcLighting(out vec4 primary_color, out vec4 secondary_color) {
unimpl_color = vec4(1.0, 0.0, 1.0, 1.0);
uint GPUREG_LIGHTING_ENABLE = readPicaReg(0x008Fu);
@ -110,7 +107,7 @@ index 23c5c4cb..a9851a8b 100644
primary_color = secondary_color = vec4(0.0);
return;
}
@@ -356,7 +363,7 @@ void calcLighting(out vec4 primary_color, out vec4 secondary_color) {
@@ -316,7 +323,7 @@ void calcLighting(out vec4 primary_color, out vec4 secondary_color) {
GPUREG_LIGHTING_LUTINPUT_ABS = readPicaReg(0x01D0u);
GPUREG_LIGHTING_LUTINPUT_SELECT = readPicaReg(0x01D1u);
@ -118,8 +115,8 @@ index 23c5c4cb..a9851a8b 100644
+ uint bump_mode = bitfieldExtractCompat(GPUREG_LIGHTING_CONFIG0, 28, 2);
// Bump mode is ignored for now because it breaks some games ie. Toad Treasure Tracker
// Could be because the texture is not sampled correctly, may need the clamp/border color configurations
@@ -370,15 +377,15 @@ void calcLighting(out vec4 primary_color, out vec4 secondary_color) {
switch (bump_mode) {
@@ -329,15 +336,15 @@ void calcLighting(out vec4 primary_color, out vec4 secondary_color) {
vec4 diffuse_sum = vec4(0.0, 0.0, 0.0, 1.0);
vec4 specular_sum = vec4(0.0, 0.0, 0.0, 1.0);
@ -138,7 +135,7 @@ index 23c5c4cb..a9851a8b 100644
uint GPUREG_LIGHTi_SPECULAR0 = readPicaReg(0x0140u + (light_id << 4u));
uint GPUREG_LIGHTi_SPECULAR1 = readPicaReg(0x0141u + (light_id << 4u));
@@ -390,12 +397,12 @@ void calcLighting(out vec4 primary_color, out vec4 secondary_color) {
@@ -349,12 +356,12 @@ void calcLighting(out vec4 primary_color, out vec4 secondary_color) {
float light_distance;
vec3 light_position = vec3(
@ -154,7 +151,7 @@ index 23c5c4cb..a9851a8b 100644
light_vector = light_position + v_view;
}
@@ -411,14 +418,14 @@ void calcLighting(out vec4 primary_color, out vec4 secondary_color) {
@@ -370,23 +377,23 @@ void calcLighting(out vec4 primary_color, out vec4 secondary_color) {
float NdotL = dot(normal, light_vector); // N dot Li
// Two sided diffuse
@ -172,9 +169,8 @@ index 23c5c4cb..a9851a8b 100644
if (use_geo_0 || use_geo_1) {
geometric_factor = dot(half_vector, half_vector);
geometric_factor = geometric_factor == 0.0 ? 0.0 : min(NdotL / geometric_factor, 1.0);
@@ -430,9 +437,9 @@ void calcLighting(out vec4 primary_color, out vec4 secondary_color) {
// fragment and the distance attenuation scale and bias to calculate where in the LUT to look up.
// See: https://www.3dbrew.org/wiki/GPU/Internal_Registers#GPUREG_LIGHTi_ATTENUATION_SCALE
}
float distance_attenuation = 1.0;
- if (bitfieldExtract(GPUREG_LIGHTING_CONFIG1, 24 + int(light_id), 1) == 0u) {
- uint GPUREG_LIGHTi_ATTENUATION_BIAS = bitfieldExtract(readPicaReg(0x014Au + (light_id << 4u)), 0, 20);
@ -185,7 +181,7 @@ index 23c5c4cb..a9851a8b 100644
float distance_attenuation_bias = decodeFP(GPUREG_LIGHTi_ATTENUATION_BIAS, 7u, 12u);
float distance_attenuation_scale = decodeFP(GPUREG_LIGHTi_ATTENUATION_SCALE, 7u, 12u);
@@ -477,8 +484,8 @@ void calcLighting(out vec4 primary_color, out vec4 secondary_color) {
@@ -431,8 +438,8 @@ void calcLighting(out vec4 primary_color, out vec4 secondary_color) {
specular_sum.rgb += light_factor * clamp_factor * (specular0 + specular1);
}
@ -229,10 +225,10 @@ index 057f9a88..dc735ced 100644
v_quaternion = a_quaternion;
}
diff --git a/third_party/opengl/opengl.hpp b/third_party/opengl/opengl.hpp
index 9997e63b..5d9d7804 100644
index 828fb784..a1861b77 100644
--- a/third_party/opengl/opengl.hpp
+++ b/third_party/opengl/opengl.hpp
@@ -561,22 +561,22 @@ namespace OpenGL {
@@ -568,22 +568,22 @@ namespace OpenGL {
static void disableScissor() { glDisable(GL_SCISSOR_TEST); }
static void enableBlend() { glEnable(GL_BLEND); }
static void disableBlend() { glDisable(GL_BLEND); }