aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2020-03-24 07:47:56 +1000
committerMarge Bot <[email protected]>2020-05-06 06:20:38 +0000
commitf036643772fca7e2f2070ab83189b695b0977a13 (patch)
tree14b14404304a8084b9eb3fa82f8dae33881bebca /src
parent8d09d621373747235d90099adf5bed647090ec97 (diff)
gallivm/nir: hooks up texture samples queries
Reviewed-by: Roland Scheidegger <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_nir.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
index 671b2800ebe..26303c946b4 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
@@ -1204,6 +1204,21 @@ static void visit_image_size(struct lp_build_nir_context *bld_base,
bld_base->image_size(bld_base, &params);
}
+static void visit_image_samples(struct lp_build_nir_context *bld_base,
+ nir_intrinsic_instr *instr,
+ LLVMValueRef result[NIR_MAX_VEC_COMPONENTS])
+{
+ nir_deref_instr *deref = nir_instr_as_deref(instr->src[0].ssa->parent_instr);
+ nir_variable *var = nir_deref_instr_get_variable(deref);
+ struct lp_sampler_size_query_params params = { 0 };
+ params.texture_unit = var->data.binding;
+ params.target = glsl_sampler_to_pipe(glsl_get_sampler_dim(var->type), glsl_sampler_type_is_array(var->type));
+ params.sizes_out = result;
+ params.samples_only = true;
+
+ bld_base->image_size(bld_base, &params);
+}
+
static void visit_shared_load(struct lp_build_nir_context *bld_base,
nir_intrinsic_instr *instr,
LLVMValueRef result[NIR_MAX_VEC_COMPONENTS])
@@ -1390,6 +1405,9 @@ static void visit_intrinsic(struct lp_build_nir_context *bld_base,
case nir_intrinsic_image_deref_size:
visit_image_size(bld_base, instr, result);
break;
+ case nir_intrinsic_image_deref_samples:
+ visit_image_samples(bld_base, instr, result);
+ break;
case nir_intrinsic_load_shared:
visit_shared_load(bld_base, instr, result);
break;
@@ -1453,7 +1471,7 @@ static void visit_intrinsic(struct lp_build_nir_context *bld_base,
static void visit_txs(struct lp_build_nir_context *bld_base, nir_tex_instr *instr)
{
- struct lp_sampler_size_query_params params;
+ struct lp_sampler_size_query_params params = { 0 };
LLVMValueRef sizes_out[NIR_MAX_VEC_COMPONENTS];
LLVMValueRef explicit_lod = NULL;
@@ -1472,7 +1490,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;
+ params.samples_only = (instr->op == nir_texop_texture_samples);
if (instr->op == nir_texop_query_levels)
params.explicit_lod = bld_base->uint_bld.zero;
@@ -1517,7 +1535,7 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst
memset(&params, 0, sizeof(params));
enum lp_sampler_lod_property lod_property = LP_SAMPLER_LOD_SCALAR;
- if (instr->op == nir_texop_txs || instr->op == nir_texop_query_levels) {
+ if (instr->op == nir_texop_txs || instr->op == nir_texop_query_levels || instr->op == nir_texop_texture_samples) {
visit_txs(bld_base, instr);
return;
}