[Mesa-dev] [PATCH 2/2] nir/drawpix: add missing samplers for draw pixel lowering.
Dave Airlie
airlied at gmail.com
Mon Oct 15 00:48:08 UTC 2018
From: Dave Airlie <airlied at redhat.com>
The drawpixel lowering references undeclared samplers, but also
missing a texture handle.
---
src/compiler/nir/nir_lower_drawpixels.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/compiler/nir/nir_lower_drawpixels.c b/src/compiler/nir/nir_lower_drawpixels.c
index 462b9c308b2..3e86cc08470 100644
--- a/src/compiler/nir/nir_lower_drawpixels.c
+++ b/src/compiler/nir/nir_lower_drawpixels.c
@@ -66,6 +66,24 @@ get_texcoord(lower_drawpixels_state *state)
return nir_load_var(&state->b, state->texcoord);
}
+static void
+add_samplers(lower_drawpixels_state *state)
+{
+ nir_variable *sampler = nir_variable_create(state->shader,
+ nir_var_uniform,
+ glsl_sampler_type(GLSL_SAMPLER_DIM_2D, false, false, GLSL_TYPE_FLOAT),
+ "s_drawpix");
+ sampler->data.location = state->options->drawpix_sampler;
+
+ if (state->options->pixel_maps) {
+ nir_variable *sampler = nir_variable_create(state->shader,
+ nir_var_uniform,
+ glsl_sampler_type(GLSL_SAMPLER_DIM_2D, false, false, GLSL_TYPE_FLOAT),
+ "s_pixelmap");
+ sampler->data.location = state->options->pixelmap_sampler;
+ }
+}
+
static nir_variable *
create_uniform(nir_shader *shader, const char *name,
const gl_state_index16 state_tokens[STATE_LENGTH])
@@ -123,6 +141,7 @@ lower_color(lower_drawpixels_state *state, nir_intrinsic_instr *intr)
b->cursor = nir_before_instr(&intr->instr);
+ add_samplers(state);
texcoord = get_texcoord(state);
/* replace load_var(gl_Color) w/ texture sample:
@@ -175,6 +194,7 @@ lower_color(lower_drawpixels_state *state, nir_intrinsic_instr *intr)
tex->sampler_dim = GLSL_SAMPLER_DIM_2D;
tex->coord_components = 2;
tex->sampler_index = state->options->pixelmap_sampler;
+ tex->texture_index = state->options->pixelmap_sampler;
tex->dest_type = nir_type_float;
tex->src[0].src_type = nir_tex_src_coord;
tex->src[0].src = nir_src_for_ssa(nir_channels(b, def, 0xc));
--
2.17.2
More information about the mesa-dev
mailing list