nir/conditional_if: Properly use the builder
[mesa.git] / src / compiler / nir / nir_lower_drawpixels.c
index 7ffaa525b5a4b4949189449728a1092af2625c38..51c52d038c7e6f0b3e9f63fd156cf8044de729ff 100644 (file)
@@ -134,6 +134,7 @@ lower_color(lower_drawpixels_state *state, nir_intrinsic_instr *intr)
    tex->sampler_index = state->options->drawpix_sampler;
    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);
 
    nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32, NULL);
@@ -161,6 +162,7 @@ lower_color(lower_drawpixels_state *state, nir_intrinsic_instr *intr)
       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_swizzle(b, def, swiz_xy, 2, true));
 
       nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32, NULL);
@@ -174,6 +176,7 @@ lower_color(lower_drawpixels_state *state, nir_intrinsic_instr *intr)
       tex->coord_components = 2;
       tex->sampler_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_swizzle(b, def, swiz_zw, 2, true));
 
       nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32, NULL);
@@ -194,6 +197,8 @@ lower_color(lower_drawpixels_state *state, nir_intrinsic_instr *intr)
 static void
 lower_texcoord(lower_drawpixels_state *state, nir_intrinsic_instr *intr)
 {
+   state->b.cursor = nir_before_instr(&intr->instr);
+
    nir_ssa_def *texcoord_const = get_texcoord_const(state);
    nir_ssa_def_rewrite_uses(&intr->dest.ssa, nir_src_for_ssa(texcoord_const));
 }
@@ -209,7 +214,7 @@ lower_drawpixels_block(lower_drawpixels_state *state, nir_block *block)
             nir_variable *var = dvar->var;
 
             if (var->data.location == VARYING_SLOT_COL0) {
-               /* gl_FragCoord should not have array/struct deref's: */
+               /* gl_Color should not have array/struct deref's: */
                assert(dvar->deref.child == NULL);
                lower_color(state, intr);
             } else if (var->data.location == VARYING_SLOT_TEX0) {