feat(d3d12_x): add committed D3D12 resources on the buffer window and device memory #61

Manually merged
github merged 1 commit from gh-pr/61/head into gh-pr/61/base 2026-11-26 19:16:49 +00:00
Owner

@⁠Dark3581 on GitHub · 2026-11-23 00:27 UTC · original
Dark3581:feat/resources → main · +567 −6 · 12 files · 1 commits · merged 2026-11-23 00:30 UTC

What

ID3D12Resource for committed resources, the next object the command lists, descriptor heaps and device need:

  • vulkan/BufferArena.cpp: first-fit allocation over the title buffer window (#36) with alignment, freed ranges merged with their neighbours.
  • objects/Resource.cpp (Resource::CreateCommitted):
    • Buffers: placed in the window at D3D12's 64 KiB placement alignment, so GetGPUVirtualAddress is an address inside the window, the console address the translated shaders add the heap base to. Map returns the CPU pointer into the window for every heap type (default-heap buffers are in host memory for now: slow, correct). Zeroed at creation unless D3D12_HEAP_FLAG_CREATE_NOT_ZEROED, as D3D12 committed resources are.
    • Textures: a VkImage from #49's TranslateTextureDesc in its own device-local memory, cleared to zero (block-compressed textures cannot be cleared that way and are not) and moved into its initial state's layout at creation, with #51's InitializeTexture. No GPU address, not mappable.
    • GetDesc (with the same MSVC-ABI handling as #60), GetHeapProperties.
    • Refused with the cause named: invalid buffer descriptions, custom, shared and protected heaps, textures outside default heaps, a window without room. WriteToSubresource and ReadFromSubresource stop the title.
  • Resource::Buffer() and Resource::Texture() give the BufferRef and TextureRef the command recorder takes.
  • The device loads vkCmdClearDepthStencilImage.

Tested

Windows 10, RTX 3070 Ti (driver 621.14), Khronos validation layer.

  • pso_probe arena-selftest: aligned allocations, refusals (zero size, non-power-of-two alignment, too large), free and double free, reuse of a freed range, coalescing back to one range.
  • pso_probe resources-gpu --validate, 19 checks in a 64 MiB window: upload, readback and default buffers with aligned, distinct addresses below 4 GB inside the window; descriptions and heap properties; mapping and refusing subresource 1; a GPU copy between two buffer resources read back through the mapped readback buffer; new color and depth textures read back as zero; a released buffer's range is reused at the same address and comes back zeroed; four refusals; every range back in the arena at the end. 0 validation errors. Both run in the pipeline_state test.
  • MinGW ctest: 72 of 72. With MSVC 2022 the targets build and resources-gpu passes. python tools/check_conventions.py and debt_fold.py --check: ok.

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: none
  • Fixes: none
  • Unblocks: none
  • Source of behaviour: public D3D12 resource and heap documentation, Vulkan 1.3 specification
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-23 00:27 UTC · [original](https://github.com/Dark3581/AnyBox/pull/61) `Dark3581:feat/resources` → `main` · +567 −6 · 12 files · 1 commits · merged 2026-11-23 00:30 UTC ### What `ID3D12Resource` for committed resources, the next object the command lists, descriptor heaps and device need: - **`vulkan/BufferArena.cpp`**: first-fit allocation over the title buffer window (#36) with alignment, freed ranges merged with their neighbours. - **`objects/Resource.cpp`** (`Resource::CreateCommitted`): - Buffers: placed in the window at D3D12's 64 KiB placement alignment, so `GetGPUVirtualAddress` is an address inside the window, the console address the translated shaders add the heap base to. `Map` returns the CPU pointer into the window for every heap type (default-heap buffers are in host memory for now: slow, correct). Zeroed at creation unless `D3D12_HEAP_FLAG_CREATE_NOT_ZEROED`, as D3D12 committed resources are. - Textures: a `VkImage` from #49's `TranslateTextureDesc` in its own device-local memory, cleared to zero (block-compressed textures cannot be cleared that way and are not) and moved into its initial state's layout at creation, with #51's `InitializeTexture`. No GPU address, not mappable. - `GetDesc` (with the same MSVC-ABI handling as #60), `GetHeapProperties`. - Refused with the cause named: invalid buffer descriptions, custom, shared and protected heaps, textures outside default heaps, a window without room. `WriteToSubresource` and `ReadFromSubresource` stop the title. - `Resource::Buffer()` and `Resource::Texture()` give the `BufferRef` and `TextureRef` the command recorder takes. - The device loads `vkCmdClearDepthStencilImage`. ### Tested Windows 10, RTX 3070 Ti (driver 621.14), Khronos validation layer. - `pso_probe arena-selftest`: aligned allocations, refusals (zero size, non-power-of-two alignment, too large), free and double free, reuse of a freed range, coalescing back to one range. - `pso_probe resources-gpu --validate`, 19 checks in a 64 MiB window: upload, readback and default buffers with aligned, distinct addresses below 4 GB inside the window; descriptions and heap properties; mapping and refusing subresource 1; a GPU copy between two buffer resources read back through the mapped readback buffer; **new color and depth textures read back as zero**; a released buffer's range is reused at the same address and comes back zeroed; four refusals; every range back in the arena at the end. 0 validation errors. Both run in the `pipeline_state` test. - MinGW `ctest`: 72 of 72. With MSVC 2022 the targets build and `resources-gpu` passes. `python tools/check_conventions.py` and `debt_fold.py --check`: ok. ### 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: none - [x] Fixes: none - [x] Unblocks: none - [x] Source of behaviour: public D3D12 resource and heap documentation, Vulkan 1.3 specification - [x] AI-assisted: yes
BufferArena allocates first-fit over the title buffer window and merges freed ranges. Resource implements committed ID3D12Resources: buffers at 64 KiB alignment in the window, mappable, with GPU addresses inside it and zeroed unless CREATE_NOT_ZEROED; textures as images in their own device memory, cleared to zero and moved to their initial state at creation; descriptions, heap properties and refusals for what is not supported. The device loads vkCmdClearDepthStencilImage. pso_probe gains an arena self test and a GPU test that copies between buffer resources and reads new textures back as zero.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:16:47 +00:00
github manually merged commit 22f2d316b2 into gh-pr/61/base 2026-11-26 19:16:49 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.