Repository navigation
Conversation
The console carries an image atomic's width in dmask, with no _x2 opcode variants: two data dwords are one 64-bit value (with cmpswap, the two of the comparison after it). So the texture's host view is an R32G32 integer view and the operation is DXIL's i64 atomic (SM 6.6), the value joined from the register pair and the old value split back into both dwords when glc asks for it. The validator wants AtomicInt64OnTypedResource (module flag bit 27) and AtomicInt64OnHeapResource (bit 32), which it gets: the handle always comes from the descriptor heap, so both hold. Tested with two shaders in emit/valu_tests.rs, validated by dxil.dll 1.6 and dispatched on the hardware adapter and WARP: an add of 0xFFFFFFFF twice carries out of the low dword (proving the pair is one value, not two 32-bit lanes) with the old value returned to both dwords, and a cmpswap that matches swaps and one whose comparison fails returns the texel unchanged. Not exercised: the signed and unsigned min/max i64 atomics, which take the same path.
BeginQuery, EndQuery and ResolveQueryData used to be recorded nowhere: a resolve wrote plausible values (a million samples, binary occlusion visible, the submission's own length as a timestamp), so an occlusion query could never cull anything and a timestamp measured nothing. A console query heap now 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, so a resolve still fills the buffer it is given. Not checked on hardware: nothing here proves the occlusion counts match what the title expects to have culled, so a scene change on a real GPU after this commit points at the queries.
|
Timestamp heap type mismatch at afffa8b. In a local integration on 940d32f I 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 The query changes can be reviewed separately from the shader work in #2241. This branch contains that PR's exact head (e2624b3), followed by 317573d and afffa8b. I applied just the GPU code from those latter two commits to main 940d32f. 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. |
catminou4
left a comment
There was a problem hiding this comment.
GPU queries answered from the host GPU (query heaps: occlusion/binary/timestamp/pipeline-stats, resolved read-backs) + README status update. mergeable=False against main 940d32f — needs a rebase. 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. Query semantics (resolve offsets, heap types per console kind) need Windows hardware validation.
|
Read through the two commits past The mechanism looks right:
One legality question: 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 |
|
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 This PR will be closed in 48 hours unless you push a change or a maintainer removes the Generated by Claude Code |
|
Rebased onto current
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. |
BeginQuery, 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.