nil: Add GOBType::TegraColor

Reviewed-by: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>
Reviewed-by: Mary Guillemard <mary@mary.zone>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37824>
This commit is contained in:
Faith Ekstrand 2025-10-09 19:58:59 -04:00 committed by Marge Bot
parent 8a758fd38a
commit e88b579f1e
3 changed files with 95 additions and 1 deletions

View file

@ -181,6 +181,54 @@ impl<C: CopyBytes> CopyGOBLines for CopyGOBFermi<C> {
}
}
/// Implements copies for [`GOBType::TegraColor`]
struct CopyGOBTegra<C: CopyBytes> {
phantom: std::marker::PhantomData<C>,
}
impl<C: CopyBytes> CopyGOBLines for CopyGOBTegra<C> {
const GOB_EXTENT_B: Extent4D<units::Bytes> = Extent4D::new(64, 8, 1, 1);
const LINE_WIDTH_B: u32 = 16;
const X_DIVISOR: u32 = C::X_DIVISOR;
unsafe fn copy(tiled: *mut u8, linear: *mut u8, bytes: usize) {
unsafe {
C::copy(tiled, linear, bytes);
}
}
unsafe fn copy_whole_line(tiled: *mut u8, linear: *mut u8) {
unsafe {
C::copy_16b(tiled as *mut _, linear as *mut _);
}
}
#[inline(always)]
fn for_each_gob_line(mut f: impl FnMut(u32, u32, u32, u32)) {
for i in 0..2 {
f(i * 0x100 + 0x00, i * 32 + 0, 0, 0);
f(i * 0x100 + 0x10, i * 32 + 0, 1, 0);
f(i * 0x100 + 0x20, i * 32 + 16, 0, 0);
f(i * 0x100 + 0x30, i * 32 + 16, 1, 0);
f(i * 0x100 + 0x40, i * 32 + 0, 2, 0);
f(i * 0x100 + 0x50, i * 32 + 0, 3, 0);
f(i * 0x100 + 0x60, i * 32 + 16, 2, 0);
f(i * 0x100 + 0x70, i * 32 + 16, 3, 0);
f(i * 0x100 + 0x80, i * 32 + 0, 4, 0);
f(i * 0x100 + 0x90, i * 32 + 0, 5, 0);
f(i * 0x100 + 0xa0, i * 32 + 16, 4, 0);
f(i * 0x100 + 0xb0, i * 32 + 16, 5, 0);
f(i * 0x100 + 0xc0, i * 32 + 0, 6, 0);
f(i * 0x100 + 0xd0, i * 32 + 0, 7, 0);
f(i * 0x100 + 0xe0, i * 32 + 16, 6, 0);
f(i * 0x100 + 0xf0, i * 32 + 16, 7, 0);
}
}
}
/// Implements copies for [`GOBType::TuringColor2D`]
struct CopyGOBTuring2D<C: CopyBytes> {
phantom: std::marker::PhantomData<C>,
@ -676,6 +724,16 @@ pub unsafe extern "C" fn nil_copy_linear_to_tiled(
end_B,
);
}
GOBType::TegraColor => {
copy_tiled::<CopyGOBTegra<RawCopyToTiled>>(
*tiling,
level_extent_B,
tiled_dst,
linear_pointer,
offset_B,
end_B,
);
}
GOBType::FermiColor => {
copy_tiled::<CopyGOBFermi<RawCopyToTiled>>(
*tiling,
@ -745,6 +803,16 @@ pub unsafe extern "C" fn nil_copy_tiled_to_linear(
end_B,
);
}
GOBType::TegraColor => {
copy_tiled::<CopyGOBTegra<RawCopyToLinear>>(
*tiling,
level_extent_B,
tiled_src,
linear_pointer,
offset_B,
end_B,
);
}
GOBType::FermiColor => {
copy_tiled::<CopyGOBFermi<RawCopyToLinear>>(
*tiling,

View file

@ -55,12 +55,17 @@ struct GOBTypeModifierInfo {
sector_layout: SectorLayout,
}
const GOB_TYPE_MODIFIER_INFOS: [GOBTypeModifierInfo; 2] = [
const GOB_TYPE_MODIFIER_INFOS: [GOBTypeModifierInfo; 3] = [
GOBTypeModifierInfo {
gob_type: GOBType::FermiColor,
gob_kind_version: GOBKindVersion::Fermi,
sector_layout: SectorLayout::Desktop,
},
GOBTypeModifierInfo {
gob_type: GOBType::TegraColor,
gob_kind_version: GOBKindVersion::Fermi,
sector_layout: SectorLayout::TegraK1,
},
GOBTypeModifierInfo {
gob_type: GOBType::TuringColor2D,
gob_kind_version: GOBKindVersion::Turing,

View file

@ -40,6 +40,24 @@ pub enum GOBType {
/// `CopyGOBFermi` implements CPU copies for Fermi color GOBs.
FermiColor,
/// The Tegra GOB format for color images
///
/// A `TegraColor` GOB is 512 bytes, arranged in a 64x8 layout and split
/// into Sectors. Each Sector is 32 Bytes, and the Sectors in a GOB are
/// arranged in a 16x2 layout (i.e., two 16B lines on top of each other).
/// It's then arranged into two columns that are 2 sectors by 4, leading to
/// a 4x4 grid of sectors:
///
/// | | | | |
/// |-----------|-----------|-----------|-----------|
/// | Sector 0 | Sector 1 | Sector 8 | Sector 9 |
/// | Sector 2 | Sector 3 | Sector 10 | Sector 11 |
/// | Sector 4 | Sector 5 | Sector 12 | Sector 13 |
/// | Sector 6 | Sector 7 | Sector 14 | Sector 15 |
///
/// `CopyGOBTegra` implements CPU copies for Tegra color GOBs.
TegraColor,
/// The Turing 2D GOB format for color images
///
/// A `TuringColor2D` GOB is 512 bytes, arranged in a 64x8 layout and split
@ -126,6 +144,8 @@ impl GOBType {
} else if dev.cls_eng3d >= cl9097::FERMI_A {
if format.is_depth_or_stencil() {
GOBType::FermiZS
} else if dev.type_ == NV_DEVICE_TYPE_SOC {
GOBType::TegraColor
} else {
GOBType::FermiColor
}
@ -139,6 +159,7 @@ impl GOBType {
GOBType::Linear => Extent4D::new(1, 1, 1, 1),
GOBType::FermiZS
| GOBType::FermiColor
| GOBType::TegraColor
| GOBType::TuringColor2D
| GOBType::Blackwell8Bit
| GOBType::Blackwell16Bit