Mesa (main): nir/lower_tex: Add filter for tex offset lowering
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Dec 14 02:25:17 UTC 2021
Module: Mesa
Branch: main
Commit: 211e0606c7805dd1ce870d736681078985d657d7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=211e0606c7805dd1ce870d736681078985d657d7
Author: Jordan Justen <jordan.l.justen at intel.com>
Date: Thu Dec 9 12:55:21 2021 -0800
nir/lower_tex: Add filter for tex offset lowering
Rework:
* Add callback_data (s-b Jason)
Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14142>
---
src/compiler/nir/nir.h | 11 +++++++++++
src/compiler/nir/nir_lower_tex.c | 4 +++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index a177daab7af..2a664c94285 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -4734,6 +4734,12 @@ typedef struct nir_lower_tex_options {
*/
bool lower_rect_offset;
+ /**
+ * If not NULL, this filter will return true for tex instructions that
+ * should lower away nir_tex_src_offset.
+ */
+ nir_instr_filter_cb lower_offset_filter;
+
/**
* If true, lower rect textures to 2D, using txs to fetch the
* texture dimensions and dividing the texture coords by the
@@ -4897,6 +4903,11 @@ typedef struct nir_lower_tex_options {
* absolute values of derivatives is 0 for all coordinates.
*/
bool lower_lod_zero_width;
+
+ /**
+ * Payload data to be sent to callback / filter functions.
+ */
+ void *callback_data;
} nir_lower_tex_options;
/** Lowers complex texture instructions to simpler ones */
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
index d3ff7ca1078..2664925568f 100644
--- a/src/compiler/nir/nir_lower_tex.c
+++ b/src/compiler/nir/nir_lower_tex.c
@@ -1321,7 +1321,9 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
if ((tex->op == nir_texop_txf && options->lower_txf_offset) ||
(sat_mask && nir_tex_instr_src_index(tex, nir_tex_src_coord) >= 0) ||
(tex->sampler_dim == GLSL_SAMPLER_DIM_RECT &&
- options->lower_rect_offset)) {
+ options->lower_rect_offset) ||
+ (options->lower_offset_filter &&
+ options->lower_offset_filter(instr, options->callback_data))) {
progress = lower_offset(b, tex) || progress;
}
More information about the mesa-commit
mailing list