DARNER_CVV=1: card memory the CPU maps on Turing via NVAPI CPU-visible vidmem #485
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!485
Loading…
Reference in a new issue
No description provided.
Delete branch "feng/Darner:nvapi-cpu-visible-vidmem"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refs #82
Contributor role (optional)
What it changes
D3D12_FEATURE_DATA_D3D12_OPTIONS16::GPUUploadHeapSupported, even though NVIDIA exposes CPU-visible VRAM via NVAPI (NvAPI_D3D12_QueryCpuVisibleVidmem+NvAPI_D3D12_CreateHeap2withNV_D3D12_HEAP_FLAG_CPUVISIBLE_VIDMEM). As a result,Host::mapped_card_bufferandheap_twin::makestay unavailable on Turing and fall back to system RAM.This adds an opt-in switch
DARNER_CVV=1(off by default,asked_for!("DARNER_CVV"), zero behaviour change when unset):crates/darner-gpu/src/nvapi.rs: loadsnvapi64.dllfromSystem32(LOAD_LIBRARY_SEARCH_SYSTEM32), queriesNvAPI_D3D12_QueryCpuVisibleVidmemdynamically per discrete NVIDIA adapter (nothing is hardcoded to 16 GiB), requires BAR1 > 256 MiB, and creates aD3D12_HEAP_TYPE_CUSTOM+WRITE_COMBINE+L0CPU-visible VRAM heap viaNvAPI_D3D12_CreateHeap2. UsingCUSTOM + WRITE_COMBINE + L0(instead ofUPLOAD) both lands in CPU-visible VRAM and permitsD3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS+COMMONstate needed byDARNER_WINDOWS_BAR_MB,DARNER_HEAP_TWIN,DARNER_SCRATCH_CARD, andhost::bus. AnyCreateHeap2failure falls back cleanly to system RAM.crates/darner-gpu/src/host.rs&heap_twin.rs: wires the NVAPI CVV fallback intoHost::mapped_card_bufferandheap_twin::make, attaching theID3D12Heaplifetime to the placedID3D12ResourceviaSetPrivateDataInterfaceand skipping redundantMakeResidenton the already-resident CVV heap.crates/darner-gpu/src/cardledger.rs,residency.rs,resource.rs: addsresidency::placed_as(MappedVram)andcardledger::made_mappedso CVV placed buffers are accounted as mapped card VRAM rather thanShared/Other, and restricts theDARNER_ALIAS_SHARE=1upload-heap guard toGpuUpload.README.md&docs/memory-separation.md: documentsDARNER_CVV.How it was tested
4c00698(rebased cleanly ontoorigin/maind91d8e4)cargo xtask policy-> PASS (566 files ok)cargo clippy --workspace --all-targets --locked -- -D warnings-> PASS (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings-> PASS (0 warnings)cargo test -p darner-gpu --lib --locked nvapi-> PASS (3/3)cargo test -p darner-gpu --lib --locked cardledger-> PASS (25/25)cargo test -p darner-gpu --lib --locked residency-> PASS (13/13)DARNER_CVV=1 cargo test -p darner-gpu --lib --locked mapped_card_memory_is_written_by_the_cpu_and_read_by_the_card-> PASS (1/1 on live RTX 2080 Ti)host::bus256 MiB benchmark (measured earlier on the same commit before rebase ontod91d8e4, identical code) on RTX 2080 Ti 22 GB withDARNER_CVV=1: CPU write10.4 GB/s, CPU read0.05 GB/s, compute shader read492.3 GB/s, UAV store139.1 GB/s(matchingDEFAULTVRAM495.0 / 141.9 GB/s, vs system RAM6.2 / 0.6 GB/s).DARNER_CVV=1, off when unset).DARNER_CVVunset creates no CVV heap, verified in live boot log on RTX 2080 Ti). Checked withDARNER_CVV=1via thehost::bus256 MiB transfer benchmark above and a 114-minute live gameplay run.cargo clippy --workspace --all-targets --locked -- -D warnings): PASS on4c00698cargo clippy --workspace --all-targets --all-features --locked -- -D warnings): PASS on4c00698cargo test --workspace --locked): targeted unit & live GPU tests above passed on4c00698; full workspace test run was not completed on this machine because pre-existing unrelateddarner-shaderoracle64::legacy_mul_forms_are_exacthangs >20 min in debug mode anddarner-gpuwatch::testshas intermittent parallel flakes (related to #262).1080to1440, DLSS Performance, 3x DLSS FG (viadlssg_for_sm86), RT off. Verified on pre-rebase equivalent commit (7b1e836, identical diff) across a 114-minute continuous session (222,000+ frames):DARNER_HEAP_TWIN=1placed the 174 MB graphics heap twin in CPU-visible VRAM;cardledgertrackedwindow-mapped(4,062 MBearly ->2,754 MBat 114 min,other-mapped 216 -> 169 MB,scratch 134 -> 142 MB); 0 crashes, 0 device losses, 0no buffer in card memory, 0no twin.GPUUploadHeapSupportedis already true (code path is skipped whenGPUUploadHeapSupportedis true or adapter is not discrete NVIDIA). Live 114-min session was run on7b1e836prior to clean rebase ontod91d8e4.Checklist
main.docs/asset-policy.md.Checked for overlap
One diagnostic still identifies every graphics heap twin as
GPU_UPLOAD. On4c00698,heap_twin::makecan also create an NVAPI CPU-visible video-memory heap. Both paths return the sameHeapTwinplacement tag.I rendered the PR's Rust log format strings with synthetic twin sizes of 17 and 5 MiB. Both produced
graphics heap twin (CPU copies to GPU_UPLOAD). The placement-success and placement-refusal messages inport.rsuse the same backend name. A CVV test log can therefore look like it used the D3D12 GPU upload heap. This was a CPU-only formatting check.A shared label such as
CPU copies to mapped card memorywould describe both paths. Logging the selected backend once at heap creation would let readers distinguish them. Heap selection · Memory summary · Placement messages@superhero-520 Good catch, thanks for checking those log strings — addressed in
4b57408:host.rs: addedMappedCardKind::label()("GPU_UPLOAD"/"NVAPI CVV") and reused it inmapped_card_kind().heap_twin.rs: logsway = kind.label()once when creating the graphics heap twin so logs clearly identify which backend backed it.residency.rs&port.rs: changed the shared twin diagnostics fromGPU_UPLOADtomapped card memory(both the memory placement summary and the port 1 placement/refusal messages).Re-verified on
4b57408:cargo xtask policy --staged(4 files ok)cargo clippy --workspace --all-targets --locked -- -D warnings(pass, 0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings(pass, 0 warnings)cargo test -p darner-gpu --lib --lockedfornvapi(3/3),cardledger(25/25),residency(13/13),heap_twin(9/9),port::(4/4), andDARNER_CVV=1mapped_card_memory_is_written_by_the_cpu_and_read_by_the_card(1/1)DARNER_CVV=1:the title's graphics heap: a twin in the card's memory, written by the CPU before submissions (DARNER_HEAP_TWIN) start=0xf10000 mb=174 gpu=0x9e00000 way="NVAPI CVV"renderer port 1: buffer placed in the mapped card memory graphics heap twin, updated by CPU copies start=0xf10000 len=182452224 window=false[pr-feature][memory][NVIDIA] DARNER_CVV=1: card memory the CPU maps on Turing via NVAPI CPU-visible vidmemto DARNER_CVV=1: card memory the CPU maps on Turing via NVAPI CPU-visible vidmemTest needed — commit
1fded26d; what to check:D3D12_FEATURE_DATA_D3D12_OPTIONS16::GPUUploadHeapSupported, even though NVIDIA exposes CPU-visible VRAM via NVAPI (NvAPI_D3D12_QueryCpuVisibleVidmem+NvAPI_D3D12_CreateHeap2withNV_D3D12_HEAP_FLAG_CPUVISIBLE_VIDMEM). As a result,Host::mapped_card_bufferandheap_twin::makestay unavailable on Turing and fall back to system RAM.This adds an opt-in switch
DARNER_CVV=1(off by default,asked_for!("DARNER_CVV"), zero behaviour change when unset):crates/darner-gpu/src/nvapi.rs: loadsnvapi64.dllfromSystem32(LOAD_LIBRARY_SEARCH_SYSTEM32), queriesNvAPI_D3D12_QueryCpuVisibleVidmemdynamically per discrete NVIDIA adapter (nothing is hardcoded to 16 GiB), requires BAR1 > 256 MiB, and creates aD3D12_HEAP_TYPE_CUSTOM+WRITE_COMBINE+L0CPU-visible VRAM heap viaNvAPI_D3D12_CreateHeap2. UsingCUSTOM + WRITE_COMBINE + L0(instead ofUPLOAD) both lands in CPU-visible VRAM and permitsD3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS+COMMONstate needed byDARNER_WINDOWS_BAR_MB,Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.
Reply
testingto take this run; it's free again after 24 h with no results.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.