st/nir: Use sampler derefs in built-in shaders.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 6 Feb 2019 03:24:16 +0000 (19:24 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 12 Feb 2019 05:34:38 +0000 (21:34 -0800)
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_pbo.c

index 881655003c413760654dfe89750f49cc1c32e9fd..119f018cd0b3d9d3b5696666d8d245affa2b421c 100644 (file)
@@ -118,16 +118,21 @@ sample_via_nir(nir_builder *b, nir_variable *texcoord,
    nir_variable *var =
       nir_variable_create(b->shader, nir_var_uniform, sampler2D, name);
    var->data.binding = sampler;
+   var->data.explicit_binding = true;
 
-   nir_tex_instr *tex = nir_tex_instr_create(b->shader, 1);
+   nir_deref_instr *deref = nir_build_deref_var(b, var);
+
+   nir_tex_instr *tex = nir_tex_instr_create(b->shader, 3);
    tex->op = nir_texop_tex;
    tex->sampler_dim = GLSL_SAMPLER_DIM_2D;
    tex->coord_components = 2;
-   tex->sampler_index = sampler;
-   tex->texture_index = sampler;
    tex->dest_type = nir_type_float;
-   tex->src[0].src_type = nir_tex_src_coord;
-   tex->src[0].src =
+   tex->src[0].src_type = nir_tex_src_texture_deref;
+   tex->src[0].src = nir_src_for_ssa(&deref->dest.ssa);
+   tex->src[1].src_type = nir_tex_src_sampler_deref;
+   tex->src[1].src = nir_src_for_ssa(&deref->dest.ssa);
+   tex->src[2].src_type = nir_tex_src_coord;
+   tex->src[2].src =
       nir_src_for_ssa(nir_channels(b, nir_load_var(b, texcoord),
                                    (1 << tex->coord_components) - 1));
 
index 6d530f073dd7d3d399306c6dfac8857ea86d9160..9b3628c0ddb903ace7d2a6cb900e0abaa8c81f2b 100644 (file)
@@ -513,14 +513,23 @@ create_fs_nir(struct st_context *st,
    nir_variable *tex_var =
       nir_variable_create(b.shader, nir_var_uniform,
                           sampler_type_for_target(target), "tex");
-   nir_tex_instr *tex = nir_tex_instr_create(b.shader, 1);
+   tex_var->data.explicit_binding = true;
+   tex_var->data.binding = 0;
+
+   nir_deref_instr *tex_deref = nir_build_deref_var(&b, tex_var);
+
+   nir_tex_instr *tex = nir_tex_instr_create(b.shader, 3);
    tex->op = nir_texop_txf;
    tex->sampler_dim = glsl_get_sampler_dim(tex_var->type);
    tex->coord_components =
       glsl_get_sampler_coordinate_components(tex_var->type);
    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_type = nir_tex_src_texture_deref;
+   tex->src[0].src = nir_src_for_ssa(&tex_deref->dest.ssa);
+   tex->src[1].src_type = nir_tex_src_sampler_deref;
+   tex->src[1].src = nir_src_for_ssa(&tex_deref->dest.ssa);
+   tex->src[2].src_type = nir_tex_src_coord;
+   tex->src[2].src = nir_src_for_ssa(texcoord);
    nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32, NULL);
    nir_builder_instr_insert(&b, &tex->instr);
    nir_ssa_def *result = &tex->dest.ssa;
@@ -536,6 +545,8 @@ create_fs_nir(struct st_context *st,
                              glsl_image_type(GLSL_SAMPLER_DIM_BUF, false,
                                              GLSL_TYPE_FLOAT), "img");
       img_var->data.image.access = ACCESS_NON_READABLE;
+      img_var->data.explicit_binding = true;
+      img_var->data.binding = 0;
       nir_deref_instr *img_deref = nir_build_deref_var(&b, img_var);
       nir_intrinsic_instr *intrin =
          nir_intrinsic_instr_create(b.shader, nir_intrinsic_image_deref_store);