zink: avoid incorrect vector-construction
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Fri, 3 Jan 2020 11:22:38 +0000 (12:22 +0100)
committerMarge Bot <eric+marge@anholt.net>
Sat, 18 Jan 2020 10:45:38 +0000 (10:45 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3275>

src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c

index 5ed0d0b..bb916cf 100644 (file)
@@ -1462,7 +1462,7 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
       return;
    }
 
-   if (proj) {
+   if (proj && coord_components > 0) {
       SpvId constituents[coord_components + 1];
       if (coord_components == 1)
          constituents[0] = coord;
@@ -1506,7 +1506,7 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
    spirv_builder_emit_decoration(&ctx->builder, result,
                                  SpvDecorationRelaxedPrecision);
 
-   if (dref) {
+   if (dref && nir_dest_num_components(tex->dest) > 1) {
       SpvId components[4] = { result, result, result, result };
       result = spirv_builder_emit_composite_construct(&ctx->builder,
                                                       dest_type,