nak: Add OpTexDepBar

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34540>
This commit is contained in:
Lorenzo Rossi 2025-04-17 01:27:33 -05:00 committed by Marge Bot
parent 043995220a
commit b8c7d937fe
3 changed files with 36 additions and 3 deletions

View file

@ -1959,6 +1959,13 @@ impl<'a> ShaderFromNir<'a> {
di += 1;
}
}
if self.sm.sm() < 50 {
// TODO: texbar should be created by calc_instr_deps() and
// should be less conservative than textures_left=0.
// See the old pass: NVC0LegalizePostRA::insertTextureBarriers
b.push_op(OpTexDepBar { textures_left: 0 });
}
self.set_ssa(tex.def.as_def(), nir_dst);
}

View file

@ -5816,6 +5816,25 @@ impl DisplayOp for OpBar {
}
impl_display_for_op!(OpBar);
/// Instruction only used on Kepler(A|B).
/// Kepler has explicit dependency tracking for texture loads.
/// When a texture load is executed, it is put on some kind of FIFO queue
/// for later execution.
/// Before the results of a texture are used we need to wait on the queue,
/// texdepbar waits until the queue has at most `textures_left` elements.
#[repr(C)]
#[derive(SrcsAsSlice, DstsAsSlice)]
pub struct OpTexDepBar {
pub textures_left: i8,
}
impl DisplayOp for OpTexDepBar {
fn fmt_op(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "texdepbar {}", self.textures_left)
}
}
impl_display_for_op!(OpTexDepBar);
#[repr(C)]
#[derive(SrcsAsSlice, DstsAsSlice)]
pub struct OpCS2R {
@ -6535,6 +6554,7 @@ pub enum Op {
Exit(OpExit),
WarpSync(OpWarpSync),
Bar(OpBar),
TexDepBar(OpTexDepBar),
CS2R(OpCS2R),
Isberd(OpIsberd),
Kill(OpKill),
@ -6699,6 +6719,7 @@ impl Op {
// Miscellaneous ops
Op::Bar(_)
| Op::TexDepBar(_)
| Op::CS2R(_)
| Op::Isberd(_)
| Op::Kill(_)
@ -7089,6 +7110,7 @@ impl Instr {
| Op::Exit(_)
| Op::WarpSync(_)
| Op::Bar(_)
| Op::TexDepBar(_)
| Op::RegOut(_)
| Op::Out(_)
| Op::OutFinal(_)

View file

@ -193,9 +193,12 @@ pub fn side_effect_type(op: &Op) -> SideEffect {
Op::Out(_) | Op::OutFinal(_) => SideEffect::Barrier,
// Miscellaneous ops
Op::Bar(_) | Op::CS2R(_) | Op::Isberd(_) | Op::Kill(_) | Op::S2R(_) => {
SideEffect::Barrier
}
Op::Bar(_)
| Op::TexDepBar(_)
| Op::CS2R(_)
| Op::Isberd(_)
| Op::Kill(_)
| Op::S2R(_) => SideEffect::Barrier,
Op::PixLd(_) | Op::Nop(_) | Op::Vote(_) => SideEffect::None,
// Virtual ops
@ -282,6 +285,7 @@ pub fn estimate_variable_latency(sm: u8, op: &Op) -> u32 {
// Miscellaneous ops
Op::Bar(_)
| Op::TexDepBar(_)
| Op::CS2R(_)
| Op::Isberd(_)
| Op::Kill(_)