nir: add nir_tex_src_{sampler,texture}_deref_intrinsic

To be used as a placeholder until after function inlining so we can
replace function params with bindless handles if needed.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30315>
(cherry picked from commit 017770ff14)
This commit is contained in:
Timothy Arceri 2024-07-23 13:04:10 +10:00 committed by Eric Engestrom
parent ecdc6e1cc3
commit 738d009a85
6 changed files with 42 additions and 1 deletions

View file

@ -13824,7 +13824,7 @@
"description": "nir: add nir_tex_src_{sampler,texture}_deref_intrinsic",
"nominated": false,
"nomination_type": 3,
"resolution": 4,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -3221,6 +3221,8 @@ nir_tex_instr_src_type(const nir_tex_instr *instr, unsigned src)
case nir_tex_src_plane:
return nir_type_int;
case nir_tex_src_sampler_deref_intrinsic:
case nir_tex_src_texture_deref_intrinsic:
case nir_tex_src_ms_mcs_intel:
case nir_tex_src_texture_deref:
case nir_tex_src_sampler_deref:

View file

@ -2330,6 +2330,15 @@ typedef enum nir_tex_src_type {
*/
nir_tex_src_sampler_handle,
/** Tex src intrinsic
*
* This is an intrinsic used before function inlining i.e. before we know
* if a bindless value has been given as function param for use as a tex
* src.
*/
nir_tex_src_sampler_deref_intrinsic,
nir_tex_src_texture_deref_intrinsic,
/** Plane index for multi-plane YCbCr textures */
nir_tex_src_plane,

View file

@ -1082,6 +1082,11 @@ intrinsic("load_persp_center_rhw_ir3", dest_comp=1,
intrinsic("load_texture_scale", src_comp=[1], dest_comp=2,
flags=[CAN_ELIMINATE, CAN_REORDER])
# Gets the texture src. This intrinsic will be lowered once functions have
# been inlined and we know if the src is bindless or not.
intrinsic("deref_texture_src", src_comp=[1], dest_comp=1,
flags=[CAN_ELIMINATE, CAN_REORDER])
# Fragment shader input interpolation delta intrinsic.
#
# For hw where fragment shader input interpolation is handled in shader, the

View file

@ -1798,6 +1798,14 @@ print_tex_instr(nir_tex_instr *instr, print_state *state)
case nir_tex_src_ddy:
fprintf(fp, "(ddy)");
break;
case nir_tex_src_sampler_deref_intrinsic:
has_texture_deref = true;
fprintf(fp, "(sampler_deref_intrinsic)");
break;
case nir_tex_src_texture_deref_intrinsic:
has_texture_deref = true;
fprintf(fp, "(texture_deref_intrinsic)");
break;
case nir_tex_src_texture_deref:
has_texture_deref = true;
fprintf(fp, "(texture_deref)");

View file

@ -897,6 +897,23 @@ validate_tex_instr(nir_tex_instr *instr, validate_state *state)
break;
}
case nir_tex_src_sampler_deref_intrinsic:
case nir_tex_src_texture_deref_intrinsic: {
nir_intrinsic_instr *intrin =
nir_instr_as_intrinsic(instr->src[i].src.ssa->parent_instr);
nir_deref_instr *deref =
nir_instr_as_deref(intrin->src[0].ssa->parent_instr);
if (!validate_assert(state, deref))
break;
if (instr->src[i].src_type == nir_tex_src_sampler_deref_intrinsic)
validate_assert(state, glsl_type_is_sampler(deref->type));
else
validate_tex_src_texture_deref(instr, state, deref);
break;
}
case nir_tex_src_coord:
case nir_tex_src_projector:
case nir_tex_src_offset: