feat(d3d12_x): add the title buffer window below 4 GB #36

Manually merged
github merged 1 commit from gh-pr/36/head into gh-pr/36/base 2026-11-26 19:14:53 +00:00
Owner

@⁠Dark3581 on GitHub · 2026-11-22 11:06 UTC · original
Dark3581:feat/buffer-window → main · +432 −3 · 11 files · 1 commits · merged 2026-11-22 11:09 UTC

What

The mechanism behind option A of the GPU memory note on #4: one buffer window below 4 GB that the CPU and the GPU share at the same addresses.

  • TitleBufferWindow finds a free range below 4 GB (VirtualQuery, aligned to the allocation granularity and the driver's import alignment), commits it, imports it as one Vulkan buffer with VK_EXT_external_memory_host and a device address, and gives the heap base = device address − window start (modulo 2^64), the value translated shaders add to every console address they read. Translated shaders set the high dword of descriptor-table pointers to 0 (25,252 of 25,889 modules of one title's store), which is why the window has to sit below 4 GB.
  • VulkanDevice gains a hostMemoryImport requirement: it then needs and enables VK_EXT_external_memory_host and records the import alignment and vkGetMemoryHostPointerPropertiesEXT.
  • anybox-pipeline-probe window [--mib N] [--validate]: a compute shader reads 4,096 32-bit pointers from a table inside the window and loads through heap base + each pointer, writing results back into the window; two rounds, with the CPU changing the data between them, so both directions are checked without copies.
  • Nothing allocates from the window yet. Which title allocations go there depends on the title's XMem and buffer calls; that is the open question on #4, and it is recorded as debt.

Tested

  • Windows 10, MinGW GCC 15.2, RTX 3070 Ti (import alignment 4,096), Vulkan SDK 1.4.363 validation layer: 60 of 60 tests pass; check_conventions.py and debt_fold.py --check pass.
  • window --validate (64 MiB at 0x10000000): 8,192 of 8,192 reads correct, 0 validation errors. The device address was below the window start, so the heap base wrapped (0xfffffffff7150000) and the 64-bit addition in the shader still landed correctly.
  • Sizes: 1 GiB (at 0x10000000) and 2 GiB (at 0x7fff0000) import and pass; 3 GiB finds no free range below 4 GB in the probe process. No game data in the PR.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • python tools/check_conventions.py passes (no comments in code, one declaration per export, Conventional Commit subjects)
  • Unimplemented paths stop (AbxNotImplemented / AbxUnsupported); silent stubs are listed under Silent stubs through a debt fragment
  • Known gaps added, changed or removed through docs/dev/debt/changes/<branch>.md
  • Generic behaviour, not specific to one title
  • No game files, keys, notes or logs added to the repository
  • Depends on: #35 (merged)
  • Fixes: none
  • Unblocks: none
  • Source of behaviour: heap-base addressing from the translator's runtime contract; the 4 GB constraint counted on one title's store; Vulkan behaviour from the specification and the validation layer
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-22 11:06 UTC · [original](https://github.com/Dark3581/AnyBox/pull/36) `Dark3581:feat/buffer-window` → `main` · +432 −3 · 11 files · 1 commits · merged 2026-11-22 11:09 UTC ### What The mechanism behind option A of the GPU memory note on #4: one buffer window below 4 GB that the CPU and the GPU share at the same addresses. - **`TitleBufferWindow`** finds a free range below 4 GB (`VirtualQuery`, aligned to the allocation granularity and the driver's import alignment), commits it, imports it as one Vulkan buffer with `VK_EXT_external_memory_host` and a device address, and gives the **heap base** = device address − window start (modulo 2^64), the value translated shaders add to every console address they read. Translated shaders set the high dword of descriptor-table pointers to 0 (25,252 of 25,889 modules of one title's store), which is why the window has to sit below 4 GB. - **`VulkanDevice`** gains a `hostMemoryImport` requirement: it then needs and enables `VK_EXT_external_memory_host` and records the import alignment and `vkGetMemoryHostPointerPropertiesEXT`. - **`anybox-pipeline-probe window [--mib N] [--validate]`**: a compute shader reads 4,096 32-bit pointers from a table inside the window and loads through heap base + each pointer, writing results back into the window; two rounds, with the CPU changing the data between them, so both directions are checked without copies. - Nothing allocates from the window yet. Which title allocations go there depends on the title's XMem and buffer calls; that is the open question on #4, and it is recorded as debt. ### Tested - Windows 10, MinGW GCC 15.2, RTX 3070 Ti (import alignment 4,096), Vulkan SDK 1.4.363 validation layer: 60 of 60 tests pass; `check_conventions.py` and `debt_fold.py --check` pass. - `window --validate` (64 MiB at `0x10000000`): 8,192 of 8,192 reads correct, 0 validation errors. The device address was below the window start, so the heap base wrapped (`0xfffffffff7150000`) and the 64-bit addition in the shader still landed correctly. - Sizes: 1 GiB (at `0x10000000`) and 2 GiB (at `0x7fff0000`) import and pass; 3 GiB finds no free range below 4 GB in the probe process. No game data in the PR. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] `python tools/check_conventions.py` passes (no comments in code, one declaration per export, Conventional Commit subjects) - [x] Unimplemented paths stop (`AbxNotImplemented` / `AbxUnsupported`); silent stubs are listed under Silent stubs through a debt fragment - [x] Known gaps added, changed or removed through `docs/dev/debt/changes/<branch>.md` - [x] Generic behaviour, not specific to one title - [x] No game files, keys, notes or logs added to the repository - [x] Depends on: #35 (merged) - [x] Fixes: none - [x] Unblocks: none - [x] Source of behaviour: heap-base addressing from the translator's runtime contract; the 4 GB constraint counted on one title's store; Vulkan behaviour from the specification and the validation layer - [x] AI-assisted: yes
TitleBufferWindow reserves one range below 4 GB, imports it as a single
Vulkan buffer with VK_EXT_external_memory_host and gives the heap base
translated shaders add to the console addresses they read, so the CPU and
GPU see the same pages. anybox-pipeline-probe window checks GPU reads
through heap base plus 32-bit pointers loaded from a table in the window,
with the CPU changing the data between rounds.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:14:50 +00:00
github manually merged commit 182dce7fd1 into gh-pr/36/base 2026-11-26 19:14:53 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.