d3d12_xs: no GPU timestamp on a COPY list; depth bounds survive a list cut (RT-XS-LIST-VALUES-COPY-TIMESTAMP-AND-DEPTH-BOUNDS) #2500

Closed
Tyrannys wants to merge 1 commit from upstream-pr/2500 into main
Tyrannys commented 2026-11-27 19:43:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-27T19:43:36Z.


Claimed in the coordination issue as: RT-XS-LIST-VALUES-COPY-TIMESTAMP-AND-DEPTH-BOUNDS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7226663134)

What and why

Item 3 of @kevincommits' finding in #1608 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7226076494). Thanks for the audit.

COPY-list timestamps. take_timestamp (d3d12_xs_device.cpp) recorded EndQuery and ResolveQueryData on the device's D3D12_QUERY_HEAP_TYPE_TIMESTAMP heap for every list that tracks values, and COPY lists track them too. A COPY list needs a COPY_QUEUE_TIMESTAMP heap: the layer's CommandQueue::timestamps_fit() refuses the whole COPY submission (invalid_query), and Windows' D3D12 validation flags it. A timestamp write (write64 flag 1 or 2) on a COPY list now takes the CPU's clock when it lands, the fallback the code already has for a device without the heap. DIRECT and COMPUTE lists keep the GPU's timestamp.

A separate COPY_QUEUE_TIMESTAMP heap per device would keep GPU timing on copy lists. That is left for later: it needs a second heap and readback, and the copy queue's clock calibration.

Depth bounds across a list cut. OMSetDepthBoundsX (console slot 70, PC slot 62) was forwarded to the real list but not kept in list_values::ListState. Any draw after a list cut (a wait after work), and any list after ExecuteBundle of a bundle that set them, went back to D3D12's default [0, 1]. ListState now records the bounds once the real list has taken them, clears them on Reset like the rest, inherits a bundle's, and replays them after a cut (through slot 62 of the new real list, which is the same kind of list).

Overlap: #2484 (RT-XS-LATE-RELAY, list values) touches the same three files on other lines; git merge-tree finds no conflict. The new test sits beside check_list_values, not in it, and runs between it and check_list_values_more, while the list-values threads are up. No conflict with #2498 either (the descriptor-mirror item, same files).

Tested

Windows 11, MSVC (VS 18), RelWithDebInfo, on main 43a9d562d. CPU only.

The mock list now answers GetType (slot 8) with the type it was created with, and records slot 62's float arguments. xs_proxy_mock_test gains check_list_values_copy_and_depth_bounds:

  1. A write64 timestamp on a COPY list records no EndQuery or ResolveQueryData, while a DIRECT list still records both, with the TIMESTAMP query type.
  2. Depth bounds:
    • set, then work and an unmet wait: the spare list the cut moves to gets OMSetDepthBounds(0.25, 0.75) again;
    • after a Reset, the next cut does not set them;
    • a bundle's (0.125, 0.5) executed in the list is replayed after its cut.

With main's shims the test fails at the COPY check. With only the ListState recording line removed, it fails at the first replay check. With the fix it passes.

  • ctest -R "^(xs_proxy_mock.*|device_proxy)$": 10/10 pass.
  • scripts/check_no_game_data.py: clean.

GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11 (CPU tests only)

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5532220290 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2500). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-27T19:43:36Z. --- Claimed in the coordination issue as: RT-XS-LIST-VALUES-COPY-TIMESTAMP-AND-DEPTH-BOUNDS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7226663134) ### What and why Item 3 of @kevincommits' finding in #1608 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7226076494). Thanks for the audit. **COPY-list timestamps.** `take_timestamp` (`d3d12_xs_device.cpp`) recorded `EndQuery` and `ResolveQueryData` on the device's `D3D12_QUERY_HEAP_TYPE_TIMESTAMP` heap for every list that tracks values, and COPY lists track them too. A COPY list needs a `COPY_QUEUE_TIMESTAMP` heap: the layer's `CommandQueue::timestamps_fit()` refuses the whole COPY submission (`invalid_query`), and Windows' D3D12 validation flags it. A timestamp write (write64 flag 1 or 2) on a COPY list now takes the CPU's clock when it lands, the fallback the code already has for a device without the heap. DIRECT and COMPUTE lists keep the GPU's timestamp. A separate `COPY_QUEUE_TIMESTAMP` heap per device would keep GPU timing on copy lists. That is left for later: it needs a second heap and readback, and the copy queue's clock calibration. **Depth bounds across a list cut.** `OMSetDepthBoundsX` (console slot 70, PC slot 62) was forwarded to the real list but not kept in `list_values::ListState`. Any draw after a list cut (a wait after work), and any list after `ExecuteBundle` of a bundle that set them, went back to D3D12's default `[0, 1]`. `ListState` now records the bounds once the real list has taken them, clears them on Reset like the rest, inherits a bundle's, and replays them after a cut (through slot 62 of the new real list, which is the same kind of list). Overlap: #2484 (`RT-XS-LATE-RELAY`, list values) touches the same three files on other lines; `git merge-tree` finds no conflict. The new test sits beside `check_list_values`, not in it, and runs between it and `check_list_values_more`, while the list-values threads are up. No conflict with #2498 either (the descriptor-mirror item, same files). ### Tested Windows 11, MSVC (VS 18), RelWithDebInfo, on `main` 43a9d562d. CPU only. The mock list now answers `GetType` (slot 8) with the type it was created with, and records slot 62's float arguments. `xs_proxy_mock_test` gains `check_list_values_copy_and_depth_bounds`: 1. A write64 timestamp on a COPY list records no `EndQuery` or `ResolveQueryData`, while a DIRECT list still records both, with the TIMESTAMP query type. 2. Depth bounds: - set, then work and an unmet wait: the spare list the cut moves to gets `OMSetDepthBounds(0.25, 0.75)` again; - after a Reset, the next cut does not set them; - a bundle's `(0.125, 0.5)` executed in the list is replayed after its cut. With `main`'s shims the test fails at the COPY check. With only the `ListState` recording line removed, it fails at the first replay check. With the fix it passes. - `ctest -R "^(xs_proxy_mock.*|device_proxy)$"`: 10/10 pass. - `scripts/check_no_game_data.py`: clean. GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11 (CPU tests only) AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
lixonik commented 2026-11-27 21:36:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T21:36:43Z.

Review: APPROVED


Reviewed the diff and tested locally on Windows 11 (MSVC 19.44, Ninja Release).

  • take_timestamp() returning early for D3D12_COMMAND_LIST_TYPE_COPY avoids recording EndQuery / ResolveQueryData against a D3D12_QUERY_HEAP_TYPE_TIMESTAMP heap on a copy list and cleanly uses the existing CPU-clock fallback.
  • list_om_set_depth_bounds() records depth_bounds(min, max) into ListState only after passing the kPcOMSetDepthBounds < self->pc_slot_count guard and forwarding to self->real; ListState merges depth bounds from bundles, clears them on Reset (set_ = 0), and replays PC slot 62 (OMSetDepthBounds) onto cut spare lists.
  • Built xs_proxy_mock_test and ran ctest --output-on-failure -V -R xs_proxy_mock: 9/9 tests passed (including check_list_values_copy_and_depth_bounds).

AI-assisted (Antigravity, Gemini).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6093534948 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2500#pullrequestreview-6093534948). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-27T21:36:43Z. **Review:** APPROVED --- Reviewed the diff and tested locally on Windows 11 (MSVC 19.44, Ninja Release). - `take_timestamp()` returning early for `D3D12_COMMAND_LIST_TYPE_COPY` avoids recording `EndQuery` / `ResolveQueryData` against a `D3D12_QUERY_HEAP_TYPE_TIMESTAMP` heap on a copy list and cleanly uses the existing CPU-clock fallback. - `list_om_set_depth_bounds()` records `depth_bounds(min, max)` into `ListState` only after passing the `kPcOMSetDepthBounds < self->pc_slot_count` guard and forwarding to `self->real`; `ListState` merges depth bounds from bundles, clears them on `Reset` (`set_ = 0`), and replays PC slot 62 (`OMSetDepthBounds`) onto cut spare lists. - Built `xs_proxy_mock_test` and ran `ctest --output-on-failure -V -R xs_proxy_mock`: 9/9 tests passed (including `check_list_values_copy_and_depth_bounds`). AI-assisted (Antigravity, Gemini).
timbot103 commented 2026-11-28 02:02:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T02:02:02Z.


Reviewed at head 7aa6520bb on Windows 11 (MSVC 2022 19.44).

Verification

  • Built xs_proxy_mock_test.
  • xs_proxy_mock_test: passed.

Notes

  • Skipping GPU timestamp query allocation/recording on COPY lists for both timestamp flags while preserving calibrated queue-tick / QPC pending writes (d3d12_xs_device.cpp:3395-3444, d3d12_xs_list_values.h:915-940) and forwarding/tracking depth bounds across list cuts, bundles, Reset, and ClearState (d3d12_xs_device.cpp:3340-3362, 3647-3695, 3861-3880, d3d12_xs_list_values.h:1274-1285, 1358-1367) all look clean and consistent with the D3D12 specs.

Approve.

AI-assisted review + local MSVC verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232082686 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2500#issuecomment-7232082686). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-28T02:02:02Z. --- Reviewed at head `7aa6520bb` on Windows 11 (MSVC 2022 `19.44`). ### Verification - Built `xs_proxy_mock_test`. - `xs_proxy_mock_test`: **passed**. ### Notes - Skipping GPU timestamp query allocation/recording on `COPY` lists for both timestamp flags while preserving calibrated queue-tick / QPC pending writes (`d3d12_xs_device.cpp:3395-3444`, `d3d12_xs_list_values.h:915-940`) and forwarding/tracking depth bounds across list cuts, bundles, `Reset`, and `ClearState` (`d3d12_xs_device.cpp:3340-3362`, `3647-3695`, `3861-3880`, `d3d12_xs_list_values.h:1274-1285`, `1358-1367`) all look clean and consistent with the D3D12 specs. Approve. AI-assisted review + local MSVC verification.
zmasi commented 2026-11-28 10:22:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T10:22:45Z.


#2500 | head 7aa6520bbb (merged cleanly with main 33db04a701) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^(xs_proxy_mock.*|d3d12_mesh)$" --output-on-failure (LEONIDA_VK_VALIDATION=1) | red on main: xs_proxy_mock_test fails (xs_proxy_mock_test.cpp:4045: copy_real->calls[53] == 0 && copy_real->calls[54] == 0: take_timestamp recorded a TIMESTAMP query on a COPY list) | green on PR+main: 10/10 CTests pass (9/9 xs_proxy_mock* variants incl. COPY-list timestamp fallback and OMSetDepthBoundsX replay across list cuts, bundles, and Reset, plus d3d12_mesh on RTX 3090 in 1.04s with LEONIDA_VK_VALIDATION=1 and 0 Khronos validation errors); check_no_game_data.py 0 violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237857467 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2500#issuecomment-7237857467). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T10:22:45Z. --- #2500 | head 7aa6520bbb2e249475700dba12f9a4c6fab617d3 (merged cleanly with main 33db04a7010e81c40a7a6a15624525aa0c4a3a58) | `ctest --test-dir runtime/build -C RelWithDebInfo -R "^(xs_proxy_mock.*|d3d12_mesh)$" --output-on-failure` (`LEONIDA_VK_VALIDATION=1`) | red on main: `xs_proxy_mock_test` fails (`xs_proxy_mock_test.cpp:4045: copy_real->calls[53] == 0 && copy_real->calls[54] == 0`: `take_timestamp` recorded a `TIMESTAMP` query on a `COPY` list) | green on PR+main: `10/10` CTests pass (`9/9` `xs_proxy_mock*` variants incl. `COPY`-list timestamp fallback and `OMSetDepthBoundsX` replay across list cuts, bundles, and `Reset`, plus `d3d12_mesh` on RTX 3090 in `1.04s` with `LEONIDA_VK_VALIDATION=1` and `0` Khronos validation errors); `check_no_game_data.py` `0` violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yes
timbot103 commented 2026-11-29 01:07:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T01:07:56Z.

Review: COMMENTED


Static audit of 7aa6520bb only. I ran no builds, tests, or GPU workloads.

The early COPY check in runtime/shims/d3d12_xs_device.cpp skips query allocation and recording for both timestamp flags while keeping the fence-driven write. Flag 1 uses calibrated queue ticks when available and QPC otherwise. Flag 2 uses QPC. DIRECT and COMPUTE still use the standard timestamp heap when available.

The presence bit in runtime/shims/d3d12_xs_list_values.h preserves explicit bounds, including [0.0f, 1.0f], and replays values set by a bundle. Reset and ClearState clear the presence bit so a cut starts with the real list's defaults. The replay uses the Windows float ABI, and the shim and mock are gated to Windows in runtime/CMakeLists.txt.

At runtime/test/xs_proxy_mock_test.cpp:4044, the COPY test would pass if the write were dropped altogether. Could you submit a list created with a COPY allocator to a COPY queue and verify that both flags write their destinations via the CPU fallback once the mock fence advances? The existing query-call checks cover the invalid-query regression.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6100845379 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2500#pullrequestreview-6100845379). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-29T01:07:56Z. **Review:** COMMENTED --- Static audit of `7aa6520bb` only. I ran no builds, tests, or GPU workloads. The early COPY check in `runtime/shims/d3d12_xs_device.cpp` skips query allocation and recording for both timestamp flags while keeping the fence-driven write. Flag 1 uses calibrated queue ticks when available and QPC otherwise. Flag 2 uses QPC. DIRECT and COMPUTE still use the standard timestamp heap when available. The presence bit in `runtime/shims/d3d12_xs_list_values.h` preserves explicit bounds, including `[0.0f, 1.0f]`, and replays values set by a bundle. Reset and ClearState clear the presence bit so a cut starts with the real list's defaults. The replay uses the Windows float ABI, and the shim and mock are gated to Windows in `runtime/CMakeLists.txt`. At `runtime/test/xs_proxy_mock_test.cpp:4044`, the COPY test would pass if the write were dropped altogether. Could you submit a list created with a COPY allocator to a COPY queue and verify that both flags write their destinations via the CPU fallback once the mock fence advances? The existing query-call checks cover the invalid-query regression. AI-assisted.
aslan2142 commented 2026-12-01 16:45:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:45:32Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318171589 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2500#issuecomment-7318171589). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:45:32Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

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
ProjectLeonida/mandy!2500
No description provided.