d3d12: BeginRenderPass and EndRenderPass on the Vulkan-backed list (D3D-27) #628

Closed
dkdknight wants to merge 1 commit from upstream-pr/628 into main
dkdknight commented 2026-11-24 10:12:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by dkdknight on 2026-11-24T10:12:35Z.


Claimed in the coordination issue as: D3D-27 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7128178677)

What and why

On main, ID3D12GraphicsCommandList4::BeginRenderPass / EndRenderPass are the generated stubs (GraphicsCommandList in runtime/shims/d3d12_com.cpp does not override them): a render pass binds no targets and runs none of its beginning or ending accesses, while the device reports RenderPassesTier = TIER_0 and docs/d3d12_vulkan.md lists render passes as handled.

This emulates them on the list's own commands, which is what the PC runtime does for a driver at tier 0 (WARP reports tier 0 too):

  • BeginRenderPass binds the pass's render targets and depth/stencil view as OMSetRenderTargets would, and records a clear for each CLEAR beginning access (colour targets one by one; depth and stencil planes with their own flags and values).
  • EndRenderPass records a ResolveSubresourceRegion for every subresource of each RESOLVE ending access (colour, depth or stencil). ResolveSubresourceRegion's body moved into a private resolve_region so both paths share it.
  • DISCARD, PRESERVE, PRESERVE_LOCAL_* and NO_ACCESS record nothing, which each of them allows.
  • A SUSPENDING_PASS keeps its ending accesses for the pass that resumes it; a RESUMING_PASS does not run its beginning accesses again (matches WARP byte for byte).
  • Recording rules, all measured against WARP (Close's verdict, not its code): no nesting, no EndRenderPass without a pass, at most 8 targets, direct lists only (bundles fail), Close fails while a pass is open but not while one is suspended, copies / resolves / Clear*View / DiscardResource / OMSetRenderTargets fail inside a pass while barriers do not, and the pass after a suspended one must be a RESUMING_PASS with nothing recorded in between (a barrier counts).

docs/d3d12_vulkan.md section 4.3 describes this (it used to describe a planned vkCmdBeginRendering mapping), and the command table and the M3 row point at it.

Tested

New runtime/test/d3d12_render_pass_test.cpp (ctest d3d12_render_pass, exit 77 without a Vulkan GPU or under Wine): 6 data cases compared byte for byte with WARP after readback (colour CLEAR + PRESERVE with depth or stencil CLEAR, two passes on one target, SUSPENDING then RESUMING, RESOLVE ending into a region and into the whole texture) and 26 Close cases.

  • On main before the change: 8 matched WARP, 24 differ (all 6 data cases and 18 of the 26 Close cases).
  • With the change: 32 matched WARP, 0 differ; also with LEONIDA_VK_VALIDATION=1, validation clean.
  • Full runtime ctest on Windows (MSVC 19.51, RelWithDebInfo): 295 registered, 282 passed, 11 skipped, 1 disabled, 1 failed — the failure is the known d3d12_execute_indirect_validation parity case (#337), the same as on main without this change (281 passed there; the new test is the one more).
  • tests/test_ctest_registration.py, test_docs_list_items.py, test_docs_repeated_lines.py, test_docs_table_ids.py: OK. git diff --check clean; scripts/check_no_game_data.py on the changed files: OK.

Not covered: draws inside a pass (the test has no shaders; draws keep using their own dynamic-rendering scope), and which targets are bound after EndRenderPass (they stay bound here).

GPUs tested: NVIDIA GeForce RTX 5080, driver 621.14, Windows 11 Home build 26200 (WARP from the same Windows).

AI-assisted: yes (Claude Code). No game files.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5470174547 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/628). Originally posted by [dkdknight](https://github.com/dkdknight) on 2026-11-24T10:12:35Z. --- Claimed in the coordination issue as: D3D-27 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7128178677) ### What and why On `main`, `ID3D12GraphicsCommandList4::BeginRenderPass` / `EndRenderPass` are the generated stubs (`GraphicsCommandList` in `runtime/shims/d3d12_com.cpp` does not override them): a render pass binds no targets and runs none of its beginning or ending accesses, while the device reports `RenderPassesTier = TIER_0` and `docs/d3d12_vulkan.md` lists render passes as handled. This emulates them on the list's own commands, which is what the PC runtime does for a driver at tier 0 (WARP reports tier 0 too): - `BeginRenderPass` binds the pass's render targets and depth/stencil view as `OMSetRenderTargets` would, and records a clear for each `CLEAR` beginning access (colour targets one by one; depth and stencil planes with their own flags and values). - `EndRenderPass` records a `ResolveSubresourceRegion` for every subresource of each `RESOLVE` ending access (colour, depth or stencil). `ResolveSubresourceRegion`'s body moved into a private `resolve_region` so both paths share it. - `DISCARD`, `PRESERVE`, `PRESERVE_LOCAL_*` and `NO_ACCESS` record nothing, which each of them allows. - A `SUSPENDING_PASS` keeps its ending accesses for the pass that resumes it; a `RESUMING_PASS` does not run its beginning accesses again (matches WARP byte for byte). - Recording rules, all measured against WARP (Close's verdict, not its code): no nesting, no `EndRenderPass` without a pass, at most 8 targets, direct lists only (bundles fail), Close fails while a pass is open but not while one is suspended, copies / resolves / `Clear*View` / `DiscardResource` / `OMSetRenderTargets` fail inside a pass while barriers do not, and the pass after a suspended one must be a `RESUMING_PASS` with nothing recorded in between (a barrier counts). `docs/d3d12_vulkan.md` section 4.3 describes this (it used to describe a planned `vkCmdBeginRendering` mapping), and the command table and the M3 row point at it. ### Tested New `runtime/test/d3d12_render_pass_test.cpp` (ctest `d3d12_render_pass`, exit 77 without a Vulkan GPU or under Wine): 6 data cases compared byte for byte with WARP after readback (colour CLEAR + PRESERVE with depth or stencil CLEAR, two passes on one target, SUSPENDING then RESUMING, RESOLVE ending into a region and into the whole texture) and 26 Close cases. - On `main` before the change: 8 matched WARP, 24 differ (all 6 data cases and 18 of the 26 Close cases). - With the change: 32 matched WARP, 0 differ; also with `LEONIDA_VK_VALIDATION=1`, validation clean. - Full runtime `ctest` on Windows (MSVC 19.51, RelWithDebInfo): 295 registered, 282 passed, 11 skipped, 1 disabled, 1 failed — the failure is the known `d3d12_execute_indirect_validation` parity case (#337), the same as on `main` without this change (281 passed there; the new test is the one more). - `tests/test_ctest_registration.py`, `test_docs_list_items.py`, `test_docs_repeated_lines.py`, `test_docs_table_ids.py`: OK. `git diff --check` clean; `scripts/check_no_game_data.py` on the changed files: OK. Not covered: draws inside a pass (the test has no shaders; draws keep using their own dynamic-rendering scope), and which targets are bound after `EndRenderPass` (they stay bound here). GPUs tested: NVIDIA GeForce RTX 5080, driver 621.14, Windows 11 Home build 26200 (WARP from the same Windows). AI-assisted: yes (Claude Code). No game files. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!628
No description provided.