From 8d09d621373747235d90099adf5bed647090ec97 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 24 Mar 2020 07:47:16 +1000 Subject: [PATCH] gallivm/sample: add num samples query for txqs (v2) v2: add false to the existing users (Roland) Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_nir.c | 1 + src/gallium/auxiliary/gallivm/lp_bld_sample.h | 1 + src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 6 ++++++ src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 1 + 4 files changed, 9 insertions(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index 4944b0f944e..671b2800ebe 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -1472,6 +1472,7 @@ static void visit_txs(struct lp_build_nir_context *bld_base, nir_tex_instr *inst params.explicit_lod = explicit_lod; params.is_sviewinfo = TRUE; params.sizes_out = sizes_out; + params.samples_only = false; if (instr->op == nir_texop_query_levels) params.explicit_lod = bld_base->uint_bld.zero; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index ac47c9e5606..954bce600ec 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -123,6 +123,7 @@ struct lp_sampler_size_query_params unsigned target; LLVMValueRef context_ptr; boolean is_sviewinfo; + bool samples_only; enum lp_sampler_lod_property lod_property; LLVMValueRef explicit_lod; LLVMValueRef *sizes_out; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index ea51ed1f2d0..5b623eda26b 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -3902,6 +3902,12 @@ lp_build_size_query_soa(struct gallivm_state *gallivm, lp_build_context_init(&bld_int_vec4, gallivm, lp_type_int_vec(32, 128)); + if (params->samples_only) { + params->sizes_out[0] = lp_build_broadcast(gallivm, lp_build_vec_type(gallivm, params->int_type), + dynamic_state->num_samples(dynamic_state, gallivm, + context_ptr, texture_unit)); + return; + } if (params->explicit_lod) { /* FIXME: this needs to honor per-element lod */ lod = LLVMBuildExtractElement(gallivm->builder, params->explicit_lod, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index efdce32d2d2..f61d05fded7 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -2644,6 +2644,7 @@ emit_size_query( struct lp_build_tgsi_soa_context *bld, params.lod_property = lod_property; params.explicit_lod = explicit_lod; params.sizes_out = sizes_out; + params.samples_only = false; bld->sampler->emit_size_query(bld->sampler, bld->bld_base.base.gallivm, -- 2.30.2