Skip to content

Commit

Permalink
Work around gradient sync issues on Oppo Reno 3 Pro
Browse files Browse the repository at this point in the history
Diffs=
32636f7dde Work around gradient sync issues on Oppo Reno 3 Pro (#8745)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
  • Loading branch information
csmartdalton and csmartdalton committed Dec 13, 2024
1 parent 06b6388 commit dcbab79
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7d39d0fca73e8cae8a1d8c1183e62ba7b6eb61f6
32636f7ddee24a23414d6a288de72179c19e9500
1 change: 1 addition & 0 deletions renderer/include/rive/renderer/gl/gles3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ struct GLCapabilities
int contextVersionMinor;
bool isGLES : 1;
bool isANGLEOrWebGL : 1;
bool isPowerVR : 1;
bool ANGLE_base_vertex_base_instance_shader_builtin : 1;
bool ANGLE_shader_pixel_local_storage : 1;
bool ANGLE_shader_pixel_local_storage_coherent : 1;
Expand Down
57 changes: 40 additions & 17 deletions renderer/src/gl/render_context_gl_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,38 @@ void RenderContextGLImpl::flush(const FlushDescriptor& desc)
desc.firstContour * sizeof(gpu::ContourData));
}

// Copy the simple color ramps to the gradient texture.
if (desc.simpleGradTexelsHeight > 0)
{
glActiveTexture(GL_TEXTURE0 + kPLSTexIdxOffset + GRAD_TEXTURE_IDX);
glTexSubImage2D(GL_TEXTURE_2D,
0,
0,
0,
desc.simpleGradTexelsWidth,
desc.simpleGradTexelsHeight,
GL_RGBA,
GL_UNSIGNED_BYTE,
heap_buffer_contents(simpleColorRampsBufferRing()) +
desc.simpleGradDataOffsetInBytes);
}
else if (m_capabilities.isPowerVR && desc.complexGradRowsHeight > 0)
{
// PowerVR needs an extra little update to the gradient texture to help
// with synchronization.
glActiveTexture(GL_TEXTURE0 + kPLSTexIdxOffset + GRAD_TEXTURE_IDX);
uint32_t nullData = 0;
glTexSubImage2D(GL_TEXTURE_2D,
0,
0,
0,
1,
1,
GL_RGBA,
GL_UNSIGNED_BYTE,
&nullData);
}

// Render the complex color ramps into the gradient texture.
if (desc.complexGradSpanCount > 0)
{
Expand All @@ -1089,29 +1121,19 @@ void RenderContextGLImpl::flush(const FlushDescriptor& desc)
glBindFramebuffer(GL_FRAMEBUFFER, m_colorRampFBO);
m_state->bindProgram(m_colorRampProgram);
GLenum colorAttachment0 = GL_COLOR_ATTACHMENT0;
glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, &colorAttachment0);
glInvalidateSubFramebuffer(GL_FRAMEBUFFER,
1,
&colorAttachment0,
0,
desc.complexGradRowsTop,
kGradTextureWidth,
desc.complexGradRowsHeight);
glDrawArraysInstanced(GL_TRIANGLE_STRIP,
0,
4,
desc.complexGradSpanCount);
}

// Copy the simple color ramps to the gradient texture.
if (desc.simpleGradTexelsHeight > 0)
{
glActiveTexture(GL_TEXTURE0 + kPLSTexIdxOffset + GRAD_TEXTURE_IDX);
glTexSubImage2D(GL_TEXTURE_2D,
0,
0,
0,
desc.simpleGradTexelsWidth,
desc.simpleGradTexelsHeight,
GL_RGBA,
GL_UNSIGNED_BYTE,
heap_buffer_contents(simpleColorRampsBufferRing()) +
desc.simpleGradDataOffsetInBytes);
}

// Tessellate all curves into vertices in the tessellation texture.
if (desc.tessVertexSpanCount > 0)
{
Expand Down Expand Up @@ -1997,6 +2019,7 @@ std::unique_ptr<RenderContext> RenderContextGLImpl::MakeContext(
#endif
const char* rendererString =
reinterpret_cast<const char*>(glGetString(rendererToken));
capabilities.isPowerVR = strstr(rendererString, "PowerVR");
if (strstr(rendererString, "Direct3D") != nullptr)
{
// Disable ANGLE_base_vertex_base_instance_shader_builtin on ANGLE/D3D.
Expand Down

0 comments on commit dcbab79

Please sign in to comment.