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@amd.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12096>
This commit is contained in:
Pierre-Eric Pelloux-Prayer
2021-07-23 18:20:26 +02:00
parent 78b4e417d4
commit ff7e339f1f

View File

@@ -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;