D3D12.X: track exact per-query byte sizes in ResolveQueryData #3393

Merged
Kalmarv merged 1 commit from upstream-pr/3393 into main 2026-12-01 07:00:18 +00:00
Kalmarv commented 2026-11-29 13:02:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T13:02:08Z.


What is in it

  • Add query_result_bytes(ty: D3D12_QUERY_TYPE) -> u64 in crates/xcl/src/hle/d3d12x/list_x.rs so resolve_query_data_x passes the exact resolved byte range ((count as u64).saturating_mul(query_result_bytes(ty))) to note_copy_into for every D3D12_QUERY_TYPE:
    • D3D12_QUERY_TYPE_SO_STATISTICS_STREAM0..=3: size_of::<D3D12_QUERY_DATA_SO_STATISTICS>() (16 bytes, previously under-reported as 8 bytes).
    • D3D12_QUERY_TYPE_VIDEO_DECODE_STATISTICS: 32 bytes (previously under-reported as 8 bytes).
    • D3D12_QUERY_TYPE_PIPELINE_STATISTICS: size_of::<D3D12_QUERY_DATA_PIPELINE_STATISTICS>() (88 bytes).
    • D3D12_QUERY_TYPE_PIPELINE_STATISTICS1: size_of::<D3D12_QUERY_DATA_PIPELINE_STATISTICS1>() (112 bytes, previously under-reported as 8 bytes).
    • OCCLUSION, BINARY_OCCLUSION, TIMESTAMP, and other 64-bit queries: 8 bytes.
  • Add a #[cfg(test)] helper real::set_test_console_buffer in crates/xcl/src/hle/d3d12x/real.rs (mirroring set_test_buffer_delta) and an isolated unit test resolve_query_data_x_notes_exact_result_bytes_for_all_query_types in crates/xcl/src/hle/d3d12x/list_x.rs verifying the exact recorded write spans in LISTS for all 10 query types.

Tested

  • Verified resolve_query_data_x_notes_exact_result_bytes_for_all_query_types fails before the fix (SO_STATISTICS_STREAM0 with count = 2 recorded 16 bytes instead of 32 bytes).
  • Targeted tests after the fix (cargo test -p xcl --lib -j 4 -- resolve_query_data --nocapture): 2 passed, 0 failed, 0 ignored.
  • Full workspace suite (cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests:: with XCL_DXC_DIR set to DXC 1.9 on RTX 5070 Ti): 41 test binaries, 2662 passed, 0 failed, 49 ignored, 9 filtered out.
  • SKIPPED breakdown (26 total): 21 no wave64 (RTX 5070 Ti is wave32), 3 refused (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32 #1426 semantics), 2 no heap windows (XCL_HEAP_WINDOWS=1 opt-in).

Regression run

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
xcl-smoke v1
commit: d65aa8963719370f639f3774373306d167a73547
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1547 (PresentX 1547)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 33958 MB

Not tested

  • Retail titles resolving SO_STATISTICS_STREAM0..3, VIDEO_DECODE_STATISTICS, or PIPELINE_STATISTICS1 into shadowed committed UMA buffers were not run directly; those paths are covered by the synthetic unit test.
  • test_title_runs_and_game_folder_is_untouched, uma_driver::tests::, wave64 GPU tests, and XCL_HEAP_WINDOWS=1 opt-in unit tests were not run in the workspace suite.

AI use

  • Authored, verified, and tested with an AI coding agent; all changes and test results were verified directly against the local repository, compiler, test suite, and 150 s smoke run.
<!-- greyfinch-sync:ivall/xcl:issue:5550961861 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3393). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-29T13:02:08Z. --- **What is in it** - Add `query_result_bytes(ty: D3D12_QUERY_TYPE) -> u64` in `crates/xcl/src/hle/d3d12x/list_x.rs` so `resolve_query_data_x` passes the exact resolved byte range (`(count as u64).saturating_mul(query_result_bytes(ty))`) to `note_copy_into` for every `D3D12_QUERY_TYPE`: - `D3D12_QUERY_TYPE_SO_STATISTICS_STREAM0..=3`: `size_of::<D3D12_QUERY_DATA_SO_STATISTICS>()` (16 bytes, previously under-reported as 8 bytes). - `D3D12_QUERY_TYPE_VIDEO_DECODE_STATISTICS`: 32 bytes (previously under-reported as 8 bytes). - `D3D12_QUERY_TYPE_PIPELINE_STATISTICS`: `size_of::<D3D12_QUERY_DATA_PIPELINE_STATISTICS>()` (88 bytes). - `D3D12_QUERY_TYPE_PIPELINE_STATISTICS1`: `size_of::<D3D12_QUERY_DATA_PIPELINE_STATISTICS1>()` (112 bytes, previously under-reported as 8 bytes). - `OCCLUSION`, `BINARY_OCCLUSION`, `TIMESTAMP`, and other 64-bit queries: 8 bytes. - Add a `#[cfg(test)]` helper `real::set_test_console_buffer` in `crates/xcl/src/hle/d3d12x/real.rs` (mirroring `set_test_buffer_delta`) and an isolated unit test `resolve_query_data_x_notes_exact_result_bytes_for_all_query_types` in `crates/xcl/src/hle/d3d12x/list_x.rs` verifying the exact recorded write spans in `LISTS` for all 10 query types. **Tested** - Verified `resolve_query_data_x_notes_exact_result_bytes_for_all_query_types` fails before the fix (`SO_STATISTICS_STREAM0` with `count = 2` recorded 16 bytes instead of 32 bytes). - Targeted tests after the fix (`cargo test -p xcl --lib -j 4 -- resolve_query_data --nocapture`): 2 passed, 0 failed, 0 ignored. - Full workspace suite (`cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::` with `XCL_DXC_DIR` set to DXC 1.9 on RTX 5070 Ti): 41 test binaries, 2662 passed, 0 failed, 49 ignored, 9 filtered out. - `SKIPPED` breakdown (26 total): 21 `no wave64` (RTX 5070 Ti is wave32), 3 `refused` (`V_MUL_F16`, `V_PK_MUL_F16`, `V_CVT_F16_F32` `#1426` semantics), 2 `no heap windows` (`XCL_HEAP_WINDOWS=1` opt-in). **Regression run** ``` 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 ``` ``` xcl-smoke v1 commit: d65aa8963719370f639f3774373306d167a73547 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 1547 (PresentX 1547) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 33958 MB ``` **Not tested** - Retail titles resolving `SO_STATISTICS_STREAM0..3`, `VIDEO_DECODE_STATISTICS`, or `PIPELINE_STATISTICS1` into shadowed committed UMA buffers were not run directly; those paths are covered by the synthetic unit test. - `test_title_runs_and_game_folder_is_untouched`, `uma_driver::tests::`, wave64 GPU tests, and `XCL_HEAP_WINDOWS=1` opt-in unit tests were not run in the workspace suite. **AI use** - Authored, verified, and tested with an AI coding agent; all changes and test results were verified directly against the local repository, compiler, test suite, and 150 s smoke run.
saintwolf commented 2026-11-29 14:20:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-29T14:20:53Z.


Reviewed and tested at d65aa896.

Looks clean and accurate — query_result_bytes matches the exact D3D12 query result struct sizes (including SO_STATISTICS_STREAM0..3 at 16 B, VIDEO_DECODE_STATISTICS at 32 B, and PIPELINE_STATISTICS1 at 112 B) with saturating_mul, and the test verifies all 10 query types through resolve_query_data_x.

Tested locally

  • Windows 11 (build 26300), NVIDIA GeForce RTX 4070 SUPER (driver 32.0.16.2140), AMD Ryzen 7 7800X3D, rustc 1.100.0.
  • cargo test -p xcl --lib hle::d3d12x::list_x::tests::resolve_query_data_x_notes_exact_result_bytes -- --test-threads=1: 1 passed, 0 failed.

AI use

  • Antigravity (Gemini 4 Neon) assisted with code review and drafting; all builds and tests were executed locally on the hardware above.
<!-- greyfinch-sync:ivall/xcl:comment:7257232399 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3393#issuecomment-7257232399). Originally posted by [saintwolf](https://github.com/saintwolf) on 2026-11-29T14:20:53Z. --- Reviewed and tested at `d65aa896`. Looks clean and accurate — `query_result_bytes` matches the exact D3D12 query result struct sizes (including `SO_STATISTICS_STREAM0..3` at 16 B, `VIDEO_DECODE_STATISTICS` at 32 B, and `PIPELINE_STATISTICS1` at 112 B) with `saturating_mul`, and the test verifies all 10 query types through `resolve_query_data_x`. ### Tested locally - Windows 11 (build 26300), NVIDIA GeForce RTX 4070 SUPER (driver `32.0.16.2140`), AMD Ryzen 7 7800X3D, `rustc 1.100.0`. - `cargo test -p xcl --lib hle::d3d12x::list_x::tests::resolve_query_data_x_notes_exact_result_bytes -- --test-threads=1`: **1 passed, 0 failed**. ### AI use - Antigravity (Gemini 4 Neon) assisted with code review and drafting; all builds and tests were executed locally on the hardware above.
Foniass commented 2026-12-01 04:40:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:40:58Z.


merge-check
base: d0832e614f
head: d65aa89637
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2891 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 +82/-2, real.rs +15). No change to what a title runs by default: note_copy_into returns early unless a committed window fell back to shadowed mode or view windows exist (XCL_HEAP_WINDOWS=1). The per-type sizes match the D3D12 structures: pipeline statistics 88, PIPELINE_STATISTICS1 112, stream-output statistics 16, video decode statistics 32, occlusion / binary occlusion / timestamp / unknown 8. Main recorded 8 bytes for everything but pipeline statistics, so stream-output, video-decode and PIPELINE_STATISTICS1 resolves were under-reported. The test fails on main (stream 0, count 2: 16 bytes instead of 32). Findings: (1) the new test runs in a child process whose output is dropped when it succeeds, so a "no UMA" skip_test there shows as a plain pass (~11826). (2) AI use names no tool or model ("an AI coding agent"); the PR's suite run skipped uma_driver::tests:: and test_title_runs_and_game_folder_is_untouched (the run above covers them). No smoke run: the default path doesn't reach this code.
performance: no smoke run (the default path doesn't reach this change); not measured.
verdict: safe to merge (the description should name the AI model)
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:7300988665 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3393#issuecomment-7300988665). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:40:58Z. --- merge-check base: d0832e614fa7d6ae027bb4feb27ccb9121f54a8f head: d65aa8963719370f639f3774373306d167a73547 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2891 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 +82/-2, real.rs +15). No change to what a title runs by default: `note_copy_into` returns early unless a committed window fell back to shadowed mode or view windows exist (`XCL_HEAP_WINDOWS=1`). The per-type sizes match the D3D12 structures: pipeline statistics 88, PIPELINE_STATISTICS1 112, stream-output statistics 16, video decode statistics 32, occlusion / binary occlusion / timestamp / unknown 8. Main recorded 8 bytes for everything but pipeline statistics, so stream-output, video-decode and PIPELINE_STATISTICS1 resolves were under-reported. The test fails on main (stream 0, count 2: 16 bytes instead of 32). Findings: (1) the new test runs in a child process whose output is dropped when it succeeds, so a "no UMA" `skip_test` there shows as a plain pass (~11826). (2) AI use names no tool or model ("an AI coding agent"); the PR's suite run skipped `uma_driver::tests::` and `test_title_runs_and_game_folder_is_untouched` (the run above covers them). No smoke run: the default path doesn't reach this code. performance: no smoke run (the default path doesn't reach this change); not measured. verdict: safe to merge (the description should name the AI model) 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.
throny commented 2026-12-01 06:55:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T06:55:36Z.


merge-check
base: d0832e614f
head: d65aa89637
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2891 passed, 0 failed, 51 ignored; failing: none (25 SKIPPED lines, all GPU tests on this adapter, e.g. no wave64)
review: Read the whole diff (list_x.rs, real.rs test helper). ResolveQueryData now notes the exact result size per query type (pipeline statistics, SO statistics, video decode, pipeline statistics 1) instead of 8 or 88 bytes, with saturating multiplication. The test checks the recorded write span for ten query types against a fake command list vtable (a no-op function replaces the PC call; the flagged code-loading line is that test stub) in a child process. The video decode size 32 is a hard-coded constant, not checked here against the SDK struct; the test would not catch a wrong value as it uses the same number. The real.rs helper is #[cfg(test)].
performance: no cost by default: a match per ResolveQueryData call; the noted span can be larger for pipeline statistics 1 (more tracked bytes), reasoned, not measured.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300; Claude Code, Claude Sonnet 5.5 ran the build and the suite and read the diff; Claude Opus 5.5 checked this report (the diff review is Sonnet's)

<!-- greyfinch-sync:ivall/xcl:comment:7303443032 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3393#issuecomment-7303443032). Originally posted by [throny](https://github.com/throny) on 2026-12-01T06:55:36Z. --- merge-check base: d0832e614fa7d6ae027bb4feb27ccb9121f54a8f head: d65aa8963719370f639f3774373306d167a73547 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2891 passed, 0 failed, 51 ignored; failing: none (25 SKIPPED lines, all GPU tests on this adapter, e.g. no wave64) review: Read the whole diff (list_x.rs, real.rs test helper). ResolveQueryData now notes the exact result size per query type (pipeline statistics, SO statistics, video decode, pipeline statistics 1) instead of 8 or 88 bytes, with saturating multiplication. The test checks the recorded write span for ten query types against a fake command list vtable (a no-op function replaces the PC call; the flagged code-loading line is that test stub) in a child process. The video decode size 32 is a hard-coded constant, not checked here against the SDK struct; the test would not catch a wrong value as it uses the same number. The real.rs helper is #[cfg(test)]. performance: no cost by default: a match per ResolveQueryData call; the noted span can be larger for pipeline statistics 1 (more tracked bytes), reasoned, not measured. verdict: safe to merge hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300; Claude Code, Claude Sonnet 5.5 ran the build and the suite and read the diff; Claude Opus 5.5 checked this report (the diff review is Sonnet's)
throny commented 2026-12-01 07:00:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T07:00:33Z.


Merged at the checked head after a combined trial of #3400, #3386, #3393 and #3535 on main d0832e61 (RTX 4080 16 GB, cargo test --workspace --no-fail-fast -- --test-threads=4: 2896 passed, 0 failed, 51 ignored, 25 SKIPPED lines). Two merge checks: Foniass and ours.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7303536806 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3393#issuecomment-7303536806). Originally posted by [throny](https://github.com/throny) on 2026-12-01T07:00:33Z. --- Merged at the checked head after a combined trial of #3400, #3386, #3393 and #3535 on `main` `d0832e61` (RTX 4080 16 GB, `cargo test --workspace --no-fail-fast -- --test-threads=4`: 2896 passed, 0 failed, 51 ignored, 25 SKIPPED lines). Two merge checks: Foniass and ours. AI use: Claude Code (Claude Opus 5.5).
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!3393
No description provided.