Module: Mesa Branch: main Commit: 29c4417fb8c5168e001dd6c0662ee9549217c917 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=29c4417fb8c5168e001dd6c0662ee9549217c917
Author: Faith Ekstrand <[email protected]> Date: Tue Apr 4 15:32:00 2023 -0500 nir: Add a backend_flags field to nir_tex_instr In 9ffd00bcf133 ("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 <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22303> --- src/compiler/nir/nir.h | 6 ++++++ src/compiler/nir/nir_clone.c | 2 ++ src/compiler/nir/nir_instr_set.c | 4 +++- src/compiler/nir/nir_serialize.c | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 6e0a927284c..30fe55177fe 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -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; /** diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c index 8fadc784055..aca2e99a3d5 100644 --- a/src/compiler/nir/nir_clone.c +++ b/src/compiler/nir/nir_clone.c @@ -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; } diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c index 8794e5978e1..040985b3a84 100644 --- a/src/compiler/nir/nir_instr_set.c +++ b/src/compiler/nir/nir_instr_set.c @@ -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; } diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c index 9d5d345c80c..10ca44b9231 100644 --- a/src/compiler/nir/nir_serialize.c +++ b/src/compiler/nir/nir_serialize.c @@ -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));
