From: Kenneth Graunke Date: Wed, 6 Feb 2019 03:24:16 +0000 (-0800) Subject: st/nir: Use sampler derefs in built-in shaders. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6a4be25a908f73d1cab8ad33bd26c3f7c9ddf7ca;p=mesa.git st/nir: Use sampler derefs in built-in shaders. Reviewed-by: Eric Anholt --- diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 881655003c4..119f018cd0b 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -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)); diff --git a/src/mesa/state_tracker/st_pbo.c b/src/mesa/state_tracker/st_pbo.c index 6d530f073dd..9b3628c0ddb 100644 --- a/src/mesa/state_tracker/st_pbo.c +++ b/src/mesa/state_tracker/st_pbo.c @@ -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);