nak/from_nir: Make fault an Option<SSAValue>

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34794>
This commit is contained in:
Mel Henning 2025-04-30 17:06:32 -04:00 committed by Marge Bot
parent ddcf0029cd
commit 0ac3296f28
2 changed files with 16 additions and 7 deletions

View file

@ -1827,9 +1827,9 @@ impl<'a> ShaderFromNir<'a> {
}
let fault = if flags.is_sparse() {
b.alloc_ssa(RegFile::Pred).into()
Some(b.alloc_ssa(RegFile::Pred))
} else {
Dst::None
None
};
if tex.op == nir_texop_hdr_dim_nv {
@ -1886,7 +1886,7 @@ impl<'a> ShaderFromNir<'a> {
assert!(!flags.has_z_cmpr());
b.push_op(OpTxd {
dsts: dsts,
fault,
fault: fault.into(),
tex: tex_ref,
srcs: srcs,
dim: dim,
@ -1909,7 +1909,7 @@ impl<'a> ShaderFromNir<'a> {
assert!(offset_mode != Tld4OffsetMode::PerPx);
b.push_op(OpTld {
dsts: dsts,
fault,
fault: fault.into(),
tex: tex_ref,
srcs: srcs,
dim: dim,
@ -1923,7 +1923,7 @@ impl<'a> ShaderFromNir<'a> {
} else if tex.op == nir_texop_tg4 {
b.push_op(OpTld4 {
dsts: dsts,
fault,
fault: fault.into(),
tex: tex_ref,
srcs: srcs,
dim: dim,
@ -1938,7 +1938,7 @@ impl<'a> ShaderFromNir<'a> {
assert!(offset_mode != Tld4OffsetMode::PerPx);
b.push_op(OpTex {
dsts: dsts,
fault,
fault: fault.into(),
tex: tex_ref,
srcs: srcs,
dim: dim,
@ -1956,7 +1956,7 @@ impl<'a> ShaderFromNir<'a> {
let mut nir_dst = Vec::new();
for i in 0..tex.def.num_components() {
if flags.is_sparse() && i == tex.def.num_components - 1 {
let Dst::SSA(fault) = fault else {
let Some(fault) = fault else {
panic!("No fault value for sparse op");
};
nir_dst.push(b.sel(fault.into(), 0.into(), 1.into()));

View file

@ -715,6 +715,15 @@ impl<T: Into<SSARef>> From<T> for Dst {
}
}
impl From<Option<SSAValue>> for Dst {
fn from(ssa: Option<SSAValue>) -> Dst {
match ssa {
Some(ssa) => Dst::SSA(ssa.into()),
None => Dst::None,
}
}
}
impl fmt::Display for Dst {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {