nir: add texops for AGX border colour emulation

AGX has limited border colour hardware. To support full
customBorderColorWithoutFormat semantics, we're forced to emulate in shaders at
a substantial performance penalty. Actually, that's needed just to pass CTS
because of other hardware issues stacking on top of each others... Hooray!

Add the texops we need to facilitate efficient custom border colour lowering.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29179>
This commit is contained in:
Alyssa Rosenzweig 2024-04-27 11:34:19 -04:00 committed by Marge Bot
parent 8b9ed851ec
commit 2912f531a7
5 changed files with 21 additions and 1 deletions

View File

@ -3095,6 +3095,7 @@ nir_tex_instr_result_size(const nir_tex_instr *instr)
case nir_texop_samples_identical:
case nir_texop_fragment_mask_fetch_amd:
case nir_texop_lod_bias_agx:
case nir_texop_has_custom_border_color_agx:
return 1;
case nir_texop_descriptor_amd:
@ -3107,6 +3108,9 @@ nir_tex_instr_result_size(const nir_tex_instr *instr)
case nir_texop_tex_type_nv:
return 4;
case nir_texop_custom_border_color_agx:
return 4;
default:
if (instr->is_shadow && instr->is_new_style_shadow)
return 1;
@ -3126,6 +3130,8 @@ nir_tex_instr_is_query(const nir_tex_instr *instr)
case nir_texop_descriptor_amd:
case nir_texop_sampler_descriptor_amd:
case nir_texop_lod_bias_agx:
case nir_texop_custom_border_color_agx:
case nir_texop_has_custom_border_color_agx:
return true;
case nir_texop_tex:
case nir_texop_txb:

View File

@ -2378,6 +2378,10 @@ typedef enum nir_texop {
nir_texop_sampler_descriptor_amd,
/** Returns the sampler's LOD bias */
nir_texop_lod_bias_agx,
/** Returns a bool indicating that the sampler uses a custom border colour */
nir_texop_has_custom_border_color_agx,
/** Returns the sampler's custom border colour (if has_custom_border_agx) */
nir_texop_custom_border_color_agx,
/** Maps to TXQ.DIMENSION */
nir_texop_hdr_dim_nv,
/** Maps to TXQ.TEXTURE_TYPE */

View File

@ -1732,6 +1732,12 @@ print_tex_instr(nir_tex_instr *instr, print_state *state)
case nir_texop_lod_bias_agx:
fprintf(fp, "lod_bias_agx ");
break;
case nir_texop_has_custom_border_color_agx:
fprintf(fp, "has_custom_border_color_agx ");
break;
case nir_texop_custom_border_color_agx:
fprintf(fp, "custom_border_color_agx ");
break;
case nir_texop_hdr_dim_nv:
fprintf(fp, "hdr_dim_nv ");
break;

View File

@ -852,12 +852,14 @@ validate_tex_instr(nir_tex_instr *instr, validate_state *state)
switch (instr->op) {
case nir_texop_descriptor_amd:
case nir_texop_sampler_descriptor_amd:
case nir_texop_custom_border_color_agx:
break;
case nir_texop_lod:
case nir_texop_lod_bias_agx:
validate_assert(state, nir_alu_type_get_base_type(instr->dest_type) == nir_type_float);
break;
case nir_texop_samples_identical:
case nir_texop_has_custom_border_color_agx:
validate_assert(state, nir_alu_type_get_base_type(instr->dest_type) == nir_type_bool);
break;
case nir_texop_txs:

View File

@ -3199,7 +3199,9 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
vtn_fail("unexpected nir_texop_*descriptor_amd");
break;
case nir_texop_lod_bias_agx:
vtn_fail("unexpected nir_texop_lod_bias_agx");
case nir_texop_custom_border_color_agx:
case nir_texop_has_custom_border_color_agx:
vtn_fail("unexpected nir_texop_*_agx");
break;
case nir_texop_hdr_dim_nv:
case nir_texop_tex_type_nv: