summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2021-03-19 18:48:53 -0400
committerMarge Bot <eric+marge@anholt.net>2021-03-24 19:07:19 +0000
commit674132dee8057c39b31a9184d2d72891285e2ce1 (patch)
treea8c7b9f63ed2b722bf6815e61eeb19b869ae650c
parent52e7297f9c7927eb9d463b6976e394c760231310 (diff)
compiler/spirv: use undefs when extending image coords
we need 4 components for the nir ops, but swizzling one value to multiple channels like this gets confusing when trying to debug image ops that don't require 4 channels Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9723>
-rw-r--r--src/compiler/spirv/spirv_to_nir.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 270a3a24eea..8c7e90a4d38 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3056,28 +3056,28 @@ fill_common_atomic_sources(struct vtn_builder *b, SpvOp opcode,
}
static nir_ssa_def *
-get_image_coord(struct vtn_builder *b, uint32_t value)
+expand_to_vec4(nir_builder *b, nir_ssa_def *value)
{
- nir_ssa_def *coord = vtn_get_nir_ssa(b, value);
-
- /* The image_load_store intrinsics assume a 4-dim coordinate */
- unsigned swizzle[4];
- for (unsigned i = 0; i < 4; i++)
- swizzle[i] = MIN2(i, coord->num_components - 1);
+ nir_ssa_def *components[4];
+ if (value->num_components == 4)
+ return value;
- return nir_swizzle(&b->nb, coord, swizzle, 4);
+ nir_ssa_def *undef = nir_ssa_undef(b, 1, value->bit_size);
+ for (unsigned i = 0; i < 4; i++) {
+ if (i < value->num_components)
+ components[i] = nir_channel(b, value, i);
+ else
+ components[i] = undef;
+ }
+ return nir_vec(b, components, 4);
}
static nir_ssa_def *
-expand_to_vec4(nir_builder *b, nir_ssa_def *value)
+get_image_coord(struct vtn_builder *b, uint32_t value)
{
- if (value->num_components == 4)
- return value;
-
- unsigned swiz[4];
- for (unsigned i = 0; i < 4; i++)
- swiz[i] = i < value->num_components ? i : 0;
- return nir_swizzle(b, value, swiz, 4);
+ nir_ssa_def *coord = vtn_get_nir_ssa(b, value);
+ /* The image_load_store intrinsics assume a 4-dim coordinate */
+ return expand_to_vec4(&b->nb, coord);
}
static void