From 8559b354ae3c5d0c22b1db08eda88c90e3eb2893 Mon Sep 17 00:00:00 2001 From: Quantum Date: Tue, 26 Jan 2021 21:49:22 -0500 Subject: [PATCH] [client] egl: always render desktop texture as opaque We ask for 32-bit colour buffer when creating the EGL context. On Wayland, this sometimes give contexts with alpha channels, resulting in unwanted transparency. So we clear the alpha channel in the desktop shader. We also switch to using constant alpha for blending the splash, which avoids more alpha issues. --- client/renderers/EGL/shader/desktop_rgb.frag | 2 ++ client/renderers/EGL/shader/splash_bg.frag | 3 +-- client/renderers/EGL/shader/splash_bg.vert | 3 --- client/renderers/EGL/shader/splash_logo.frag | 3 +-- client/renderers/EGL/shader/splash_logo.vert | 8 ++------ client/renderers/EGL/splash.c | 9 +++------ 6 files changed, 9 insertions(+), 19 deletions(-) diff --git a/client/renderers/EGL/shader/desktop_rgb.frag b/client/renderers/EGL/shader/desktop_rgb.frag index 59128b8b..2fba4a91 100644 --- a/client/renderers/EGL/shader/desktop_rgb.frag +++ b/client/renderers/EGL/shader/desktop_rgb.frag @@ -84,4 +84,6 @@ void main() color *= 1.0 + lumi; color *= nvGain; } + + color.a = 1.0; } diff --git a/client/renderers/EGL/shader/splash_bg.frag b/client/renderers/EGL/shader/splash_bg.frag index 058afdbe..cff04f20 100644 --- a/client/renderers/EGL/shader/splash_bg.frag +++ b/client/renderers/EGL/shader/splash_bg.frag @@ -1,7 +1,6 @@ #version 300 es in highp vec3 pos; -in highp float a; out highp vec4 color; uniform sampler2D sampler1; @@ -9,5 +8,5 @@ uniform sampler2D sampler1; void main() { highp float d = 1.0 - sqrt(pos.x * pos.x + pos.y * pos.y) / 2.0; - color = vec4(0.234375 * d, 0.015625f * d, 0.425781f * d, a); + color = vec4(0.234375 * d, 0.015625f * d, 0.425781f * d, 1); } diff --git a/client/renderers/EGL/shader/splash_bg.vert b/client/renderers/EGL/shader/splash_bg.vert index d47bc73c..c863e2ed 100644 --- a/client/renderers/EGL/shader/splash_bg.vert +++ b/client/renderers/EGL/shader/splash_bg.vert @@ -2,8 +2,6 @@ layout(location = 0) in vec3 vertexPosition_modelspace; -uniform float alpha; - out highp vec3 pos; out highp float a; @@ -13,5 +11,4 @@ void main() gl_Position.w = 1.0; pos = vertexPosition_modelspace; - a = alpha; } diff --git a/client/renderers/EGL/shader/splash_logo.frag b/client/renderers/EGL/shader/splash_logo.frag index bd09551c..4c7840b6 100644 --- a/client/renderers/EGL/shader/splash_logo.frag +++ b/client/renderers/EGL/shader/splash_logo.frag @@ -1,11 +1,10 @@ #version 300 es out highp vec4 color; -in highp float a; uniform sampler2D sampler1; void main() { - color = vec4(1.0, 1.0, 1.0, a); + color = vec4(1.0, 1.0, 1.0, 1.0); } diff --git a/client/renderers/EGL/shader/splash_logo.vert b/client/renderers/EGL/shader/splash_logo.vert index a717f3a1..a4125b7d 100644 --- a/client/renderers/EGL/shader/splash_logo.vert +++ b/client/renderers/EGL/shader/splash_logo.vert @@ -2,15 +2,11 @@ layout(location = 0) in vec3 vertexPosition_modelspace; -uniform vec2 scale; - -out highp float a; +uniform float scale; void main() { gl_Position.xyz = vertexPosition_modelspace; - gl_Position.y *= scale.y; + gl_Position.y *= scale; gl_Position.w = 1.0; - - a = scale.x; } diff --git a/client/renderers/EGL/splash.c b/client/renderers/EGL/splash.c index eeb81c84..9fe9663c 100644 --- a/client/renderers/EGL/splash.c +++ b/client/renderers/EGL/splash.c @@ -45,7 +45,6 @@ struct EGL_Splash EGL_Model * logo; // uniforms - GLint uBGAlpha; GLint uScale; }; @@ -74,8 +73,6 @@ bool egl_splash_init(EGL_Splash ** splash) return false; } - (*splash)->uBGAlpha = egl_shader_get_uniform_location((*splash)->bgShader, "alpha"); - if (!egl_model_init(&(*splash)->bg)) { DEBUG_ERROR("Failed to intiailize the splash bg model"); @@ -166,14 +163,14 @@ void egl_splash_free(EGL_Splash ** splash) void egl_splash_render(EGL_Splash * splash, float alpha, float scaleY) { glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendColor(0, 0, 0, alpha); + glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA); egl_shader_use(splash->bgShader); - glUniform1f(splash->uBGAlpha, alpha); egl_model_render(splash->bg); egl_shader_use(splash->logoShader); - glUniform2f(splash->uScale, alpha, scaleY); + glUniform1f(splash->uScale, scaleY); egl_model_render(splash->logo); glDisable(GL_BLEND);