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

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


Module: Mesa
Branch: main
Commit: ff7e339f1fa48b080c82c24a23cf3fc39e29e1c0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ff7e339f1fa48b080c82c24a23cf3fc39e29e1c0

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>

---

 src/mesa/state_tracker/st_pbo.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/mesa/state_tracker/st_pbo.c b/src/mesa/state_tracker/st_pbo.c
index 22e0a1e40e1..e185aa8ec5a 100644
--- a/src/mesa/state_tracker/st_pbo.c
+++ b/src/mesa/state_tracker/st_pbo.c
@@ -484,6 +484,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