Bug 1932416 - Avoid shader miscompile due to if statement on Adreno devices. r=gfx-reviewers,nical

The brush_image shader handles normalized input UV coordinates by
first unnormalizing them if the flag is set, allowing the same logic
to be used subsequently regardless of whether the flag is
set. Unfortunately this appears to cause a miscompilation in the
REPETITION variant of the shader on some Adreno devices. Removing the
additional branch by replacing the if statement with a mix() avoids
the issue.

Differential Revision: https://phabricator.services.mozilla.com/D229796
This commit is contained in:
Jamie Nicol 2024-11-21 15:45:51 +00:00
parent 8ffd3c4e04
commit 5d2a68fda0

View File

@ -170,10 +170,15 @@ void brush_vs(
float perspective_interpolate = (brush_flags & BRUSH_FLAG_PERSPECTIVE_INTERPOLATION) != 0 ? 1.0 : 0.0;
v_perspective.x = perspective_interpolate;
if ((brush_flags & BRUSH_FLAG_NORMALIZED_UVS) != 0) {
uv0 *= texture_size;
uv1 *= texture_size;
}
// We deliberately use mix() here rather than scaling the UVs in an if
// statement. The latter caused issues in the REPETITION variant of this
// shader on some Adreno devices. Perhaps due to the excessive number of
// branches in the repetition code, and this one broke the camel's back?
// See bug 1932416.
vec2 uv_scale = mix(vec2(1.0), texture_size,
bvec2((brush_flags & BRUSH_FLAG_NORMALIZED_UVS) != 0));
uv0 *= uv_scale;
uv1 *= uv_scale;
// Handle case where the UV coords are inverted (e.g. from an
// external image).