nir,nak: Add a nir_texop_sample_pos_nv and plumb it through

Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36207>
This commit is contained in:
Faith Ekstrand 2025-07-17 12:16:28 -04:00 committed by Marge Bot
parent 3d59f56ab8
commit 9fbb57e0a4
5 changed files with 19 additions and 0 deletions

View file

@ -3237,6 +3237,7 @@ nir_tex_instr_result_size(const nir_tex_instr *instr)
case nir_texop_hdr_dim_nv:
case nir_texop_tex_type_nv:
case nir_texop_sample_pos_nv:
return 4;
case nir_texop_custom_border_color_agx:
@ -3266,6 +3267,7 @@ nir_tex_instr_is_query(const nir_tex_instr *instr)
case nir_texop_has_custom_border_color_agx:
case nir_texop_hdr_dim_nv:
case nir_texop_tex_type_nv:
case nir_texop_sample_pos_nv:
return true;
case nir_texop_tex:
case nir_texop_txb:

View file

@ -2356,6 +2356,8 @@ typedef enum nir_texop {
nir_texop_hdr_dim_nv,
/** Maps to TXQ.TEXTURE_TYPE */
nir_texop_tex_type_nv,
/** Maps to TXQ.SAMPLER_POS */
nir_texop_sample_pos_nv,
} nir_texop;
/** Represents a texture instruction */

View file

@ -1865,6 +1865,9 @@ print_tex_instr(nir_tex_instr *instr, print_state *state)
case nir_texop_tex_type_nv:
fprintf(fp, "tex_type_nv ");
break;
case nir_texop_sample_pos_nv:
fprintf(fp, "sample_pos_nv ");
break;
default:
unreachable("Invalid texture operation");
break;

View file

@ -3508,6 +3508,7 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
break;
case nir_texop_hdr_dim_nv:
case nir_texop_tex_type_nv:
case nir_texop_sample_pos_nv:
vtn_fail("unexpected nir_texop_*_nv");
break;
}

View file

@ -1866,6 +1866,17 @@ impl<'a> ShaderFromNir<'a> {
nodep: flags.nodep(),
channel_mask,
});
} else if tex.op == nir_texop_sample_pos_nv {
let src = self.get_src(&srcs[0].src);
assert!(fault.is_none());
b.push_op(OpTxq {
dsts: dsts,
tex: tex_ref,
src: src,
query: TexQuery::SamplerPos,
nodep: flags.nodep(),
channel_mask,
});
} else {
let lod_mode = match flags.lod_mode() {
NAK_NIR_LOD_MODE_AUTO => TexLodMode::Auto,