Skip to content

Runtime: record and replay D3D12 render passes as Vulkan dynamic rendering (D3D-27) - #2064

Open
opit80 wants to merge 7 commits into
ItsNotRexed:mainfrom
opit80:d3d27-render-pass
Open

opit80 wants to merge 7 commits into
ItsNotRexed:mainfrom
opit80:d3d27-render-pass

Conversation

@opit80

@opit80 opit80 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D-27 (claim; critical path #313)

What and why

ID3D12GraphicsCommandList4::BeginRenderPass/EndRenderPass had no replay path: the layer rebuilt a rendering scope per draw from the bound RTVs/DSV, losing the pass-lifetime attachment set, in-pass clears and access hints. This records both calls into the command-list IR, deep-copying every CPU descriptor at the call so rewriting a slot before ExecuteCommandLists cannot change what is submitted, and replays the pass as one vkCmdBeginRendering scope closed at EndRenderPass.

Supported subset:

  • Beginning DISCARD/PRESERVE/CLEAR map to DONT_CARE/LOAD/CLEAR; a bound DSV plane with beginning NO_ACCESS still binds DONT_CARE because core 1.3 has no "do not load" op (LOAD_OP_NONE would need VK_KHR_load_store_op_none), while a colour slot with beginning NO_ACCESS is not raster-bound and is skipped entirely (see the packing rule below). Ending PRESERVE/DISCARD/NO_ACCESS map to STORE/STORE_OP_NONE/STORE_OP_NONE (VK_ATTACHMENT_STORE_OP_NONE is core in Vulkan 1.3, promoted with VK_KHR_dynamic_rendering, not VK_KHR_load_store_op_none; no extension is enabled).
  • Depth and stencil have independent activity flags and aspect masks but share one DSV view when both are active (VUID 06085); D24 clears are quantised as elsewhere, and CLEAR depth is validated to [0,1] at record time.
  • All layout transitions run before BeginRendering; a draw inside a scope takes attachments and PSO formats from the pass snapshot, not the stale OM bindings (VUID 08910), and emits no barrier inside the scope.
  • Raster-bound RTVs are packed without gaps. The Microsoft render-passes spec binds "the order the raster bound surfaces appear in the render pass RTV list without any gaps": a colour slot whose beginning access is NO_ACCESS is not raster-bound, so its descriptor is not resolved and produces no view or layout transition, and the remaining RTVs bind from index 0 in descriptor order. VkRenderingInfo and the pipeline variant use that packed count and order, ending access does not change what is bound, and SV_Target i addresses packed raster surface i — in the spec's example, pass surfaces [2] and [4] are what the PSO's entries [0] and [1] render to.
  • The pass fixes the pipeline's attachment count. The PSO's RTVFormats count and the pass's raster count are independent in D3D12, so a draw inside a pass binds a pipeline variant whose VkPipelineRenderingCreateInfo::colorAttachmentCount equals the pass raster count: missing PSO RTVs are padded and extra ones dropped with UNDEFINED formats (VUID 06179). An active slot present in both with two different real formats is refused as a genuine mismatch. The variant's blend attachments start from the PSO's blend states, padding new slots with the first state, so the array stays identical when independentBlend is off (VUID 00605); VK_FORMAT_UNDEFINED slots keep their state and are exempt from the blend-format check, matching the validation layers' explicit skip of UNDEFINED formats. When blending is enabled and a padded or pass-reinterpreted slot's real format lacks VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT, blending is disabled on that slot alone if independentBlend is available, and otherwise the draw is refused with a diagnostic before pipeline creation (VUID 06062). The blend attachment count always equals the rendering count (VUID 06055).
  • A two-plane DSV with one active plane is supported: a two-plane PSO DSV used by a pass that activates only depth or stencil keeps its format on the active plane and sets the other plane UNDEFINED (VUID 08913/08914/08916). The pass path requires the pass and PSO depth formats to match exactly; typeless reinterpretation is not supported here. PSO outputs beyond the pass raster count have no attachment in the variant (their formats are dropped); D3D12 discards such writes.
  • Between Begin/End only Draw, DebugMarker and EndRenderPass are accepted. Barriers, dispatches, copies, resolves, queries (including BeginQuery/EndQuery), ExecuteIndirect and predication are refused in preparation rather than approximated. An unclosed pass fails Close, the error is persisted and surfaced again by Reset (a deliberate second signal so a caller that ignores Close cannot miss the rejected pass), and the queue refuses the list before any batch is emitted.
  • CheckFeatureSupport still reports RenderPassesTier = TIER_0 and RenderPassesValid = FALSE.

Explicitly refused with a diagnostic instead of being silently approximated:

  • Ending RESOLVE — this layer has no resolve path inside a dynamic-rendering scope. A pass ending in RESOLVE is rejected outright: MSAA passes that resolve in-pass do not run and there is no in-pass workaround; use ResolveSubresource/the depth-resolve replay path instead.
  • ALLOW_UAV_WRITES — UAV writes cannot be expressed inside this replay scope, so the list is refused rather than the writes dropped.
  • Read-only depth/stencil bindings — there is no read-only attachment path here; accepting them would silently discard what the application expects to be written.
  • LOCAL access types / unknown access enum values — no defined mapping in this layer, so they are rejected.
  • All nonzero render-pass flags, including SUSPENDING/RESUMING — Vulkan does have VK_RENDERING_SUSPENDING/RESUMING_BIT and VkRenderingAttachmentInfo.resolveMode, but this layer has no path for them and claims no matching submit-group/flags semantics.
  • Typeless reinterpretation of an active colour slot — a PSO RTVFormats entry that is typeless while the bound RTV carries a concrete format is legal D3D12, but this replay refuses it as a real-format mismatch with a diagnostic instead of producing a pipeline that does not match the views (depth/stencil formats already had to match exactly).
  • MSAA/1D/3D attachments and multi-planar formats have no separate dimension/sample check in prepare_render_pass; the views RTV/DSV creation can produce are the practical limit and such a view is not specially diagnosed.

Review follow-up

Both findings from @whattheflop's review are addressed in 9c8da913:

  • RTV mapping: the replay now packs raster-bound surfaces without gaps, per the Microsoft render-passes spec — beginning-NO_ACCESS colour slots are skipped entirely (no view, no layout transition) and the remaining RTVs bind from index 0 in descriptor order, with VkRenderingInfo and the pipeline variant sharing the packed count and order. Regression tests cover skipped leading/middle/trailing NO_ACCESS slots (including NO_ACCESS/PRESERVE), a DISCARD/NO_ACCESS slot that still binds its view, and a single-RTV PSO over [NO_ACCESS/NO_ACCESS, CLEAR/PRESERVE] rendering to target 0 via the base pipeline.
  • Variant blending: padded slots inherit the PSO's blend states instead of unconditionally disabling blending, and VK_FORMAT_UNDEFINED slots are exempt from the blend-format check as the Khronos validation layers are; with independentBlend off the array stays identical (VUID 00605). A real format lacking VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT used with blending enabled disables blending on that slot alone when independentBlend is available, and is refused with a diagnostic before pipeline creation otherwise (VUID 06062). The out-of-pass unbound-RTV path keeps upstream's blend array.

No Depends on:. Based on upstream/main aa2988cc (ahead 7, behind 0). Diff: 9 files, +1315/-107. The last commit (e0cb4c08) makes the CLEAR test colours exact on 8-bit UNORM so the test also passes with #589's quantized clears (found by @ddm-j).

Tested

Tested on: NVIDIA GeForce RTX 5070 Ti, driver 617.42, Windows 11 25H2 (build 26200.9974), Vulkan SDK 1.4.363.0, MSVC 19.44.35229.0, Ninja, RelWithDebInfo. Synthetic tests only.

  • Clean MSVC RelWithDebInfo Ninja builds, -j 4: 455/455 targets on 9c8da913 and 453/453 on upstream/main aa2988cc, both exit 0. Both builds logged the same MSVC C4456 and GLSL precision warnings. 0 new warnings.
  • ctest -C RelWithDebInfo -V (normal): branch 145 passed / 0 failed / 9 skipped / 1 disabled. Clean main 144 passed / 0 failed / 9 skipped / 1 disabled.
  • ctest -C RelWithDebInfo -V with LEONIDA_VK_VALIDATION=1: branch 146 passed / 0 failed / 8 skipped / 1 disabled. Clean main 145 passed / 0 failed / 8 skipped / 1 disabled. Both logged the intentional WRITE_AFTER_WRITE from the vk_sync_validation self-test. No VUIDs or new validation diagnostics.
  • ctest -R "^(replay_render_pass|command_list)$": 2/2 passed in both modes. replay_render_pass is the only additional test compared with clean main.
  • replay_render_pass_test.exe (direct, exit 0): skipped leading/middle/trailing NO_ACCESS slots (including NO_ACCESS/PRESERVE) while a DISCARD/NO_ACCESS slot still binds its view with DONT_CARE/STORE_OP_NONE; a single-RTV PSO over [NO_ACCESS/NO_ACCESS, CLEAR/PRESERVE] binds the first raster RTV at target 0 with the base pipeline; the variant follows the packed order with differing active formats; and the full variant blend array — UNDEFINED and blend-capable padding, a blend-unsupported real format under both independentBlend feature states (slot-local disable vs diagnostic refusal), and the out-of-pass unbound-RTV variant. The blend-format coverage is mock-based and does not rely on GPU feature emulation.

AI-assisted (Claude Code orchestration; Hy4/GLM sub-agents)

Checklist

  • 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: runtime-only change, no translator rule.

@whattheflop

Copy link
Copy Markdown
Contributor

AI-assisted independent review of 0e4bc370fb55c060d32440d9997bacc26dddf970 against 4eb6155d3ac4f9d3fadb0d095c4ce13e76783615.

Offscreen GPU check passed on both adapters. I linked a disposable harness based on the stock d3d12_draw shader/readback pattern against the unmodified exact-head gta6rt_d3d12_com and gta6rt_root_signature libraries. Windows 11, MSVC x64 19.38, WSDK 26100, Ninja RelWithDebInfo. Each adapter ran serially with its native ICD alone, an empty implicit-layer path and Khronos 1.4.363 core and synchronization validation. The harness used synthetic shaders, a single 64×64 RGBA8_UNORM 1× target and one scissored color draw per pass.

Adapter and driver CLEAR/PRESERVE PRESERVE/PRESERVE Validation
RTX 3080, 616.64 4096/4096 4096/4096 0 errors
Radeon iGPU (1002:13c0), 32.0.21030.2001 4096/4096 4096/4096 0 errors

The first readback matched 1024 yellow and 3072 blue pixels. The control preserved the first quadrant and added a second, matching 2048 yellow and 2048 blue. Both exited 0 with zero VUIDs and synchronization hazards. The GPU runs covered two successful single-RTV passes and readback.

Two source-review findings outside that GPU fixture:

  • NO_ACCESS shifts the color output to the wrong slot. With the pass descriptors [NO_ACCESS/NO_ACCESS, CLEAR/PRESERVE], the raster-bound RTV is target 0 in D3D12. A one-RTV PSO writing SV_Target0 should draw into it. The head leaves a null view in slot 0 and puts the real RTV in slot 1, so the target 0 output lands on the null view and the real RTV keeps its clear color. The existing gap mock asserts the slot layout that causes this. Replay code · Microsoft raster binding rules
  • The shared variant builder can violate VUID 00605 when independentBlend is disabled. With a common enabled blend state, the matching slot keeps blendEnable=TRUE and the undefined slot gets FALSE. Matching write masks still leave different attachment states. This also reaches the existing non-render-pass unbound-RTV variant path, where the base preserved the original blend array. Variant helper · Vulkan blend-state rule

@CharlyRien

Copy link
Copy Markdown

Code review of 0e4bc37 (AI-assisted). These findings don't overlap with @whattheflop's NO_ACCESS slot shift and VUID 00605 points. Differential probes compared the layer with Windows WARP on an RTX 3090 (driver 616.56, Windows 11 23H2) under LEONIDA_VK_VALIDATION=1, with 0 validation errors. Replay-level probes ran in a copy of replay_render_pass_test (mock Vulkan). Nothing was pushed.

  1. A refused BeginRenderPass drops the pass, but the list still executes (proved).
    • BeginRenderPass refuses unsupported flags and accesses (ALLOW_UAV_WRITES, SUSPENDING/RESUMING, read-only, RESOLVE, LOCAL) through check(false), which sets invalid_. ExecuteCommandLists (~L1131) only rejects render_pass_close_failed() or an open pass, never invalid_. So Close returns E_INVALIDARG, yet the list runs.
    • The pass's CLEAR is lost, and draws recorded inside it replay into whatever OMSetRenderTargets bound before the pass.
    • Repro, ALLOW_UAV_WRITES with CLEAR red over a blue RT:
      [WARP]    Close=0x00000000 RT(1,1)=ff0000ff
      [Leonida] Close=0x80070057 RT(1,1)=ffff0000   (list submitted, pass gone)
      
    • The PR text says such lists are refused "rather than the writes dropped". Checking invalid_ in ExecuteCommandLists, as ExecuteBundle already does with bundle->invalid_, would make that true.
  2. A render-pass CLEAR only covers renderArea, which is shrunk to the smallest attachment (proved). prepare_render_pass shrinks the area and the emit uses rendering.renderArea = p.area. D3D12 clears each whole view.
    • Repro: RT A 4×4 CLEAR, RT B 8×8 CLEAR green, an 8×8 D32 DSV CLEAR 0.25:
      [WARP]    RT_B(6,6)=ff00ff00 depth(6,6)=0.25
      [Leonida] RT_B(6,6)=ffff0000 depth(6,6)=1      (not cleared)
      
    • Clearing outside the shared area separately, or not intersecting the area for CLEAR accesses, would fix it.
  3. A predicated render-pass CLEAR is not predicated (proved). LOAD_OP_CLEAR ignores conditional rendering, but D3D12 skips the clear when the predicate says so. The existing ClearRenderTargetView path handles this; the render-pass path doesn't.
    • Repro: a zero buffer with EQUAL_ZERO, then CLEAR red over blue:
      [WARP]    RT(1,1)=ffff0000   (skipped)
      [Leonida] RT(1,1)=ff0000ff   (cleared)
      
  4. Typeless or reinterpreted RTVs make draws inside a pass fail (proved).
    • prepare_render_pass takes the view format from color_view_format (the resource family's default outside RGBA8), so prepare_draw returns unsupported on the mismatch with the PSO. The same draw outside a pass works, because that path views the image as the PSO format.
    • Repro: R16G16B16A16_TYPELESS (mapped to SFLOAT) with a UNORM PSO, OM draw result=0 draws=1 | same draw in pass result=9 draws=0.
    • The same applies to B8G8R8A8_TYPELESS with an sRGB RTV, and R32_TYPELESS rendered as UINT.
  5. A PSO with DSVFormat = UNKNOWN fails inside a pass with an active DSV (proved). prepare_draw returns unsupported when depth_format == VK_FORMAT_UNDEFINED. Outside a pass this is tolerated, and colour slots get padded in the same situation.
    • Repro: OM draw result=0 draws=1 | in pass result=9 draws=0.
  6. Unpaired NO_ACCESS is accepted (proved). D3D12 requires beginning and ending NO_ACCESS to be paired. Beginning NO_ACCESS with ending PRESERVE is recorded and replayed as DONT_CARE/STORE, which writes undefined contents back.
    • Mock: recorded=1 result=0 load=2 store=0.
  7. Smaller:
    • A pass whose only RT is NO_ACCESS/NO_ACCESS records, then fails at replay with invalid_render_pass.
    • After an unclosed pass, Reset returns E_INVALIDARG but has already reset the list: a second Reset gives E_FAIL, and Close then gives S_OK. WARP returns E_FAIL throughout, so the expected HRESULT is debatable.

Checked and found correct:

  • The DISCARD/PRESERVE/CLEAR load/store mapping.
  • Integer clear-colour conversion and D24 clear quantisation.
  • Passive slots keep their index.
  • Independent depth/stencil plane activity sharing one view, and the single-plane variants of a two-plane DSV.
  • No barriers or nested scopes inside a pass.
  • Nesting and unclosed passes refused.
  • Descriptors copied at record time.
  • Bundles and non-direct lists refused.
  • OM bindings left as they are after a pass, which the docs leave undefined.

ctest here also fails d3d12_draw, d3d12_vulkan_device and d3d12_typeless_rtv. Those fail on main on this machine too (#1966, and the 23H2 driver/format limits), so they aren't from this PR. Synthetic probes only, no game files.

@whattheflop

Copy link
Copy Markdown
Contributor

AI-assisted follow-up to my review of 0e4bc370. I independently verified 80a05c6884de5581ca1a2238330358a08b17bfd9 against base 4eb6155d3ac4f9d3fadb0d095c4ce13e76783615. Both findings from my earlier comment are resolved in the tested scope.

I rebuilt the exact-head runtime libraries with MSVC x64 19.38, WSDK 26100 and Ninja RelWithDebInfo, then relinked the scratch offscreen fixture. The RTX 3080 (616.64) and Radeon iGPU (1002:13c0, 32.0.21030.2001) ran serially, one native ICD per process, with an empty implicit-layer path and Khronos 1.4.363 core and synchronization validation. All six draw runs exited 0 with zero validation errors, VUIDs or sync hazards.

64×64 RGBA8 1× check Result on each GPU
Single-RTV CLEAR/PRESERVE, then PRESERVE/PRESERVE 4096/4096 each. Yellow/blue counts 1024/3072, then 2048/2048.
Leading NO_ACCESS/NO_ACCESS before the active RTV, one-RTV PSO writing SV_Target0 4096/4096 in both active readbacks, with the same yellow/blue counts as the control. All 4096 inactive pixels stayed magenta.
Additive blend, two-format PSO trimmed to one raster-bound RTV, independentBlend disabled 4096/4096 each. White/blue counts 1024/3072, then 2048/2048.

The trim case exercises a real blend variant. A separate CPU-only check passed 3/3 on the exact-head helper: the unbound OM slot and a blend-capable added slot each preserve the full common blend state with independentBlend disabled, and a mixed-format case with independentBlend allowed disables blending only for the simulated non-blendable slot. The mixed-format case was CPU-only.

The PR description still describes the old slot-preserving and blend-padding behavior. The updated implementation and runtime docs describe raster packing and common blend-state preservation. RTV packing · Blend helper

@nonverifiedperson

Copy link
Copy Markdown
Contributor

Tested 0e4bc370 on two GPUs: no regressions. Every result matches the main baseline (4eb6155d), and the new replay_render_pass test passes on both.

Windows 10 22H2, MSVC 19.44, Vulkan SDK 1.4.363.0, scripts/build_runtime.ps1 (RelWithDebInfo, Ninja): 354/354 targets. GPU chosen with LEONIDA_VK_DEVICE.

  • AMD Radeon iGPU of a Ryzen 7 9800X3D (gfx1036, RDNA2), AMD driver 32.0.13036.4. That's a newer driver than the 32.0.21030 in @whattheflop's run.
  • NVIDIA RTX 5070 Ti, driver 32.0.16.2135.

ctest, PR vs baseline (baseline = 4eb6155d plus only test-shader files, built the same way):

GPU LEONIDA_VK_VALIDATION PR (117 tests) main (116 tests) VUIDs (PR / main)
Radeon 0 2 fail 2 fail (same) —
Radeon 1 2 fail 2 fail (same) 1 / 1
RTX 5070 Ti 0 1 fail 1 fail (same) —
RTX 5070 Ti 1 1 fail 1 fail (same) 1 / 1
  • replay_render_pass and command_list pass in all four PR runs.
  • Failures that are already on main:
    • d3d12_draw fails on both GPUs with the bundle blend check ("got 128,0,128,255, expected red 64"), as in the PR description.
    • On the Radeon only, d3d12_vulkan_device also fails at line 3594: argument_mismatches <= 0. It fails identically on main and passes on the 5070 Ti.
  • The only VUID is VUID-vkDestroyPipeline-pipeline-00765, which also shows up on main.

scripts/run_gpu_tests.py at the PR head: Radeon 167/180 passed, 13 skipped; RTX 5070 Ti 136/180 passed, 44 skipped (wave64 tests without emulation). No failures.

What this doesn't cover: no render-pass draw on real hardware beyond the mock-Vulkan replay_render_pass test. So @whattheflop's NO_ACCESS slot-shift point and @CharlyRien's findings (a refused pass still executes, CLEAR clipped to renderArea, unpredicated CLEAR, typeless RTVs and DSVFormat = UNKNOWN inside a pass) are neither confirmed nor ruled out here.

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

@kapitche

Copy link
Copy Markdown
Contributor

Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51): no regression. RTX 4080 SUPER: 116/117. Not from this PR: d3d12_draw (the bundle-blend regression on main, fixed by #1995). The other Intel UHD 770 failures are known (#2078): d3d12_descriptor, d3d12_present, d3d12_m3_frame, d3d12_subgroup.

@opit80

opit80 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review and for running the offscreen checks on both adapters.

  • Render-pass replay now skips RTVs with a NO_ACCESS beginning and binds the remaining views in descriptor order. The replay test captures target 0 for a one-RTV PSO after a leading NO_ACCESS descriptor and checks ordering across an interior gap.
  • Pipeline variants preserve the blend state of undefined-format slots, including the unbound-RTV path outside render passes. If a newly used real format lacks blend support and the inherited state enables blending, the variant requires independentBlend to disable blending for that slot. The blend-state tests exercise both feature settings.

Fixed in 80a05c6884de5581ca1a2238330358a08b17bfd9, and thanks for re-checking that head. The PR description now describes the packing and blend behaviour (and lists the typeless colour-slot refusal). Thanks also to @nonverifiedperson and @kapitche for the extra AMD, NVIDIA and Intel runs.

@SpositoDouglas

Copy link
Copy Markdown
Contributor

Tested 80a05c68 on AMD Radeon RX 9060 XT (RDNA4), AMD Software 26.11.2 (32.0.32029.2010, Vulkan 1.4.359), Windows 11 Pro 26H2 (26300.9974), MSVC 19.44, Vulkan SDK 1.4.363.0: no regression from this PR. This adds an RDNA4 discrete GPU to the Radeon iGPU runs above.

  • replay_render_pass_test: pass, 2/2 runs, with and without LEONIDA_VK_VALIDATION=1.
  • command_list_test: pass, with and without validation.
  • ctest -C RelWithDebInfo: 116/117, the same with validation. Only d3d12_draw fails, at the bundle-blend check (fence signal 21 is not above 30), as on this PR's base 4eb6155d; current main waits on 31 there and passes.
  • Build (scripts/build_runtime.ps1, RelWithDebInfo): no warnings.

GitHub now reports a conflict with current main (49475796): a local merge stops in runtime/src/vulkan_replay.h.

AI-assisted (Claude Code). Synthetic tests only, no game data.

@RipcuBAN

Copy link
Copy Markdown
Contributor

Independent Windows verification of head 80a05c68 against its own merge base 4eb6155d. AI-assisted run; synthetic shaders only, no game files.

I did not merge current main (49475796) into the PR: the local merge conflicts in three hunks of runtime/src/vulkan_replay.h, one large, and resolving it would no longer be the PR head. Those numbers below are therefore PR vs its base, not vs current main.

Hardware / environment. Windows 10 build 19045, VS 2026 Community (Visual Studio 18 2026, x64), MSVC 19.51.36260, CMake 4.5.0-rc3, MSYS2 glslangValidator. Both trees built fresh with 0 errors.

  • AMD Radeon(TM) Graphics, Ryzen 5 7600X iGPU (Raphael, gfx1036 / RDNA2), driver 23.40.02, wave64, 128-byte push constants.
  • NVIDIA GeForce RTX 3060, driver 621.14, wave32, 256-byte push constants.

Full ctest -C RelWithDebInfo -j 6 --output-on-failure:

tree AMD iGPU RTX 3060
base 4eb6155d 95/101; 6 failed 100/101; 1 failed
PR 80a05c68 96/102; 6 failed 100/102; 2 failed

AMD: the failure set is identical to the base (d3d12_vulkan_device, d3d12_typeless_rtv, d3d12_compute, d3d12_draw, d3d12_set0_compute, d3d12_pipeline_library). The PR adds one test, replay_render_pass, and it passes, so the extra test is a genuine pass rather than a new failure.

RTX 3060: d3d12_draw fails on both base and PR with the known bundle-blend fence race (fence signal 21 is not above 30, bundle blend pixel (0, 0): got 127,0,127,255, expected red 64). The extra PR failure, d3d12_depth_resolve, is the -j 6 flake seen in the other runs on this machine: it passes 5/5 in isolation on the PR build (--repeat until-fail:5, -j 1). replay_render_pass and command_list pass on both GPUs.

No regression from this PR on either GPU in the tested scope. The open caveat remains that these are synthetic/runtime tests; real render-pass draws from the game still need RT-5.

…ering (D3D-27)

Record BeginRenderPass/EndRenderPass into the command-list IR, copying every CPU
descriptor at the call so later slot rewrites cannot change submitted attachments.
Replay opens one vkCmdBeginRendering scope and closes it at EndRenderPass.

Supported subset: PRESERVE/CLEAR/DISCARD beginning and PRESERVE/DISCARD/NO_ACCESS
ending accesses; passive NO_ACCESS colour slots are dropped and remaining MRT slots
compacted; depth and stencil have independent activity/aspects but share one DSV
view; layout transitions run before BeginRendering; draws inside a pass take
attachments and formats from the pass snapshot. Unbalanced passes fail Close, Reset
and ExecuteCommandLists.

Explicitly refused with a diagnostic rather than approximated: ending RESOLVE,
ALLOW_UAV_WRITES, read-only depth/stencil bindings, LOCAL access types, MSAA/1D/3D
and multi-planar attachments, and all nonzero render-pass flags (SUSPENDING/
RESUMING included). No suspend/resume or submit-group semantics are claimed.
CheckFeatureSupport still reports TIER_0 / RenderPassesValid = FALSE.

Adds command_list and replay_render_pass regression tests plus the docs/d3d12_vulkan.md
section 4.3 update.
Passive NO_ACCESS colour slots keep their original OM index with a null image view and VK_FORMAT_UNDEFINED instead of being dropped and compacted, so SV_Target k still reaches attachment k. PSO format matching and the pipeline variant use the same slot indices. Fix the MSVC C4838 aspect-flag cast, set the primitive-restart function pointer in the replay test mock, and validate CLEAR depth in [0,1] at record time. Regression tests cover an interior passive slot in both the captured VkRenderingInfo and the pass-snapshot draw path.
Document that passive NO_ACCESS slots keep their index with a null image view and that Vulkan 1.3 promotes STORE_OP_NONE to core. Clarify the refused command list, the effect of rejecting RESOLVE endings on MSAA passes, the absence of a dimension/sample check, and the deliberate Reset HRESULT deviation.
… DSV (D3D-27)

Build a pipeline variant whose rendering color count and formats come from the
active pass so vkCmdDraw's 06179 count rule holds for any PSO RTV count, and keep
the blend attachment count equal to it. Allow a two-plane D24S8 PSO in a
depth-only pass by making the inactive stencil plane UNDEFINED. Correct the
STORE_OP_NONE promotion attribution in the docs and cover both cases with tests.
…-27)

Pipeline variants built for a render-pass draw could copy the PSO's blendEnable=TRUE into slots the pass padded or reinterpreted, invalid when the slot's format lacks COLOR_ATTACHMENT_BLEND_BIT (VUID 06062). A shared helper now keeps the PSO's blend state only for its own real formats and disables blending elsewhere; the write mask is preserved so attachments stay identical when independentBlend is off (VUID 00605). The replay test covers padded and reinterpreted slots.

Document the remaining render-pass caveats: dropped RTV writes, inactive test planes, exact depth-format matching.
@ddm-j

ddm-j commented Nov 22, 2026

Copy link
Copy Markdown

Clash with #589, found by merging both onto main aa2988c and testing (Windows runtime cross-built with clang-cl + xwin, Wine 11.21 on Fedora 45, RDNA2 iGPU with RADV Mesa 26.2.6 and RTX 4070 Ti with 615.78.08): replay_render_pass fails once #589 is in.

Cause: #589 rounds a float clear colour to the target's normalised format the way D3D does (quantize_unorm in render_target_clear_color, runtime/src/vulkan_replay.h). The CLEAR case here clears an R8G8B8A8_UNORM target with {0.25f, 0.5f, 0.75f, 1.0f} (replay_render_pass_test.cpp:185) and expects those exact floats (:225). On 8 bits, 0.25 becomes 64/255 and 0.75 becomes 191/255, and 0.5 is a tie that goes to 128/255. #589 does that on purpose, so the expectation here is what should change.

Fix, checked on both GPUs with #589 merged (and it still holds without #589, since these floats pass through unchanged):

-    c.beginning.color = {0.25f, 0.5f, 0.75f, 1.0f};
+    c.beginning.color = {0.2f, 0.4f, 0.6f, 1.0f};   // 51/255, 102/255, 153/255: exact on 8-bit UNORM
...
-    expect(seen.color_clear[0].float32[0] == 0.25f && seen.color_clear[0].float32[1] == 0.5f &&
-               seen.color_clear[0].float32[2] == 0.75f && seen.color_clear[0].float32[3] == 1.0f,
+    expect(seen.color_clear[0].float32[0] == 0.2f && seen.color_clear[0].float32[1] == 0.4f &&
+               seen.color_clear[0].float32[2] == 0.6f && seen.color_clear[0].float32[3] == 1.0f,

With it: replay_render_pass_test: raster attachment order, blend states, pass-snapshot draw, DSV aspects, scope gates PASS on both GPUs.

Whichever of the two lands second will hit this. cc #589.

AI-assisted (Claude Code); results copied from the run logs.

@opit80

opit80 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@ddm-j Thanks for the thorough report and the verified fix — applied in e0cb4c0 on d3d27-render-pass.

The CLEAR case now uses {0.2f, 0.4f, 0.6f, 1.0f} (= 51/102/153 over 255, exact on 8-bit UNORM, so the values survive quantize_unorm unchanged) and the expectation matches; command_list_test's IR copy keeps the raw floats and needed no change.

Verified on Windows/MSVC: branch alone 154/154 ctest PASS; with #589 (ffe9b18) merged into this branch, replay_render_pass + command_list PASS both normally and with LEONIDA_VK_VALIDATION=1. One caveat for #589: on this machine's RTX 5070 Ti the merged combo fails d3d12_typeless_families (14/82 clear mismatches — the host driver truncates 0.5·255 to 0x7f where WARP and the layer round to even 0x80), which is #589's own behaviour on this GPU and unchanged by this fix.

AI-assisted (Claude Code orchestration; GLM sub-agent).

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.

8 participants