From 0a498a9c760cabf16b6e2fa561bc7c015b82bf95 Mon Sep 17 00:00:00 2001 From: yangjw Date: Thu, 23 Jul 2026 15:53:14 +0800 Subject: [PATCH 1/2] fix(shaders): avoid unused swizzle helper on older Adreno Some older Adreno GLSL compilers silently miscompile non-atomic path shaders when they contain the unused unsigned shifts in swizzle_image_buffer_idx. Restrict the helper to storage-buffer PLS and clockwise-atomic variants. This preserves its WebGPU use and the previous atomic shader behavior while keeping it out of unrelated path shaders. --- renderer/src/shaders/draw_path_common.glsl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/renderer/src/shaders/draw_path_common.glsl b/renderer/src/shaders/draw_path_common.glsl index 7d0220327..c84e76a88 100644 --- a/renderer/src/shaders/draw_path_common.glsl +++ b/renderer/src/shaders/draw_path_common.glsl @@ -862,6 +862,11 @@ INLINE half incremental_clockwise_coverage(half c0, half c1, half paintAlpha) return (c1 - c0) / max(1. - c0 * paintAlpha, EPSILON_FP16_NON_DENORM); } +// Older Adreno GLSL compilers can miscompile non-atomic path shaders when they +// contain the unused unsigned shifts below. Keep this helper in storage-buffer +// PLS and clockwise-atomic variants, where it is used or was already present. +#if defined(@PLS_IMPL_STORAGE_BUFFER) || \ + defined(@RENDER_MODE_CLOCKWISE_ATOMIC) // Converts an x,y image coordinate into a buffer index, swizzling into // BUFFER_IMAGE_TILE_SIZE x BUFFER_IMAGE_TILE_SIZE tiles for better cache // performance. @@ -879,6 +884,7 @@ INLINE uint swizzle_image_buffer_idx(uint2 imageCoord, uint imageWidth) idx += ((imageCoord.y & 0x3u) << 2) + (imageCoord.x & 0x3u); return idx; } +#endif #ifdef @RENDER_MODE_CLOCKWISE_ATOMIC From c6ec882a1b661b93b0b831062caed8976d3e1763 Mon Sep 17 00:00:00 2001 From: yangjw Date: Mon, 3 Aug 2026 15:41:47 +0800 Subject: [PATCH 2/2] fix(shaders): preserve macro token boundaries --- renderer/src/shaders/minify.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/renderer/src/shaders/minify.py b/renderer/src/shaders/minify.py index c01fade10..46f554a18 100644 --- a/renderer/src/shaders/minify.py +++ b/renderer/src/shaders/minify.py @@ -479,7 +479,11 @@ def emit_tokens_to_rewritten_glsl(self, out, *, preserve_exported_switches, call # Adding this calling_token_type != 'DEFINE' prevents us from adding a new line to stringify macros if is_directive and not is_newline and calling_token_type != 'DEFINE': out.write('\n') - elif needs_whitespace and lasttoken_needs_whitespace: + # Mesa 20.3 can merge a function-like macro's expansion with an + # immediately following identifier (e.g. OUT(float2)A -> out float2A). + elif (needs_whitespace and lasttoken_needs_whitespace) or ( + tok.type == "ID" and lasttoken.type == "OP" and lasttoken.value == ")" + ): out.write(' ') # is_newline will be false once we output the token (unless this value otherwise gets