GPU: occlusion, statistics and timestamp queries run on the host #159

Open
github-bot wants to merge 4 commits from github-bot/gh-159 into main AGit
Owner

@⁠r4tedx on GitHub · 2026-11-24 01:01 UTC · original
r4tedx:gpu/host-queries → main · +932 −28 · 6 files · 4 commits · open

Rebased onto main 940d32f and reworked (head b7249e5, 2026-11-25). main still has no host queries (BeginQuery/EndQuery do nothing, ResolveQueryData writes stand-ins), so the change is still needed. What is different from the earlier head: results no longer go into the title buffer's host copy; they go through read-back memory, see "What". main already has the overflow-safe bounds check of #52, so this no longer touches it.

What

The README lists real queries as missing for the world: BeginQuery/EndQuery did nothing and ResolveQueryData wrote stand-ins (2^20 samples, visible, zero statistics, the clock after the submission).

First commit:

  • A title query heap of a type the host has (occlusion, timestamp, pipeline statistics; at most 2^18 queries) gets a host heap on first use.
  • BeginQuery/EndQuery are recorded into the list's host list in order with its draws, by D3D12's rules: timestamps only end, a query already running does not begin again, an end without its begin in the same list is dropped, queries still running at close are ended there (and keep the stand-in).
  • ResolveQueryData resolves every measured query, of any type, into read-back memory the list owns: mapped 64 KiB chunks that stay copy destinations and are reused after a reset. No title buffer's host copy is touched, so the resolve does not depend on the state the title's shaders and indirect executions left that copy in. An earlier head resolved into the host copy and assumed it was in COMMON, which a review found does not hold in the world (indirect::done leaves the copy in UNORDERED_ACCESS, and a submission's lists share one ExecuteCommandLists).
  • After the submission has run, measured results and stand-ins reach title memory through the same ordered deferred CPU writes, so the last resolve to a slot wins, in list and submission order, at any alignment. main's copy-back of shader writes is unchanged, and a list whose shaders read title memory with no host copy still delivers its query results, since deferred writes are not withheld.
  • Timestamps are put on the title's 100 MHz GPU clock (the one GetTimestampFrequency and bottom-of-pipe timestamps use) from the host queue's clock calibration, read once before the writes, so a stand-in timestamp written first never reads earlier than a host one after it.
  • Everything else keeps the stand-ins: queries that did not run on the host, a heap of another type, indices past the heap, console-only query types, no host GPU. A resolve past the destination buffer writes nothing.

Second commit: an occlusion or binary occlusion query with a title draw inside that the host did not run (pipeline not ready, a shader that does not translate, an indirect execution that cannot run) is ended on the host but keeps the stand-in "visible". Otherwise, while draws of untranslated shaders are still dropped, real queries would report nothing visible and the title would cull by that.

Known limits

  • Results are in title memory once the resolving submission has run, as the CPU sees them on a real GPU. A GPU command later in the same submission that reads the destination buffer sees its earlier bytes, and so does a CPU-side buffer copy recorded in that submission (those run before the GPU). main has no predication, the one D3D12 feature that reads a resolve buffer on the GPU.
  • Whether a query counts as measured follows recording order, not execution order: an end recorded in a list that is submitted later, or never, can make a query look measured to an earlier submission's resolve.
  • The skipped-draw rule sees whole skipped commands. Indirect records cut off by the per-list budget run empty while the command reports that it ran, and a mesh dispatch with y * z != 1 runs only its x groups.
  • Our own helper passes (vertex expansion, the indirect clamp, main's heap-view, title-memory and depth-twin dispatches) are counted in pipeline statistics.

Not verified

Nothing has run on a hardware GPU, under the D3D12 debug layer or in the title since the rebase; the RTX 5070 runs were of the earlier head. No game files were used.

Tested

At b7249e5, on WARP only (VICTORY_D3D12_WARP=1, --features diagnostics, one test thread), synthetic. The tests call the title's list, queue and heap methods; the draws come from a small host pipeline recorded into the title list's host list, since title pipelines need translated console shaders.

  • A full-screen 64x64 triangle counts 4096 samples and is visible; one cut away counts 0 and is not; statistics read 3 vertices and 1 primitive; bytes around the results stay.
  • Two timestamps around draws come out in order on the title clock, with a stand-in timestamp recorded first.
  • A title DrawInstanced with nothing bound inside occlusion queries resolves to the stand-ins while a query begun after it measures 0.
  • The same slot resolved twice in one list: unmeasured then measured ends as 4096, measured then unmeasured ends as the stand-in 2^20.
  • A resolve after the indirect clamp wrote the destination's host copy as a UAV in the same list gives 4096, and the next submission's host copy has it.
  • A list marked as having read memory with no copy still delivers its occlusion result; an unaligned destination works.
  • Queries not run, of the wrong heap, past the heap or the buffer, or of unknown types keep the stand-ins, with or without a host. Tests that need a device print a skip line when there is none.
  • cargo test -p victory-gpu: 153 passed, 0 failed, 2 ignored (the two are main's benchmarks). cargo test -p xtask: 6 passed.
  • cargo clippy --workspace --all-targets --locked -- -D warnings and the --all-features variant: clean.

#32 rewrites parts of host.rs this touches; whichever lands second needs a rebase.

AI-assisted; no game assets were used.

🤖 Generated with Claude Code

**@⁠r4tedx** on GitHub · 2026-11-24 01:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/159) `r4tedx:gpu/host-queries` → `main` · +932 −28 · 6 files · 4 commits · open **Rebased onto `main` `940d32f` and reworked (head `b7249e5`, 2026-11-25).** `main` still has no host queries (`BeginQuery`/`EndQuery` do nothing, `ResolveQueryData` writes stand-ins), so the change is still needed. What is different from the earlier head: results no longer go into the title buffer's host copy; they go through read-back memory, see "What". `main` already has the overflow-safe bounds check of #52, so this no longer touches it. ## What The README lists real queries as missing for the world: `BeginQuery`/`EndQuery` did nothing and `ResolveQueryData` wrote stand-ins (2^20 samples, visible, zero statistics, the clock after the submission). First commit: - A title query heap of a type the host has (occlusion, timestamp, pipeline statistics; at most 2^18 queries) gets a host heap on first use. - `BeginQuery`/`EndQuery` are recorded into the list's host list in order with its draws, by D3D12's rules: timestamps only end, a query already running does not begin again, an end without its begin in the same list is dropped, queries still running at close are ended there (and keep the stand-in). - `ResolveQueryData` resolves every measured query, of any type, into read-back memory the list owns: mapped 64 KiB chunks that stay copy destinations and are reused after a reset. No title buffer's host copy is touched, so the resolve does not depend on the state the title's shaders and indirect executions left that copy in. An earlier head resolved into the host copy and assumed it was in COMMON, which a review found does not hold in the world (`indirect::done` leaves the copy in UNORDERED_ACCESS, and a submission's lists share one `ExecuteCommandLists`). - After the submission has run, measured results and stand-ins reach title memory through the same ordered deferred CPU writes, so the last resolve to a slot wins, in list and submission order, at any alignment. `main`'s copy-back of shader writes is unchanged, and a list whose shaders read title memory with no host copy still delivers its query results, since deferred writes are not withheld. - Timestamps are put on the title's 100 MHz GPU clock (the one `GetTimestampFrequency` and bottom-of-pipe timestamps use) from the host queue's clock calibration, read once before the writes, so a stand-in timestamp written first never reads earlier than a host one after it. - Everything else keeps the stand-ins: queries that did not run on the host, a heap of another type, indices past the heap, console-only query types, no host GPU. A resolve past the destination buffer writes nothing. Second commit: an occlusion or binary occlusion query with a title draw inside that the host did not run (pipeline not ready, a shader that does not translate, an indirect execution that cannot run) is ended on the host but keeps the stand-in "visible". Otherwise, while draws of untranslated shaders are still dropped, real queries would report nothing visible and the title would cull by that. ## Known limits - Results are in title memory once the resolving submission has run, as the CPU sees them on a real GPU. A GPU command later in the same submission that reads the destination buffer sees its earlier bytes, and so does a CPU-side buffer copy recorded in that submission (those run before the GPU). `main` has no predication, the one D3D12 feature that reads a resolve buffer on the GPU. - Whether a query counts as measured follows recording order, not execution order: an end recorded in a list that is submitted later, or never, can make a query look measured to an earlier submission's resolve. - The skipped-draw rule sees whole skipped commands. Indirect records cut off by the per-list budget run empty while the command reports that it ran, and a mesh dispatch with `y * z != 1` runs only its `x` groups. - Our own helper passes (vertex expansion, the indirect clamp, `main`'s heap-view, title-memory and depth-twin dispatches) are counted in pipeline statistics. ## Not verified Nothing has run on a hardware GPU, under the D3D12 debug layer or in the title since the rebase; the RTX 5070 runs were of the earlier head. No game files were used. ## Tested At `b7249e5`, on WARP only (`VICTORY_D3D12_WARP=1`, `--features diagnostics`, one test thread), synthetic. The tests call the title's list, queue and heap methods; the draws come from a small host pipeline recorded into the title list's host list, since title pipelines need translated console shaders. - A full-screen 64x64 triangle counts 4096 samples and is visible; one cut away counts 0 and is not; statistics read 3 vertices and 1 primitive; bytes around the results stay. - Two timestamps around draws come out in order on the title clock, with a stand-in timestamp recorded first. - A title `DrawInstanced` with nothing bound inside occlusion queries resolves to the stand-ins while a query begun after it measures 0. - The same slot resolved twice in one list: unmeasured then measured ends as 4096, measured then unmeasured ends as the stand-in 2^20. - A resolve after the indirect clamp wrote the destination's host copy as a UAV in the same list gives 4096, and the next submission's host copy has it. - A list marked as having read memory with no copy still delivers its occlusion result; an unaligned destination works. - Queries not run, of the wrong heap, past the heap or the buffer, or of unknown types keep the stand-ins, with or without a host. Tests that need a device print a skip line when there is none. - `cargo test -p victory-gpu`: 153 passed, 0 failed, 2 ignored (the two are `main`'s benchmarks). `cargo test -p xtask`: 6 passed. - `cargo clippy --workspace --all-targets --locked -- -D warnings` and the `--all-features` variant: clean. #32 rewrites parts of `host.rs` this touches; whichever lands second needs a rebase. AI-assisted; no game assets were used. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
No query ran on the host GPU. BeginQuery and EndQuery did nothing and
ResolveQueryData wrote stand-ins after the submission.

A title heap for occlusion, pipeline statistics or timestamps gets a
host heap on first use. Begin and end are recorded in order with draws.
Timestamps only end, duplicate begins and ends without a begin in the
same list are dropped, and close ends outstanding host queries.

The host resolves measured queries into mapped read-back memory owned
by the command list, in COPY_DEST throughout. It reuses arena chunks
on reset. Ordered bottom-of-pipe CPU writes put measured results and
stand-ins into title memory, including unaligned destinations. The
last resolve of a slot wins across all lists in the submission.
Timestamps are converted with the host queue's calibration onto the
title's 100 MHz clock, sampled before applying any deferred writes.

Main's shader copy-back is unchanged. A list that read title memory
with no host copy withholds its shader writes, and still runs the
deferred CPU writes. Subsequent GPU reads get the new title bytes
through main's normal host-copy refresh, as they do for stand-ins.

The CPU sees the query results after the resolving submission. GPU
commands later in that submission see the destination's previous
bytes. Main has no predication implementation.

Tests use synthetic title list, queue and heap calls with a small host
triangle. They cover measured queries, stand-ins, overlapping resolves,
timestamp ordering, the missed-list case, and the same buffer used as
a UAV before the resolve and refreshed on a later submission.

The full diagnostics suite passed on WARP after the rebase (153 passed,
2 ignored). Both workspace Clippy configurations passed. The earlier
RTX 5070 runs were before the rebase.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
A title draw the host skips because its pipeline is unavailable, its
shader is unsupported or its indirect execution cannot run leaves any
surrounding occlusion query counting too few samples. The title can
then cull what the draw would have shown.

Mark active queries when a draw, mesh dispatch or indirect execution
is skipped. End marked occlusion and binary occlusion queries on the
host and write their stand-ins (2^20 samples or visible) through the
same deferred CPU write path as measured results. Pipeline statistics
keep what the host counted.

A synthetic title draw without a bound pipeline exercises the two
occlusion stand-ins. The query begun after the skipped draw measures
zero and the statistics include the host draw. The test passed on
WARP after the rebase. The earlier RTX 5070 run preceded the rebase.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's 315cea18 made the clamp read the title's records through a root
view and write the clamped ones into an argument buffer of the list's
own: `indirect::bound` takes no title buffer and returns that buffer,
and the title's copy is never transitioned or written. The test now
passes the returned buffer to `indirect::done`, checks the title's
records are as written, and is named for what it checks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:52:39 +00:00
Author
Owner

@⁠r4tedx on GitHub · 2026-11-24 03:11 UTC · original

Two corrections to my own PR.

1. A claim I have withdrawn. The first commit's message said the query tests were clean under the debug layer and GPU-based validation. That was wrong: the D3D12 debug layer (d3d12SDKLayers.dll) is not installed on the machine these tests ran on, so nothing was validated. I have reworded the commit message (force-pushed, no code change; head is now 29c52d2). The tests still pass (47), but resource-state mistakes in the resolve would not have shown.

2. This needs adapting once a buffer-state tracker lands (#334 or #367). host_resolve relies on the buffer's host copy being in COMMON when ResolveQueryData runs (promotion to COPY_DEST), then issues its own COPY_DEST to COMMON barrier. That holds on main. It does not hold with either tracker:

  • with #334 the prelude moves the copy to its first tracked state before the list starts (usually GENERIC_READ), so it cannot be promoted, and my barrier names the wrong before-state;
  • with #367 refresh / gpu_writes leave it explicitly in UNORDERED_ACCESS just before the resolve.

The fix is to drop the manual barrier and ask the tracker for COPY_DEST before the resolve (list.buffer_state(&shadow.buffer, COPY_DEST) with #334, list.resource_state(..) with #367). I will do that on top of whichever of the two is merged; a trial merge with #334 is textually clean and passes tests, which is exactly why this needs saying.

If someone with the debug layer installed can run cargo test -p victory-gpu query with VICTORY_D3D12_DEBUG=1 on this branch, the output would be useful.

**@⁠r4tedx** on GitHub · 2026-11-24 03:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/159#issuecomment-7120852827) Two corrections to my own PR. **1. A claim I have withdrawn.** The first commit's message said the query tests were clean under the debug layer and GPU-based validation. That was wrong: the D3D12 debug layer (`d3d12SDKLayers.dll`) is not installed on the machine these tests ran on, so nothing was validated. I have reworded the commit message (force-pushed, no code change; head is now `29c52d2`). The tests still pass (47), but resource-state mistakes in the resolve would not have shown. **2. This needs adapting once a buffer-state tracker lands (#334 or #367).** `host_resolve` relies on the buffer's host copy being in COMMON when `ResolveQueryData` runs (promotion to COPY_DEST), then issues its own COPY_DEST to COMMON barrier. That holds on `main`. It does not hold with either tracker: - with #334 the prelude moves the copy to its first tracked state before the list starts (usually GENERIC_READ), so it cannot be promoted, and my barrier names the wrong before-state; - with #367 `refresh` / `gpu_writes` leave it explicitly in UNORDERED_ACCESS just before the resolve. The fix is to drop the manual barrier and ask the tracker for COPY_DEST before the resolve (`list.buffer_state(&shadow.buffer, COPY_DEST)` with #334, `list.resource_state(..)` with #367). I will do that on top of whichever of the two is merged; a trial merge with #334 is textually clean and passes tests, which is exactly why this needs saying. If someone with the debug layer installed can run `cargo test -p victory-gpu query` with `VICTORY_D3D12_DEBUG=1` on this branch, the output would be useful.
Author
Owner

@⁠465d6a0eac on GitHub · 2026-11-24 16:29 UTC · original · edited 2026-11-24 17:20 UTC

Thank you for this, @⁠r4tedx! Many pull requests here are still waiting to be merged, so I've ported this one to 465d6a0eac/AgentRecompVI, a VIctory fork where AI agents review and merge each other's work: https://github.com/465d6a0eac/AgentRecompVI/pull/28. You're credited as the author there. This pull request stays the original.

Test results

  • Windows 11, NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1088, 32-lane waves): cargo clippy (both variants) and cargo test --workspace pass (346 passed, 0 failed), including the four query::tests on the GPU (occlusion around draws, draw statistics, timestamps on the title clock, queries not run).
  • With it in, the title boots and runs its menus at 30 fps on that machine, through the intro video, first-boot settings and legal screens up to the terms screen. I haven't reached the world yet.
**@⁠465d6a0eac** on GitHub · 2026-11-24 16:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/159#issuecomment-7137735462) · edited 2026-11-24 17:20 UTC Thank you for this, @⁠r4tedx! Many pull requests here are still waiting to be merged, so I've ported this one to [465d6a0eac/AgentRecompVI](https://github.com/465d6a0eac/AgentRecompVI), a VIctory fork where AI agents review and merge each other's work: https://github.com/465d6a0eac/AgentRecompVI/pull/28. You're credited as the author there. This pull request stays the original. **Test results** - Windows 11, NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1088, 32-lane waves): `cargo clippy` (both variants) and `cargo test --workspace` pass (346 passed, 0 failed), including the four `query::tests` on the GPU (occlusion around draws, draw statistics, timestamps on the title clock, queries not run). - With it in, the title boots and runs its menus at 30 fps on that machine, through the intro video, first-boot settings and legal screens up to the terms screen. I haven't reached the world yet.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:18 UTC · original · edited 2026-11-26 03:19 UTC

Automated triage for the maintainers.

Thanks for the merge of main and the test update. Re-reviewed at ba872ae2: occlusion, binary occlusion, pipeline statistics and timestamp queries are recorded into the host list (list.rs begin_query/end_query, HostList::begin_query/end_query), resolved into list-owned read-back chunks (HostList::query_readback, host_resolve), and copied into title memory by the existing ordered deferred writes, with timestamps converted to the 100 MHz title clock via Host::clock. Queries around draws the host dropped keep the "visible" stand-in (missed_draw in draw.rs and the indirect paths). This avoids the earlier dependence on the title buffer's host-copy state, and the README line is updated to match. The cfg(windows) gating looks consistent with mod state/host_list. A third-party run on an RTX 3050 reported matching occlusion, statistics and timestamp results.

Open items, as the description lists them: no debug-layer or DRED run yet, and GPU reads of a resolve buffer later in the same submission still see the old bytes.

Verdict: merge candidate (a recommendation to look, not an approval). CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/159#issuecomment-7148376663) · edited 2026-11-26 03:19 UTC <!-- victory-triage v1 head=ba872ae2306c80b3968198dd673eead322664959 verdict=merge-candidate at=2026-11-26T03:19:55Z --> Automated triage for the maintainers. Thanks for the merge of `main` and the test update. Re-reviewed at `ba872ae2`: occlusion, binary occlusion, pipeline statistics and timestamp queries are recorded into the host list (`list.rs` `begin_query`/`end_query`, `HostList::begin_query`/`end_query`), resolved into list-owned read-back chunks (`HostList::query_readback`, `host_resolve`), and copied into title memory by the existing ordered deferred writes, with timestamps converted to the 100 MHz title clock via `Host::clock`. Queries around draws the host dropped keep the "visible" stand-in (`missed_draw` in `draw.rs` and the indirect paths). This avoids the earlier dependence on the title buffer's host-copy state, and the README line is updated to match. The cfg(windows) gating looks consistent with `mod state`/`host_list`. A third-party run on an RTX 3050 reported matching occlusion, statistics and timestamp results. Open items, as the description lists them: no debug-layer or DRED run yet, and GPU reads of a resolve buffer later in the same submission still see the old bytes. **Verdict: merge candidate** (a recommendation to look, not an approval). CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠r4tedx on GitHub · 2026-11-25 04:30 UTC · original

@⁠JurajSimicevic thank you, both for closing #1740 in this one's favour and for the offer there, which I only saw now. Yes please.

This branch is being brought up to main (940d32f) at the moment. It conflicts in host.rs, list.rs, shadow.rs and the README, and host_resolve has to be checked against how main handles the states of its buffer copies today (my note of 24 Nov above: it relies on the host copy being in COMMON when ResolveQueryData runs). I will post the new head here when it is pushed.

What a run in the game with the debug layer and DRED would settle, and what I cannot check here (this machine has no debug layer, and the title is not launched on it):

  • resource-state messages around ResolveQueryData and the copy that follows it;
  • an occlusion query around a draw the host drops: that the stand-in result is what the title reads, with no message about a query that was begun and never ended or resolved;
  • the three kinds together in one frame: occlusion, pipeline statistics, timestamps.

Nothing was run for this comment.

AI-assisted (Claude Code).

**@⁠r4tedx** on GitHub · 2026-11-25 04:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/159#issuecomment-7152910664) @⁠JurajSimicevic thank you, both for closing #1740 in this one's favour and for the offer there, which I only saw now. Yes please. This branch is being brought up to `main` (`940d32f`) at the moment. It conflicts in `host.rs`, `list.rs`, `shadow.rs` and the README, and `host_resolve` has to be checked against how `main` handles the states of its buffer copies today (my note of 24 Nov above: it relies on the host copy being in COMMON when `ResolveQueryData` runs). I will post the new head here when it is pushed. What a run in the game with the debug layer and DRED would settle, and what I cannot check here (this machine has no debug layer, and the title is not launched on it): - resource-state messages around `ResolveQueryData` and the copy that follows it; - an occlusion query around a draw the host drops: that the stand-in result is what the title reads, with no message about a query that was begun and never ended or resolved; - the three kinds together in one frame: occlusion, pipeline statistics, timestamps. Nothing was run for this comment. AI-assisted (Claude Code).
Author
Owner

@⁠r4tedx on GitHub · 2026-11-25 05:26 UTC · original

@⁠JurajSimicevic the head for your run is b7249e5: rebased onto main 940d32f, two commits.

One thing changed beyond the rebase, and it bears on what your debug-layer run would have shown. The earlier head resolved occlusion and statistics results straight into the title buffer's host copy and assumed that copy was in COMMON. A review of the rebased code found that this does not hold in the world: indirect::done leaves the copy in UNORDERED_ACCESS, and a submission's lists share one ExecuteCommandLists, so a resolve after a shader write or an indirect execution on the same buffer would have been two state errors. Now every query type resolves into read-back memory the list owns, and the results reach title memory by the same ordered CPU writes as the stand-ins once the submission has run. main's copy-back is untouched.

What a run would settle now:

  • no resource-state message around ResolveQueryData (the destination is always the list's own read-back buffer);
  • an occlusion query around a draw the host drops keeps "visible";
  • the three query kinds in one frame, and whether anything in the title reads a resolve buffer on the GPU inside the same submission, which this design does not serve (listed under known limits).

Tested at b7249e5 on WARP only (diagnostics build, one test thread): cargo test -p victory-gpu 153 passed, 0 failed, 2 ignored; both clippy commands clean. Nothing has run on a hardware GPU or under the debug layer since the rebase. The description has the details and the limits.

No game data was used. AI-assisted.

**@⁠r4tedx** on GitHub · 2026-11-25 05:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/159#issuecomment-7153785157) @⁠JurajSimicevic the head for your run is `b7249e5`: rebased onto `main` `940d32f`, two commits. One thing changed beyond the rebase, and it bears on what your debug-layer run would have shown. The earlier head resolved occlusion and statistics results straight into the title buffer's host copy and assumed that copy was in COMMON. A review of the rebased code found that this does not hold in the world: `indirect::done` leaves the copy in UNORDERED_ACCESS, and a submission's lists share one `ExecuteCommandLists`, so a resolve after a shader write or an indirect execution on the same buffer would have been two state errors. Now every query type resolves into read-back memory the list owns, and the results reach title memory by the same ordered CPU writes as the stand-ins once the submission has run. `main`'s copy-back is untouched. What a run would settle now: - no resource-state message around `ResolveQueryData` (the destination is always the list's own read-back buffer); - an occlusion query around a draw the host drops keeps "visible"; - the three query kinds in one frame, and whether anything in the title reads a resolve buffer on the GPU inside the same submission, which this design does not serve (listed under known limits). Tested at `b7249e5` on WARP only (diagnostics build, one test thread): `cargo test -p victory-gpu` 153 passed, 0 failed, 2 ignored; both clippy commands clean. Nothing has run on a hardware GPU or under the debug layer since the rebase. The description has the details and the limits. No game data was used. AI-assisted.
Author
Owner

@⁠Dathinel on GitHub · 2026-11-25 09:51 UTC · original

Hardware result for b7249e5 on an NVIDIA GeForce RTX 3050 Laptop GPU (adapter identified from the D3D12 device LUID). I extended the synthetic triangle test to bracket its draws with two timestamps, resolve all three query types into separate ranges of the same buffer, and submit the list once.

  • Occlusion returned 4,096 samples for the visible triangle and 0 for the clipped one. Pipeline statistics reported 3 input vertices, 1 primitive and 4,096 pixel shader invocations.
  • The second timestamp followed the first on the title clock. In an instrumented repeat the native delta was 31,744 ticks, converted to 3,174 title ticks; the values read after submission matched the conversions. Both fell strictly within the measured submission interval. All 47 words outside the three result ranges retained their original sentinel.
  • The existing skipped-draw, resolve-after-UAV and timestamp-clock tests also passed. In the pristine full GPU crate suite, 148 passed, 2 failed and 2 were ignored. Both failures (dynamic descriptor slots and shared table/views) reproduced at the same assertions on parent main 940d32f.

This exercises CPU readback after completion. D3D12GetDebugInterface(ID3D12Debug) returned 0x887A002D here. Debug-layer/DRED diagnostics and GPU consumption of the result within the same submission remain open. AI-assisted, synthetic inputs only.

**@⁠Dathinel** on GitHub · 2026-11-25 09:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/159#issuecomment-7158886385) Hardware result for b7249e5 on an NVIDIA GeForce RTX 3050 Laptop GPU (adapter identified from the D3D12 device LUID). I extended the synthetic triangle test to bracket its draws with two timestamps, resolve all three query types into separate ranges of the same buffer, and submit the list once. - Occlusion returned 4,096 samples for the visible triangle and 0 for the clipped one. Pipeline statistics reported 3 input vertices, 1 primitive and 4,096 pixel shader invocations. - The second timestamp followed the first on the title clock. In an instrumented repeat the native delta was 31,744 ticks, converted to 3,174 title ticks; the values read after submission matched the conversions. Both fell strictly within the measured submission interval. All 47 words outside the three result ranges retained their original sentinel. - The existing skipped-draw, resolve-after-UAV and timestamp-clock tests also passed. In the pristine full GPU crate suite, 148 passed, 2 failed and 2 were ignored. Both failures (dynamic descriptor slots and shared table/views) reproduced at the same assertions on parent main 940d32f. This exercises CPU readback after completion. D3D12GetDebugInterface(ID3D12Debug) returned 0x887A002D here. Debug-layer/DRED diagnostics and GPU consumption of the result within the same submission remain open. AI-assisted, synthetic inputs only.
Author
Owner

@⁠r4tedx on GitHub · 2026-11-26 02:58 UTC · original

Merged main 842b0cb into the branch (merge 543de3b6, no force-push), head now ba872ae2. The follow-up commit updates the query-resolve test for main's three-argument indirect::bound (#158's clamp) and renames it to say what it checks. Verified on this head: cargo clippy clean; VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib -- --test-threads=1: 253 passed, 0 failed, 1 ignored. Synthetic tests on WARP only, no title data used.

AI-assisted

**@⁠r4tedx** on GitHub · 2026-11-26 02:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/159#issuecomment-7181285244) Merged main `842b0cb` into the branch (merge `543de3b6`, no force-push), head now `ba872ae2`. The follow-up commit updates the query-resolve test for main's three-argument `indirect::bound` (#158's clamp) and renames it to say what it checks. Verified on this head: `cargo clippy` clean; `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib -- --test-threads=1`: 253 passed, 0 failed, 1 ignored. Synthetic tests on WARP only, no title data used. AI-assisted
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/159/head:github-bot/gh-159'
git switch 'github-bot/gh-159'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-159'
git switch 'github-bot/gh-159'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-159'
git switch 'github-bot/gh-159'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-159'
git switch 'main'
git merge --squash 'github-bot/gh-159'
git switch 'main'
git merge --ff-only 'github-bot/gh-159'
git switch 'main'
git merge 'github-bot/gh-159'
git push origin 'main'
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!159
No description provided.