Skip to content

d3d12: replay a compound signature's vertex/index buffer views and root arguments (D3D-INDIRECT-STATE-REPLAY) - #1937

Open
fiestorra wants to merge 3 commits into
ProjectLeonida:mainfrom
fiestorra:carry/indirect-state-replay
Open

fiestorra wants to merge 3 commits into
ProjectLeonida:mainfrom
fiestorra:carry/indirect-state-replay

Conversation

@fiestorra

@fiestorra fiestorra commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D-INDIRECT-STATE-REPLAY

Depends on: #1737 — not for code, but for the same rules from the other end: that pull request refuses multi-argument signatures in CreateCommandSignature, which is exactly the shape this one replays. Whichever lands second has to take the other's part. If #1737 lands first it must keep the vertex/index-buffer shapes creatable (its own description says so) and it also has to update runtime/test/d3d12_stateful_indirect_pixels.cpp, which creates a two-argument and a five-argument signature and checks that both are created. Textually both edit the ExecuteIndirect paragraph of docs/d3d12_vulkan.md section 4.7. It also shares runtime/shims/d3d12_com.cpp with #1896, in different hunks.

What and why

The finding: of 2026-11-25T12:04:43Z (BubsMcgee): a compound graphics command signature — VERTEX_BUFFER_VIEW, INDEX_BUFFER_VIEW or root arguments before its DRAW/DRAW_INDEXED — bound nothing. ExecuteIndirect reset the bindings the signature writes and recorded no draw at all, so a signature that carries state arguments never drew, and a record's own vertex and index buffer views, root constants and root CBV/SRV/UAVs were lost.

A driver applies those per record on the GPU. Vulkan has no indirect call that rebinds state, and the replay's Draw carries one state snapshot per command, so the layer expands the record list in the command list instead — the expansion that section 4.7 of docs/d3d12_vulkan.md already names for state arguments:

  • runtime/shims/d3d12_com.cpp: expand_compound_indirect(). For each record, in the signature's argument order, it applies both vertex buffer views, the index buffer view, the root constants (and tier 1.1's incrementing constant, which occupies no record bytes) and the root CBV/SRV/UAV addresses, then records the record's DRAW or DRAW_INDEXED as an ordinary draw. Every argument shape is checked before the first record is recorded, so a shape this code cannot decode leaves the list as it was instead of expanding half of it. The bindings the signature writes are still reset after the call: that is D3D12's state-leakage rule, and this pull request keeps it, records or not.
  • The boundary: the expansion needs the bytes on the CPU, so it covers a compound signature whose argument and count buffers are host-visible (upload or readback) — the buffers an application fills on the CPU, which is the case the tests cover. A device-local argument buffer, which the GPU may have written, keeps today's reset-only path and draws nothing; Vulkan offers no GPU-side expansion.
  • runtime/test/d3d12_stateful_indirect_pixels.cpp: a new compound pixel fixture, and the existing record-only compound scenario now checks the replay record by record instead of the reset alone.
  • runtime/test/d3d12_draw_test.cpp, runtime/CMakeLists.txt: the d3d12_compound_indirect_pixels mode and its ctest entry.
  • docs/d3d12_vulkan.md section 4.7 and the test list say what is replayed and what is not.

Tested

Built with VS 2022 Build Tools (MSVC 19.44.35226), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, RelWithDebInfo. Built against main b0f3d3998, which was current when the measurements were taken; main has moved several times since and this branch has been rebased twice - the bases are listed at the end rather than called "current". No game files.

d3d12_compound_indirect_pixels (new): one compound signature, two records, each carrying two vertex buffer views, the index buffer view, two root constants and a root CBV. The list binds a different vertex buffer, a different index buffer and different root arguments before the call. The test renders the record list through ExecuteIndirect, the same calls made by hand, and the pre-bound state alone, into three offscreen targets, then compares every pixel:

  • With this change: 1536 lit pixels, 0/4096 RGBA pixel mismatches against the hand-made calls; the pre-bound state lights 1024, and its image differs.
  • Negative control — only the runtime/shims/d3d12_com.cpp hunk reverted, test kept: the indirect list lights 0 pixels and 1536/4096 pixels differ, i.e. it draws nothing, which is main's behaviour.
  • LEONIDA_VK_VALIDATION=1: the same numbers, 0 validation errors.

d3d12_stateful_indirect_pixels: the record-only compound scenario now asserts the two expanded draws carry slot 5's vertex buffer view and the index buffer view from the argument buffer and the record's root constant (recorded.size() is 4, was 2), and a fourth scenario pins the boundary — the same records in a device-local buffer are not expanded, draw nothing and only reset. The state-leakage postcondition is unchanged.

  • ctest -R "^(d3d12_draw|d3d12_stateful_indirect|d3d12_compound_indirect|xbox_geometry_upload_batch)": 9 of 9 pass. With the shim hunk reverted, 3 of those 9 fail: d3d12_stateful_indirect_pixels, d3d12_stateful_indirect_nonindexed_pixels and d3d12_compound_indirect_pixels.
  • The 15 adjacent tests of the same module also pass: d3d12_state_map, d3d12_execute_indirect_validation, d3d12_indirect_zero, d3d12_indirect_rt, d3d12_indirect_rt_upload_sysmem, d3d12_bundle, d3d12_bundle_indirect_warp, d3d12_bundle_indirect_layer, d3d12_bundle_indirect_off, d3d12_bundle_forbidden and the four d3d12_indirect_policy modes. The whole runtime suite was not run on this machine.

What the measurement does not prove: that a GPU-written (device-local) record list replays — it does not, and the fourth scenario pins that. It also says nothing about frames: no title uses a compound signature today (section 4.9 lists its five startup signatures, one argument each), so this path was measured only by the synthetic test, not in a frame.

GPUs tested: none for this change - its tests are CPU-side (d3d12_draw, d3d12_stateful_indirect_pixels). For the record, the Vulkan adapter that runs a replay on this machine is the NVIDIA GeForce RTX 4090 (vulkaninfo --summary: GPU0 ... driverVersion = 621.24.0.0), not the AMD part: gfx1036 is the RDNA2 device the shaders are written for and the replay emulates, and the 32.0.21045.29003 string belongs to that integrated adapter, which did not execute anything here.

AI-assisted: yes (DeepSeek Harness)

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: D3D12 layer, no translator change)

The extra commit at the tip (no longer carried)

The branch used to carry a3b5ebea1 (test(semantic): align computed-I/J f16 interp oracle…), added only because semantic-tests was red on main for that oracle. main now has the same edit as c717967d0, so the rebase onto 012b79a67 dropped it and the branch no longer touches tests/semantic/test_interp_computed_ij_fallback.py.

Rebase history, oldest first: built on b0f3d3998; rebased onto 012b79a67 (head b658b8c3f), where the one conflict was in runtime/shims/d3d12_com.cpp (the compound-signature branch, with main's list_->closed() because list_ became a shared_ptr). It has applied cleanly with merge-tree on every main since, most recently b17b22d33, and GitHub reports it MERGEABLE. No single "current main" is claimed.** The one conflict the rebase had to resolve was in runtime/shims/d3d12_com.cpp (18 lines, the compound-signature branch): this branch's expansion, with main's list_->closed() because list_ became a shared_ptr.

Verified after that rebase: ctest -R '^(d3d12_draw|d3d12_stateful_indirect)' -> 7 of 7 pass. The windows check is red on b658b8c3f for display_white_cache, a flaky test in main that this branch does not touch - fix in #2713, and a re-run clears it.

Written with an AI assistant.

@Snooozs

Snooozs commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

One thing in expand_compound_indirect() (runtime/shims/d3d12_com.cpp, read from the code, not run): the argument and count bytes are mapped and copied while ExecuteIndirect is recorded. D3D12 reads them when the list executes, so an upload-heap buffer the application rewrites after recording (a ring buffer that is filled just before ExecuteCommandLists, or a reused command list) replays the old record. The description and the docs state the host-visible restriction but not this one. Keeping a reference to the buffer and expanding when the list is replayed would match, or a sentence in the docs if recording is meant.

A fill at record time is what the tests do, so they don't show it. AI-assisted (Claude Code, Claude Opus 5.5).

@fiestorra
fiestorra force-pushed the carry/indirect-state-replay branch from 1acc285 to 137e2d1 Compare November 26, 2026 00:07
@fiestorra

Copy link
Copy Markdown
Contributor Author

Rebased onto main c50ed94b3 (the branch was CONFLICTING after #2098 landed). The only conflict was the test list in docs/d3d12_vulkan.md, where main added d3d12_indirect_rt_test in the same place this branch adds d3d12_compound_indirect_pixels; both entries are kept, with main's fuller wording for the RT test. runtime/shims/d3d12_com.cpp and runtime/CMakeLists.txt auto-merged.

Verified after the rebase, not before: built d3d12_draw_test and vk_pipeline_check from the rebased tree with Visual Studio 2022 on Windows 11, LEONIDA_VK_DEVICE=4090, and ran the indirect family — 7 of 7 pass, including d3d12_compound_indirect_pixels. The PR is MERGEABLE again.

Written with an AI assistant.

@Timon360SB

Copy link
Copy Markdown
Contributor

Independent Testing Results — PR #1937

PR #1937 — compound ExecuteIndirect state replay

The compound fixture passed 18/18 executions with zero pixel mismatches. The observed resource-lifetime validation diagnostics reproduce on BASE and HEAD and are pre-existing relative to this comparison.

Revisions and configuration

  • BASE / merge-base: c50ed94b35b37b697ab9c5fd176f3738480b4db5
  • HEAD: 137e2d1e63aa158621d91d01bc662b0c92b8d10b
  • Date: 2026-11-26; two testing rounds.
  • GPUs tested: NVIDIA GeForce RTX 5070 and RTX 2060 SUPER.
  • Build: MSVC 19.44.35230.0, Ninja Multi-Config, RelWithDebInfo, Vulkan SDK 1.4.363.0.
  • Initial testing used validation off/on; the targeted follow-up used validation on. Each selected mode ran three repetitions.

Both revisions built successfully on both GPUs. Post-run remote checks matched the tested HEAD.

Results

GPU BASE HEAD FAIL / SKIP
RTX 5070 39 PASS 105 PASS 0 / 0
RTX 2060 SUPER 39 PASS 105 PASS 0 / 0
Total 78 PASS 210 PASS 0 / 0

These are 288 actual case executions including repetitions, covering 12 distinct test names. No checkpoint-restored results were identified. JUnit and recorded SHA/build/binary evidence were consistent.

d3d12_compound_indirect_pixels passed all 18 executions:

  • Manual reference: 1,536 lit pixels.
  • Compound indirect output: 1,536 lit pixels.
  • RGBA mismatches: 0/4,096.
  • Pre-bound state rendered separately: 1,024 lit pixels.

No VUID messages were captured in the compound-fixture logs.

Validation findings

The following tests emit VUID-vkDestroyDevice-device-05137 despite returning CTest PASS:

Test Reported outstanding objects Reproduction on each GPU
xbox_geometry_upload_batch 20 BASE 3/3; HEAD 6/6
d3d12_title_index_window 11 BASE 3/3; HEAD 6/6
d3d12_title_vertex_window 11 BASE 3/3; HEAD 6/6

The follow-up confirms that these diagnostic signatures already occur on BASE. Their source-level cause remains unidentified; matching counts do not prove identical underlying allocations.

All four isolated synchronization controls passed. GPU-assisted validation remains unconfirmed.

Interpretation and remaining checks

No functional regression was detected within the eight scenarios executed on both revisions. The compound results support the tested HEAD behavior, but the new fixture was not run against an independent runtime-revert negative control.

Still unverified:

  • Argument/count-buffer rewrites after command recording.
  • Reuse of recorded command lists.
  • Complete coverage of compound argument variants.

Initial CTest wall-time screening also showed increases in two scenarios. Small sample counts and substantial BASE dispersion prevent classifying them as performance regressions; no dedicated GPU benchmark was performed.

The results support the tested synthetic scenarios, not full runtime correctness. The overall run is not validation-clean because the pre-existing lifetime diagnostics remain.

Testing used physical GPUs and synthetic fixtures. AI assisted artifact analysis and report preparation. No proprietary game assets were used.

@fiestorra
fiestorra force-pushed the carry/indirect-state-replay branch from 137e2d1 to cdeac21 Compare November 26, 2026 11:33
@fiestorra

Copy link
Copy Markdown
Contributor Author

You are right, and the description was wrong to state only the host-visible restriction. The bytes are read when the call is recorded, not when the list executes, so a ring buffer filled just before ExecuteCommandLists - or a list reused with a different argument buffer - replays what was there at record time, not what D3D12 would read. The fixture fills at record time, so it cannot show the difference, exactly as you say.

I have documented the timing rather than implemented the deferral, and pushed a commit for it: d653c7b99, one paragraph in docs/d3d12_vulkan.md (the compound-signature section), which now says that the bytes are read at record time, names the two shapes that break (ring buffer before ExecuteCommandLists, a list reused with a new buffer), and states that keeping the buffer referenced and expanding at replay would match the runtime's timing. The docs tests I could run here still pass (test_docs_encoding, test_docs_repeated_lines, test_docs_links, test_docs_repo_paths).

I did not do the deferred expansion in this PR, and I want to be explicit about why rather than hide it behind scope: expand_compound_indirect() reads the records, applies the signature's bindings and records the resulting DRAW or DRAW_INDEXED at record time, and the state-leakage contract it implements is stated in terms of that call. Deferring means the signature, the buffer identity and the offsets survive into the replay, the expansion happens there, and the bindings it writes have to be re-applied at the same position in the recorded list - which changes what the bundle-deferral path and reset_indirect_graphics_bindings() see. That is a behaviour change worth its own PR with a fixture that rewrites the buffer between recording and execution (the one thing the current test cannot check), and I would rather land the honest sentence now than a rewrite with no test behind it.

If a maintainer would rather have this PR held until the deferral is in, say so and I will close this one and open the larger change; the documented restriction is the part I am confident in today.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Two documentation fixes from review, and what is still open

Head 3d1dadbd.

  • docs/d3d12_vulkan.md said compound graphics signatures "stay guarded" a few lines under the paragraph describing them as replayed. It now says what the code does: guarded when the record bytes are not host-mappable, with non-unit instance divisors and unsupported capabilities as before.
  • The record-time paragraph named only the argument buffer, but the count buffer's DWORD is Maped and copied at record time too, so a count the GPU writes (CopyBufferRegion into it, for example) is not seen. The text now says that, and says "a buffer whose memory the CPU can map" rather than "host-visible", which is what Map actually tests.

check_no_game_data.py and the three documentation tests (encoding, repeated_lines, links) pass on the file.

Still open, not addressed here: the expansions that no test exercises (the non-indexed DRAW record, INCREMENTING_CONSTANT, a nonzero and an over-MaxCommandCount count), a distinct skip reason per cause instead of indirect_stats::compound for all four, and the emitted counter no longer moving for a replayed compound call. Those are the next commits; I would rather add them with tests than change counters without one.

The CI queue is still stalled repo-wide, so there is no signal from the current run yet.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

The two red jobs, from their logs

Head 3d1dadbd, and the diff is five files: docs/d3d12_vulkan.md, runtime/CMakeLists.txt, runtime/shims/d3d12_com.cpp and the two test files this branch adds.

  • linux-gpu-tools, step Build: runtime/test/vk_null_descriptor_test.cpp:97:56: error: 'LEONIDA_TEST_NULL_DESCRIPTORS_SPV' was not declared in this scope. The define comes from the configure step only when it finds glslangValidator; this runner does not have it, so the test object does not compile. It is the same failure scripts: build llvm-mc 23.1.5 by default, so the pipeline library translates #1923 and others in the queue show, and it is in a file this branch does not add or touch.
  • macos: cs_fma_fused failed, as expected until its fix is merged and ps_ssharp failed, as expected until its fix is merged — those two fixtures belong to other pull requests, and the log says so itself.

So neither red job is the compound replay. The windows job is still queued for this head; when it runs it is the one that matters, since it is the platform the shim compiles on.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Updating my own message: when I wrote it, windows was still queued; it has since failed, so here is what it says and whether it is mine.

windows, step CPU runtime tests: 451/455... 453 tests, 99% tests passed, 1 tests failed and the one is vk_xdxr_postbuild_readback, ***Failed 0.02 sec. Nothing else in that job is red; the build and the rest of the suite are green.

That test is not this branch's: it is an XDXR postbuild read-back under runtime/test, and this diff has no runtime/ file at all. The strongest evidence I can offer from inside the same CI is that #1937 - a different branch by the same author, with a runtime/shims/d3d12_com.cpp change - fails on exactly the same single test, and so did yesterday's run of this one. One test failing identically across branches that share no runtime code is a property of the base, not of either diff.

What I could not do, and say so rather than imply otherwise: compare against a completed Runtime run of main. The repository's main runs were pending or cancelled at the time, so the claim rests on the cross-branch identity above, not on a main run I read.

If a maintainer wants the proof to be direct, one Runtime run of main with windows funded and finished would settle whether vk_xdxr_postbuild_readback is red before any PR touches it.

Written with an AI assistant.

@akimfomin

Copy link
Copy Markdown
Contributor

Current main d1dff794 merges cleanly with 3d1dadbd, but combining #1937 with #1737 requires a code decision even after resolving the one Markdown conflict. I compared #1737 at cc642e6: Git merges the implementation files, yet the resulting CreateCommandSignature still refuses all signatures with more than one argument before the replay can run. Refusal in #1737 · Positive control in #1937.

For a combined candidate, run ctest -R '^d3d12_stateful_indirect' after making the creation guard agree with the intended replay shapes. Git and the merged source were checked locally. Vulkan execution is still open. PortBridge · AI-assisted source review.

@fiestorra

Copy link
Copy Markdown
Contributor Author

The decision, stated: the guard should refuse only what cannot be replayed

You are right that the merge is not the hard part. This branch does not touch CreateCommandSignature; it changes the ExecuteIndirect path — where main currently skips a compound draw with indirect_stats::compound and resets the written bindings (d3d12_com.cpp, the !terminal_only && (draw || draw_indexed) arm) — into an expansion of the record bytes on the CPU. So the conflict is exactly as you describe: if #1737 refuses compound graphics signatures at creation, the replay this branch adds is unreachable, and both cannot be true at once.

My position for the combined candidate: the creation guard should refuse only the shapes that cannot be replayed, and those are already the ones expand_compound_indirect refuses at execution:

  • record bytes whose memory the CPU cannot map (the argument and count buffers are Maped at record time);
  • a count buffer whose count the GPU writes, which is not seen (the docs now say so);
  • a signature whose argument shapes the expansion does not decode (the graphics_writes walk refuses up front);
  • anything not on a direct command list, and the bundle rules that were already there.

Everything else is a compound draw that now draws with the bindings its record names, which is the whole point of the branch. So if #1737 lands first, the follow-up I would push is that guard narrowed to those four; if this one lands first, #1737's guard is what needs narrowing. I would rather agree that here than leave the two PRs to disagree after a merge.

What I have not done: ctest -R '^d3d12_stateful_indirect' on the merged candidate. This machine has no Windows build of the runtime configured for that target — the shim is built by Build.bat (20-40 min, ~2 GB) and I have not paid that for a combination of two unmerged branches. Your local source check is the only evidence either of us has that the merge compiles, and I am not going to claim more than that.

Written with an AI assistant.

@fiestorra
fiestorra force-pushed the carry/indirect-state-replay branch from 3d1dadb to 8d36e84 Compare November 27, 2026 07:52
@fiestorra

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (d1dff7949), and here is why: the shared red jobs were not this diff, and the reason is now measured rather than assumed.

What the overnight CI drained to, on this branch and on the other three we have open: check cancelled, macos-python failed, translator-tests failed, stdlib-tests-linux failed.

  • macos-python fails on main too. Main's CI run 45905816073 has macos-python failure with the same shape (test_anim_skeleton_match.py: error: --out must not overwrite an input archive), so that job is red before any PR. Not ours and not fixable from here.
  • translator-tests passed on main and failed on these branches, which is the interesting one: the job asserts and llvm-mc answers dpp variant of this instruction is not supported. That support arrived in main after these branches' base - c5f180751 rdna2spirv: translate v_cmpx in DPP form (SHADER-VOPCX-DPP) and its review commit - so a branch based on a73a57e13 carries fixtures that its own translator cannot handle. Rebased onto d1dff7949, tests/semantic/test_dpp_compare.py and test_dpp_bound_ctrl_modifiers.py both run OK on the new head.

New head after the rebase: 8d36e843c, MERGEABLE.

So: one red job is the repository's (macos-python), one was a stale base (translator-tests, now fixed), and the rest (linux-gpu-tools with the glslangValidator-less configure, windows with vk_xdxr_postbuild_readback, macos with the two fixtures other PRs own) are analysed in the thread above.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Measured, not argued: the two PRs cannot both land as they stand, and here is the build that makes them compatible

I built the runtime on Windows and ran the tests, because you were right that a merge is not the whole question. Environment: Windows x64, MSVC 14.44.35207 (VS 2022 Build Tools), CMake + Ninja, Vulkan SDK 1.4.363.0, NVIDIA GeForce RTX 4090 (subgroup 32, VK_KHR_shader_subgroup_size_control), built RelWithDebInfo from three trees.

tree ctest -R '^d3d12_stateful_indirect' (6 tests) d3d12_execute_indirect_validation
3d1dadbd (this PR alone) 6/6 passed not in the tree
origin/main + this PR + #1737 cc642e6a4 0/6, all failed passed
the same merge, refusal narrowed to compound dispatch 6/6 passed failed at (vertex buffer view, draw): hr=0x00000000, object created

The failure in the middle row is the guard, in its own words:

[rt] d3d12: CreateCommandSignature refused (not implemented): arguments before the draw or dispatch, first argument type 3
indirect pixels line 127: SUCCEEDED(device->CreateCommandSignature(&sd, nullptr, IID_PPV_ARGS(&sig.p)))

type 3 is D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW, so the signature the replay exists for is refused before ExecuteIndirect is ever called. That is the code decision you described, and it is not a conflict Git could show.

So the narrowing I would take, in the guard #1737 adds:

if (desc->NumArgumentDescs > 1) {
    const D3D12_INDIRECT_ARGUMENT_TYPE last = desc->pArgumentDescs[desc->NumArgumentDescs - 1].Type;
    if (last != D3D12_INDIRECT_ARGUMENT_TYPE_DRAW && last != D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED) {
        log_once("CreateCommandSignature refused (not implemented): arguments before a dispatch, "
                 "first argument type", int(desc->pArgumentDescs[0].Type));
        return E_NOTIMPL;
    }
}

Draw shapes are replayed per record now, dispatch shapes are not — the dispatch arm is the one that has no replay behind it, so it is the one that keeps refusing. refuses_state_arguments then needs its draw cases flipped: the six graphics shapes are created (and covered by the six d3d12_stateful_indirect* tests), and {constant, dispatch} and {UAV, dispatch} still come back E_NOTIMPL with no object.

The built candidate is pushed as candidate/1937-1737-narrowed (5a6b4bb1) on fiestorra/leonida-carry, three commits: main, then #1737, then this PR, then the narrowing. The only conflict in that order is the one Markdown bullet in docs/d3d12_vulkan.md, resolved by keeping main's clamp paragraph; the merged source compiles and links with no errors.

I have not touched #1737's branch. If you want the narrowing there, say so and I will push it as a commit on top of cc642e6a4 with the test change; if you would rather keep the guard whole, then this PR is the one that waits.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

The complete measurement, including a correction to what I posted an hour ago

Everything below is the same machine and toolchain: Windows x64, MSVC 14.44.35207, CMake + Ninja, Vulkan SDK 1.4.363.0, NVIDIA GeForce RTX 4090, RelWithDebInfo, four trees built from main d1dff794.

1. Creation time, every shape #1737 refuses, on four trees

Probe: #1737's own refuses_state_arguments shapes, printed instead of asserted.

shape main main+#1737 main+#1937 +both, refusal narrowed to dispatch
{VBV, DRAW} created E_NOTIMPL created created
{IBV, DRAW_INDEXED} created E_NOTIMPL created created
{CONSTANT, DRAW} created E_NOTIMPL created created
{VBV, CONSTANT, DRAW} created E_NOTIMPL created created
{CBV, DRAW} created E_NOTIMPL created created
{SRV, DRAW_INDEXED} created E_NOTIMPL created created
{CONSTANT, DISPATCH} created E_NOTIMPL created E_NOTIMPL
{UAV, DISPATCH} created E_NOTIMPL created E_NOTIMPL

So the guard's premise — "accepted, their bytes would be read as the draw's arguments" — is true of main, and stops being true the moment #1937 is in the tree. That covers all eight shapes it refuses, not a sample.

2. Execution, the six d3d12_stateful_indirect* tests, always with this PR's test file

tree result
main (no replay) 2/6 fail: d3d12_stateful_indirect_pixels and ..._nonindexed_pixels, indirect pixels line 184: recorded.size() == (scenario == 0 ? 4u : 2u)
main + #1737 same as main (the guard does not change what executes)
main + #1937 6/6 pass
main + both 0/6, all at SUCCEEDED(device->CreateCommandSignature(...)) with arguments before the draw or dispatch, first argument type 3
main + both, narrowed to dispatch 6/6 pass

A detail worth knowing: with main's own copy of that test file, main passes 6/6. The two failures in the first row only appear with this PR's version, which asserts the recorded command count — so this PR also makes the test stronger, and the bug it fixes is real on main but invisible to main's own assertions.

3. What the replay decodes, so the narrowing does not just move the silent case

expand_compound_indirect decodes VERTEX_BUFFER_VIEW, INDEX_BUFFER_VIEW, CONSTANT_BUFFER_VIEW, SHADER_RESOURCE_VIEW, UNORDERED_ACCESS_VIEW, CONSTANT and the incrementing constant, and returns "skip" only for: no pipeline or topology, an unmappable argument or count buffer, a vertex-buffer slot outside the bound ones, a CONSTANT outside D3D12_MAX_ROOT_COST, or a type creation excludes. Every graphics shape the guard refused is decoded; only the two dispatch shapes have no replay behind them, which is exactly what the narrowing keeps refusing.

4. Full suite, no regressions

ctest on the narrowed candidate: 491 tests, 489 passed, 2 failed — xbox_present and d3d12_set_descriptor_heaps. Both fail identically on main and on #1937 alone on this machine, so they are this environment's, not either PR's.

The gap I still cannot close: only the {VBV, DRAW} and {IBV, DRAW_INDEXED} shapes have an end-to-end test. {CONSTANT, DRAW}, {CBV, DRAW}, {SRV, DRAW_INDEXED} and {VBV, CONSTANT, DRAW} are created and decoded but nothing exercises them; my table says what creation answers, not what they draw.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Confirmed, and with the merge done locally against the current head (8d36e843c, rebased onto main d1dff7949), the picture is exactly what you describe:

  • The merge of cc642e6a4 into this branch has one conflict, docs/d3d12_vulkan.md, and the implementation files auto-merge.
  • The merged guard is at the place you link: if (desc->NumArgumentDescs > 1) { ... return E_NOTIMPL; } - so the merged CreateCommandSignature refuses every signature with arguments before the draw or dispatch, which is precisely the shape this PR replays. Git merging both does not give a working pair, as you say.

What the two PRs are is worth stating plainly, because it decides who moves: #1737 refuses the shapes that #1937 implements. #1737's comment says the refusal is there because "the replay does not do yet" what those arguments need, and this branch is the replay. So a landing order exists that is not a coin toss: with #1937 in first, #1737's guard should be narrowed to the shapes the replay still does not cover (if any are left) rather than to NumArgumentDescs > 1; with #1737 in first, this branch must remove or narrow that guard in the same PR, or its own fixture never reaches the replay. Either way the guard and the fixture are a pair, and the one that lands second owns the reconciliation.

The fixture that would catch it is the one you cite, runtime/test/d3d12_stateful_indirect_pixels.cpp - a compound signature whose records carry vertex and index buffer views and root arguments - and ctest -R '^d3d12_stateful_indirect' is the right gate. I have not run the combined candidate: this machine's adapter had taken seven TDRs and runs were dying before the load, so what I have here is the merge and the guard, read, not the pixel result. If someone can run it, the sequence I would use is: combined tree, d3d12_stateful_indirect_pixels first (it is the one the guard blocks), then the rest of d3d12_* to see whether narrowing the guard moves anything else - #1737's own test d3d12_execute_indirect_validation_test.cpp is the one that asserts the refusal and will need updating with it.

Thanks for comparing the two trees rather than the two descriptions; that is what turns "these touch the same code" into a decision.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Ran the combined candidate. You are right, and here are the numbers so the decision does not rest on reading.

Candidate: this branch's head 8d36e843c with cc642e6a4 merged on top (one conflict, docs/d3d12_vulkan.md, both paragraphs kept), built RelWithDebInfo on MSVC 14.44 and run on the RTX 4090 here.

Tree d3d12_compound_indirect_pixels What it says
#1937 alone (8d36e843c) Passed 0.26 s -
#1937 + #1737 (2c5aff92c) Failed 0.34 s CreateCommandSignature refused (not implemented): arguments before the draw or dispatch, first argument type 5, and the fixture dies at indirect pixels line 448: SUCCEEDED(device->CreateCommandSignature(...))

So the pair does not work as merged: git takes both files, and #1737's guard refuses the signature this PR's fixture needs before the replay is ever reached. That is exactly the negative control you predicted, now measured rather than argued.

Two details worth carrying into the decision:

  • The other five d3d12_stateful_indirect* tests pass in both trees, which is why the suite looks healthy either way: they do not exercise a compound signature at all. A gate that only runs ^d3d12_stateful_indirect would miss this; d3d12_compound_indirect_pixels is the one that fails.
  • The guard's own test (d3d12_execute_indirect_validation_test.cpp, added by d3d12: refuse command signatures with arguments before the draw (D3D-INDIRECT-STATE-REFUSE) #1737) asserts the refusal, so narrowing the guard moves that test too - the pair has to be reconciled in one change, whichever lands second.

The landing order I would argue for, from what the two PRs are: #1937 first, then #1737 narrowed to the shapes the replay still does not cover (argument type 5 among them, if root CBVs before the draw stay unsupported). The other order works too, but then this branch must remove or narrow the guard itself, and its fixture is the proof.

Written with an AI assistant.

@OreoFR

OreoFR commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Verified by OreoFR

Run 1 (lot 4)

  • Base: main 09c153948 + PR head 8d36e843c; integration package 3 of 6 (4 PRs, merged without conflict)
  • Test: full runtime build; ctest -j 6 without the 28 tests that launch gta6rt; the PRs' Python tests
  • Red on main: n/a (integration test; main baseline: xbox_present and d3d12_set_descriptor_heaps)
  • Green with the PR: ctest: only xbox_present and d3d12_set_descriptor_heaps fail, as on main
  • Verdict: CLEAN PACKAGE (no new failure vs main)

Run 2 (lot 4 bis)

  • Base: main 33db04a70 + PR head 8d36e843c; integration package of 15 PRs
  • Test: full runtime build; ctest -j 6 without the 28 tests that launch gta6rt; the PRs' Python tests; translator suite
  • Red on main: n/a (integration test; main baseline: xbox_present, and flaky xmem)
  • Green with the PR: ctest: only xbox_present fails as on main (xs_proxy_mock failed once, flaky: passes on rerun and 5/5 direct runs); Python: same failures as main, the PRs' tests pass; translator: 507 files, 6405 tests, 0 failures
  • Verdict: CLEAN PACKAGE (no new failure vs main)

All runs

  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

@zmasi

zmasi commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Windows 11 + RTX 3090 Verification (8d36e843c9 merged with main 791899f652) — PASS

  • Environment: Windows 11 (10.0.26200), MSVC 19.44.35207 (/O2 /MD /EHsc /std:c++20 /W4 /permissive- /utf-8), NVIDIA GeForce RTX 3090 (610.88) + VK_LAYER_KHRONOS_validation 1.4.363.1 (LEONIDA_VK_VALIDATION=1).
  • Merge, Docs & CTest Gates: Clean git merge-tree onto main (791899f652) (0 conflicts); check_no_game_data.py, test_docs_env_vars.py (5/5), test_docs_table_rows.py (2/2), test_docs_encoding.py (1/1), test_ctest_registration.py (7/7), and test_ci_registration.py (18/18) all OK; 0 new /W4 warnings.
  • Red -> Green on RTX 3090:
    • Red (d3d12_draw_test --compound-indirect-pixels linked against main runtime/shims/d3d12_com.cpp): fails with rc=1 ([rt] indirect graphics: recorded=0 emitted=0 record_skips=1 replay_skips=0 [compound=1], 1536/4096 RGBA pixel mismatches against the same calls made by hand; the indirect list alone lights 0).
    • Green (8d36e843c9 + main 791899f652): all 5 d3d12_draw_test invocations pass (rc=0) with 0 VUID- validation errors:
      1. d3d12_draw_test --compound-indirect-pixels: 1536 lit pixels, 0/4096 RGBA pixel mismatches against the same calls made by hand; the indirect list alone lights 1536 and the state the list had bound alone lights 1024.
      2. d3d12_draw_test (default suite, including compound_indirect_vb_ib_and_root_args across per-record VB/IB views, CONSTANT, kIndirectArgumentIncrementingConstant, root CBV/SRV/UAV virtual addresses, count-buffer min(count, MaxCommandCount) clamping, post-call D3D12 state resets, and non-mappable device-local reset-only fallback): rc=0.
      3. d3d12_draw_test --stateful-indirect-pixels: 0/4096 RGBA mismatches, direct image identical (DRAW & DRAW_INDEXED).
      4. d3d12_draw_test --stateful-indirect-multi-pixels: 576 red / 576 magenta, 0/4096 RGBA mismatches, direct image identical.
      5. d3d12_draw_test --stateful-indirect-counted-pixels: input=0..3, max=2 all 0/4096 RGBA mismatches, direct image identical.
  • Non-blocking note: expand_compound_indirect (runtime/shims/d3d12_com.cpp:1840, 1865) calls argument_buffer->Map(0, nullptr, &base) and count_buffer->Map(0, nullptr, &counts) without pairing Unmap(0, &empty_range) (D3D12_RANGE{0, 0}). This is safe on the layer's Resource::Map (d3d12_vulkan_device.cpp:10286, which persistently returns mapped_ with no map refcount), though pairing Unmap with an empty written range matches ID3D12Resource's contract if ever backed by a refcounting resource.

AI-assisted.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 29, 2026
@fiestorra
fiestorra force-pushed the carry/indirect-state-replay branch from 8d36e84 to c6c6d52 Compare November 29, 2026 13:44
@fiestorra

Copy link
Copy Markdown
Contributor Author

Rebased onto current main; the branch was 3,205 commits behind and had become CONFLICTING. Head is now c6c6d52da, GitHub reports
MERGEABLE, and this one needed more than a mechanical rebase because it carries runtime code.

Conflict: one paragraph in docs/d3d12_vulkan.md, and neither side was right on its own. main had added a sentence about
d3d12_bundle_indirect_dispatch checking DISPATCH against the counters WARP and the default adapter; this branch had rewritten the following
sentence to say a compound graphics signature stays guarded when its record bytes are not host-mappable. Resolved by keeping both: main's
sentence, then this branch's wording. Taking either side alone would have dropped a true statement.

Verified after the rebase, on this machine (RTX 4090, 32..32 subgroups):

  • the runtime builds from the rebased tree (gta6rt target, MSVC 2022, RelWithDebInfo, no errors);
  • d3d12_draw_test.exe --compound-indirect-pixels passes, exit code 0, and its own line reports the case it exercises:
    compound DRAW_INDEXED x2 (two vertex buffer views, the index buffer, two root constants and a root CBV per record): 1536.

That matters because the earlier discussion in this thread ended with a landing-order question against a much older main: the combined
candidate was measured failing while this branch alone passed. Those measurements were taken against trees thousands of commits old. On current
main the branch merges cleanly and the test it exists for passes, which is the part I can state; the interaction with #1737 is not something I
have re-measured here.

Not re-run: the full ctest suite (528 tests) and the semantic suite on this tree. The change is in the indirect replay path and the test
above is the one that covers it; if you want the whole suite as part of accepting the rebase rather than of the original change, say so and I
will run it and paste the result.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

After the rebase, the red checks on this pull request are not from this diff: every job failing here is already failing on main.

Measured, both sides from CI rather than from a local run:

  • main at 51d343b86 (this branch's merge base): the CI workflow is red, with these jobs failing -
    check, translator-tests, macos-python, stdlib-tests-linux, semantic-tests (ubuntu-latest).
  • this pull request: the failing jobs are a subset of that list, with no job of its own.

What that establishes: the rebase did not introduce a red job, and anyone reading the checks can discount them when judging the change.

What it does not establish: that the passing jobs exercise this diff. A green check on a job that does not touch the changed files says
nothing either way, and I am not claiming otherwise.

The state before the rebase was different and worth remembering: the same jobs were red then too, but the branch was also CONFLICTING, so a
reviewer could not tell an inherited failure from a merge problem. That is fixed now - MERGEABLE, and the red set matches main's.

Written with an AI assistant.

@merzleckeier

Copy link
Copy Markdown
Contributor

AGENT-MSG | 2026-11-29 14:00 UTC | merzleckeier | AI-assisted: Codex

BASE: 51d343b86 + PR head c6c6d52da, clean integration. The extra count cases change the fixture only.
MACHINE: RTX 4070 SUPER (NVIDIA 620.73.04) and Radeon 610M (RADV Mesa 26.3.1) | CachyOS, Wine 11.22.
EVIDENCE: MEASURED. All eight stock d3d12_draw_test modes passed on each GPU. The stock compound draw rendered 1,536 pixels and matched all 4,096 RGBA pixels of the direct-draw reference on both cards.

The additional synthetic fixture adds an upload count buffer with CountBufferOffset=128, a different DWORD at offset zero, and MaxCommandCount=2. Counts 0, 1, 2, and 7 render 0, 1,024, 1,536, and 1,536 pixels respectively. Every image matches its direct-draw reference on both GPUs.

This also gives a GPU readback for the documented timing limit. Changing only that DWORD after Close() and before ExecuteCommandLists from 1→2 or 2→0 still renders 1,024 or 1,536 pixels respectively. Both images match the record-time reference on both GPUs.

Run the fixture with d3d12_draw_test --compound-indirect-pixels. Set MANDY_TEST_EXPECT_SUBMIT_COUNT=1 to check a later deferred implementation against the submit-time reference. That mode currently fails after printing both comparisons. Host Khronos validation reported the baseline Wine device-creation VUID 01387.

@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 29, 2026
@fiestorra
fiestorra force-pushed the carry/indirect-state-replay branch from c6c6d52 to aa2ede8 Compare November 29, 2026 14:37
@fiestorra

Copy link
Copy Markdown
Contributor Author

Heads refreshed: main moved from 51d343b86 to ddfe24fba (14 commits) since the last rebase, so the branch was 14 behind again. Rebased
onto the new tip; the rebase was clean, with no conflicts this time because the resolutions from the previous one are already in the history.

  • new head for this pull request: see the branch named above, pushed with --force-with-lease;
  • git diff --stat origin/main..HEAD still shows the same files as before (nothing was lost or added by the rebase).

Verification on the new base, run here rather than assumed: the runtime and the test target build from the rebased tree, and the pull request's own
test passes (d3d12_draw_test --compound-indirect-pixels, exit 0, compound DRAW_INDEXED x2 …: 1536).

One thing I cannot state: GitHub was still recomputing mergeability when I pushed (MERGEABLE/UNKNOWN alternating), so if the checks look odd in
the first minutes, that is the force-push settling, not a new conflict. Give it a minute and re-read rather than trusting a snapshot.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

A note on the macos check, since it is red here and I want to be precise about what I can and cannot attribute.

The failure is ps_exp_f32_denorm_rt:

macos  GPU tests on MoltenVK
199/274 passed, 73 skipped
##[error]ps_exp_f32_denorm_rt failed
##[warning]ps_ssharp failed, as expected until its fix is merged

Two things, in order of certainty:

  1. I cannot call it inherited. The latest CI run on main (46275295773, c22a0a732) has no macos job at all - only macos-python.
    So the job runs for these pull requests (it is the MoltenVK GPU job, which the path filter only brings in when the change touches the shader
    or translator side) and there is no main-side equivalent to compare against in the same run.
  2. The failure itself is already documented as an environment effect. CI: fix the three tests red on main (CI-F16-INT16-OMOD-REJECT, CI-RUNTIME-STACK-RESERVE, CI-BCPACK-POOL-DEDUPE) #2593's body lists it under "Still red: macOS runtime
    ps_exp_f32_denorm_rt (the runner's GPU returns exp2(-125) two ulps low; needs a device to …)". That is a precision difference on the CI
    machine's GPU, not a shader produced by this diff - and this diff changes the replay of indirect records, not exp or denormal arithmetic.

So: not attributable to this change by comparison, and consistent with a known runner effect - which is weaker than "it is not mine", and I would
rather say it that way. If a maintainer wants it settled, the decisive check is the same job on main with a change that touches those paths,
or a re-run of this job: a precision failure two ulps wide should be stable across re-runs if it is the hardware, and intermittent if it is not.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Re-verified against today's main, not just the base it was rebased onto: I merged origin/main (38719cc36) into the branch locally, rebuilt
d3d12_draw_test from that tree, and ran the pull request's own test:

merge: clean, no conflicts
d3d12_draw_test --compound-indirect-pixels
  compound DRAW_INDEXED x2 (two vertex buffer views, the index buffer, two root constants and a root CBV per record): 1536 lit …
  exit 0

Why it was worth doing: main changed runtime/shims/d3d12_vulkan_device.cpp by +15/−1 since this branch was cut, so the file this change lives in is
not the one it was tested against. The three changes there are unrelated to indirect replay - a sparse tile heap now prefers device-local memory
without requiring it, and two needs_maintenance8 refusals with their reasons - and the merge is clean, which is why the test passing is not a
surprise, but "not a surprise" is not a measurement.

For the record on the other three of my open pull requests, I checked the same thing and none of the files they touch changed on main
between 51d343b86 and 38719cc36 (tools/awc_opus.py, tests/test_awc_opus.py, docs/design.md, scripts/build_llvm_mc.ps1), so their
earlier verifications still hold and they do not need another run for this reason.

Written with an AI assistant.

ItsNotRexed pushed a commit that referenced this pull request Nov 29, 2026
…e paired forms, switches by turns

Picture:
- Cutscene faces with only their eyes and teeth since the LDS bounds: the 25 face programs
  (the face network's operations, the normals rebuilt from blend shapes) keep their LDS
  accesses unbounded, by name and in the cache's key (LEONIDA_LDS_BOUNDS_EXEMPT; trustno1-coder
  9eb44fa6, Victorywillbeours222). Six of them run in the waterside tour.
- Copies and resolves into textures the title fills go back into title memory once their list
  has run, only the subresources written and of them the 4 KiB pages that change
  (LEONIDA_COPY_BACK, on; voidopcode/vilocity ee93826): a view the title places over that
  memory was made from bytes the copy never reached (faces in blocks of colour, clothes in
  another texture's). 9,216 copies (52 MB) in a run of 8 minutes; by turns the frame's median
  -0.33 +-0.50 and +0.34 +-0.25 ms.
- A list's prelude leaves out its upload of a texture another list wrote on the host GPU and
  submitted first (LEONIDA_UPLOAD_GUARD; trustno1-coder e530c003, aventureroestelar-source),
  noted only while the texture is still the title's.
- A texture asked for as reserved (levels on demand) is no longer cut from the pool, where it
  was never reserved and was made whole again (aki-gta6/aki-runtime ad214cd, KeethSmith).
- The launcher names all 33 programs the chain gave an approximate form in LEONIDA_PAIRED_FOR
  (timing runs d39: 1.98 ms of card a frame against 2.31 for the eleven before; tours d37, d38
  with nothing broken), and keeps device-removed data to the faulting address (d35: the card
  83 % busy against 89 % with breadcrumbs, the frames alike).

Shader translator (one re-translation): global stores count as UAV writes for early depth
(trustno1 788fe236); a sum of high halves is not taken for a wave reduction (Bebrik229); SDWA
sign-extended selects; mesh loops leave at their own exit at the limit instead of a `ret`
(LEONIDA_MESH_LOOP_EXITS, trustno1 6bbb6bca); readers indexed once per lowering (trustno1
7cc0d153, 101Leafy); raw FSSM records (XDAT 0x0c) read (fuzeofficial, via MiniVI 96e788c7).

Submitting thread, by turns of 4 s standing (runs d41, d43):
- Two lock passes, off by default (`=1` on): slot writes past the heap's lock of placed views
  (LEONIDA_SPANS_QUICK; Belobug a284ca7 via readmet3xt 96dfd9bb8, trustno1 #1937) and the
  texture queue's lock spared by marks (LEONIDA_QUEUE_MARKS; readmet3xt-lab b377071). Here no
  one waited for those locks: the submitting thread +0.12 to +0.30 ms a frame with them.
  `crate::asked!` is `toggled!` off by default.
- 8 parts joined against 2 (LEONIDA_JOIN_PARTS_AB): with 8 the frame -3.09 +-0.51 and -3.03
  +-0.26 ms, so the launcher's 8 stays. The write-watch asking joined across 8 MiB against
  256 KiB (LEONIDA_ASK_GAP_KB, _AB): with 8 MiB the card -1.08 +-0.50 and -1.14 +-0.22 ms busy.

AI-assisted (Claude). Tested on an RTX 4060 Ti, driver 616.64: the named unit tests of each
port (shader 12, gpu 11, texback and resource 36), a warm-up start (the same three programs
refused as before, no device removed), the turns above and recorded tours.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fiestorra

Copy link
Copy Markdown
Contributor Author

The failing checks on this pull request are not its own failures: they are the three items that keep main red, and since their fixes exist and are
verified, I merged them into this branch instead of waiting.

check what it fails on now
check, stdlib-tests-linux, macos-python tests/test_text_encoding.py - two read_text() calls without encoding= in scripts/windows-boot/test_crash_monitor.py OK (2 tests)
translator-tests tests/test_mesh_serial_waves.py - the slot stores became OpBitcast after #850 (#2506's lower_addr64) and the test counted only OpConvertUToPtr 31 passed
semantic-tests (ubuntu-latest) tests/semantic/test_interp_computed_ij_fallback.py - the oracle predates the toward-zero p2 narrow 9 passed, 13 subtests

Two things about how it is done, because they change how this lands:

  • the three commits come from Bloh09 and Zack and are merged unchanged, authors intact; this branch only adds them on top, so if their items reach
    main first the whole thing collapses to a no-op instead of conflicting;
  • they are exactly the ones I verified red-to-green on main earlier, so this is not a new risk introduced by this diff.

The branch was also re-verified end to end after the merge, including the GitHub Actions tree on the current main: the runtime test this pull request
is about still passes (compound DRAW_INDEXED x2 …: 1536 lit pixels, 0/4096 mismatches, exit 0) and tests/test_awc_opus.py still passes (OK).

What this does not fix: the macos job, which fails on ps_exp_f32_denorm_rt. That one is not inherited and not a shader defect in this diff - it is
a fixture that demands the last bit (runtime/test/shaders/check.py:2089 asks for 2^-125 exactly) and an Apple Paravirtual device that returns it two
units low. Settling it means deciding whether that contract allows 2 ULP, which is a maintainer's call, not something to slip into this pull request.

Written with an AI assistant.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 29, 2026
@fiestorra
fiestorra force-pushed the carry/indirect-state-replay branch from 5aa64f3 to 15857fe Compare November 29, 2026 20:13
@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 29, 2026
@fiestorra

Copy link
Copy Markdown
Contributor Author

The only failing check on this pull request is macos, and it is not from this diff: it is ps_exp_f32_denorm_rt, where the fixture demands the exact bit pattern of 2^-125
(runtime/test/shaders/check.py) and the runner's Apple Paravirtual device returns it two ulps low.

I opened #2635 (a draft) with the shape of a fix: a two-ulp tolerance confined to the OpExp2 channel, with zero kept exact and the channels the shader computes itself left bit-exact. It
is a draft because it changes a test's contract and none of us can verify it without a MoltenVK device - but if the maintainers accept it, macos stops being red for this pull request and for
every other one in the queue.

Everything else here is green: 8 checks SUCCESS, macos the only failure.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Two things a reviewer should know about the red check here, both measured rather than assumed:

The branch merges cleanly into main. git merge-tree --write-tree origin/main <branch> reports no conflict, and the pull request is MERGEABLE. Nothing about this change blocks a merge.

The macos failure is from an older base. It is not produced by this diff: on main 1d22590b9 the macos job passes (the only failing job there is semantic-tests, the interp oracle). When I rebased #2650, #2652 and #2634 onto the current main, that job came back SKIPPED on all three and those pull requests went green without a line changing. So a maintainer can merge this as it stands, or the author can refresh the branch with one rebase - either way the red disappears without touching the change.

What stops me from doing that rebase for you: replaying the commits onto current main conflicts in documentation, not in code -

  • here, docs/d3d12_vulkan.md;
  • in #1923, README.md, where the branch restructures the requirements block that main has since edited.

Resolving that means choosing which structure the documentation keeps, and that is the author's decision, not mine. The merge itself is clean, so the conflict is only in the replay.

Written with an AI assistant.

@fiestorra
fiestorra force-pushed the carry/indirect-state-replay branch from 15857fe to a9c0b78 Compare November 30, 2026 04:15
@fiestorra

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (1d22590b9) and the rebase was clean this time - which corrects something I wrote yesterday: the conflicts I reported (docs/d3d12_vulkan.md here, README.md on #1923) were in my stale local copy of the branch, not in the branch the pull request shows. The synced head rebased without a single conflict, and I have learned to check local against fork before drawing conclusions about a pull request.

Verified after the rebase, on this branch:

cmake --build … --target d3d12_draw_test   -> built
d3d12_draw_test.exe                        -> exit 0, 0   (two runs)
  "M1: five draws and a culled triangle matched all 4096 pixels: input layout by semantic, root constants and a r…"
tests/semantic/test_interp_computed_ij_fallback.py -q  -> 9 passed, 13 subtests

The macos red should now come off with the base: on main that job passes, and on the four pull requests I rebased today it came back SKIPPED and took the red with it.

Written with an AI assistant.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 30, 2026
fiestorra and others added 2 commits November 30, 2026 11:59
…TATE-REPLAY)

The compound branch of ExecuteIndirect reset the bindings a signature writes and
recorded no draw, so a signature whose records carry vertex buffer views, an index
buffer view or root arguments bound nothing.

Vulkan has no indirect call that rebinds state and the replay's Draw carries one
state snapshot, so expand each record in the command list into the state calls it
stands for and the DRAW or DRAW_INDEXED that follows, when the argument and count
buffers are host-visible. A device-local buffer keeps the reset-only path. The
bindings the signature writes are still reset after the call, as D3D12 does.

Written with an AI assistant.
Snooozs (with reason): the expansion reads the argument and count bytes while
ExecuteIndirect is recorded, while D3D12 reads them when the list executes, so
an application that rewrites a host-visible argument buffer between the two - a
ring buffer filled just before ExecuteCommandLists, or a list reused with a new
buffer - replays the records that were there at record time. The description
and the docs stated the host-visible restriction but not this one, and the
fixture fills at record time, so it cannot show the difference.

A sentence in the same paragraph, with the deferral named as what would match
the runtime's timing.
@fiestorra
fiestorra force-pushed the carry/indirect-state-replay branch from a9c0b78 to b658b8c Compare November 30, 2026 11:01
@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 30, 2026
@fiestorra

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (012b79a67) after it started conflicting this morning. Head is now b658b8c3f, three commits, and merge-tree is clean again.

Why it needed it: runtime/shims/d3d12_com.cpp is one of the files main changes most - three commits touched it since this branch was cut (399a5eabd sample-mask slot, 091bfa8d4 pending_stream/eviction, 1aefed0da present_mutex deadlock). The conflict was 18 lines, one block, at the compound-signature branch of ExecuteIndirect.

What the conflict actually was, and how I resolved it:

side what it said
main "Compound draw emission is not yet supported" - skip the record and reset the written bindings
this branch expand the compound into the calls it stands for (expand_compound_indirect), then reset
resolution the branch's logic, with main's API: list_.closed() -> list_->closed()

That last line is the whole subtlety: main moved list_ to a std::shared_ptr, so the branch's list_.closed() would not compile. Everything else in the branch applied without a manual edit.

Verified after the rebase, on this machine (Windows 11, MSVC 19.44.35226):

cmake -S runtime -B runtime/build-ninja …            configure clean
cmake --build … --target d3d12_draw_test             [26/26] Linking CXX executable d3d12_draw_test.exe
ctest -R '^(d3d12_draw|d3d12_stateful_indirect)'     100% tests passed, 0 tests failed out of 7

One commit disappeared in the rebase, and it was correct: test(semantic): align computed-I/J f16 interp oracle with toward-zero p2 narrow is now c717967d0 in main, so the rebase dropped it as already applied. Three commits remain: two doc commits and the replay change.

What I did not re-verify: the semantic test the branch carried (it is in main now) and the GPU readback paths. The seven tests above are the CPU-side ones this branch owns.

If you would rather I had not pushed to the branch, say so and I will leave rebases to you - the fork head is fiestorra/leonida-carry and I can revert it to a9c0b786a.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

The windows failure on this branch is not this branch's fault: it is display_white_cache, a flaky test in main that I reproduced on the current main and fixed in #2713.

The CI log says:

11/547 Test  #11: display_white_cache ......***Failed
FAIL: the first get() has no value yet (the caller falls back to 203)

And on main d367675c7, on this machine:

30 runs with four CPU hogs in the background:  29 pass, 1 fail
the failing assertion is the same one

Why: DisplayWhiteCache::get() wakes the worker and then reads value_:

if (!wanted_.exchange(true)) { … read_now_ = true; wake_.notify_all(); }
return value_.load();

so whether the first call returns 0 or the freshly read value is a scheduling fact. The test asserted 0 unconditionally.

Timeline for this branch, which is what made it look causal: the previous head a9c0b786a had Runtime success at 04:15, and the rebased head b658b8c3f failed at 11:01 - on a test that touches none of the files this branch changes. #2713 relaxes that one assertion and keeps the reads() checks, and it is green on this machine over 60 runs under load.

What I would do with the red check here: re-run it. It will pass most of the time, and #2713 removes the coin flip for everyone.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

A second correction to this body, found by auditing the version strings in it against the machine rather than trusting them. Two were wrong, and one of the two was the GPU.

1. MSVC 14.44 was wrong. The compiler on this machine is:

cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.44.35226 for x64

2. The "GPUs tested" line named a GPU that did not run the tests. It said AMD Radeon(TM) Graphics (gfx1036 iGPU), driver 32.0.21045.29003, and that string is a real adapter on this machine (Win32_VideoController reports it) - which is what made it plausible. But the Vulkan adapter that actually executes a replay here is the discrete one:

vulkaninfo --summary
GPU0:
  apiVersion    = 1.4.357
  driverVersion = 621.24.0.0
  deviceType    = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
  deviceName    = NVIDIA GeForce RTX 4090

So gfx1036 is the RDNA2 target the shaders are written for and the replay emulates, not the device that ran them, and 32.0.21045.29003 is the integrated adapter's string. The line now says both things explicitly.

What this does not change: this pull request's tests are CPU-side (d3d12_draw, d3d12_stateful_indirect_pixels), so no GPU was required for the result - which is exactly why the wrong line was possible: it described a field nobody needed to check for the claim to hold.

The pattern, third time today: a number is plausible exactly when it matches the machine's shape - 14.44 next to VS 2022, an AMD adapter on a machine that has one. A wrong number that looks right is what a model produces when the field is optional; the only defence is running the command that prints it. The commands are in this comment.

Written with an AI assistant.

… signature is guarded only when its bytes are not mappable
@fiestorra
fiestorra force-pushed the carry/indirect-state-replay branch from b658b8c to 6ae77b0 Compare November 30, 2026 20:44
@fiestorra

Copy link
Copy Markdown
Contributor Author

Re-running the CI with an amended commit (6ae77b015, same tree), because the red on windows is a flaky test in main that this branch does not touch and I cannot ask GitHub to re-run it.

The red, for the record: 11 - display_white_cache at head b658b8c3f, with the message FAIL: the first get() has no value yet (the caller falls back to 203).

That assertion is not an invariant of the cache: DisplayWhiteCache::get() wakes the worker and then reads the value, so whether the first call returns 0 or the freshly read value is the scheduler's decision. Measured on main d367675c7: 1 failure in 30 runs with four CPU hogs, and the same assertion. Fixed in #2713 (green on the windows job, 60/60 locally, plus a mutation control showing the relaxed assertion still fails on a broken cache).

Why an amend instead of a re-run: gh run rerun answers "Must have admin rights to Repository" for this account. Pushing new commits does start a run, so the options were an empty commit, a rebase onto a main that has moved 77 commits, or an amend. The amend is the only one that changes nothing about the branch: git rev-parse HEAD^{tree} is identical before and after, and the diff is still the same five files.

What I expect: the same five files, and windows green - the flake fails about 1 run in 30, so a single re-run is likely to pass and is not proof that it will always pass. The proof is #2713 landing.

What this does not fix: if the re-run comes back red on display_white_cache again, that is the flake beating a 29-in-30, not this branch. The job to watch is windows, and the test to look for is display_white_cache, not the compound-signature tests.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Green, all of it, at 6ae77b015:

change-scope SUCCESS   no-game-data SUCCESS   windows SUCCESS
check SUCCESS          linux-gpu-tools SUCCESS  linux-python-and-viewer SUCCESS  semantic-tests SUCCESS

What that does and does not mean, said before anyone reads it as proof:

  • It means the branch is not what failed. display_white_cache did not fail on this run, and every other test in the windows job passed with this diff in the tree - the compound-signature tests this PR adds included.
  • It does not mean display_white_cache is fixed. The failing assertion is a race in the test: get() wakes the worker and then reads the value, so the first call returns 0 or the freshly read one depending on the scheduler. Measured on main d367675c7: 1 failure in 30 runs with four CPU hogs. A 29-in-30 pass is what a green run looks like whether or not the race is still there.
  • The repair is display_white_cache: accept that the first get() may already have the value it woke #2713, which is green on its own windows job, 60/60 locally, and carries a mutation control showing the relaxed assertion still fails on a cache that does not refresh.

So the state of this PR is: ready, with one known flake in the tree it lives in, waiting for #2713 to remove the second half of that sentence.

The amend that produced 6ae77b015 changed nothing but the commit object - HEAD^{tree} is identical to b658b8c3f - and the diff is still the same five files:

docs/d3d12_vulkan.md                        22/6
runtime/CMakeLists.txt                       4/1
runtime/shims/d3d12_com.cpp                130/3
runtime/test/d3d12_draw_test.cpp            10/0
runtime/test/d3d12_stateful_indirect_pixels.cpp  247/7

Written with an AI assistant.

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.

7 participants