nil: Add support for Blackwell 8 and 16-bit modifiers

Backport-to: 25.2
Reviewed-by: James Jones <jajones@nvidia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36336>
(cherry picked from commit f1cb63a21d)
This commit is contained in:
Faith Ekstrand 2025-07-23 16:47:16 -04:00 committed by Eric Engestrom
parent 3d594aba56
commit d35aa6f444
2 changed files with 21 additions and 5 deletions

View file

@ -894,7 +894,7 @@
"description": "nil: Add support for Blackwell 8 and 16-bit modifiers",
"nominated": true,
"nomination_type": 4,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -35,6 +35,8 @@ impl TryFrom<u64> for GOBKindVersion {
pub enum SectorLayout {
TegraK1 = 0,
Desktop = 1,
Blackwell8Bpp = 2,
Blackwell16Bpp = 3,
}
impl TryFrom<u64> for SectorLayout {
@ -44,6 +46,8 @@ impl TryFrom<u64> for SectorLayout {
match sector_layout {
0 => Ok(SectorLayout::TegraK1),
1 => Ok(SectorLayout::Desktop),
2 => Ok(SectorLayout::Blackwell8Bpp),
3 => Ok(SectorLayout::Blackwell16Bpp),
_ => Err("Invalid gob/kind version"),
}
}
@ -55,7 +59,7 @@ struct GOBTypeModifierInfo {
sector_layout: SectorLayout,
}
const GOB_TYPE_MODIFIER_INFOS: [GOBTypeModifierInfo; 2] = [
const GOB_TYPE_MODIFIER_INFOS: [GOBTypeModifierInfo; 4] = [
GOBTypeModifierInfo {
gob_type: GOBType::FermiColor,
gob_kind_version: GOBKindVersion::Fermi,
@ -66,6 +70,16 @@ const GOB_TYPE_MODIFIER_INFOS: [GOBTypeModifierInfo; 2] = [
gob_kind_version: GOBKindVersion::Turing,
sector_layout: SectorLayout::Desktop,
},
GOBTypeModifierInfo {
gob_type: GOBType::Blackwell8Bit,
gob_kind_version: GOBKindVersion::Turing,
sector_layout: SectorLayout::Blackwell8Bpp,
},
GOBTypeModifierInfo {
gob_type: GOBType::Blackwell16Bit,
gob_kind_version: GOBKindVersion::Turing,
sector_layout: SectorLayout::Blackwell16Bpp,
},
];
impl GOBType {
@ -144,7 +158,7 @@ impl TryFrom<u64> for BlockLinearModifier {
} else if !bv.get_bit(4) {
Err("modifier is not block linear")
} else if bv.get_bit_range_u64(5..12) != 0
|| bv.get_bit_range_u64(26..56) != 0
|| bv.get_bit_range_u64(28..56) != 0
{
Err("unknown reserved bits")
} else {
@ -167,7 +181,7 @@ impl BlockLinearModifier {
bv.set_bit(4, true); // Must be 1, to indicate block-linear layout.
bv.set_field(12..20, pte_kind);
bv.set_field(20..22, gob_kind_version as u8);
bv.set_field(22..23, sector_layout as u8);
bv.set_field2(22..23, 26..28, sector_layout as u8);
bv.set_field(23..26, compression_type as u8);
bv.set_field(56..64, DRM_FORMAT_MOD_VENDOR_NVIDIA);
BlockLinearModifier { drm_modifier }
@ -190,7 +204,9 @@ impl BlockLinearModifier {
pub fn sector_layout(&self) -> SectorLayout {
let bv = BitView::new(&self.drm_modifier);
bv.get_bit_range_u64(22..23).try_into().unwrap()
(bv.get_bit_range_u64(22..23) | (bv.get_bit_range_u64(26..28) << 1))
.try_into()
.unwrap()
}
pub fn compression_type(&self) -> CompressionType {