nir: Add a backend_flags field to nir_tex_instr

In 9ffd00bcf1 ("nir_to_tgsi: Pack our tex coords into vec4
nir_tex_src_backend[12]"), Emma added a pair of back-end sources to
nir_tex_instr to allow complex lowering to be done in NIR.  This adds a
tiny bit more hw-specific back-end information that a NIR lowering pass
can communicate to the back-end compiler.

While the opcode contains most of the information needed, some thing
such as the presence of offsets is currently only communicated via the
presence of specific source types in the source list.  This information
is gone when the texture instruction is lowered to back-end sources.
Adding a backend_flags field fixes this by allowing the lowering pass to
communicate a small amount of side-band information if needed.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22303>
This commit is contained in:
Faith Ekstrand
2023-04-04 15:32:00 -05:00
committed by Marge Bot
parent 3954d545ca
commit 29c4417fb8
4 changed files with 13 additions and 1 deletions

View File

@@ -2432,6 +2432,12 @@ typedef struct {
* then the sampler index is given by sampler_index + sampler_offset.
*/
unsigned sampler_index;
/* Back-end specific flags, intended to be used in combination with
* nir_tex_src_backend1/2 to provide additional hw-specific information
* to the back-end compiler.
*/
uint32_t backend_flags;
} nir_tex_instr;
/**

View File

@@ -415,6 +415,8 @@ clone_tex(clone_state *state, const nir_tex_instr *tex)
ntex->texture_non_uniform = tex->texture_non_uniform;
ntex->sampler_non_uniform = tex->sampler_non_uniform;
ntex->backend_flags = tex->backend_flags;
return ntex;
}

View File

@@ -283,6 +283,7 @@ hash_tex(uint32_t hash, const nir_tex_instr *instr)
hash = HASH(hash, instr->sampler_index);
hash = HASH(hash, instr->texture_non_uniform);
hash = HASH(hash, instr->sampler_non_uniform);
hash = HASH(hash, instr->backend_flags);
return hash;
}
@@ -659,7 +660,8 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2)
tex1->is_new_style_shadow != tex2->is_new_style_shadow ||
tex1->component != tex2->component ||
tex1->texture_index != tex2->texture_index ||
tex1->sampler_index != tex2->sampler_index) {
tex1->sampler_index != tex2->sampler_index ||
tex1->backend_flags != tex2->backend_flags) {
return false;
}

View File

@@ -1506,6 +1506,7 @@ write_tex(write_ctx *ctx, const nir_tex_instr *tex)
blob_write_uint32(ctx->blob, tex->texture_index);
blob_write_uint32(ctx->blob, tex->sampler_index);
blob_write_uint32(ctx->blob, tex->backend_flags);
if (tex->op == nir_texop_tg4)
blob_write_bytes(ctx->blob, tex->tg4_offsets, sizeof(tex->tg4_offsets));
@@ -1544,6 +1545,7 @@ read_tex(read_ctx *ctx, union packed_instr header)
tex->op = header.tex.op;
tex->texture_index = blob_read_uint32(ctx->blob);
tex->sampler_index = blob_read_uint32(ctx->blob);
tex->backend_flags = blob_read_uint32(ctx->blob);
if (tex->op == nir_texop_tg4)
blob_copy_bytes(ctx->blob, tex->tg4_offsets, sizeof(tex->tg4_offsets));