d3d12: reclaim shader-visible descriptor slots via lease and fence pinning #172
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/brcly--TuxBox!172
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/172/head"
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?
@Vladimir-Human on GitHub · 2026-11-25 13:53 UTC · original
Vladimir-Human:d3d12/reclaim-descriptor-slots→main· +1875 −256 · 14 files · 2 commits · merged 2026-11-25 14:32 UTCSummary
Reclaim shader-visible descriptor slots in
runtime/d3d12/src/device/descriptor_paging.rsinstead of allocating monotonically until exhaustion (ProjectScarlett Priority #2 indocs/PROGRESS.md), while preserving descriptor lifetimes across open command lists,ClearState, bundle adoption,Reset()while in-flight, multi-queue out-of-order retirement, andResourceDescriptorHeapindex_mapstability:device/descriptor_paging.rs:FreeSpansbest-fit coalescing span allocator with left/right neighbor merging andusedtail shrinking.TableEntry { id, slot, pins, direct_pinned, last_used },by_id, LRUtick, andin_flightqueue submissions (RetireFence) for non-blocking out-of-orderretire_completed()(never treatingGetCompletedValue() == u64::MAXdevice-removed sentinel as completed).gpu_tablemiss, tryFreeSpans::alloc-> bumpused->retire_completed()-> evict oldest unpinned (pins == 0 && !direct_pinned) entries -> log full diagnostic and returnErr(E_OUTOFMEMORY)if pinned/direct usage still exceedslimit. Drop displacedRetiredViewsoutside thetablesmutex and cleanresident_recordsand host view tracking (imported,placed,scenes,display::texture_view).DescriptorLeasesdeduplicated per(Arc<Arena>, id)on allgpu_table/gpucallers and RAIIPendingSubmissionsbatch pins inexecute_batch.device/descriptor_paging/index_map.rs&device/placement/descriptors.rs:rangesentriesdirect_pinned = true(leaving fully covered redundant aliases reclaimable), allowensure_direct_capacityto retire/evict unpinned tables before reportingE_OUTOFMEMORY, and addDescriptorRange::clear_deferred/copy_to_deferredso displaced view metadata drops outside external locks.commands.rs&commands/*.rs:&mut DescriptorLeasesthroughdescriptors::table,compute_bindings(with_reflected_table,refresh_inline_tables), anddepth::clear_uav; propagate leases inadopt_bundle; clear onRecording::resetandDrop, not inclear_state.retire_fence: OnceLock<RetireQueueFence>at the tail ofQueueState(preservingkindat+0x10) and commit fence tokens aftermemory_wait::submitonly whenPendingSubmissionsis non-empty, rolling back pre-submit errors via RAII drop.device.rs:TUXBOX_DESCRIPTOR_HEAP_LIMITpositiveu32clamp for shader-visibleCBV_SRV_UAVheaps (leaving defaultMaxViewDescriptorHeapSizebehavior unchanged when unset).examples/lanes/&project_tuxbox/verify.py:descriptor-reclaimselftest (reclaim.hlsl,selftest.cpp,README.md,build.py,verify.py) exercising an oversized2,097,152-descriptor shader-visible heap (> 2xRTX 4070 SUPER's1,000,000limit) across sustained mixed-size turnover, overlapping in-flightReset(),ClearStatepin retention, post-eviction rebinding, and fail-closedE_OUTOFMEMORY.Verified on Lanes
python tuxbox.py checkpassed on this branch (branch is based on682a0e4prior to#169MSVC/W4buffer_import_guest.cppand#ordinalimport lookup fixes,tests/contains pre-existing Linux-onlyfcntl/os.sched_getaffinitytest modules on Windows, andlanes-shader-cacheis Proton-only; equivalent Rust suites, Windows-compatible Python suites, native MSVC builds withcl /W4 /WXonexamples/lanes/selftest.cpp, and alllanes.exe/d3d12-tables.exeGPU checks plus negative control passed below)lanes.exe --selftest descriptor-reclaimverifies all 5 reclamation and pin-retention behaviors on a2,097,152-slot paged heap on GPU)GPU, driver and backend: NVIDIA GeForce RTX 4070 SUPER (
pci=10de:2783), NVIDIA driver32.0.16.2114, Windows10.0.26300.0native backend (MSVC19.44.35230, Windows SDK10.0.26100.0DXC, Rust1.100.0, Python3.13.9).Paste the summary printed at the end:
Checks
cargo test --locked -p tuxbox-d3d12: 107 passed, 0 failedcargo test --locked -p tuxbox-dxbc --features native-bindings: 53 passed, 0 failedcargo test --locked -p tuxbox-xg-layout: 14 passed, 0 failedcargo test --locked --manifest-path tools/shader-compiler/Cargo.toml: 279 unit + 2 integration passed, 0 failedcargo check --locked --target x86_64-pc-windows-msvc -p tuxbox-d3d12 -p tuxbox-bvh: exit 0python -m unittest tests.test_verify tests.test_check tests.test_repository_hygiene tests.test_cli tests.test_d3d12_regressions tests.test_d3d12_status tests.test_build_msvc -v: 32 passed, 0 failedcl /W4 /WXonexamples/lanes/selftest.cpp: 0 warnings, exit 0AI-assisted implementation and verification.