gpu: probe a CPU-visible placed-buffer arena #501
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/501"
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?
Imported from Marvisak/VIctory. Originally posted by ToxicmaggotRP on 2026-11-24T04:14:15Z.
[Related to #407. This is the first isolated step toward the CPU/GPU shared-memory path described there, and groundwork for the commit-limit investigation in #471.
What
Noneif heap creation or mapping fails, capacity is exhausted, or size rounding overflows.None.The arena uses one placed resource across the heap because separate placed resources are not guaranteed to have contiguous GPU virtual addresses. The test uses the D3D12 aliasing barrier to activate the resource before its first GPU use, then transitions it for shader access.
Scope and limits
This PR verifies shared CPU/GPU backing and relative offsets on the tested adapter. It does not set the GPU virtual address equal to a title/guest address, route title/XMEM allocations through the arena, or remove the shadow-copy bridge. The world-load commit-limit report in #471 remains outside this PR's scope.
Verification
cargo test --locked -p victory-gpu: 44 passed, 1 ignored (benchmark).cargo test --locked --workspace: passed.cargo clippy --locked -p victory-gpu --all-targets: passed.cargo fmt --all -- --checkreports formatting differences across existing workspace files; no broad formatting change is included here.References:
AI-assisted contribution (ChatGPT).](https://github.com/Marvisak/VIctory/pull/501)
Imported from Marvisak/VIctory. Originally posted by aycow on 2026-11-24T04:44:49Z.
Independent Windows validation of
4ec7939: the stockcargo test -p victory-gpu --features diagnostics host::tests::placed_custom_heap_shares_memory_between_cpu_and_gpu -- --exact --nocapturepassed. I also ran the same arena and compute fixture with a local test-only adapter selector using Agility SDK 1.620.2. AMD Radeon Graphics, NVIDIA RTX 5070 Laptop GPU, and WARP all allocated the 256 MiB arena, reserved the 174 MiB slice, and returned0xb7910c22through the mapped destination after the fence. Full GPU-based validation and the debug layer reported zero errors.All three emitted the same advisory:
CreatePlacedResourceignoredUNORDERED_ACCESSas the buffer’s initial state and usedCOMMON. I would specifyCOMMONin the arena and document first-use buffer promotion (or transition explicitly). This validates the Windows placed-buffer primitive and offset arithmetic. Guest VA identity, allocation routing, concurrency and residency remain separate.I can rerun this matrix on a revised head.
Imported from Marvisak/VIctory. Originally posted by aycow on 2026-11-24T06:34:25Z.
Thanks for switching the placed buffer to COMMON in
262874b. I'm evaluating a narrow opt-in integration that uses the mapped arena for bounded, allocator-owned, GPU-read-only scratch chunks. The committed upload path remains the per-allocation fallback. This gives us a place to measure translated addresses, ownership and allocation pressure before routing title-owned memory. I'll test the exact output and implementation on AMD, NVIDIA and WARP and share the branch and results here.Imported from Marvisak/VIctory. Originally posted by aycow on 2026-11-24T06:49:43Z.
The opt-in scratch integration is available at
f68b332on top of262874b. It routes only allocator-owned, GPU-read-only list scratch to the mapped arena. The byte-exact fixture checks a nonzero CPU/GPU offset, reset reuse, and committed-upload fallback after capacity is exhausted. AMD Radeon Graphics, RTX 5070 Laptop, and WARP passed with full GBV.The separate 1 MiB synthetic shadow comparison across three access strides measured 49–89 µs of median submit preparation through the ordinary private-memory shadow and 0–1 µs through the arena. These numbers exclude arena initialization, list and PSO creation, and output checking. The queue-fence interval is recorded separately in the fixture. Branch and reproducible benchmark
Imported from Marvisak/VIctory. Originally posted by aycow on 2026-11-24T07:29:51Z.
I extended the read-only scratch work with an opt-in allocation for the host's GPU-writable indirect budget word. It uses independent placed resources in a 4 MiB L0 heap, returns slots only after completion and falls back to a committed buffer per allocation. AMD, RTX 5070 Laptop and WARP checked reset reuse, slot replacement, exhaustion fallback and byte-exact atomic output under full GBV.
The guide separates CPU allocation, submission preparation, and actual GPU timestamps. The results describe one 1,024-thread contended atomic workload. Guest memory and Wine remain separate because their ownership and mapping conditions differ. Implementation and benchmark
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T15:36:40Z.
Review: COMMENTED
Tested
e5990eaon Windows 11, RTX 5070, MSVC: builds;cargo test -p victory-gpu -- --test-threads=144 passed, 0 failed, 1 ignored, includingplaced_custom_heap_shares_memory_between_cpu_and_gpuon the hardware device.This is a probe: nothing outside the test calls
unified_buffer, so it has no effect on a run. The arena itself (one placed buffer over a 256 MiB CUSTOM/WRITE_BACK/L0 heap, mapped once, bump-allocated at 256-byte alignment with checked arithmetic) looks right.Findings:
placed_custom_heap_shares_memory_between_cpu_and_gpu).sourceanddestinationare two offsets in the sameID3D12Resource, so there is one state for both. The test moves it toUNORDERED_ACCESSand then readssourcethrough a root SRV. A shader-resource read needsNON_PIXEL_SHADER_RESOURCE, and that can't be combined withUNORDERED_ACCESS. It works on hardware, but it is outside the resource-state rules, and GPU-based validation flags it. Fix: read the source through a second root UAV (RWByteAddressBuffer source : register(u1), root signatureUAV(u0), UAV(u1)).COMMONand rely on promotion and decay. That constrains how title allocations can be routed here.world_heap.offset == 2 * SLOT), so it relies on being the first user of the process-wide host's arena. Once anything else allocates from it, this test breaks. Compare offsets relative to the first allocation instead.It conflicts with current main in
host.rs(2 hunks), so it isn't merged into our fork.AI-assisted (Claude Code).
upstream-sync referenced this pull request2026-11-25 02:06:17 +00:00
Pull request closed