Mesa (master): nir: Pick just the channels we want for bitmap and drawpixels lowering.

Eric Anholt anholt at kemper.freedesktop.org
Tue May 2 17:28:36 UTC 2017


Module: Mesa
Branch: master
Commit: fba6559a1e76a22135b14490fdf5a6f1de1ae272
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fba6559a1e76a22135b14490fdf5a6f1de1ae272

Author: Eric Anholt <eric at anholt.net>
Date:   Wed Mar  8 15:20:31 2017 -0800

nir: Pick just the channels we want for bitmap and drawpixels lowering.

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 at jlekstrand.net> (v1)
Cc: <mesa-stable at lists.freedesktop.org>

---

 src/compiler/nir/nir_lower_bitmap.c     | 4 +++-
 src/compiler/nir/nir_lower_drawpixels.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/compiler/nir/nir_lower_bitmap.c b/src/compiler/nir/nir_lower_bitmap.c
index f08fb9b9c3..a1b4a32a5d 100644
--- a/src/compiler/nir/nir_lower_bitmap.c
+++ b/src/compiler/nir/nir_lower_bitmap.c
@@ -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);
diff --git a/src/compiler/nir/nir_lower_drawpixels.c b/src/compiler/nir/nir_lower_drawpixels.c
index e221fd5ce0..c01ae9e253 100644
--- a/src/compiler/nir/nir_lower_drawpixels.c
+++ b/src/compiler/nir/nir_lower_drawpixels.c
@@ -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);




More information about the mesa-commit mailing list