From bce70f79f6e073ecc39a17b759aef14ffcdd1a6a Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 13 Oct 2017 10:03:51 -0400 Subject: [PATCH] Switched uMode to be accessible to fragment shaders only --- webrender/res/ps_text_run.glsl | 9 ++++++--- webrender/res/shared.glsl | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/webrender/res/ps_text_run.glsl b/webrender/res/ps_text_run.glsl index 1e797e568a..439ee9092b 100644 --- a/webrender/res/ps_text_run.glsl +++ b/webrender/res/ps_text_run.glsl @@ -83,16 +83,19 @@ void main(void) { // if we should instead handle the mode via // a combination of mix() etc. Branching on // a uniform is probably fast in most GPUs now though? + vec4 modulate_color = vec4(0.0); switch (uMode) { case MODE_ALPHA: - oFragColor = alpha * color * vColor; + modulate_color = alpha * vColor; break; case MODE_SUBPX_PASS0: - oFragColor = alpha * color; + modulate_color = vec4(alpha); break; case MODE_SUBPX_PASS1: - oFragColor = vColor * color; + modulate_color = vColor; break; } + + oFragColor = color * modulate_color; } #endif diff --git a/webrender/res/shared.glsl b/webrender/res/shared.glsl index 54f6f741ca..4fc3f7247a 100644 --- a/webrender/res/shared.glsl +++ b/webrender/res/shared.glsl @@ -39,6 +39,10 @@ // Fragment shader attributes and uniforms //====================================================================================== #ifdef WR_FRAGMENT_SHADER + // A generic uniform that shaders can optionally use to configure + // an operation mode for this batch. + uniform int uMode; + // Uniform inputs // Fragment shader outputs @@ -70,10 +74,6 @@ uniform sampler2DArray sColor2; uniform sampler2D sDither; #endif -// A generic uniform that shaders can optionally use to configure -// an operation mode for this batch. -uniform int uMode; - //====================================================================================== // Interpolator definitions //======================================================================================