feat(d3d12_x): map D3D12 resource states to Vulkan barriers #48

Manually merged
github merged 1 commit from gh-pr/48/head into gh-pr/48/base 2026-11-26 19:15:52 +00:00
Owner

@⁠Dark3581 on GitHub · 2026-11-22 21:19 UTC · original
Dark3581:feat/resource-states → main · +391 −3 · 9 files · 1 commits · merged 2026-11-22 21:23 UTC

What

The barrier half of command lists, which does not depend on a title's calls:

  • commands/ResourceState.cpp: UsageOfState turns a D3D12_RESOURCE_STATES mask into Vulkan 2 stages, access and an image layout. Each state maps by name (render target to colour attachment, UNORDERED_ACCESS to storage read and write in GENERAL, depth write and read, the two shader resource states, indirect arguments, copy and resolve source and destination). COMMON is GENERAL with all commands and memory access. Read states combine: they share a layout when they can (ALL_SHADER_RESOURCE stays shader read-only, copy plus resolve source stays transfer source) and fall back to GENERAL otherwise (GENERIC_READ, copy source plus shader resource). A depth image in a shader resource state uses the depth read-only layout, so DEPTH_READ | PIXEL_SHADER_RESOURCE needs no layout change.
  • ImageTransition and BufferTransition build VkImageMemoryBarrier2 and VkMemoryBarrier2 (buffers share one buffer, so a global memory barrier covers them); UnorderedAccessBarrier and AliasingBarrier cover the other two barrier types.
  • Refused with an error naming the bits: a write state combined with any other state, two write states, stream output, ray tracing, shading rate and video states, and unknown bits.
  • The device enables synchronization2 (core in Vulkan 1.3) and loads vkCmdPipelineBarrier2.

What is left for command lists (implicit promotion and decay, split barriers, per-subresource tracking) is in the debt fragment.

Tested

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

  • pso_probe states-selftest: the layout of 13 single and combined states, sampled depth, the access of GENERIC_READ (all its reads, no writes), a render-target-to-shader-resource transition field by field, a buffer transition, the UAV and aliasing barriers, and 6 refusals with their messages.
  • pso_probe states-gpu --validate: a colour image through 11 states, a depth image through 7 and a buffer through 6, with UAV and aliasing barriers, recorded and executed: 26 barriers, 0 validation errors. Both run in the pipeline_state test.
  • ctest: 66 of 66. 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 state documentation, Vulkan 1.3 synchronization2
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-22 21:19 UTC · [original](https://github.com/Dark3581/AnyBox/pull/48) `Dark3581:feat/resource-states` → `main` · +391 −3 · 9 files · 1 commits · merged 2026-11-22 21:23 UTC ### What The barrier half of command lists, which does not depend on a title's calls: - **`commands/ResourceState.cpp`**: `UsageOfState` turns a `D3D12_RESOURCE_STATES` mask into Vulkan 2 stages, access and an image layout. Each state maps by name (render target to colour attachment, `UNORDERED_ACCESS` to storage read and write in `GENERAL`, depth write and read, the two shader resource states, indirect arguments, copy and resolve source and destination). `COMMON` is `GENERAL` with all commands and memory access. Read states combine: they share a layout when they can (`ALL_SHADER_RESOURCE` stays shader read-only, copy plus resolve source stays transfer source) and fall back to `GENERAL` otherwise (`GENERIC_READ`, copy source plus shader resource). A depth image in a shader resource state uses the depth read-only layout, so `DEPTH_READ | PIXEL_SHADER_RESOURCE` needs no layout change. - `ImageTransition` and `BufferTransition` build `VkImageMemoryBarrier2` and `VkMemoryBarrier2` (buffers share one buffer, so a global memory barrier covers them); `UnorderedAccessBarrier` and `AliasingBarrier` cover the other two barrier types. - Refused with an error naming the bits: a write state combined with any other state, two write states, stream output, ray tracing, shading rate and video states, and unknown bits. - The device enables `synchronization2` (core in Vulkan 1.3) and loads `vkCmdPipelineBarrier2`. What is left for command lists (implicit promotion and decay, split barriers, per-subresource tracking) is in the debt fragment. ### Tested Windows 10, MinGW build, RTX 3070 Ti (driver 621.14), Khronos validation layer. - `pso_probe states-selftest`: the layout of 13 single and combined states, sampled depth, the access of `GENERIC_READ` (all its reads, no writes), a render-target-to-shader-resource transition field by field, a buffer transition, the UAV and aliasing barriers, and 6 refusals with their messages. - `pso_probe states-gpu --validate`: a colour image through 11 states, a depth image through 7 and a buffer through 6, with UAV and aliasing barriers, recorded and executed: 26 barriers, 0 validation errors. Both run in the `pipeline_state` test. - `ctest`: 66 of 66. `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 state documentation, Vulkan 1.3 synchronization2 - [x] AI-assisted: yes
ResourceState turns a D3D12 resource state mask into Vulkan stages, access and an image layout, and builds image transitions, buffer memory barriers and UAV and aliasing barriers from them. Read states share a layout when they can and fall back to GENERAL, depth images read by shaders stay in the depth read-only layout, and write states combined with others, unsupported and unknown bits are refused. The device enables synchronization2 and loads vkCmdPipelineBarrier2; pso_probe gains a self test and a GPU test that walks images and a buffer through every supported state under the validation layer.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:15:50 +00:00
github manually merged commit e7548f0a22 into gh-pr/48/base 2026-11-26 19:15:52 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.