nak: Set .NODEP on tex ops based on nir_opt_tex_skip_helpers()

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33402>
This commit is contained in:
Faith Ekstrand 2025-02-05 06:24:13 -06:00 committed by Marge Bot
parent a65009e808
commit 47ca264dc2
7 changed files with 54 additions and 18 deletions

View file

@ -1812,6 +1812,7 @@ impl<'a> ShaderFromNir<'a> {
tex: tex_ref,
src: src,
query: TexQuery::Dimension,
nodep: flags.nodep(),
mask: mask,
});
} else if tex.op == nir_texop_tex_type_nv {
@ -1822,6 +1823,7 @@ impl<'a> ShaderFromNir<'a> {
tex: tex_ref,
src: src,
query: TexQuery::TextureType,
nodep: flags.nodep(),
mask: mask,
});
} else {
@ -1862,6 +1864,7 @@ impl<'a> ShaderFromNir<'a> {
dim: dim,
offset: offset_mode == Tld4OffsetMode::AddOffI,
mem_eviction_priority: MemEvictionPriority::Normal,
nodep: flags.nodep(),
mask: mask,
});
} else if tex.op == nir_texop_lod {
@ -1871,6 +1874,7 @@ impl<'a> ShaderFromNir<'a> {
tex: tex_ref,
srcs: srcs,
dim: dim,
nodep: flags.nodep(),
mask: mask,
});
} else if tex.op == nir_texop_txf || tex.op == nir_texop_txf_ms {
@ -1885,6 +1889,7 @@ impl<'a> ShaderFromNir<'a> {
is_ms: tex.op == nir_texop_txf_ms,
offset: offset_mode == Tld4OffsetMode::AddOffI,
mem_eviction_priority: MemEvictionPriority::Normal,
nodep: flags.nodep(),
mask: mask,
});
} else if tex.op == nir_texop_tg4 {
@ -1898,6 +1903,7 @@ impl<'a> ShaderFromNir<'a> {
offset_mode: offset_mode,
z_cmpr: flags.has_z_cmpr(),
mem_eviction_priority: MemEvictionPriority::Normal,
nodep: flags.nodep(),
mask: mask,
});
} else {
@ -1912,6 +1918,7 @@ impl<'a> ShaderFromNir<'a> {
z_cmpr: flags.has_z_cmpr(),
offset: offset_mode == Tld4OffsetMode::AddOffI,
mem_eviction_priority: MemEvictionPriority::Normal,
nodep: flags.nodep(),
mask: mask,
});
}

View file

@ -4836,6 +4836,7 @@ pub struct OpTex {
pub z_cmpr: bool,
pub offset: bool,
pub mem_eviction_priority: MemEvictionPriority,
pub nodep: bool,
pub mask: u8,
}
@ -4852,6 +4853,9 @@ impl DisplayOp for OpTex {
write!(f, ".dc")?;
}
write!(f, "{}", self.mem_eviction_priority)?;
if self.nodep {
write!(f, ".nodep")?;
}
write!(f, " {} {} {}", self.tex, self.srcs[0], self.srcs[1])
}
}
@ -4873,6 +4877,7 @@ pub struct OpTld {
pub lod_mode: TexLodMode,
pub offset: bool,
pub mem_eviction_priority: MemEvictionPriority,
pub nodep: bool,
pub mask: u8,
}
@ -4889,6 +4894,9 @@ impl DisplayOp for OpTld {
write!(f, ".ms")?;
}
write!(f, "{}", self.mem_eviction_priority)?;
if self.nodep {
write!(f, ".nodep")?;
}
write!(f, " {} {} {}", self.tex, self.srcs[0], self.srcs[1])
}
}
@ -4910,6 +4918,7 @@ pub struct OpTld4 {
pub offset_mode: Tld4OffsetMode,
pub z_cmpr: bool,
pub mem_eviction_priority: MemEvictionPriority,
pub nodep: bool,
pub mask: u8,
}
@ -4923,6 +4932,9 @@ impl DisplayOp for OpTld4 {
write!(f, ".dc")?;
}
write!(f, "{}", self.mem_eviction_priority)?;
if self.nodep {
write!(f, ".nodep")?;
}
write!(f, " {} {} {}", self.tex, self.srcs[0], self.srcs[1])
}
}
@ -4939,16 +4951,17 @@ pub struct OpTmml {
pub srcs: [Src; 2],
pub dim: TexDim,
pub nodep: bool,
pub mask: u8,
}
impl DisplayOp for OpTmml {
fn fmt_op(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"tmml.lod{} {} {} {}",
self.dim, self.tex, self.srcs[0], self.srcs[1]
)
write!(f, "tmml.lod{}", self.dim)?;
if self.nodep {
write!(f, ".nodep")?;
}
write!(f, " {} {} {}", self.tex, self.srcs[0], self.srcs[1])
}
}
impl_display_for_op!(OpTmml);
@ -4967,6 +4980,7 @@ pub struct OpTxd {
pub dim: TexDim,
pub offset: bool,
pub mem_eviction_priority: MemEvictionPriority,
pub nodep: bool,
pub mask: u8,
}
@ -4977,6 +4991,9 @@ impl DisplayOp for OpTxd {
write!(f, ".aoffi")?;
}
write!(f, "{}", self.mem_eviction_priority)?;
if self.nodep {
write!(f, ".nodep")?;
}
write!(f, " {} {} {}", self.tex, self.srcs[0], self.srcs[1])
}
}
@ -4993,12 +5010,17 @@ pub struct OpTxq {
pub src: Src,
pub query: TexQuery,
pub nodep: bool,
pub mask: u8,
}
impl DisplayOp for OpTxq {
fn fmt_op(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "txq {} {} {}", self.tex, self.src, self.query)
write!(f, "txq")?;
if self.nodep {
write!(f, ".nodep")?;
}
write!(f, " {} {} {}", self.tex, self.src, self.query)
}
}
impl_display_for_op!(OpTxq);

View file

@ -2087,7 +2087,7 @@ impl SM50Op for OpTex {
e.set_tex_dim(28..31, self.dim);
e.set_field(31..35, self.mask);
e.set_bit(35, false); // ToDo: NDV
e.set_bit(49, false); // TODO: .NODEP
e.set_bit(49, self.nodep);
e.set_bit(50, self.z_cmpr);
}
}
@ -2120,7 +2120,7 @@ impl SM50Op for OpTld {
e.set_tex_dim(28..31, self.dim);
e.set_field(31..35, self.mask);
e.set_bit(35, self.offset);
e.set_bit(49, false); // TODO: .NODEP
e.set_bit(49, self.nodep);
e.set_bit(50, self.is_ms);
assert!(
@ -2168,7 +2168,7 @@ impl SM50Op for OpTld4 {
e.set_tex_dim(28..31, self.dim);
e.set_field(31..35, self.mask);
e.set_bit(35, false); // ToDo: NDV
e.set_bit(49, false); // TODO: .NODEP
e.set_bit(49, self.nodep);
e.set_bit(50, self.z_cmpr);
}
}
@ -2200,7 +2200,7 @@ impl SM50Op for OpTmml {
e.set_tex_dim(28..31, self.dim);
e.set_field(31..35, self.mask);
e.set_bit(35, false); // ToDo: NDV
e.set_bit(49, false); // TODO: .NODEP
e.set_bit(49, self.nodep);
}
}
@ -2232,7 +2232,7 @@ impl SM50Op for OpTxd {
e.set_tex_dim(28..31, self.dim);
e.set_field(31..35, self.mask);
e.set_bit(35, self.offset);
e.set_bit(49, false); // TODO: .NODEP
e.set_bit(49, self.nodep);
}
}
@ -2272,7 +2272,7 @@ impl SM50Op for OpTxq {
},
);
e.set_field(31..35, self.mask);
e.set_bit(49, false); // TODO: .NODEP
e.set_bit(49, self.nodep);
}
}

View file

@ -2485,7 +2485,7 @@ impl SM70Op for OpTex {
e.set_bit(78, self.z_cmpr);
e.set_eviction_priority(&self.mem_eviction_priority);
e.set_tex_lod_mode(87..90, self.lod_mode);
e.set_bit(90, false); // TODO: .NODEP
e.set_bit(90, self.nodep);
}
}
@ -2532,7 +2532,7 @@ impl SM70Op for OpTld {
);
e.set_eviction_priority(&self.mem_eviction_priority);
e.set_tex_lod_mode(87..90, self.lod_mode);
e.set_bit(90, false); // TODO: .NODEP
e.set_bit(90, self.nodep);
}
}
@ -2581,7 +2581,7 @@ impl SM70Op for OpTld4 {
e.set_bit(78, self.z_cmpr);
e.set_eviction_priority(&self.mem_eviction_priority);
e.set_field(87..89, self.comp);
e.set_bit(90, false); // TODO: .NODEP
e.set_bit(90, self.nodep);
}
}
@ -2618,7 +2618,7 @@ impl SM70Op for OpTmml {
e.set_tex_dim(61..64, self.dim);
e.set_field(72..76, self.mask);
e.set_bit(77, false); // ToDo: NDV
e.set_bit(90, false); // TODO: .NODEP
e.set_bit(90, self.nodep);
}
}
@ -2658,7 +2658,7 @@ impl SM70Op for OpTxd {
e.set_bit(76, self.offset);
e.set_bit(77, false); // ToDo: NDV
e.set_eviction_priority(&self.mem_eviction_priority);
e.set_bit(90, false); // TODO: .NODEP
e.set_bit(90, self.nodep);
}
}
@ -2699,6 +2699,7 @@ impl SM70Op for OpTxq {
},
);
e.set_field(72..76, self.mask);
e.set_bit(90, self.nodep);
}
}

View file

@ -972,6 +972,10 @@ nak_postprocess_nir(nir_shader *nir,
nak_optimize_nir(nir, nak);
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
nir_divergence_analysis(nir);
OPT(nir, nir_opt_tex_skip_helpers, true);
}
OPT(nir, nak_nir_lower_tex, nak);
OPT(nir, nir_lower_idiv, NULL);

View file

@ -250,6 +250,7 @@ lower_tex(nir_builder *b, nir_tex_instr *tex, const struct nak_compiler *nak)
.offset_mode = offset_mode,
.has_z_cmpr = tex->is_shadow,
.is_sparse = tex->is_sparse,
.nodep = tex->skip_helpers,
};
STATIC_ASSERT(sizeof(flags) == sizeof(tex->backend_flags));
memcpy(&tex->backend_flags, &flags, sizeof(flags));

View file

@ -184,7 +184,8 @@ struct nak_nir_tex_flags {
enum nak_nir_offset_mode offset_mode:2;
bool has_z_cmpr:1;
bool is_sparse:1;
uint32_t pad:23;
bool nodep:1;
uint32_t pad:22;
};
PRAGMA_DIAGNOSTIC_POP
static_assert(sizeof(struct nak_nir_tex_flags) == 4,