gpu: cap slot 133 OpenExistingHeapFromAddress size and grow upload ring on demand #2765
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#2765
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@triggered02 on GitHub · 2026-11-26 06:46 UTC · original
Problem
In
src/startup_stubs/d3d12_xs_device.cpp(device_place_resource_x, slot 133):x2w_local::commit_lazy_block(address)is called unconditionally at the start of the buffer branch (~line 4958), before checking(offset & 0xFFFF) == 0 && range.covered && range.type == MEM_PRIVATE. Even a tiny unaligned buffer or aMEM_MAPPEDbuffer that falls back toCreateCommittedResourcecommits the entire multi-GiBX2W_XMEM_LAZY_STARTUPblock up front.OpenExistingHeapFromAddress(base)wraps the entireMEM_PRIVATEVirtualAllocallocation regardless of size. In startup workloads this opens2.15 GiBand1.14 GiB(3.29 GiBtotal) D3D12 heaps just to alias ~160 MiBof placed buffers (including a14 KiBbuffer). As confirmed by a standalone D3D12 probe on GTX 1660 SUPER,OpenExistingHeapFromAddress(256 MiB)immediately pinsWorkingSetSize +256.03 MiBand DXGINonLocal +256.00 MiBeven on untouchedMEM_COMMITpages. (slot 70already guards against this viax2w_startup::unplaced_existing_heap_allowedatsrc/startup_stubs/memory_srv_buffer.h:136.)reserve_upload_ring(src/startup_stubs/d3d12_xs_device.cpp:2425) eagerly commits a single256 MiBD3D12_HEAP_TYPE_UPLOADbuffer on the first translated draw even when only a few KiB are used.Proposed changes
slot 133OpenExistingHeapFromAddressbyx2w_startup::unplaced_existing_heap_allowed(x2w_startup::allocation_bytes(base))(<= 256 MiB, with an opt-in override if needed) and movecommit_lazy_block(address)inside theOpenExistingHeapFromAddressbranch so unaligned/non-private/oversized blocks only commit[address, address + width).reserve_upload_ringincrementally (e.g., starting from a16 MiBchunk and appending chunks on demand up to256 MiB).Acceptance
Source-built fixture
startup_slot133_heap_cap_checkverifying:slot 133buffer in a> 256 MiBMEM_PRIVATEX2W_XMEM_LAZY_STARTUPblock does not open anexisting_heap(x2w-budgetheapremains0/0) and leaves untouched pagesMEM_RESERVE;<= 256 MiBblock still opensexisting_heap(aliased);reserve_upload_ringinitially commits16 MiBinstead of256 MiBand grows on demand.Command:
ctest --preset dev --no-tests=error -R '^(startup_slot133_heap_cap|startup_placed_|startup_resource_budget)'NOT established
> 256 MiBMEM_PRIVATEpool and relies on CPU-visiblealiasedwrites withoutX2W_D3D12_LINEAR_BUFFERS=copy.Refs #1199, #874.
@R0Y00 on GitHub · 2026-11-26 07:04 UTC · original
Please take the slot-133 heap and commit changes first and split upload-ring growth into a separate patch. The buffer path explicitly distinguishes an aliased buffer from a copied resource. Add a data test to the allocation probe: bind a buffer containing sentinel A, update the guest address to B before GPU submission, and require B at readback anywhere the new cap would switch backing. Check the existing small-block alias against the same input. Keep the old path for uses where copy synchronization has no equivalent, and verify untouched pages remain MEM_RESERVE. This can be tested independently of the lazy textures in #2764.