Skip to content

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

Closed
dkdknight wants to merge 1 commit into
ProjectLeonida:mainfrom
dkdknight:d3d-27-render-passes
Closed

dkdknight wants to merge 1 commit into
ProjectLeonida:mainfrom
dkdknight:d3d-27-render-passes

Conversation

@dkdknight

@dkdknight dkdknight commented Nov 24, 2026 •

Copy link
Copy Markdown

Claimed in the coordination issue as: D3D-27 (#14 (comment))

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 (d3d12: ExecuteIndirect accepts the argument ranges newer D3D12 runtimes accept (D3D-EXECIND-RANGE) #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

…3D-27)

Both were the generated stubs, so a render pass bound no targets and ran
none of its accesses while the device reports RenderPassesTier 0. They are
now emulated on the list's own commands, as the PC runtime does at tier 0:
Begin binds the targets and runs the CLEAR beginning accesses (colour,
depth and stencil planes), End runs each RESOLVE ending access through
ResolveSubresourceRegion; SUSPENDING keeps the ending accesses for the
resuming pass, which skips its beginning accesses.

The recording rules are WARP's, measured by the new d3d12_render_pass_test
(6 data cases byte for byte, 26 Close cases): no nesting, no End without a
pass, at most 8 targets, direct lists only, Close fails while a pass is
open, copies/resolves/clears/DiscardResource/OMSetRenderTargets fail
inside a pass, and nothing may be recorded between a suspended pass and
the one that resumes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant