GPU: queries answer from the host GPU #2260
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2260
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2260"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@FoxxoOwO on GitHub · 2026-11-25 09:14 UTC · original
FoxxoOwO:gpu/real-queries→main· +550 −56 · 9 files · 3 commits · openBeginQuery, EndQuery and ResolveQueryData now run on the host GPU when a device exists. A console query heap makes a host heap of its own kind on first use (occlusion, timestamp, pipeline statistics) and the list records into it. A resolve lands in a read-back buffer of exactly the results' size; the copy into the title's buffer waits for the list where the fence wait already puts the bottom-of-pipe writes. Kinds that map to no host type, and heaps whose host heap could not be made, keep the old plausible values.
Verified on GTA VI (I:\GTA6-Xbox): occlusion queries (kind 0) resolve per frame (~30 queries per resolve) and the world reaches mesh pipelines.
Tests: cargo test -p victory-gpu passes (51), check/clippy clean.
@Dathinel on GitHub · 2026-11-25 09:25 UTC · original · edited 2026-11-25 09:32 UTC
Timestamp heap type mismatch at
afffa8bd.Host::query_heapreceivesheap.desc.kindbut matches query-operation numbers. The existingquery.rsfixture uses descriptor kind 1 for timestamps. An assertion immediately before native heap creation got OCCLUSION (0) for that descriptor, expected TIMESTAMP (1). The kind-0 occlusion test below therefore misses this.In a local integration on
940d32fI changed just the heap mapping to 0 → occlusion, 1 → timestamp, 2 → pipeline statistics, leaving the command-list query type mapping alone. With four timestamp EndQuery calls, the deferred native resolve wrote 32 bytes and preserved the 32-byte sentinel tail. The four ticks were equal, so this checks readback only. With one statistics query around no work, the native resolve wrote eleven zero counters (88 bytes) and preserved the next 40 bytes. Synthetic Windows tests. D3D12 heap types and query types.Timestamp units after the heap fix. Three separate command lists on the same queue each recorded one timestamp and resolved eight bytes. On this machine native D3D12 reported 1,000,000,000 ticks/s; the emulated queue's GetTimestampFrequency (slot 16) returned 100,000,000. Successive returned values differed by 42,782,720 and 42,169,344 ticks across roughly 42 ms gaps. A caller using the advertised frequency would compute 427.8 ms and 421.7 ms (10× the native intervals). The earlier four equal timestamps in one batch could not reveal this. This measured ratio is adapter-specific. #159 already has a clock conversion and a synthetic regression named
host_timestamps_are_on_the_title_clockfor keeping native and fallback results in the same clock domain.The query changes can be reviewed separately from the shader work in #2241. This branch contains that PR's exact head (
e2624b3), followed by317573dandafffa8bd. I applied just the GPU code from those latter two commits to main940d32f. In the list method-table conflict I kept main's 12 entries, including slots 53–55, and routed slots 28/29 to begin_query/end_query. Six query-filtered tests passed on Windows.I also adapted the empty-draw fixture from #1731 to exercise the public command-list slots. With a host occlusion heap present, I initialized a 64-byte result buffer to 0xa5, began and ended four queries with no draws, then resolved and submitted. The first 32 bytes became zero and the remaining 32 retained 0xa5. This verifies the empty-draw readback on that integration; timestamps, statistics and positive sample counts remain outside this check. #159 also has relevant fixtures for skipped draws and repeated resolves.
AI-assisted; synthetic data only.
@kotekompotek on GitHub · 2026-11-25 09:40 UTC · original
Read through the two commits past
e2624b3(this PR is stacked on #2241 — the atomics andvalu_testschanges in the Files view are that base's, the actual delta here is ~200 lines inhost.rs/list.rs/query.rs).The mechanism looks right:
OnceLock, kinds mapped 0|1→OCCLUSION / 2→TIMESTAMP / 3→PIPELINE_STATISTICS, unknown kinds and host-heap creation failures fall back to the plausible-value path rather than failing the resolve.ResolveQueryDatalands in a fresh read-back buffer of exactlycount * 8, and the CPU copy rides the existing deferred-writes point — after the list's fence wait, so the bottom-of-pipe results are final. Bounds are checked against the title buffer beforedata.add(offset).One legality question:
BeginQueryis not valid forD3D12_QUERY_TYPE_TIMESTAMPon the host — timestamps may only beEndQuery'd. If a title ever callsBeginQuery(heap, 2, i), the debug layer will flag it (and the call is ignored). Harmless, but filteringkind == 2inbegin_querywould keepVICTORY_D3D12_DEBUGoutput clean.Smaller notes: a fresh committed read-back buffer per resolve is correct but allocation-heavy if a title resolves every frame — a pooled buffer would help later, no need to block on it. The
?desc→ fielded log fix inafffa8bis right (Descderives noDebug).@Marvisak on GitHub · 2026-11-25 10:14 UTC · original · edited 2026-11-25 12:32 UTC
Automated triage for the maintainers.
Proposed close: superseded by #2354. As you say above, the rebased change is in #2354 ("GPU: queries run on the host GPU"), with the timestamp rescaling and the
BeginQueryfilter. This branch still conflicts withmain(940d32f) in seven files. #2354 will be reviewed in its own right.This PR will be closed in 48 hours unless you push a change or a maintainer removes the
triage: proposed closelabel. Thanks for carrying the review points over.Generated by Claude Code
@FoxxoOwO on GitHub · 2026-11-25 11:29 UTC · original
Rebased onto current
mainand addressing the review:GetTimestampFrequencyof the queue) before they are copied into title memory.BeginQueryon timestamps: D3D12 has noBeginQueryfor a timestamp query.begin_querynow skips timestamps;end_querymarks them.The old branch could not be force-pushed, so the rebased change is in #2354. Happy to close this one if you prefer to review there.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.