diff --git a/.github/gles.patch b/.github/gles.patch index 5a922fcf2..c5cdb7d41 100644 --- a/.github/gles.patch +++ b/.github/gles.patch @@ -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 b9f9fe4c..f1cf286f 100644 +index 9f07df0b..2ab623af 100644 --- a/src/host_shaders/opengl_fragment_shader.frag +++ b/src/host_shaders/opengl_fragment_shader.frag @@ -1,4 +1,5 @@ @@ -31,6 +31,17 @@ index b9f9fe4c..f1cf286f 100644 in vec4 v_quaternion; in vec4 v_colour; +@@ -41,8 +42,8 @@ vec3 normal; + const uint samplerEnabledBitfields[2] = uint[2](0x7170e645u, 0x7f013fefu); + + bool isSamplerEnabled(uint environment_id, uint lut_id) { +- uint index = 7 * environment_id + lut_id; +- uint arrayIndex = (index >> 5); ++ uint index = 7u * environment_id + lut_id; ++ uint arrayIndex = (index >> 5u); + return (samplerEnabledBitfields[arrayIndex] & (1u << (index & 31u))) != 0u; + } + @@ -166,11 +167,17 @@ float lutLookup(uint lut, int index) { return texelFetch(u_tex_luts, ivec2(index, int(lut)), 0).r; } @@ -50,6 +61,15 @@ index b9f9fe4c..f1cf286f 100644 } // Convert an arbitrary-width floating point literal to an f32 +@@ -201,7 +208,7 @@ float lightLutLookup(uint environment_id, uint lut_id, uint light_id, vec3 light + // These are the spotlight attenuation LUTs + bit_in_config1 = 8 + int(light_id & 7u); + lut_index = 8u + light_id; +- } else if (lut_id <= 6) { ++ } else if (lut_id <= 6u) { + bit_in_config1 = 16 + int(lut_id); + lut_index = lut_id; + } else { @@ -210,16 +217,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 @@ -70,19 +90,16 @@ index b9f9fe4c..f1cf286f 100644 switch (input_id) { case 0u: { delta = dot(normal, normalize(half_vector)); -@@ -241,11 +248,11 @@ float lightLutLookup(uint environment_id, uint lut_id, uint light_id, vec3 light - int GPUREG_LIGHTi_SPOTDIR_LOW = int(readPicaReg(0x0146u + (light_id << 4u))); - int GPUREG_LIGHTi_SPOTDIR_HIGH = int(readPicaReg(0x0147u + (light_id << 4u))); +@@ -243,9 +250,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 + // Sign extend them. Normally bitfieldExtract 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); ++ int se_x = bitfieldExtract(uint(GPUREG_LIGHTi_SPOTDIR_LOW), 0, 13); ++ int se_y = bitfieldExtract(uint(GPUREG_LIGHTi_SPOTDIR_LOW), 16, 13); ++ int se_z = bitfieldExtract(uint(GPUREG_LIGHTi_SPOTDIR_HIGH), 0, 13); if ((se_x & 0x1000) == 0x1000) se_x |= 0xffffe000; if ((se_y & 0x1000) == 0x1000) se_y |= 0xffffe000; @@ -225,10 +242,10 @@ index 057f9a88..dc735ced 100644 v_quaternion = a_quaternion; } diff --git a/third_party/opengl/opengl.hpp b/third_party/opengl/opengl.hpp -index 4a08650a..21af37e3 100644 +index 607815fa..cbfcc096 100644 --- a/third_party/opengl/opengl.hpp +++ b/third_party/opengl/opengl.hpp -@@ -583,22 +583,22 @@ namespace OpenGL { +@@ -602,22 +602,22 @@ namespace OpenGL { static void disableScissor() { glDisable(GL_SCISSOR_TEST); } static void enableBlend() { glEnable(GL_BLEND); } static void disableBlend() { glDisable(GL_BLEND); } diff --git a/src/core/PICA/shader_gen_glsl.cpp b/src/core/PICA/shader_gen_glsl.cpp index 60887d56b..aa605dd24 100644 --- a/src/core/PICA/shader_gen_glsl.cpp +++ b/src/core/PICA/shader_gen_glsl.cpp @@ -44,6 +44,7 @@ std::string FragmentGenerator::getDefaultVertexShader() { if (api == API::GLES) { ret += R"( #define USING_GLES 1 + #define fma(a, b, c) ((a) * (b) + (c)) precision mediump int; precision mediump float;