diff --git a/.rive_head b/.rive_head index 8fa4c06e..db3979ee 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -3c322193bf69e92663ae4346cf16396ef1578239 +7cc6f5bbe3c726fc1c94f2075aed7f262240282d diff --git a/renderer/include/rive/renderer/gl/gles3.hpp b/renderer/include/rive/renderer/gl/gles3.hpp index d61e0532..bc5df5bb 100644 --- a/renderer/include/rive/renderer/gl/gles3.hpp +++ b/renderer/include/rive/renderer/gl/gles3.hpp @@ -119,7 +119,7 @@ struct GLCapabilities int contextVersionMajor; int contextVersionMinor; bool isGLES : 1; - bool isANGLEOrWebGL : 1; + bool isAndroidANGLE : 1; bool isPowerVR : 1; bool ANGLE_base_vertex_base_instance_shader_builtin : 1; bool ANGLE_shader_pixel_local_storage : 1; diff --git a/renderer/src/gl/render_context_gl_impl.cpp b/renderer/src/gl/render_context_gl_impl.cpp index ea32fe72..292e41d2 100644 --- a/renderer/src/gl/render_context_gl_impl.cpp +++ b/renderer/src/gl/render_context_gl_impl.cpp @@ -1683,18 +1683,10 @@ void RenderContextGLImpl::flush(const FlushDescriptor& desc) } else { - // Depth/stencil don't need to be written out. - glInvalidateFramebuffer(GL_DRAW_FRAMEBUFFER, + // Depth/stencil can be discarded. + glInvalidateFramebuffer(GL_FRAMEBUFFER, 2, msaaDepthStencilColor.data()); - if ((desc.combinedShaderFeatures & - gpu::ShaderFeatures::ENABLE_ADVANCED_BLEND) && - m_capabilities.KHR_blend_equation_advanced_coherent) - { - glDisable(GL_BLEND_ADVANCED_COHERENT_KHR); - } - glDisable(GL_DEPTH_TEST); - glDisable(GL_STENCIL_TEST); if (msaaResolveAction == RenderTargetGL::MSAAResolveAction::framebufferBlit) { @@ -1702,7 +1694,21 @@ void RenderContextGLImpl::flush(const FlushDescriptor& desc) glutils::BlitFramebuffer(desc.renderTargetUpdateBounds, renderTarget->height(), GL_COLOR_BUFFER_BIT); + // Now that color is resolved elsewhere we can discard the MSAA + // color buffer as well. + glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, + 1, + msaaDepthStencilColor.data() + 2); } + + if ((desc.combinedShaderFeatures & + gpu::ShaderFeatures::ENABLE_ADVANCED_BLEND) && + m_capabilities.KHR_blend_equation_advanced_coherent) + { + glDisable(GL_BLEND_ADVANCED_COHERENT_KHR); + } + glDisable(GL_DEPTH_TEST); + glDisable(GL_STENCIL_TEST); if (clipPlanesEnabled) { glDisable(GL_CLIP_DISTANCE0_EXT); @@ -1779,10 +1785,8 @@ std::unique_ptr RenderContextGLImpl::MakeContext( #endif if (capabilities.isGLES) { -#ifdef RIVE_WEBGL - capabilities.isANGLEOrWebGL = true; -#else - capabilities.isANGLEOrWebGL = strstr(glVersionStr, "ANGLE") != NULL; +#ifdef RIVE_ANDROID + capabilities.isAndroidANGLE = strstr(glVersionStr, "ANGLE") != NULL; #endif #ifdef _MSC_VER sscanf_s( @@ -1796,7 +1800,6 @@ std::unique_ptr RenderContextGLImpl::MakeContext( } else { - capabilities.isANGLEOrWebGL = false; #ifdef _MSC_VER sscanf_s( #else @@ -1924,7 +1927,7 @@ std::unique_ptr RenderContextGLImpl::MakeContext( // this extension but then doesn't support gl_ClipDistance in the // shader. Only use clip planes on ANGLE if ANGLE_clip_cull_distance is // supported. - else if (!capabilities.isANGLEOrWebGL && + else if (!capabilities.isAndroidANGLE && strcmp(ext, "GL_EXT_clip_cull_distance") == 0) { capabilities.EXT_clip_cull_distance = true; diff --git a/tests/gm/texture_target_gl.cpp b/tests/gm/texture_target_gl.cpp index b3351506..709cfdd4 100644 --- a/tests/gm/texture_target_gl.cpp +++ b/tests/gm/texture_target_gl.cpp @@ -84,6 +84,17 @@ class TextureTargetGL : public GM copyFrameDescriptor.clearColor = 0xffff0000; renderContext->beginFrame(std::move(copyFrameDescriptor)); originalRenderTarget->bindDestinationFramebuffer(GL_FRAMEBUFFER); + if (plsImplGL->capabilities().isAndroidANGLE) + { + // Some android devices shipping with ANGLE have a + // syncronization issue drawing this texture into the main + // framebuffer. glFinish is a very heavy handed workaround, but + // it's the only one so far to work. + // Sadly, we can't incorporate a workaround this heavy into the + // main GL runtime. Apps that run into it will have to come up + // with the best workaround for them. + glFinish(); + } plsImplGL->blitTextureToFramebufferAsDraw(m_offscreenTex, {0, 0, 256, 256}, 256);