feat(d3d12_x): copy depth and stencil planes and render read-only depth-stencil passes #54

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

@⁠Dark3581 on GitHub · 2026-11-22 23:13 UTC · original
Dark3581:feat/depth-stencil-planes → main · +239 −26 · 8 files · 1 commits · merged 2026-11-22 23:17 UTC

What

Two gaps of the command recorder (#51, #52):

  • Plane copies: a depth-stencil texture's subresources in plane 0 copy the depth aspect and in plane 1 the stencil aspect, as D3D12 numbers them. The footprint format has to match the plane (4 bytes per texel for the depth plane of D24S8 and D32S8, as Vulkan copies it; 1 byte for stencil). CopyTexture picks the aspect per plane too and refuses copies between different planes. PlaneAspect holds the rule; R24G8_TYPELESS and R24_UNORM_X8_TYPELESS join the copy block table.
  • Read-only depth-stencil passes: AttachmentRef carries the view's D3D12_DSV_FLAG_READ_ONLY_* flags; BeginRendering then uses DEPTH_STENCIL_READ_ONLY_OPTIMAL and STORE_OP_NONE, matching the layout #48 gives DEPTH_READ (also combined with shader resource states). A pass read-only for only one plane of a depth-stencil texture is refused: it would need per-plane state tracking.

The recorder's pending debt entry is updated in place.

Tested

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

  • pso_probe commands-selftest: plane aspects, a stencil plane with a 4-byte footprint refused, a second plane of a depth-only texture refused.
  • pso_probe planes-gpu --validate: a D32S8 texture cleared to depth 0.5 and stencil 0x5A with a 0x33 stencil rectangle; the depth plane reads back as 0.5f and the stencil plane with the rectangle; the stencil plane copied into a second texture reads back the same; a mixed-plane copy, a 4-byte stencil footprint and a half read-only pass are refused; with the texture in DEPTH_READ | PIXEL_SHADER_RESOURCE, a read-only pass draws where the depth test 0 <= 0.5 passes and nothing with GREATER. 5 checks, 0 validation errors. commands-gpu still passes.
  • MinGW ctest: 66 of 66. The d3d12_x targets also build with MSVC 2022. 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 (the pending recorder entry updated)
  • 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 subresource and depth-stencil view documentation, Vulkan 1.3 specification
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-22 23:13 UTC · [original](https://github.com/Dark3581/AnyBox/pull/54) `Dark3581:feat/depth-stencil-planes` → `main` · +239 −26 · 8 files · 1 commits · merged 2026-11-22 23:17 UTC ### What Two gaps of the command recorder (#51, #52): - **Plane copies**: a depth-stencil texture's subresources in plane 0 copy the depth aspect and in plane 1 the stencil aspect, as D3D12 numbers them. The footprint format has to match the plane (4 bytes per texel for the depth plane of D24S8 and D32S8, as Vulkan copies it; 1 byte for stencil). `CopyTexture` picks the aspect per plane too and refuses copies between different planes. `PlaneAspect` holds the rule; `R24G8_TYPELESS` and `R24_UNORM_X8_TYPELESS` join the copy block table. - **Read-only depth-stencil passes**: `AttachmentRef` carries the view's `D3D12_DSV_FLAG_READ_ONLY_*` flags; `BeginRendering` then uses `DEPTH_STENCIL_READ_ONLY_OPTIMAL` and `STORE_OP_NONE`, matching the layout #48 gives `DEPTH_READ` (also combined with shader resource states). A pass read-only for only one plane of a depth-stencil texture is refused: it would need per-plane state tracking. The recorder's pending debt entry is updated in place. ### Tested Windows 10, RTX 3070 Ti (driver 621.14), Khronos validation layer. - `pso_probe commands-selftest`: plane aspects, a stencil plane with a 4-byte footprint refused, a second plane of a depth-only texture refused. - `pso_probe planes-gpu --validate`: a D32S8 texture cleared to depth 0.5 and stencil 0x5A with a 0x33 stencil rectangle; the depth plane reads back as 0.5f and the stencil plane with the rectangle; the stencil plane copied into a second texture reads back the same; a mixed-plane copy, a 4-byte stencil footprint and a half read-only pass are refused; with the texture in `DEPTH_READ | PIXEL_SHADER_RESOURCE`, a read-only pass draws where the depth test `0 <= 0.5` passes and nothing with `GREATER`. 5 checks, 0 validation errors. `commands-gpu` still passes. - MinGW `ctest`: 66 of 66. The `d3d12_x` targets also build with MSVC 2022. `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` (the pending recorder entry updated) - [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 subresource and depth-stencil view documentation, Vulkan 1.3 specification - [x] AI-assisted: yes
A depth-stencil texture now copies plane 0 as depth (4 bytes per texel) and plane 1 as stencil (1 byte), to and from footprints and between textures, with the footprint format checked against the plane. An attachment carries its depth-stencil view's read-only flags, and a pass over a read-only view uses the read-only layout without a store; a pass read-only for only one plane is refused. pso_probe gains a GPU test that clears depth and stencil, reads both planes back, copies the stencil plane and draws through read-only passes with passing and failing depth tests.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:16:19 +00:00
github manually merged commit a27398ce0e into gh-pr/54/base 2026-11-26 19:16:20 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.