From f4ac517cc885ac655422925b4c421ee2261977fd Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Fri, 29 Mar 2024 11:14:19 -0500 Subject: [PATCH] nak: Plumb through LDC modes Part-of: --- src/nouveau/compiler/nak/encode_sm70.rs | 10 +++++++++- src/nouveau/compiler/nak/from_nir.rs | 2 ++ src/nouveau/compiler/nak/ir.rs | 22 +++++++++++++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/nouveau/compiler/nak/encode_sm70.rs b/src/nouveau/compiler/nak/encode_sm70.rs index ae033d5e770..c8aace7f4fb 100644 --- a/src/nouveau/compiler/nak/encode_sm70.rs +++ b/src/nouveau/compiler/nak/encode_sm70.rs @@ -1492,7 +1492,15 @@ impl SM70Instr { ); self.set_mem_type(73..76, op.mem_type); - self.set_field(78..80, 0_u8); // subop + self.set_field( + 78..80, + match op.mode { + LdcMode::Indexed => 0_u8, + LdcMode::IndexedLinear => 1_u8, + LdcMode::IndexedSegmented => 2_u8, + LdcMode::IndexedSegmentedLinear => 3_u8, + }, + ); } fn encode_stg(&mut self, op: &OpSt) { diff --git a/src/nouveau/compiler/nak/from_nir.rs b/src/nouveau/compiler/nak/from_nir.rs index 5874b42f402..44379deb897 100644 --- a/src/nouveau/compiler/nak/from_nir.rs +++ b/src/nouveau/compiler/nak/from_nir.rs @@ -2502,10 +2502,12 @@ impl<'a> ShaderFromNir<'a> { dst: dst.into(), cb: cb.into(), offset: off, + mode: LdcMode::Indexed, mem_type: MemType::from_size(size_B, false), }); } } else { + panic!("Indirect UBO indices not yet supported"); } self.set_dst(&intrin.def, dst); diff --git a/src/nouveau/compiler/nak/ir.rs b/src/nouveau/compiler/nak/ir.rs index 3a3d118caa9..d622d2549df 100644 --- a/src/nouveau/compiler/nak/ir.rs +++ b/src/nouveau/compiler/nak/ir.rs @@ -3811,6 +3811,25 @@ impl DisplayOp for OpLd { } impl_display_for_op!(OpLd); +#[allow(dead_code)] +pub enum LdcMode { + Indexed, + IndexedLinear, + IndexedSegmented, + IndexedSegmentedLinear, +} + +impl fmt::Display for LdcMode { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + LdcMode::Indexed => Ok(()), + LdcMode::IndexedLinear => write!(f, ".il"), + LdcMode::IndexedSegmented => write!(f, ".is"), + LdcMode::IndexedSegmentedLinear => write!(f, ".isl"), + } + } +} + #[repr(C)] #[derive(SrcsAsSlice, DstsAsSlice)] pub struct OpLdc { @@ -3822,6 +3841,7 @@ pub struct OpLdc { #[src_type(GPR)] pub offset: Src, + pub mode: LdcMode, pub mem_type: MemType, } @@ -3830,7 +3850,7 @@ impl DisplayOp for OpLdc { let SrcRef::CBuf(cb) = self.cb.src_ref else { panic!("Not a cbuf"); }; - write!(f, "ldc{} {}[", self.mem_type, cb.buf)?; + write!(f, "ldc{}{} {}[", self.mode, self.mem_type, cb.buf)?; if self.offset.is_zero() { write!(f, "+{:#x}", cb.offset)?; } else if cb.offset == 0 {