nir/lower_tex: Add filter for tex offset lowering

Rework:
 * Add callback_data (s-b Jason)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14142>
This commit is contained in:
Jordan Justen 2021-12-09 12:55:21 -08:00
parent abace2b8a4
commit 211e0606c7
2 changed files with 14 additions and 1 deletions

View file

@ -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 */

View file

@ -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;
}