nak: add scalar tex encoding support

Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40900>
This commit is contained in:
Karol Herbst 2026-04-11 14:38:35 +02:00 committed by Marge Bot
parent 8c10eab1f3
commit f76e7d8e62
5 changed files with 25 additions and 1 deletions

View file

@ -1950,6 +1950,7 @@ impl<'a> ShaderFromNir<'a> {
assert!(lod_mode == TexLodMode::Auto);
assert!(offset_mode != TexOffsetMode::PerPx);
assert!(!flags.has_z_cmpr());
assert!(!flags.scalar());
b.push_op(OpTxd {
dsts: dsts,
fault: fault.into(),
@ -1964,6 +1965,7 @@ impl<'a> ShaderFromNir<'a> {
} else if tex.op == nir_texop_lod {
assert!(lod_mode == TexLodMode::Auto);
assert!(offset_mode == TexOffsetMode::None);
assert!(!flags.scalar());
b.push_op(OpTmml {
dsts: dsts,
tex: tex_ref,
@ -1987,6 +1989,7 @@ impl<'a> ShaderFromNir<'a> {
mem_eviction_priority: MemEvictionPriority::Normal,
nodep: flags.nodep(),
channel_mask,
scalar: flags.scalar(),
});
} else if tex.op == nir_texop_tg4 {
b.push_op(OpTld4 {
@ -2001,6 +2004,7 @@ impl<'a> ShaderFromNir<'a> {
mem_eviction_priority: MemEvictionPriority::Normal,
nodep: flags.nodep(),
channel_mask,
scalar: flags.scalar(),
});
} else {
assert!(offset_mode != TexOffsetMode::PerPx);
@ -2017,6 +2021,7 @@ impl<'a> ShaderFromNir<'a> {
mem_eviction_priority: MemEvictionPriority::Normal,
nodep: flags.nodep(),
channel_mask,
scalar: flags.scalar(),
});
}
}

View file

@ -5448,6 +5448,7 @@ pub struct OpTex {
pub mem_eviction_priority: MemEvictionPriority,
pub nodep: bool,
pub channel_mask: ChannelMask,
pub scalar: bool,
}
impl DisplayOp for OpTex {
@ -5461,6 +5462,9 @@ impl DisplayOp for OpTex {
write!(f, ".dc")?;
}
write!(f, "{}", self.mem_eviction_priority)?;
if self.scalar {
write!(f, ".scr")?;
}
if self.nodep {
write!(f, ".nodep")?;
}
@ -5488,6 +5492,7 @@ pub struct OpTld {
pub mem_eviction_priority: MemEvictionPriority,
pub nodep: bool,
pub channel_mask: ChannelMask,
pub scalar: bool,
}
impl DisplayOp for OpTld {
@ -5497,6 +5502,9 @@ impl DisplayOp for OpTld {
write!(f, ".ms")?;
}
write!(f, "{}", self.mem_eviction_priority)?;
if self.scalar {
write!(f, ".scr")?;
}
if self.nodep {
write!(f, ".nodep")?;
}
@ -5524,6 +5532,7 @@ pub struct OpTld4 {
pub mem_eviction_priority: MemEvictionPriority,
pub nodep: bool,
pub channel_mask: ChannelMask,
pub scalar: bool,
}
impl DisplayOp for OpTld4 {
@ -5533,6 +5542,9 @@ impl DisplayOp for OpTld4 {
write!(f, ".dc")?;
}
write!(f, "{}", self.mem_eviction_priority)?;
if self.scalar {
write!(f, ".scr")?;
}
if self.nodep {
write!(f, ".nodep")?;
}

View file

@ -506,6 +506,7 @@ pub fn test_texture() {
mem_eviction_priority: MemEvictionPriority::First,
nodep: true,
channel_mask: ChannelMask::for_comps(3),
scalar: false,
};
c.push(
instr,
@ -530,6 +531,7 @@ pub fn test_texture() {
mem_eviction_priority: MemEvictionPriority::First,
nodep: true,
channel_mask: ChannelMask::for_comps(3),
scalar: false,
};
c.push(
instr,
@ -562,6 +564,7 @@ pub fn test_texture() {
mem_eviction_priority: MemEvictionPriority::First,
nodep: true,
channel_mask: ChannelMask::for_comps(3),
scalar: false,
};
c.push(
instr,

View file

@ -2614,6 +2614,7 @@ impl SM70Op for OpTex {
e.set_ureg_src(48..56, &Src::ZERO); // offset
}
e.set_bit(60, self.scalar);
e.set_tex_dim(61..64, self.dim);
e.set_tex_channel_mask(72..76, self.channel_mask);
if e.sm >= 100 {
@ -2694,6 +2695,7 @@ impl SM70Op for OpTld {
} else {
e.set_bit(76, self.offset_mode == TexOffsetMode::AddOffI);
}
e.set_bit(60, self.scalar);
e.set_tex_dim(61..64, self.dim);
e.set_tex_channel_mask(72..76, self.channel_mask);
@ -2757,6 +2759,7 @@ impl SM70Op for OpTld4 {
e.set_ureg_src(48..56, &Src::ZERO); // offset
}
e.set_bit(60, self.scalar);
e.set_tex_dim(61..64, self.dim);
e.set_tex_channel_mask(72..76, self.channel_mask);
e.set_field(

View file

@ -181,7 +181,8 @@ struct nak_nir_tex_flags {
bool has_z_cmpr:1;
bool is_sparse:1;
bool nodep:1;
uint32_t pad:22;
bool scalar:1;
uint32_t pad:21;
};
PRAGMA_DIAGNOSTIC_POP
static_assert(sizeof(struct nak_nir_tex_flags) == 4,