Skip to content

Commit 4502bf5

Browse files
weston: handle shader compiler differences across GPU implementations
Weston currently relies on shader compiler optimizations that are not guaranteed across all GPU implementations. When unused YUV shader uniforms are not optimized out, this leads to assertion failures and crashes on some platforms. Backport the upstream fix using a Weston .bbappend to ensure consistent behavior across GPU drivers in Yocto builds, without altering the upstream recipe. Signed-off-by: Mahesh Angadi <mangadi@qti.qualcomm.com>
1 parent b3d953b commit 4502bf5

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
From 5c49563ef49a502a6b8fae44f8778e109d32c2d9 Mon Sep 17 00:00:00 2001
2+
From: Robert Mader <robert.mader@collabora.com>
3+
Date: Mon, 2 Mar 2026 13:11:05 +0100
4+
Subject: [PATCH] gl-shaders: Remove asserts relying on shader compiler
5+
behavior
6+
7+
yuv_coefficients and yuv_offsets should get optimized away by shader
8+
compilers as the related code paths can never be reached. This seems to
9+
work well on Mesa but not necessarily with other drivers.
10+
11+
While on it, assert that the uniforms *are* present, unless the
12+
yuv-to-rgb conversion is handled by the driver.
13+
14+
Upstream-Status: Backport [https://gitlab.freedesktop.org/wayland/weston/-/commit/5c49563ef49a502a6b8fae44f8778e109d32c2d9]
15+
Signed-off-by: Robert Mader <robert.mader@collabora.com>
16+
---
17+
libweston/renderer-gl/gl-shaders.c | 14 ++++++++++++--
18+
1 file changed, 12 insertions(+), 2 deletions(-)
19+
20+
diff --git a/libweston/renderer-gl/gl-shaders.c b/libweston/renderer-gl/gl-shaders.c
21+
index 98041882..18eeedf6 100644
22+
--- a/libweston/renderer-gl/gl-shaders.c
23+
+++ b/libweston/renderer-gl/gl-shaders.c
24+
@@ -762,8 +762,18 @@ gl_shader_load_config_representation(struct weston_compositor *compositor,
25+
26+
if (sconf->yuv_coefficients == WESTON_COLOR_MATRIX_COEF_UNSET ||
27+
sconf->yuv_coefficients == WESTON_COLOR_MATRIX_COEF_IDENTITY) {
28+
- assert(shader->yuv_coefficients_uniform == -1);
29+
- assert(shader->yuv_offsets_uniform == -1);
30+
+ /*
31+
+ * In this case the yuv_coefficients and yuv_offsets uniforms
32+
+ * should never be used and thus get optimized away by the
33+
+ * shader compiler. Unfortunately on some drivers this is not
34+
+ * the case, so we can't assert on it.
35+
+ */
36+
+ return;
37+
+ }
38+
+
39+
+ if (shader->yuv_coefficients_uniform == -1 ||
40+
+ shader->yuv_offsets_uniform == -1) {
41+
+ assert(shader->key.variant == SHADER_VARIANT_EXTERNAL);
42+
return;
43+
}
44+
45+
--
46+
2.34.1
47+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
2+
3+
SRC_URI:append:qcom = " \
4+
file://0001-gl-shaders-Remove-asserts-relying-on-shader-compiler.patch \
5+
"

0 commit comments

Comments
 (0)