From 361a7d245187d7f7aa7c6d63d4162765efc51f67 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Sat, 11 Sep 2021 11:16:16 -0400 Subject: [PATCH] compiler/spirv: add a fail if tex instr coord components aren't dimensional enough this is really hard to pin down later on, so catch it here instead gotta have those dimensions. Reviewed-by: Jason Ekstrand Part-of: --- src/compiler/spirv/spirv_to_nir.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 697af85388e..4b86a10a30a 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -2803,6 +2803,15 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, struct vtn_ssa_value *coord_val = vtn_ssa_value(b, w[idx++]); coord = coord_val->def; + /* From the SPIR-V spec verxion 1.5, rev. 5: + * + * "Coordinate must be a scalar or vector of floating-point type. It + * contains (u[, v] ... [, array layer]) as needed by the definition + * of Sampled Image. It may be a vector larger than needed, but all + * unused components appear after all used components." + */ + vtn_fail_if(coord->num_components < coord_components, + "Coordinate value passed has fewer components than sampler dimensionality."); p->src = nir_src_for_ssa(nir_channels(&b->nb, coord, (1 << coord_components) - 1));