From c67c648c1a2de1be3e1ca0d9c7d6f9ee2521e9c6 Mon Sep 17 00:00:00 2001
From: Stuart Kenny <stuken@users.noreply.github.com>
Date: Thu, 1 Jun 2023 16:22:57 +0100
Subject: [PATCH] mmpx: Fix GLES crashes. (#6588)

---
 .../host_shaders/texture_filtering/mmpx.frag      | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/video_core/host_shaders/texture_filtering/mmpx.frag b/src/video_core/host_shaders/texture_filtering/mmpx.frag
index fbfa2517b..26f192e51 100644
--- a/src/video_core/host_shaders/texture_filtering/mmpx.frag
+++ b/src/video_core/host_shaders/texture_filtering/mmpx.frag
@@ -9,17 +9,10 @@ layout(location = 0) in vec2 tex_coord;
 layout(location = 0) out vec4 frag_color;
 layout(binding = 0) uniform sampler2D tex;
 
-vec2 source_size = vec2(textureSize(tex, 0));
-vec2 pos = fract(tex_coord * source_size) - vec2(0.5, 0.5);
-vec2 coord = tex_coord - pos / source_size;
-
-vec4 src(float x, float y)
-{
-    return texture(tex, coord + vec2(x, y) * 1 / source_size);
-}
+#define src(x, y) texture(tex, coord + vec2(x, y) * 1.0 / source_size)
 
 float luma(vec4 col){
-    return dot(col.rgb, vec3(0.2126, 0.7152, 0.0722)) * (1 - col.a);
+    return dot(col.rgb, vec3(0.2126, 0.7152, 0.0722)) * (1.0 - col.a);
 }
 
 bool same(vec4 B, vec4 A0){
@@ -56,6 +49,10 @@ bool none_eq4(vec4 B, vec4 A0, vec4 A1, vec4 A2, vec4 A3) {
 
 void main()
 {
+    vec2 source_size = vec2(textureSize(tex, 0));
+    vec2 pos = fract(tex_coord * source_size) - vec2(0.5, 0.5);
+    vec2 coord = tex_coord - pos / source_size;
+
     vec4 E = src(0.0,0.0);
 
     vec4 A = src(-1.0,-1.0);