Backport MR #28414 to fix GTK 4 app rendering on rpi (#2269412)

This commit is contained in:
Adam Williamson 2024-03-28 14:03:48 -07:00
parent b676f3ea1f
commit 5c31c47163
2 changed files with 90 additions and 0 deletions

84
28414.patch Normal file
View file

@ -0,0 +1,84 @@
From 4204fc291b6d78507efc3a1ea6ebe3e2065de03c Mon Sep 17 00:00:00 2001
From: Iago Toral Quiroga <itoral@igalia.com>
Date: Wed, 27 Mar 2024 11:02:12 +0100
Subject: [PATCH] v3d: fix GFXH-930 workaround
When we are reading any builtins like VertexID or InstanceID
the hw requires the first attribute to be active. In the
coordinate shader, however, it may have been DCEd, so we need
to detect that case and program a dummy attribute in that
scenario.
Fixes missing window decorations with GTK4+.
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10853
---
src/broadcom/compiler/nir_to_vir.c | 17 +++++++++++++++--
src/gallium/drivers/v3d/v3dx_draw.c | 12 +++++++++++-
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index 265654625017c..f0309935ccc6d 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -2745,8 +2745,21 @@ ntq_emit_load_input(struct v3d_compile *c, nir_intrinsic_instr *instr)
SYSTEM_VALUE_VERTEX_ID)) {
index++;
}
- for (int i = 0; i < offset; i++)
- index += c->vattr_sizes[i];
+
+ for (int i = 0; i < offset; i++) {
+ /* GFXH-930: if any builtins (vid, iid, etc) are read then
+ * attribute 0 must be active (size > 0). When we hit this,
+ * the driver is expected to program attribute 0 to have a
+ * size of 1, so here we need to add that.
+ */
+ if (i == 0 && c->vs_key->is_coord &&
+ c->vattr_sizes[i] == 0 && index > 0) {
+ index++;
+ } else {
+ index += c->vattr_sizes[i];
+ }
+ }
+
index += nir_intrinsic_component(instr);
for (int i = 0; i < instr->num_components; i++) {
struct qreg vpm_offset = vir_uniform_ui(c, index++);
diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c
index 8fb99f735ab0f..163b7a037e6f1 100644
--- a/src/gallium/drivers/v3d/v3dx_draw.c
+++ b/src/gallium/drivers/v3d/v3dx_draw.c
@@ -709,6 +709,9 @@ v3d_emit_gl_shader_state(struct v3d_context *v3d,
}
bool cs_loaded_any = false;
+ const bool cs_uses_builtins = v3d->prog.cs->prog_data.vs->uses_iid ||
+ v3d->prog.cs->prog_data.vs->uses_biid ||
+ v3d->prog.cs->prog_data.vs->uses_vid;
for (int i = 0; i < vtx->num_elements; i++) {
struct pipe_vertex_element *elem = &vtx->pipe[i];
struct pipe_vertex_buffer *vb =
@@ -738,11 +741,18 @@ v3d_emit_gl_shader_state(struct v3d_context *v3d,
* inputs. (Since CS is just dead-code-elimination
* compared to VS, we can't have CS loading but not
* VS).
+ *
+ * Also, if any builtins are loaded, then we always
+ * need the first attribute to be enabled.
*/
if (v3d->prog.cs->prog_data.vs->vattr_sizes[i])
cs_loaded_any = true;
- if (i == vtx->num_elements - 1 && !cs_loaded_any) {
+ if (i == 0 && cs_uses_builtins && !cs_loaded_any) {
+ attr.number_of_values_read_by_coordinate_shader = 1;
+ cs_loaded_any = true;
+ } else if (i == vtx->num_elements - 1 && !cs_loaded_any) {
attr.number_of_values_read_by_coordinate_shader = 1;
+ cs_loaded_any = true;
}
attr.maximum_index = 0xffffff;
}
--
GitLab

View file

@ -81,6 +81,12 @@ Patch10: gnome-shell-glthread-disable.patch
Patch20: 0001-Pass-no-verify-fixpoint-option-to-instcombine-in-LLV.patch Patch20: 0001-Pass-no-verify-fixpoint-option-to-instcombine-in-LLV.patch
Patch21: 0001-winsys-radeon-pass-priv-instead-NULL-to-radeon_bo_ca.patch Patch21: 0001-winsys-radeon-pass-priv-instead-NULL-to-radeon_bo_ca.patch
# Fix broken rendering with new GTK4 renderer on Raspberry Pi
# https://bugzilla.redhat.com/show_bug.cgi?id=2269412
# https://gitlab.freedesktop.org/mesa/mesa/-/issues/10853
# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28414
Patch22: 28414.patch
BuildRequires: meson >= 1.3.0 BuildRequires: meson >= 1.3.0
BuildRequires: gcc BuildRequires: gcc
BuildRequires: gcc-c++ BuildRequires: gcc-c++