Skip to content

GPU: queries run on the host GPU - #2354

Closed
FoxxoOwO wants to merge 1 commit into
Marvisak:mainfrom
FoxxoOwO:gpu/queries-host
Closed

FoxxoOwO wants to merge 1 commit into
Marvisak:mainfrom
FoxxoOwO:gpu/queries-host

Conversation

@FoxxoOwO

Copy link
Copy Markdown

Console query heaps now run on the host GPU instead of answering with constants.

What changed

  • BeginQuery/EndQuery/ResolveQueryData record into the host list. A console heap gets a host heap on first use, of the matching type: occlusion kinds share one, timestamps their own, pipeline statistics theirs.
  • A resolution lands in a read-back buffer that the list maps once it has run and copies into title memory.
  • Timestamps are the host GPU's clock, so they are rescaled to the title's 100 MHz ticks on the way out (GetTimestampFrequency of the queue). This also fixes the review note about the frequency mismatch.
  • D3D12 has no BeginQuery for timestamps: begin_query skips them, end_query marks them. Fixes the review note about BeginQuery on a timestamp heap.
  • A heap whose kind or device cannot give a host heap keeps the previous plausible answers, marked with a shortcut: comment.

Tests

  • cargo test -p victory-gpu: 141 passed, 2 failed (dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views — both fail on main too, unrelated).
  • cargo clippy -p victory-gpu --all-targets: clean.
  • The ioctl path itself is unchanged, so the codec tests are untouched.

Supersedes #2260 (same change, rebased onto current main; I cannot force-push over the old branch, so this is a fresh head).

BeginQuery, EndQuery and ResolveQueryData now record into the host list:
a console query heap gets a host heap on first use, of the matching type
(occlusion kinds share one, timestamps their own, pipeline statistics
theirs). Resolutions land in a read-back buffer the list maps once it has
run and copies into title memory.

Timestamps are the host GPU's clock, so they are rescaled to the title's
TICKS (100 MHz) on the way out; the queue's frequency comes from
GetTimestampFrequency. D3D12 has no BeginQuery for timestamps, so
begin_query skips them and only EndQuery marks them, as the API requires.

A heap whose kind or device cannot give a host heap keeps the previous
plausible answers, marked as a shortcut.
@DrDarkDK

Copy link
Copy Markdown

I found a timestamp conversion regression at acc9353. I recorded two timestamp queries in separate submissions, then resolved the same query slots through the guest path and directly through D3D12.

Backend Native queue frequency Native delta Expected delta at 100 MHz Guest delta
RTX 4070 Ti (621.01) 1 GHz 26,509,312 2,650,931 0
WARP 10 MHz 254,637 2,546,370 0

Both raw timestamps exceeded u64::MAX / 100_000_000. The saturating_mul in host.rs turns both products into u64::MAX before division, so the guest receives identical timestamps. Multiplying and dividing in u128 before narrowing the result would preserve the interval.

Synthetic queries only. No game data used.

AI-assisted with Codex.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Host GPU query heap backing, command list begin/end/resolve wiring, and queue integration compile cleanly and pass tests.
  • cargo test -p victory-gpu query::: 3/3 passed on RTX 5090, 3/3 passed on WARP.
  • cargo test -p victory-gpu list::tests: 4/4 passed on RTX 5090.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

@catminou4 catminou4 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.

Queries run on the host GPU (resolves with timestamp scaling). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Note: this looks like a rebase/narrower redo of #2260 (mergeable=False, same feature) — suggest closing #2260 if this supersedes it. README updated consistently.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-gpu/src/host.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (needs-work) was for an older state of main.


Generated by Claude Code

@FoxxoOwO

Copy link
Copy Markdown
Author

Superseded by #3138, which is rebased onto main and takes the reviewed fix: the timestamp scaling is multiplied in u128, with the two reviewed intervals pinned by timestamps_scale_to_the_title_clock.

@FoxxoOwO FoxxoOwO closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants