gpu: add 6GB VRAM mip dropping, 16GB RAM pool caps/OOM recovery, and clear_air +inf clamp

This commit is contained in:
theme613 committed 2026-11-28 13:19:56 +08:00
1 parent 63b902fe17
commit c9067a7d3f
8 files changed
+366 -51

No files matched your search

+22 -12
View File
@@ -5159,20 +5159,30 @@ fn make_twinned(
}
/// The view `desc` of a texture, of a host copy of its levels from `base`
/// on (`crate::resource::held_only`). What it shows of larger ones, if any,
/// is left out.
/// on (`crate::resource::held_only` / `VICTORY_TEXTURE_DROP_MIPS`). What it
/// shows of larger ones, if any, is left out.
fn from_base(desc: &mut D3D12_SHADER_RESOURCE_VIEW_DESC, base: u32) {
if desc.ViewDimension != D3D12_SRV_DIMENSION_TEXTURE2D {
return;
let shift = |first: &mut u32, levels: &mut u32, clamp: &mut f32| {
let lost = base.saturating_sub(*first);
*first = first.saturating_sub(base);
if *levels != u32::MAX {
*levels = levels.saturating_sub(lost).max(1);
}
*clamp = (*clamp - base as f32).max(0.0);
};
match desc.ViewDimension {
D3D12_SRV_DIMENSION_TEXTURE2D => {
// SAFETY: the member its dimension says.
let t = unsafe { &mut desc.Anonymous.Texture2D };
shift(&mut t.MostDetailedMip, &mut t.MipLevels, &mut t.ResourceMinLODClamp);
}
D3D12_SRV_DIMENSION_TEXTURE2DARRAY => {
// SAFETY: the member its dimension says.
let t = unsafe { &mut desc.Anonymous.Texture2DArray };
shift(&mut t.MostDetailedMip, &mut t.MipLevels, &mut t.ResourceMinLODClamp);
}
_ => {}
}
// SAFETY: the member its dimension says.
let t = unsafe { &mut desc.Anonymous.Texture2D };
let lost = base.saturating_sub(t.MostDetailedMip);
t.MostDetailedMip = t.MostDetailedMip.saturating_sub(base);
if t.MipLevels != u32::MAX {
t.MipLevels = t.MipLevels.saturating_sub(lost).max(1);
}
t.ResourceMinLODClamp = (t.ResourceMinLODClamp - base as f32).max(0.0);
}
/// Writes of a slot with another view of the placed texture it showed,