From 42992b8ff8dc97831468f0ec01c1d1f5c3687cc1 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 30 Nov 2024 10:33:37 +0100 Subject: [PATCH] (Android) Fixed an issue where on some devices, disabling the "Blur background when menu is open" option led to rendering issues --- es-core/src/renderers/RendererOpenGL.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/es-core/src/renderers/RendererOpenGL.cpp b/es-core/src/renderers/RendererOpenGL.cpp index 9b78fab4f..299174ecc 100644 --- a/es-core/src/renderers/RendererOpenGL.cpp +++ b/es-core/src/renderers/RendererOpenGL.cpp @@ -669,6 +669,19 @@ void RendererOpenGL::shaderPostprocessing(unsigned int shaders, if (shaders & Shader::SCANLINES) shaderList.push_back(Shader::SCANLINES); +#if defined(__ANDROID__) + // For unknown reasons some specific Android devices won't be able to render directly + // from screen to a texture using one FBO and then read the pixels from there, instead + // they need to render twice to both FBOs. This hack simply adds another core shader pass + // to work around this issue. It only happens when the background is dimmed, i.e. when + // opening a menu and when the blur has also been disabled. + bool renderHack {false}; + if (textureRGBA && shaderList.size() == 1) { + renderHack = true; + shaderList.push_back(Shader::CORE); + } +#endif + setMatrix(getIdentity()); bindTexture(mPostProcTexture1, 0); @@ -754,6 +767,12 @@ void RendererOpenGL::shaderPostprocessing(unsigned int shaders, drawTriangleStrips(vertices, 4, BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA); +#if defined(__ANDROID__) + if (renderHack) { + vertices->dimming = 1.0f; + vertices->shaderFlags ^= ShaderFlags::CONVERT_PIXEL_FORMAT; + } +#endif if (shaderCalls == 1) break;