nir: Pick just the channels we want for bitmap and drawpixels lowering.
authorEric Anholt <eric@anholt.net>
Wed, 8 Mar 2017 23:20:31 +0000 (15:20 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 2 May 2017 17:24:40 +0000 (10:24 -0700)
NIR now validates that SSA references use the same number of channels as
are in the SSA value.

v2: Reword commit message, since the commit didn't land before the
    validation change did.

Fixes: 370d68babcbb ("nir/validate: Validate that bit sizes and components always match")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> (v1)
Cc: <mesa-stable@lists.freedesktop.org>
src/compiler/nir/nir_lower_bitmap.c
src/compiler/nir/nir_lower_drawpixels.c

index f08fb9b9c346b09b946b9730f1b51cf21ea75d35..a1b4a32a5d4b7af6a69a13e38880107b383855cc 100644 (file)
@@ -96,7 +96,9 @@ lower_bitmap(nir_shader *shader, nir_builder *b,
    tex->texture_index = options->sampler;
    tex->dest_type = nir_type_float;
    tex->src[0].src_type = nir_tex_src_coord;
-   tex->src[0].src = nir_src_for_ssa(texcoord);
+   tex->src[0].src =
+      nir_src_for_ssa(nir_channels(b, texcoord,
+                                   (1 << tex->coord_components) - 1));
 
    nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32, NULL);
    nir_builder_instr_insert(b, &tex->instr);
index e221fd5ce0fec611fe69288e82d4fae88bee6018..c01ae9e2536ad190d8fc776f882600dedf4c1eb3 100644 (file)
@@ -135,7 +135,9 @@ lower_color(lower_drawpixels_state *state, nir_intrinsic_instr *intr)
    tex->texture_index = state->options->drawpix_sampler;
    tex->dest_type = nir_type_float;
    tex->src[0].src_type = nir_tex_src_coord;
-   tex->src[0].src = nir_src_for_ssa(texcoord);
+   tex->src[0].src =
+      nir_src_for_ssa(nir_channels(b, texcoord,
+                                   (1 << tex->coord_components) - 1));
 
    nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32, NULL);
    nir_builder_instr_insert(b, &tex->instr);