Repository navigation
Conversation
Add low-VRAM quality switch LEONIDA_TEXTURE_MIP_DROP (0..3, default 0) to drop top mip level(s) of pure sampled textures at creation time (#6043). - Drops top N mips of pure sampled textures (no RenderTarget, DepthStencil, or UAV) to reduce VRAM consumption by ~75% (drop 1) or ~93.75% (drop 2). - Replaces function-local static guards with constant-initialized std::atomic<int> to avoid thread-safety init guards on guest threads (RT-488). - Automatically scales width, height, and depth dimensions down to a minimum of 1. - Accurately remaps Subresource in Map(), Unmap(), WriteToSubresource(), and ReadFromSubresource(). - In cpu_copy, skips writes to dropped mips (S_OK) and zeroes buffers on read; validates subresource bounds and sentinel against original mip counts. - Remaps SRV MostDetailedMip and adjusts ResourceMinLODClamp down by dropped mips. - Remaps command-list subresources and skips dropped-mip copies (prepare_texture_copy, prepare_resource_copy) and barriers (TransitionBarrier, TextureBarrier). - Adds standalone test suite test_texture_mip_drop.py (22 tests) and test_command_list_mip_skip.py (2 tests). - Adds D3D12 device fixture d3d12_texture_mip_drop_test.cpp validating real D3D12/Vulkan allocations, SRV binding, and readback skip.
|
Tested 87064bf on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300), native Windows: Built at this head with
in the custom-heap block ( |
|
Hi @antikohza, thanks for this pull request. It currently conflicts with AI-assisted (Claude Code, Claude Opus 5.5). |
Fixes: #6043 (original tracking issue #6043 / low-VRAM memory pressure #2375)
What and why
Adds a configurable low-VRAM quality switch
LEONIDA_TEXTURE_MIP_DROP=N(0..3, default 0) to drop top mip level(s) of pure sampled textures at creation time.Width >> drop,Height >> drop,Depth >> drop) with a minimum clamp of 1.MipLevels - dropin the underlyingVkImageCreateInfoand allocation query.std::atomic<int> s_texture_mip_drop{-1}) to avoid thread-safety init guards on guest threads (RT-488).Map()/Unmap()cleanly rebinds subresources to the reduced mip structure and validates bounds against original descriptor counts.cpu_copy()ignores CPU writes to dropped mips (returnsS_OK) and zeroes destination buffers on read; validates box offsets and format blocks.MostDetailedMipdown by dropped mips and adjustsResourceMinLODClamp.vulkan_replay.h):prepare_texture_copy,prepare_resource_copy) are skipped (p.skip = true).TransitionBarrier,TextureBarrier) skip dropped mips and rebase subresource ranges.Tested
tests/test_texture_mip_drop.py: 22/22 tests passed (validates dimension scaling, SRV clamp remapping, CPU copy skipping/zeroing, and sentinel handling).tests/test_command_list_mip_skip.py: 2/2 tests passed (validates command list dropped mip copy skipping).runtime/test/d3d12_texture_mip_drop_test.cpp: passed on D3D12 device (verifies reduced VRAM allocation footprint, SRV sampling, and dropped-mip readback).GPUs tested: NVIDIA GeForce RTX 4050 Laptop GPU (Windows 11, driver 572.16), Apple M-series (macOS 15)
AI-assisted: yes
Checklist
mainand merges cleanly.docs/design.md(n/a - D3D12 runtime switch).