From ad4d1787a15a733ee2883c140055b0d53ba3f6a7 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 13 Nov 2020 12:38:36 -0500 Subject: [PATCH] gpu: fix intel miscompiles of fragui shader Having all 3 sampling branches feed into one colorblind() call was breaking some versions of Intel's drivers whenever the xbr sampling code was merely present. Changing each branch to individually call colorblind() seems to fix it. --- .../client/plugins/gpu/colorblind.glsl | 1 - .../runelite/client/plugins/gpu/fragui.glsl | 23 +++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/gpu/colorblind.glsl b/runelite-client/src/main/resources/net/runelite/client/plugins/gpu/colorblind.glsl index 2a6a16883d..b2c2c49b51 100644 --- a/runelite-client/src/main/resources/net/runelite/client/plugins/gpu/colorblind.glsl +++ b/runelite-client/src/main/resources/net/runelite/client/plugins/gpu/colorblind.glsl @@ -53,7 +53,6 @@ vec3 colorblind(int mode, vec3 color) lms = LMS * lms2lmst; // blue deficiency } else { - // Should be impossible to get here return color; } diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/gpu/fragui.glsl b/runelite-client/src/main/resources/net/runelite/client/plugins/gpu/fragui.glsl index cf013aacdd..e522d34400 100644 --- a/runelite-client/src/main/resources/net/runelite/client/plugins/gpu/fragui.glsl +++ b/runelite-client/src/main/resources/net/runelite/client/plugins/gpu/fragui.glsl @@ -24,7 +24,6 @@ */ #version 330 -#define SAMPLING_DEFAULT 0 #define SAMPLING_MITCHELL 1 #define SAMPLING_CATROM 2 #define SAMPLING_XBR 3 @@ -48,15 +47,19 @@ out vec4 FragColor; void main() { vec4 c; - if (samplingMode == SAMPLING_DEFAULT) - c = texture(tex, TexCoord); - else if (samplingMode == SAMPLING_CATROM || samplingMode == SAMPLING_MITCHELL) - c = textureCubic(tex, TexCoord, samplingMode); - else if (samplingMode == SAMPLING_XBR) - c = textureXBR(tex, TexCoord, xbrTable, ceil(1.0 * targetDimensions.x / sourceDimensions.x)); - - if (colorBlindMode > 0) { - c.rgb = colorblind(colorBlindMode, c.rgb); + switch (samplingMode) { + case SAMPLING_CATROM: + case SAMPLING_MITCHELL: + c = textureCubic(tex, TexCoord, samplingMode); + c.rgb = colorblind(colorBlindMode, c.rgb); + break; + case SAMPLING_XBR: + c = textureXBR(tex, TexCoord, xbrTable, ceil(1.0 * targetDimensions.x / sourceDimensions.x)); + c.rgb = colorblind(colorBlindMode, c.rgb); + break; + default: // NEAREST or LINEAR, which uses GL_TEXTURE_MIN_FILTER/GL_TEXTURE_MAG_FILTER to affect sampling + c = texture(tex, TexCoord); + c.rgb = colorblind(colorBlindMode, c.rgb); } FragColor = c;