Skip to content

D3D-494: Fix ANV pipeline statistics for transfers - #4792

Open
gut0to wants to merge 2 commits into
ItsNotRexed:mainfrom
gut0to:gut0to/d3d-494-anv-stat-query-transfers
Open

gut0to wants to merge 2 commits into
ItsNotRexed:mainfrom
gut0to:gut0to/d3d-494-anv-stat-query-transfers

Conversation

@gut0to

@gut0to gut0to commented Nov 23, 2026 •

Copy link
Copy Markdown

Summary

Intel Mesa ANV may count internal compute work used to implement Vulkan transfers in active D3D12 pipeline-statistics queries. The planner now splits statistics segments around transfer commands only for the Intel open-source Mesa driver, and the emitter closes the active query before each transfer and starts the next segment afterward. The existing segment summation combines the results.

Adds synthetic coverage for ordinary and overlapping statistics queries. The emission regression checks the actual order: begin query, end query, native copy, begin query, end query. The workaround stays disabled for other drivers.

Work item: D3D-494 (claimed in the D3D12 coordination issue). Related report and standalone Vulkan repro: #4709.

Validation

  • Passed after the emission fix: replay_query_edges on Windows (CPU-side synthetic test).
  • Independent Windows/MSVC validation reported replay_query_edges_test and d3d12_vulkan_device_test passing at 0555b56; the latter had two existing C4456 warnings.
  • Intel ANV hardware repro: not run; this machine has an AMD RX 6600, and WSL2 is unavailable.
  • No game files.

AI-assisted (GPT-6).

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built and ran replay_query_edges_test at 0555b563b on Windows 11, RTX 5070 Ti: exit 0, heap boundaries, chunking, persistent queries, predicated copies and queue ownership passed; git diff --check clean.

Pipeline statistics for transfers now use the ANV-correct query path: the shim and replay handle the transfer stage in the statistics query instead of reading a zeroed slot; the added edge test covers the heap boundaries, chunking, persistent queries, predicated copies and queue ownership. No blocking issue.

@shdann

shdann commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

At 0555b563, the planner splits a statistics query around an ordinary buffer copy. The emitter leaves segment 0 active during the copy. It then ends segment 1 before it starts segment 1. The new test checks the plan and passes. The same test fails when it emits the planned commands.

To reproduce, insert this block immediately before CommandList overlapping_transfer; in runtime/test/replay_query_edges_test.cpp:

    auto probe_pool = make_segment_pool(15);
    c.values[probe_pool->pool].resize(2);
    QueryReplay probe_batch;
    expect(probe_batch.plan(transfer_split, {}, 0, true, probe_pool)
           == ReplayResult::success, "plan probe");
    c.events.clear();
    try { emit(transfer_split, {}, vk); }
    catch (...) {
        for (auto& e : c.events) std::printf("%s\n", e.c_str());
        throw;
    }

Build and run replay_query_edges_test. The mock records begin_query, native_copy. It then reports end inactive query and exits 1. The expected order is begin_query, end_query, native_copy, begin_query, end_query.

I also emitted the existing transfer_control list with the workaround off. It records begin_query, native_copy, end_query and passes. The unmodified test also passes. I ran these checks on Windows 11 with MSVC and the CPU mock. No Intel hardware is needed to reproduce this command sequence.

Please apply the planned end and begin operations around the native copy. Please also check the other transfer paths and keep an emission check in the regression test.

AI-assisted.

Fix verified at e84c51f on Windows 11 with MSVC. The original emission probe records begin_query, end_query, native_copy, begin_query, end_query and exits 0. I also emitted the overlapping two-query case. It closes the active physical segment before the copy and opens the next segment after it. The updated replay_query_edges_test passes. These are CPU mock results. Intel ANV hardware behavior remains untested here.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 0555b56 merged with main 98fa503 on Windows (MSVC 14.51, RelWithDebInfo): pass

  • replay_query_edges_test (CPU only): passes, exit 0. d3d12_vulkan_device_test (shim changed) builds with only the two C4456 warnings that main already has (fixed by runtime test: remove two MSVC C4456 shadowing warnings in d3d12_vulkan_device_test #4781).
  • Negative control: with runtime/src and runtime/shims restored from main, the new test fails to build (C2039: 'exclude_transfers_from_pipeline_statistics' is not a member of ReplayFunctions); with the PR files back it passes again.
  • Not run: the ANV detection (VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA) in the shim needs an Intel Mesa driver, which is not available here; the test only covers the planner with the flag set directly.

@gut0to

gut0to commented Nov 23, 2026

Copy link
Copy Markdown
Author

@shdann Thanks for catching this: the planner had assigned segment boundaries, but replay was not emitting them around the native transfer. Fixed in e84c51f: the active query now ends before the transfer and the next segment begins after it. The emission regression asserts the full begin_query, end_query, native_copy, begin_query, end_query sequence. The same command-level guard covers every transfer variant in the classifier; existing per-helper brackets are skipped inside that guard to avoid duplicate query operations. replay_query_edges passes on the updated branch.

@Kam471 and @kapitche, thanks for the independent test and build checks. The Intel ANV hardware run remains outstanding.

@tupacfan04

Copy link
Copy Markdown
Contributor

Tested e84c51fb on Windows 11 x64 (MSVC 19.51.36260.0, NVIDIA RTX 5070, driver 621.24, Vulkan SDK 1.4.363.0): pass.

  • replay_query_edges_test: exit 0. The new emission assertion records exactly begin_query, end_query, native_copy, begin_query, end_query, and the overlapping two-query case sums both sides of the transfer as expected.
  • d3d12_vulkan_device_test: builds (only the two pre-existing C4456 warnings) and passes end to end on the RTX 5070 through the Xbox-ABI proxy, including queries and the non-Intel driver path. The new driver-properties query correctly leaves the workaround off here and does not affect device creation.

Not run: Intel ANV hardware — no Intel GPU available, so the VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA detection remains untested on real hardware. The planner/emitter behavior is covered by the CPU mock.

No game data used. AI-assisted verification.

@abilliontokens

Copy link
Copy Markdown
Contributor

Tested e84c51fbe92e0061d6fe51eb7ad437e3b856a322 on NVIDIA GeForce RTX 5060 Ti (621.24, Windows 11): pass.

Worktree at the PR head, runtime built with scripts/build_runtime.ps1 (MSVC 14.44, RelWithDebInfo), Vulkan pinned to the RTX 5060 Ti (driver 621.24.0.0). The ANV-specific workaround is inert on NVIDIA; this confirms the build and the affected tests pass with no regression on a non-Intel device.

Command and result:

ctest --test-dir runtime/build -R 'replay_query_edges|d3d12_vulkan_device' --output-on-failure
  -> d3d12_vulkan_device ... Passed (11.83 sec)
  -> replay_query_edges  ... Passed (0.01 sec)

python -I -m compileall -q make_game.py tools tests is clean. Synthetic tests only, no game files, no Intel ANV hardware.

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.

6 participants