Mesa (master): nir: Create sampler2D variables in nir_lower_{bitmap,drawpixels}.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Oct 15 06:36:09 UTC 2018


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Fri Aug 24 01:34:30 2018 -0700

nir: Create sampler2D variables in nir_lower_{bitmap,drawpixels}.

This is needed for nir_gather_info to actually count the new textures,
since it operates solely on variables.

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Dave Airlie <airlied at redhat.com>

---

 src/compiler/nir/nir_lower_bitmap.c     |  7 +++++++
 src/compiler/nir/nir_lower_drawpixels.c | 17 ++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_lower_bitmap.c b/src/compiler/nir/nir_lower_bitmap.c
index a4d9498576..03eb627312 100644
--- a/src/compiler/nir/nir_lower_bitmap.c
+++ b/src/compiler/nir/nir_lower_bitmap.c
@@ -88,6 +88,13 @@ lower_bitmap(nir_shader *shader, nir_builder *b,
 
    texcoord = nir_load_var(b, get_texcoord(shader));
 
+   const struct glsl_type *sampler2D =
+      glsl_sampler_type(GLSL_SAMPLER_DIM_2D, false, false, GLSL_TYPE_FLOAT);
+
+   nir_variable *tex_var =
+      nir_variable_create(shader, nir_var_uniform, sampler2D, "bitmap_tex");
+   tex_var->data.binding = options->sampler;
+
    tex = nir_tex_instr_create(shader, 1);
    tex->op = nir_texop_tex;
    tex->sampler_dim = GLSL_SAMPLER_DIM_2D;
diff --git a/src/compiler/nir/nir_lower_drawpixels.c b/src/compiler/nir/nir_lower_drawpixels.c
index 462b9c308b..99eb646b24 100644
--- a/src/compiler/nir/nir_lower_drawpixels.c
+++ b/src/compiler/nir/nir_lower_drawpixels.c
@@ -35,7 +35,7 @@ typedef struct {
    const nir_lower_drawpixels_options *options;
    nir_shader   *shader;
    nir_builder   b;
-   nir_variable *texcoord, *scale, *bias;
+   nir_variable *texcoord, *scale, *bias, *tex, *pixelmap;
 } lower_drawpixels_state;
 
 static nir_ssa_def *
@@ -125,6 +125,15 @@ lower_color(lower_drawpixels_state *state, nir_intrinsic_instr *intr)
 
    texcoord = get_texcoord(state);
 
+   const struct glsl_type *sampler2D =
+      glsl_sampler_type(GLSL_SAMPLER_DIM_2D, false, false, GLSL_TYPE_FLOAT);
+
+   if (!state->tex) {
+      state->tex =
+         nir_variable_create(b->shader, nir_var_uniform, sampler2D, "drawpix");
+      state->tex->data.binding = state->options->drawpix_sampler;
+   }
+
    /* replace load_var(gl_Color) w/ texture sample:
     *   TEX def, texcoord, drawpix_sampler, 2D
     */
@@ -151,6 +160,12 @@ lower_color(lower_drawpixels_state *state, nir_intrinsic_instr *intr)
    }
 
    if (state->options->pixel_maps) {
+      if (!state->pixelmap) {
+         state->pixelmap = nir_variable_create(b->shader, nir_var_uniform,
+                                               sampler2D, "pixelmap");
+         state->pixelmap->data.binding = state->options->pixelmap_sampler;
+      }
+
       /* do four pixel map look-ups with two TEX instructions: */
       nir_ssa_def *def_xy, *def_zw;
 




More information about the mesa-commit mailing list