D3D12.X: forward DrawIndexedX IndexOffset as BaseVertexLocation #3233

Closed
Kalmarv wants to merge 1 commit from upstream-pr/3233 into main
Kalmarv commented 2026-11-28 23:37:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-28T23:37:34Z.


Forward DrawIndexedX 4th parameter (IndexOffset) as BaseVertexLocation (index_offset as i32) when dispatching to prepare_indexed_draw and emit_prepared_indexed_draw instead of hardcoding 0.

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs: forward index_offset as i32 as base_vertex in draw_indexed_x and extend draw_indexed_x_routes_through_bind_and_restores_index_buffer to verify positive (42) and negative (0x8000_0007) sign-cast offsets.

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11 Pro (build 26200), rustc 1.99.0, DXC 1.9 (XCL_DXC_DIR), debug for unit tests and release for xcl-smoke.
  • Targeted unit test: cargo test -p xcl --lib draw_indexed_x_routes_through_bind -- --nocapture: 1 passed, 0 failed, 0 ignored.
  • Live steady-world run (BISECT1, RTX 5070 Ti, XCL_DIRECT_DXIL=all): exit 0x0, 1.69 fps (matching baseline), 0 removals, 0 crashes.

Regression run
main (f0e8fdd5c3942ddd399d5ee11384c8595c5aacff):

xcl-smoke v1
commit: f0e8fdd5c3942ddd399d5ee11384c8595c5aacff
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1695 (PresentX 1695)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 31546 MB

PR head (568806cb05c71fac4819a7bba5d07b4cf646f453):

xcl-smoke v1
commit: 568806cb05c71fac4819a7bba5d07b4cf646f453
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1742 (PresentX 1742)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 32813 MB

Not tested

  • AMD RDNA / Intel GPUs.
  • SV_VertexID offset injection for input-layout-less shaders when IndexOffset != 0.

AI use

  • Antigravity (Gemini) assisted with implementation, unit test extension, and xcl-smoke regression run.
<!-- greyfinch-sync:ivall/xcl:issue:5545688046 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3233). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-28T23:37:34Z. --- Forward `DrawIndexedX` 4th parameter (`IndexOffset`) as `BaseVertexLocation` (`index_offset as i32`) when dispatching to `prepare_indexed_draw` and `emit_prepared_indexed_draw` instead of hardcoding `0`. **What is in it** - `crates/xcl/src/hle/d3d12x/list_x.rs`: forward `index_offset as i32` as `base_vertex` in `draw_indexed_x` and extend `draw_indexed_x_routes_through_bind_and_restores_index_buffer` to verify positive (`42`) and negative (`0x8000_0007`) sign-cast offsets. **Tested** - Hardware / toolchain: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11 Pro (build 26200), `rustc 1.99.0`, DXC 1.9 (`XCL_DXC_DIR`), debug for unit tests and release for `xcl-smoke`. - Targeted unit test: `cargo test -p xcl --lib draw_indexed_x_routes_through_bind -- --nocapture`: 1 passed, 0 failed, 0 ignored. - Live steady-world run (`BISECT1`, RTX 5070 Ti, `XCL_DIRECT_DXIL=all`): `exit 0x0`, `1.69 fps` (matching baseline), `0` removals, `0` crashes. **Regression run** main (`f0e8fdd5c3942ddd399d5ee11384c8595c5aacff`): ``` xcl-smoke v1 commit: f0e8fdd5c3942ddd399d5ee11384c8595c5aacff gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 1695 (PresentX 1695) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 31546 MB ``` PR head (`568806cb05c71fac4819a7bba5d07b4cf646f453`): ``` xcl-smoke v1 commit: 568806cb05c71fac4819a7bba5d07b4cf646f453 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 1742 (PresentX 1742) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 32813 MB ``` **Not tested** - AMD RDNA / Intel GPUs. - `SV_VertexID` offset injection for input-layout-less shaders when `IndexOffset != 0`. **AI use** - Antigravity (Gemini) assisted with implementation, unit test extension, and `xcl-smoke` regression run.
Foniass commented 2026-12-01 07:24:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:24:06Z.


merge-check
base: 7d86c5d2b7
head: 568806cb05
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2896 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (list_x.rs, +15/-11). Every DrawIndexedX whose 4th argument isn't zero now draws with that value as BaseVertexLocation. Findings: (1) nothing shows the argument's meaning: main's doc comment and HANDOFF.md (~611) call it flags, and the PR shows no trace of a title passing a non-zero value. If it is flags, every such draw shifts its vertex fetches by that value and the geometry comes out wrong. Logging the first non-zero values a retail title passes (index address, format, count, 4th argument) would settle it, and the description should note that HANDOFF.md's "flags" becomes wrong. (2) The capture record (capture.rs ~1063) doesn't store the offset. (3) The full suite wasn't run; AI use says "Antigravity (Gemini)", not an exact model. The PR's CI failure was an access violation during the eh:: / gpu::agility tests, before list_x; it passes in the run above. Fine: the u32 -> i32 cast keeps the bits (the test covers 0x8000_0007), prepare_indexed_draw and the emitted draw get the same value, sync_title_buffers(None, ..., 2) copies the whole mirrored vertex buffer so a base vertex can't read stale data, the indexed path has no rect-list expansion, and the test fails without the change.
performance: 60 s smoke of a retail title, main 7d86c5d2 vs this merge (104474ef): 1663 -> 1686 frames shown (101 %; last presents per 2 s: 60 60 60), peak commit 17153 -> 17599 MB, 0 device removals, 0 crashes. The title doesn't show whether it passes a non-zero 4th argument, so this run doesn't settle the finding.
verdict: not yet: nothing shows DrawIndexedX's 4th argument is a base vertex rather than the flags main and HANDOFF.md call it; if it is flags, every such draw fetches shifted vertices
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7304010805 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3233#issuecomment-7304010805). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:24:06Z. --- merge-check base: 7d86c5d2b7845695031eeea1327aa81b6c439323 head: 568806cb05c71fac4819a7bba5d07b4cf646f453 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2896 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: read the whole diff (list_x.rs, +15/-11). Every DrawIndexedX whose 4th argument isn't zero now draws with that value as BaseVertexLocation. Findings: (1) nothing shows the argument's meaning: main's doc comment and HANDOFF.md (~611) call it `flags`, and the PR shows no trace of a title passing a non-zero value. If it is flags, every such draw shifts its vertex fetches by that value and the geometry comes out wrong. Logging the first non-zero values a retail title passes (index address, format, count, 4th argument) would settle it, and the description should note that HANDOFF.md's "flags" becomes wrong. (2) The capture record (capture.rs ~1063) doesn't store the offset. (3) The full suite wasn't run; AI use says "Antigravity (Gemini)", not an exact model. The PR's CI failure was an access violation during the `eh::` / `gpu::agility` tests, before `list_x`; it passes in the run above. Fine: the u32 -> i32 cast keeps the bits (the test covers 0x8000_0007), `prepare_indexed_draw` and the emitted draw get the same value, `sync_title_buffers(None, ..., 2)` copies the whole mirrored vertex buffer so a base vertex can't read stale data, the indexed path has no rect-list expansion, and the test fails without the change. performance: 60 s smoke of a retail title, main 7d86c5d2 vs this merge (104474ef): 1663 -> 1686 frames shown (101 %; last presents per 2 s: 60 60 60), peak commit 17153 -> 17599 MB, 0 device removals, 0 crashes. The title doesn't show whether it passes a non-zero 4th argument, so this run doesn't settle the finding. verdict: not yet: nothing shows DrawIndexedX's 4th argument is a base vertex rather than the flags main and HANDOFF.md call it; if it is flags, every such draw fetches shifted vertices hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
Kalmarv commented 2026-12-02 19:38:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T19:38:19Z.


Closing: unsourced ABI guess on DrawIndexedX's 4th argument (flags on main) flagged in review.

<!-- greyfinch-sync:ivall/xcl:comment:7356489233 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3233#issuecomment-7356489233). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T19:38:19Z. --- Closing: unsourced ABI guess on `DrawIndexedX`'s 4th argument (`flags` on `main`) flagged in review.

Pull request closed

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

No due date set.

Reference
xcl-dev/xcl!3233
No description provided.