From: Dave Airlie Date: Fri, 27 Mar 2020 04:49:37 +0000 (+1000) Subject: gallivm/nir: add texture unit indexing X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9172e405ef656fb26140237395abc54d9ac97e30;p=mesa.git gallivm/nir: add texture unit indexing This hooks up the index from NIR into the sampler code. Reviewed-by: Roland Scheidegger Part-of: --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index 09b1068663c..734e0098f14 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -1521,12 +1521,15 @@ static void visit_txs(struct lp_build_nir_context *bld_base, nir_tex_instr *inst struct lp_sampler_size_query_params params = { 0 }; LLVMValueRef sizes_out[NIR_MAX_VEC_COMPONENTS]; LLVMValueRef explicit_lod = NULL; - + LLVMValueRef texture_unit_offset = NULL; for (unsigned i = 0; i < instr->num_srcs; i++) { switch (instr->src[i].src_type) { case nir_tex_src_lod: explicit_lod = cast_type(bld_base, get_src(bld_base, instr->src[i].src), nir_type_int, 32); break; + case nir_tex_src_texture_offset: + texture_unit_offset = get_src(bld_base, instr->src[i].src); + break; default: break; } @@ -1538,6 +1541,7 @@ static void visit_txs(struct lp_build_nir_context *bld_base, nir_tex_instr *inst params.is_sviewinfo = TRUE; params.sizes_out = sizes_out; params.samples_only = (instr->op == nir_texop_texture_samples); + params.texture_unit_offset = texture_unit_offset; if (instr->op == nir_texop_query_levels) params.explicit_lod = bld_base->uint_bld.zero; @@ -1575,6 +1579,7 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst unsigned sample_key = 0; nir_deref_instr *texture_deref_instr = NULL; nir_deref_instr *sampler_deref_instr = NULL; + LLVMValueRef texture_unit_offset = NULL; LLVMValueRef texel[NIR_MAX_VEC_COMPONENTS]; unsigned lod_src = 0; LLVMValueRef coord_undef = LLVMGetUndef(bld_base->base.int_vec_type); @@ -1687,6 +1692,12 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst sample_key |= LP_SAMPLER_FETCH_MS; ms_index = cast_type(bld_base, get_src(bld_base, instr->src[i].src), nir_type_int, 32); break; + + case nir_tex_src_texture_offset: + texture_unit_offset = get_src(bld_base, instr->src[i].src); + break; + case nir_tex_src_sampler_offset: + break; default: assert(0); break; @@ -1743,6 +1754,7 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst params.sample_key = sample_key; params.offsets = offsets; params.texture_index = base_index; + params.texture_index_offset = texture_unit_offset; params.sampler_index = base_index; params.coords = coords; params.texel = texel; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c index 3cefcdb6614..9c8b5221888 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c @@ -1296,6 +1296,10 @@ static void emit_tex(struct lp_build_nir_context *bld_base, params->context_ptr = bld->context_ptr; params->thread_data_ptr = bld->thread_data_ptr; + if (params->texture_index_offset) + params->texture_index_offset = LLVMBuildExtractElement(bld_base->base.gallivm->builder, + params->texture_index_offset, + lp_build_const_int32(bld_base->base.gallivm, 0), ""); bld->sampler->emit_tex_sample(bld->sampler, bld->bld_base.base.gallivm, params); @@ -1309,6 +1313,10 @@ static void emit_tex_size(struct lp_build_nir_context *bld_base, params->int_type = bld_base->int_bld.type; params->context_ptr = bld->context_ptr; + if (params->texture_unit_offset) + params->texture_unit_offset = LLVMBuildExtractElement(bld_base->base.gallivm->builder, + params->texture_unit_offset, + lp_build_const_int32(bld_base->base.gallivm, 0), ""); bld->sampler->emit_size_query(bld->sampler, bld->bld_base.base.gallivm, params);