GPU: queries run on the host GPU #2354

Closed
github-bot wants to merge 1 commit from github-bot/gh-2354 into main AGit
Owner

@⁠FoxxoOwO on GitHub · 2026-11-25 11:29 UTC · original
FoxxoOwO:gpu/queries-host → main · +249 −25 · 5 files · 1 commits · closed without merging

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).

**@⁠FoxxoOwO** on GitHub · 2026-11-25 11:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2354) `FoxxoOwO:gpu/queries-host` → `main` · +249 −25 · 5 files · 1 commits · closed without merging 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:03:12 +00:00
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-25 11:34 UTC · original

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.

**@⁠DrDarkDK** on GitHub · 2026-11-25 11:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2354#issuecomment-7161214748) 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.*
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:33 UTC · original · edited 2026-11-25 16:00 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 15:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2354#issuecomment-7167036600) · edited 2026-11-25 16:00 UTC <!-- victory-triage v1 head=acc935373ca94a0ae78965d9a75ae2698cc74ecc verdict=needs-rebase at=2026-11-25T15:59:50Z --> 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](https://claude.ai/code)_
github-bot closed this pull request 2026-11-26 11:10:05 +00:00
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 11:41 UTC · original · approved these changes

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).

**@⁠DenRakEiw** on GitHub · 2026-11-25 11:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2354#pullrequestreview-6056955319) · **approved these changes** 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).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 11:52 UTC · original · reviewed

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.

**@⁠catminou4** on GitHub · 2026-11-25 11:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2354#pullrequestreview-6057090689) · **reviewed** 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.
Author
Owner

@⁠FoxxoOwO on GitHub · 2026-11-26 09:53 UTC · original

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** on GitHub · 2026-11-26 09:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2354#issuecomment-7188605811) 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`.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2354
No description provided.