From 1841dd7549c20c850e61503fba90ac1319370fb7 Mon Sep 17 00:00:00 2001 From: Konstantin Seurer Date: Fri, 28 Apr 2023 11:27:52 +0200 Subject: [PATCH] gallivm: Add lp_img_op_from_intrinsic Reviewed-by: Dave Airlie Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_nir.c | 37 +++++++++++++++++++++++++++--- src/gallium/auxiliary/gallivm/lp_bld_nir.h | 3 +++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index a28ad07..db12c0f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -1705,6 +1705,37 @@ lp_translate_atomic_op(nir_atomic_op op) } } +void +lp_img_op_from_intrinsic(struct lp_img_params *params, nir_intrinsic_instr *instr) +{ + if (instr->intrinsic == nir_intrinsic_image_load || + instr->intrinsic == nir_intrinsic_bindless_image_load) { + params->img_op = LP_IMG_LOAD; + return; + } + + if (instr->intrinsic == nir_intrinsic_image_store || + instr->intrinsic == nir_intrinsic_bindless_image_store) { + params->img_op = LP_IMG_STORE; + return; + } + + if (instr->intrinsic == nir_intrinsic_image_atomic_swap || + instr->intrinsic == nir_intrinsic_bindless_image_atomic_swap) { + params->img_op = LP_IMG_ATOMIC_CAS; + return; + } + + if (instr->intrinsic == nir_intrinsic_image_atomic || + instr->intrinsic == nir_intrinsic_bindless_image_atomic) { + params->img_op = LP_IMG_ATOMIC; + params->op = lp_translate_atomic_op(nir_intrinsic_atomic_op(instr)); + } else { + params->img_op = -1; + } +} + + static void visit_atomic_image(struct lp_build_nir_context *bld_base, nir_intrinsic_instr *instr, @@ -1719,9 +1750,6 @@ visit_atomic_image(struct lp_build_nir_context *bld_base, memset(¶ms, 0, sizeof(params)); - if (instr->intrinsic != nir_intrinsic_image_atomic_swap) - params.op = lp_translate_atomic_op(nir_intrinsic_atomic_op(instr)); - params.target = glsl_sampler_to_pipe(nir_intrinsic_image_dim(instr), nir_intrinsic_image_array(instr)); for (unsigned i = 0; i < 4; i++) { @@ -1744,6 +1772,9 @@ visit_atomic_image(struct lp_build_nir_context *bld_base, } params.outdata = result; + + lp_img_op_from_intrinsic(¶ms, instr); + params.img_op = (instr->intrinsic == nir_intrinsic_image_atomic_swap) ? LP_IMG_ATOMIC_CAS : LP_IMG_ATOMIC; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.h b/src/gallium/auxiliary/gallivm/lp_bld_nir.h index 3b04dfd..8884c9e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.h @@ -377,4 +377,7 @@ uint32_t lp_build_nir_sample_key(gl_shader_stage stage, nir_tex_instr *instr); +void lp_img_op_from_intrinsic(struct lp_img_params *params, nir_intrinsic_instr *instr); + + #endif -- 2.7.4