d3d12: remap directly-indexed heaps to arena shader VA (RT-DIRECT-HEAP-ARENA-REMAP) #2141
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2141
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2141/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?
@abnalstlll-byte on GitHub · 2026-11-25 22:58 UTC · original
abnalstlll-byte:feat/rt-direct-heap-arena-remap→main· +36 −10 · 3 files · 1 commits · merged 2026-11-25 23:27 UTCRemap directly indexed CBV/SRV/UAV and sampler heap console base addresses to arena shader virtual addresses in user SGPRs.
Problem
In
write_direct_heaps(), the bound resource and sampler heaps were passed into user SGPRs using rawcbv_srv_uav_base_andsampler_base_. For console descriptor heaps shadowed in the GPU address arena (where the title's pages are mirrored/shadowed into the GPU address arena so thatheap_base + VAreaches them), passing raw console base addresses gave shaders the host title virtual address (e.g.0x34ab42000) rather than the arena copy's shader VA (console_shader_va_).When compute shaders (such as
lib_cs_01405/01410/01455/00863/00867) or graphics shaders index directly into the resource heap usings[end]during the world load transition (~200s), addingheap_base + s[end]attempted to read unmapped memory outside the arena, triggering GPU device loss (READ_INVALID). Notice thatrecord_dispatch()diagnostic logging already distinguishedbound-heap(raw console base) fromshader-heap(console_descriptor_table_va(cbv_srv_uav_base_)), butwrite_direct_heaps()andnote_direct_heap_indexing()passed the raw console base.Solution
write_direct_heaps(): passconsole_descriptor_table_va(cbv_srv_uav_base_)andconsole_descriptor_table_va(sampler_base_)into the user SGPR data dwords. For ordinary unshadowed heaps,console_descriptor_table_va()returns the address unchanged.note_direct_heap_indexing(): trackremember_table(console_descriptor_table_va(cbv_srv_uav_base_), ...)using the translated shader VA so table origin tracking correlates properly.graphics_user_data(): log the remapped shader VA for diagnostic consistency.runtime/test/d3d12_set_descriptor_heaps_test.cpp: assert that recorded dispatch user data dwords receive the remappedconsole_descriptor_table_vaaddresses atcompute_arguments_end.docs/d3d12_vulkan.mdwith the direct heap arena remapping contract.Verification
python -I scripts/check_no_game_data.py runtime/shims/d3d12_com.cpp runtime/test/d3d12_set_descriptor_heaps_test.cpp docs/d3d12_vulkan.md-> 0 violations.python -I tests/test_text_write_line_endings.py-> 3/3 PASS.python -m compileall -q make_game.py tools tests-> Clean.ninja -C runtime/build_portable descriptor_table_test root_signature_test title_va_alias_test console_heap_vsharp_slots_test-> All PASS.AI-assisted (Claude Code, Claude Opus 5.5).
@ZroIsHere on GitHub · 2026-11-25 23:20 UTC · original
I reproduced the test failure and pushed a testable fix on the integration branch:
github.com/ZroIsHere/leonida@3b613c512It factors the runtime packing into
write_direct_heap_bases()and tests that exact helper rather than dispatching without a compute PSO. Focused MSVC/Vulkan checks pass:dstorage_test(551),title_memory_map_test(21),d3d12_set_descriptor_heaps_test, andqueue_holds_report_test. No game files used.