From 1da50d220e28319d48d5bcf33c1fcfd106b71815 Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Sun, 5 Nov 2023 21:04:58 -0500 Subject: [PATCH] [client] EGL: stop unpacking data across rows --- .../EGL/shader/convert_bgr_bgra.frag | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/client/renderers/EGL/shader/convert_bgr_bgra.frag b/client/renderers/EGL/shader/convert_bgr_bgra.frag index 060545e9..d1bf7e3e 100644 --- a/client/renderers/EGL/shader/convert_bgr_bgra.frag +++ b/client/renderers/EGL/shader/convert_bgr_bgra.frag @@ -11,25 +11,22 @@ uniform vec2 outputSize; void main() { - uvec2 inputSize = uvec2(textureSize(sampler1, 0)); - uvec2 pos = uvec2(fragCoord * outputSize); - uint outputWidth = uint(outputSize.x); + uvec2 inputSize = uvec2(textureSize(sampler1, 0)); + uvec2 outputPos = uvec2(fragCoord * outputSize); - uint output_idx = pos.y * outputWidth + pos.x; + uint fst = outputPos.x * 3u / 4u; + vec4 color_0 = texelFetch(sampler1, ivec2(fst, outputPos.y), 0); - uint fst = output_idx * 3u / 4u; - vec4 color_0 = texelFetch(sampler1, ivec2(fst % inputSize.x, fst / inputSize.x), 0); + uint snd = (outputPos.x * 3u + 1u) / 4u; + vec4 color_1 = texelFetch(sampler1, ivec2(snd, outputPos.y), 0); - uint snd = (output_idx * 3u + 1u) / 4u; - vec4 color_1 = texelFetch(sampler1, ivec2(snd % inputSize.x, snd / inputSize.x), 0); - - uint trd = (output_idx * 3u + 2u) / 4u; - vec4 color_2 = texelFetch(sampler1, ivec2(trd % inputSize.x, trd / inputSize.x), 0); + uint trd = (outputPos.x * 3u + 2u) / 4u; + vec4 color_2 = texelFetch(sampler1, ivec2(trd, outputPos.y), 0); fragColor.bgra = vec4( - color_0.barg[output_idx % 4u], - color_1.gbar[output_idx % 4u], - color_2.rgba[output_idx % 4u], + color_0.barg[outputPos.x % 4u], + color_1.gbar[outputPos.x % 4u], + color_2.rgba[outputPos.x % 4u], 1.0 ); }