Mesa (staging/21.2): st/pbo: only use x coord when reading a PIPE_TEXTURE_1D

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 6 17:27:11 UTC 2021


Module: Mesa
Branch: staging/21.2
Commit: 54ba58e68e2c4094116a56e78e40450f6d28b8a0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=54ba58e68e2c4094116a56e78e40450f6d28b8a0

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Fri Jul 23 18:20:26 2021 +0200

st/pbo: only use x coord when reading a PIPE_TEXTURE_1D

This fixes the following NIR validation error in the
st/pbo download FS:

	vec2 32 ssa_14 = mov ssa_4.xy
	vec2 32 ssa_15 = f2i32 ssa_14
	vec1 32 ssa_16 = deref_var &tex (uniform sampler1D)
	vec4 32 ssa_17 = (float32)txf ssa_16 (texture_deref), ssa_16 (sampler_deref), ssa_15 (coord)
error: nir_src_num_components(instr->src[i].src) == instr->coord_components (../src/compiler/nir/nir_validate.c:839)

With this change, the FS becomes:

	vec4 32 ssa_2 = intrinsic load_frag_coord () ()
	vec1 32 ssa_3 = f2i32 ssa_2.x
	[...]
	vec1 32 ssa_9 = deref_var &tex (uniform sampler1D)
	vec4 32 ssa_10 = (float32)txf ssa_9 (texture_deref), ssa_9 (sampler_deref), ssa_3 (coord), ssa_0 (lod)

Fixes: a01ad311 ("st/mesa: Add NIR versions of the PBO upload/download shaders. ")
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12096>
(cherry picked from commit ff7e339f1fa48b080c82c24a23cf3fc39e29e1c0)

---

 .pick_status.json               | 2 +-
 src/mesa/state_tracker/st_pbo.c | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index 940cf75005a..ff2070b5d84 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -103,7 +103,7 @@
         "description": "st/pbo: only use x coord when reading a PIPE_TEXTURE_1D",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "a01ad3110a92e88f815242b59ad1da6d2623decc"
     },
diff --git a/src/mesa/state_tracker/st_pbo.c b/src/mesa/state_tracker/st_pbo.c
index 31d5fd81084..216549d6d1e 100644
--- a/src/mesa/state_tracker/st_pbo.c
+++ b/src/mesa/state_tracker/st_pbo.c
@@ -483,6 +483,11 @@ create_fs(struct st_context *st, bool download,
    if (download) {
       texcoord = nir_f2i32(&b, nir_channels(&b, coord, TGSI_WRITEMASK_XY));
 
+      if (target == PIPE_TEXTURE_1D) {
+         unsigned sw = 0;
+         texcoord = nir_swizzle(&b, texcoord, &sw, 1);
+      }
+
       if (layer) {
          nir_ssa_def *src_layer = layer;
 



More information about the mesa-commit mailing list