mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:50:51 +01:00
[PR #1937] d3d12: replay a compound signature's vertex/index buffer views and root arguments (D3D-INDIRECT-STATE-REPLAY) #1945
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1945
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1937
Author: @fiestorra
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:carry/indirect-state-replay📝 Commits (3)
cdeac21d3d12: replay a compound signature's per-record state (D3D-INDIRECT-STATE-REPLAY)d653c7bdocs: say when the compound signature's argument bytes are read3d1dadbdocs: the recorded-count rule covers the count buffer, and a compound signature is guarded only when its bytes are not mappable📊 Changes
5 files changed (+411 additions, -15 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+20 -4)📝
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)📄 Description
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 updateruntime/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 theExecuteIndirectparagraph ofdocs/d3d12_vulkan.mdsection 4.7. It also sharesruntime/shims/d3d12_com.cppwith #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_VIEWor root arguments before itsDRAW/DRAW_INDEXED— bound nothing.ExecuteIndirectreset 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
Drawcarries one state snapshot per command, so the layer expands the record list in the command list instead — the expansion that section 4.7 ofdocs/d3d12_vulkan.mdalready 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'sDRAWorDRAW_INDEXEDas 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.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: thed3d12_compound_indirect_pixelsmode and its ctest entry.docs/d3d12_vulkan.mdsection 4.7 and the test list say what is replayed and what is not.Tested
Built with VS 2022 Build Tools (MSVC 14.44), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, RelWithDebInfo, on current
mainb0f3d3998. 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 throughExecuteIndirect, the same calls made by hand, and the pre-bound state alone, into three offscreen targets, then compares every pixel:runtime/shims/d3d12_com.cpphunk reverted, test kept: the indirect list lights 0 pixels and 1536/4096 pixels differ, i.e. it draws nothing, which ismain'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_pixelsandd3d12_compound_indirect_pixels.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_forbiddenand the fourd3d12_indirect_policymodes. 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: AMD Radeon(TM) Graphics (gfx1036 iGPU), driver 32.0.21045.29003, Windows 11 Pro build 26300
AI-assisted: yes (DeepSeek Harness)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: D3D12 layer, no translator change)Written with an AI assistant.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.