Skip to content

Commit

Permalink
Work around Android GL driver bugs that surfaced with the feather change
Browse files Browse the repository at this point in the history
Diffs=
77a886e285 Work around Android GL driver bugs that surfaced with the feather change (#8901)

Co-authored-by: Chris Dalton <[email protected]>
  • Loading branch information
csmartdalton and csmartdalton committed Jan 21, 2025
1 parent 0b8d292 commit 40afae8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
52c045aaf73d9dac513a68c86323c956c0063136
77a886e2855287d72c853d3da89a09db3f139e42
11 changes: 10 additions & 1 deletion renderer/src/gl/render_context_gl_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,16 @@ std::unique_ptr<RenderContext> RenderContextGLImpl::MakeContext(
{
if (capabilities.isContextVersionAtLeast(3, 1))
{
capabilities.ARB_shader_storage_buffer_object = true;
// Don't use storage buffers if we're on Android ANGLE. ANGLE
// doesn't have strong support for 3.1+ functionality, and storage
// buffers get rendering artifacts on Galaxy S22
// (OpenGL Samsung Electronics Co., Ltd.;
// ANGLE (Samsung Xclipse 920) on Vulkan 1.1.179;
// OpenGL ES 3.2 ANGLE git hash: c7c78c41d520).
if (!capabilities.isAndroidANGLE)
{
capabilities.ARB_shader_storage_buffer_object = true;
}
}
}
else
Expand Down
6 changes: 3 additions & 3 deletions renderer/src/shaders/draw_path.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,15 @@ PLS_MAIN(@drawFragmentMain)
if (is_stroke(v_edgeDistance))
{
half fragCoverage;
#if defined(@ENABLE_FEATHER)
#ifdef @ENABLE_FEATHER
if (@ENABLE_FEATHER && is_feathered_stroke(v_edgeDistance))
{
fragCoverage = feathered_stroke_coverage(
v_edgeDistance,
SAMPLED_R16F(@featherTexture, featherSampler));
}
else
#endif
#endif // @ENABLE_FEATHER
{
fragCoverage = min(v_edgeDistance.x, v_edgeDistance.y);
}
Expand All @@ -396,7 +396,7 @@ PLS_MAIN(@drawFragmentMain)
SAMPLED_R16F(@featherTexture, featherSampler));
}
else
#endif
#endif // @CLOCKWISE_FILL && @ENABLE_FEATHER
{
fragCoverage = v_edgeDistance.x;
}
Expand Down
2 changes: 2 additions & 0 deletions renderer/src/shaders/draw_path_common.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ unpack_interior_triangle_vertex(float3 triangleVertex,
#ifdef @FRAGMENT
INLINE bool is_stroke(half2 edgeDistance) { return edgeDistance.y >= .0; }

#ifdef @ENABLE_FEATHER
INLINE bool is_feathered_stroke(half2 edgeDistance)
{
return edgeDistance.x < FEATHER_COVERAGE_THRESHOLD;
Expand Down Expand Up @@ -490,4 +491,5 @@ INLINE half feathered_fill_coverage(half2 edgeDistance,
fragCoverage *= exp2(x);
return fragCoverage;
}
#endif // @ENABLE_FEATHER
#endif // @FRAGMENT
2 changes: 2 additions & 0 deletions renderer/src/shaders/metal/draw.metal
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#undef DRAW_IMAGE
#define DRAW_PATH
#define DRAW_INTERIOR_TRIANGLES
#define ENABLE_FEATHER
#include "draw_path_common.minified.glsl"
#undef ENABLE_FEATHER
#undef DRAW_INTERIOR_TRIANGLES
#undef DRAW_PATH
#undef VERTEX
Expand Down

0 comments on commit 40afae8

Please sign in to comment.