GPU: queries run on the host GPU #2352

Closed
FoxxoOwO wants to merge 1 commit from upstream-pr/2354 into main
FoxxoOwO commented 2026-11-25 11:29:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by FoxxoOwO on 2026-11-25T11:29:07Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6603468869 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2354). Originally posted by [FoxxoOwO](https://github.com/FoxxoOwO) on 2026-11-25T11:29:07Z. --- 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).
DenRakEiw commented 2026-11-25 12:03:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T11:41:43Z.

Review: APPROVED


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

<!-- greyfinch-sync:Marvisak/VIctory:review:6056955319 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2354#pullrequestreview-6056955319). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T11:41:43Z. **Review:** APPROVED --- 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 commented 2026-11-25 12:03:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T11:52:03Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6057090689 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2354#pullrequestreview-6057090689). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T11:52:03Z. **Review:** COMMENTED --- 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.
DrDarkDK commented 2026-11-25 12:03:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T11:34:05Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7161214748 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2354#issuecomment-7161214748). Originally posted by [DrDarkDK](https://github.com/DrDarkDK) on 2026-11-25T11:34:05Z. --- 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.*
Marvisak commented 2026-11-25 16:09:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:33:51Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167036600 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2354#issuecomment-7167036600). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:33:51Z. --- <!-- 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)_
upstream-sync closed this pull request 2026-11-26 10:04:20 +00:00
FoxxoOwO commented 2026-11-26 10:05:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by FoxxoOwO on 2026-11-26T09:53:08Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7188605811 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2354#issuecomment-7188605811). Originally posted by [FoxxoOwO](https://github.com/FoxxoOwO) on 2026-11-26T09:53:08Z. --- 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

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
Marvisak/VIctory!2352
No description provided.