gpu: add a range provenance fixture for bound-range writers #1984

Merged
thepatrickworld merged 1 commit from upstream-pr/1991 into main 2026-11-24 22:50:38 +00:00
thepatrickworld commented 2026-11-24 22:40:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-24T22:40:04Z.


Adds the source-only example #870 asks for: which producer last wrote the range a draw binds, and whether that write was visible once its submission fence had completed.

Shape. One committed buffer of four 64-element RGBA32F ranges and one bound window. Range A [0, 64) is red, written by CopyBufferRegion; range B [64, 128) is green, written by a draw whose pixel shader stores it through a structured UAV; range C [128, 192) is never written; [192, 256) lies outside every window. The bound range is a StructuredBuffer SRV whose FirstElement and NumElements select one range — a buffer SRV is the desktop view that carries an explicit offset and scope, where a 2D SRV has no texel offset at all — and a neighbouring window is the next range along the same buffer.

Each producer is submitted and waited on its own fence before the consumer list is recorded, and the completed value is checked at that point. The consumer draws 64×1 pixels, one element of its window each, and copies its target to a readback on the same list; the whole buffer goes to a second readback after the last submission, so the log reports what the producers wrote as well as what the draw sampled. Each case prints one line with the write class, the relation of the bound window to that write, the submission order with its fence values, and the sampled colour.

case writer bound sampled measured
exact copy [0, 64) red matches model
neighbouring draw [64, 128) green matches model
stale copy [0, 64) red, though a blue rewrite is submitted after the consumer's fence buffer reads blue, sample stays red
empty none [128, 192) zero, never written matches model
cleared clear [128, 192) zero, written by a whole-store clear matches model

Result. On an AMD Radeon RX 9070 XT (1002:7550, driver 32.0.32029.2010) and on in-box WARP (10.0.26100.9818) both tests pass: 0 sampled mismatches of 64 and 0 store mismatches of 256 in every case. The stale case is the one that separates the readings — after the blue rewrite is submitted and its fence completes, the whole-buffer readback holds blue in range A while the consumer's readback still holds the red it sampled. Both mutants mismatch 64 of 64: the exact case bound to the neighbouring range samples green instead of red, and the stale case with the rewrite moved before the consumer samples blue.

What it says about the reported zero. The cleared and empty cases sample the same colour. A readback alone therefore cannot separate a zero fill from a range no producer wrote, which is exactly the ambiguity the issue raises; the writer class and the submission order are what classify it. This fixture supplies both, per case, so the same two lines can be read off a title run.

What it does not do. No title data, no addresses, no dump: every resource is created by the code. It does not reproduce the RX 590 result and does not, by itself, classify that zero — it makes the classification available from the run that observes it.

Notes. ps_write is the first pixel shader in this tree that stores through a UAV (the existing UAV writers are compute and raytracing), so it is the one D3D12 shape here without precedent; it compiles and runs on both backends. The stale case assumes only that the fences are waited on the CPU between submissions, which the fixture does explicitly. Two ranges and one extra window would extend it to a producer that writes the neighbouring range after the consumer, if that case is wanted.

cmake --build --preset dev --target offscreen_check
ctest --preset dev --no-tests=error -R '^startup_range_provenance' -V

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6592844217 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1991). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-24T22:40:04Z. --- Adds the source-only example #870 asks for: which producer last wrote the range a draw binds, and whether that write was visible once its submission fence had completed. **Shape.** One committed buffer of four 64-element `RGBA32F` ranges and one bound window. Range A `[0, 64)` is red, written by `CopyBufferRegion`; range B `[64, 128)` is green, written by a draw whose pixel shader stores it through a structured UAV; range C `[128, 192)` is never written; `[192, 256)` lies outside every window. The bound range is a `StructuredBuffer` SRV whose `FirstElement` and `NumElements` select one range — a buffer SRV is the desktop view that carries an explicit offset and scope, where a 2D SRV has no texel offset at all — and a neighbouring window is the next range along the same buffer. Each producer is submitted and waited on its own fence before the consumer list is recorded, and the completed value is checked at that point. The consumer draws 64×1 pixels, one element of its window each, and copies its target to a readback on the same list; the whole buffer goes to a second readback after the last submission, so the log reports what the producers wrote as well as what the draw sampled. Each case prints one line with the write class, the relation of the bound window to that write, the submission order with its fence values, and the sampled colour. | case | writer | bound | sampled | measured | |---|---|---|---|---| | exact | copy | `[0, 64)` | red | matches model | | neighbouring | draw | `[64, 128)` | green | matches model | | stale | copy | `[0, 64)` | red, though a blue rewrite is submitted after the consumer's fence | buffer reads blue, sample stays red | | empty | none | `[128, 192)` | zero, never written | matches model | | cleared | clear | `[128, 192)` | zero, written by a whole-store clear | matches model | **Result.** On an AMD Radeon RX 9070 XT (`1002:7550`, driver `32.0.32029.2010`) and on in-box WARP (`10.0.26100.9818`) both tests pass: 0 sampled mismatches of 64 and 0 store mismatches of 256 in every case. The stale case is the one that separates the readings — after the blue rewrite is submitted and its fence completes, the whole-buffer readback holds blue in range A while the consumer's readback still holds the red it sampled. Both mutants mismatch 64 of 64: the exact case bound to the neighbouring range samples green instead of red, and the stale case with the rewrite moved before the consumer samples blue. **What it says about the reported zero.** The cleared and empty cases sample the same colour. A readback alone therefore cannot separate a zero fill from a range no producer wrote, which is exactly the ambiguity the issue raises; the writer class and the submission order are what classify it. This fixture supplies both, per case, so the same two lines can be read off a title run. **What it does not do.** No title data, no addresses, no dump: every resource is created by the code. It does not reproduce the RX 590 result and does not, by itself, classify that zero — it makes the classification available from the run that observes it. **Notes.** `ps_write` is the first pixel shader in this tree that stores through a UAV (the existing UAV writers are compute and raytracing), so it is the one D3D12 shape here without precedent; it compiles and runs on both backends. The stale case assumes only that the fences are waited on the CPU between submissions, which the fixture does explicitly. Two ranges and one extra window would extend it to a producer that writes the neighbouring range after the consumer, if that case is wanted. ```powershell cmake --build --preset dev --target offscreen_check ctest --preset dev --no-tests=error -R '^startup_range_provenance' -V ``` _AI-assisted._
upstream-sync closed this pull request 2026-11-24 23:03:28 +00:00
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
R0Y00/Xbox2Windows!1984
No description provided.