gl-renderer: drop redundant texture lookups

Do not call texture2D() in the shader when we already have the result.
Simpler code, maybe even a little bit faster?

Suggested-by: Harish Krupo <harishkrupo@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 4 years ago
parent a88144f9e1
commit d278015d00
  1. 10
      libweston/renderer-gl/fragment.glsl

@ -106,22 +106,18 @@ main()
} else if (c_variant == SHADER_VARIANT_Y_UV) { } else if (c_variant == SHADER_VARIANT_Y_UV) {
yuva.x = texture2D(tex, v_texcoord).x; yuva.x = texture2D(tex, v_texcoord).x;
yuva.y = texture2D(tex1, v_texcoord).r; yuva.yz = texture2D(tex1, v_texcoord).rg;
yuva.z = texture2D(tex1, v_texcoord).g;
yuva.w = alpha; yuva.w = alpha;
gl_FragColor = yuva2rgba(yuva); gl_FragColor = yuva2rgba(yuva);
} else if (c_variant == SHADER_VARIANT_Y_XUXV) { } else if (c_variant == SHADER_VARIANT_Y_XUXV) {
yuva.x = texture2D(tex, v_texcoord).x; yuva.x = texture2D(tex, v_texcoord).x;
yuva.y = texture2D(tex1, v_texcoord).g; yuva.yz = texture2D(tex1, v_texcoord).ga;
yuva.z = texture2D(tex1, v_texcoord).a;
yuva.w = alpha; yuva.w = alpha;
gl_FragColor = yuva2rgba(yuva); gl_FragColor = yuva2rgba(yuva);
} else if (c_variant == SHADER_VARIANT_XYUV) { } else if (c_variant == SHADER_VARIANT_XYUV) {
yuva.x = texture2D(tex, v_texcoord).b; yuva.xyz = texture2D(tex, v_texcoord).bgr;
yuva.y = texture2D(tex, v_texcoord).g;
yuva.z = texture2D(tex, v_texcoord).r;
yuva.w = alpha; yuva.w = alpha;
gl_FragColor = yuva2rgba(yuva); gl_FragColor = yuva2rgba(yuva);

Loading…
Cancel
Save