diff --git a/src/nouveau/nil/modifiers.rs b/src/nouveau/nil/modifiers.rs index 9286a26ebc6..722ba0843b7 100644 --- a/src/nouveau/nil/modifiers.rs +++ b/src/nouveau/nil/modifiers.rs @@ -6,7 +6,6 @@ use crate::image::Image; use crate::tiling::{GOBType, Tiling}; use bitview::*; -use nvidia_headers::classes::{cl9097, clc597}; pub const MAX_DRM_FORMAT_MODS: usize = 7; @@ -31,18 +30,6 @@ impl TryFrom for GOBKindVersion { } } -impl GOBKindVersion { - pub fn for_dev(dev: &nil_rs_bindings::nv_device_info) -> GOBKindVersion { - if dev.cls_eng3d >= clc597::TURING_A { - GOBKindVersion::Turing - } else if dev.cls_eng3d >= cl9097::FERMI_A { - GOBKindVersion::Fermi - } else { - GOBKindVersion::G80 - } - } -} - #[repr(u8)] #[derive(Clone, Copy, Eq, PartialEq)] pub enum SectorLayout { @@ -62,9 +49,29 @@ impl TryFrom for SectorLayout { } } -impl SectorLayout { +impl GOBType { + fn supports_modifiers(&self) -> bool { + matches!( + self, + GOBType::Linear | GOBType::Fermi | GOBType::TuringColor2D + ) + } + + fn kind_version(&self) -> GOBKindVersion { + match self { + GOBType::Linear => { + panic!("Linear modifierss are handled elsewhere"); + } + GOBType::Fermi => GOBKindVersion::Fermi, + GOBType::TuringZS => { + panic!("Modifiers are not supported for Z/S images"); + } + GOBType::TuringColor2D => GOBKindVersion::Turing, + } + } + // For now, this always returns desktop, but will be different for Tegra - pub fn for_dev(_dev: &nil_rs_bindings::nv_device_info) -> SectorLayout { + fn sector_layout(&self) -> SectorLayout { SectorLayout::Desktop } } @@ -224,8 +231,11 @@ pub fn drm_format_mods_for_format( } let compression_type = CompressionType::None; - let sector_layout = SectorLayout::for_dev(dev); - let gob_kind_version = GOBKindVersion::for_dev(dev); + let gob_type = GOBType::choose(dev, format); + if !gob_type.supports_modifiers() { + return; + } + let pte_kind = Image::choose_pte_kind(dev, format, 1, false); // We assume bigger tiling is better @@ -234,8 +244,8 @@ pub fn drm_format_mods_for_format( let bl_mod = BlockLinearModifier::block_linear_2d( compression_type, - sector_layout, - gob_kind_version, + gob_type.sector_layout(), + gob_type.kind_version(), pte_kind, height_log2, ); @@ -267,11 +277,16 @@ pub fn drm_format_mod_is_supported( return false; } - if bl_mod.gob_kind_version() != GOBKindVersion::for_dev(dev) { + let gob_type = GOBType::choose(dev, format); + if !gob_type.supports_modifiers() { return false; } - if bl_mod.sector_layout() != SectorLayout::for_dev(dev) { + if bl_mod.gob_kind_version() != gob_type.kind_version() { + return false; + } + + if bl_mod.sector_layout() != gob_type.sector_layout() { return false; }