Skip to content

test: trace GPU-written indirect Dispatch to offscreen pixels - #3222

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
xiaoqi72665:native/phase4c-indirect-pixel
Nov 27, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
xiaoqi72665:native/phase4c-indirect-pixel

Conversation

@xiaoqi72665

Copy link
Copy Markdown
Contributor

Closes #3209. Reuses #2492 / #2771 and the existing compute and graphics test helpers; related: #3211, #3213, #1759, #3074.

Scope

Extend the existing synthetic slot-67 indirect fixture rather than adding a new runtime path, executable or dependency. The GPU writer stores a 12-byte Dispatch record at byte interval [4,16) in the actual placed argument resource, with a leading DWORD guard and a three-DWORD neighboring guard at [16,28).

  • Submit the writer, wait for guest fence 1, and read back all seven DWORDs.
  • Record a second GPU copy immediately before guest slot 61 ExecuteIndirect, submit the translated slot-67 compute consumer, wait for guest fence 2, and read back the second argument snapshot. Check native resource identity, GPU address, byte interval, both tuples and all guards.
  • Consume the translated compute output directly as the native graphics root SRV, on the same underlying DIRECT queue, after the compute fence. The desktop HLSL graphics observer draws into an 8x4 RGBA8 target. Separate clear and draw captures are fenced and checked; no CPU-generated pixel data is uploaded.
  • Check all 320 compute input/output words, both seven-DWORD argument snapshots, all 64 captured pixels, and the translated-dispatch census. A stale-SRV negative control must fail the positive pixel oracle.

Actual local evidence

Final commit 3228f8c, rebased onto main 9345c21 (including merged #3217). Debug and Release, RX 7900 XT (32.0.32029.2010) and WARP (1.0.22.0), app-local Agility SDK 1.620.2.

Case Argument tuple (both snapshots) Changed pixels / 32
GPU writer X=2 (2,1,1) 8
GPU writer X=5 (5,1,1) 20
Explicit GPU writer X=0 (0,1,1) 0
Writer omitted (0,0,0) 0
X=5, deliberately stale SRV (5,1,1) 32 (rejected by positive oracle)

All 20 cases across the four adapter/configuration combinations passed. 6,400 output DWORDs, 280 argument/guard DWORDs and 1,280 captured RGBA8 pixels checked.

Example: final Release RX 7900 XT, X=5 (addresses are process-specific):

chain queue=000002505EB1D6B0 output=000002505EAF9BA0 gpu=0x200950000
writer resource=000002505EB548B0 gpu=0x200960000 interval=[4,16) writer=dispatch
guest queue=000002505EB2C090 writer fence=1 completed
GPU argument record: a5a5a5a5 [5,1,1] 5a5a5a5a 12345678 9abcdef0 (after writer)
consumer resource=000002505EB548B0 gpu=0x200960000 interval=[4,16)
guest queue=000002505EB2C090 consumer fence=2 completed
GPU argument record: a5a5a5a5 [5,1,1] 5a5a5a5a 12345678 9abcdef0 (before consumer)
graphics queue=000002505EB1D6B0 output=000002505EAF9BA0 gpu=0x200950000
graphics fence completed: clear and draw captures
pixel first row: ff21e296 ff25fec5 ff298a34 ff2da663 ff31b3d2 ff000000 ff000000 ff000000

The existing indirect controls remain intact. Device-free mutation oracle and documentation link check pass (122 Markdown files, 621 links).

Expanded regression: 23/25 passed in each configuration (Debug 14.05s, Release 12.36s), no skips. Two unrelated native-compute tests fail identically on a clean, unmodified main 2e12dd8 baseline:

  • WARP native compute reports translation but leaves 288 expected words unwritten.
  • RX native compute rejects the intentional revision.txt cache marker. A diagnostic-only copy allowing this filename passes on both configurations, including the shared UAV case.

Separate evidence: #3213 (comment). Neither unrelated failure was hidden or changed in this PR.

Reproduction

cmake --build --preset dev --target startup_stream_consumer startup_indirect_dispatch startup_indirect_draw_indexed compile_dxil startup_per_reason_refusal_census_check
ctest --preset dev --no-tests=error -j 1 -R "^startup_slot67_indirect_dispatch_(warp|hardware)$" -V
python -B tests/startup_slot67_indirect_dispatch_check.py mutation

Repeat with the release preset. Expanded regression filter:

^(startup_per_reason_refusal_census|startup_indirect_(translated|other)_refusal_census_(warp|hardware|control_warp)|startup_slot67_indirect_dispatch_(warp|hardware)|startup_indirect_(dispatch|root_constants|count|count_split|draw|draw_indexed)_(warp|hardware)|startup_compute_dispatch(_native)?_(warp|hardware))$

The compute consumer uses the existing offline translator/DXC path. The graphics observer is desktop HLSL, not a translated title graphics shader. This is an offscreen synthetic end-to-end proof, not retail scene rendering or a performance claim. The D3D12 debug layer was unavailable locally. No production change was needed for this fixture.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independently reviewed 3228f8c9 over main fad97f47 (clean trial tree 106b6cf6). The test records the actual placed resource and byte range before and after the GPU writer and before ExecuteIndirect, checks both fenced snapshots and guard words, and reads the GPU-written compute output directly in the offscreen observer. The stale-SRV draw is a discriminating pixel control. The patch is confined to the source fixture and its reproduction note.

I built startup_stream_consumer d3d12_xs_shim compile_dxil startup_indirect_dispatch and ran ctest --test-dir <build> --no-tests=error -j1 -V -R '^(startup_slot67_indirect_dispatch_(warp|hardware)|startup_indirect_(dispatch|root_constants|count|count_split)_(warp|hardware))$'. Debug and Release /O2 each passed 10/10, no skips. Both WARP 10.0.26100.9818 and RTX 4060 Laptop driver 32.0.16.1656 exercised the writer, zero, omitted-writer and stale-SRV cases. Windows 11 26200.9974; the slot-67 fixture reported debug layer enabled. python -B tests/startup_slot67_indirect_dispatch_check.py mutation, docs links and required hosted Windows all passed. This is source-built evidence for #3209.

@R0Y00
R0Y00 merged commit 05d1873 into R0Y00:main Nov 27, 2026
5 checks passed

@pigalot pigalot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed 3228f8c9 merged over main fad97f47. The merge is clean (tree 106b6cf6) and git diff --cached --check is clean.

What I traced.

  • Writer stage: it is submitted on its own and fenced at value 1. The seven-DWORD record is read back there.
  • Second snapshot: capture_before_consumer copies the same placed resource on the guest list just before slot 61. It checks the native resource pointer and GPU VA against the writer's.
  • Observer:
    • it runs on the same native DIRECT queue after fence 2;
    • it binds the translated output itself as a root SRV;
    • it discards the 0xc5c5c5c5 sentinel and writes the low three bytes as UNORM8, which is exact for 0..255;
    • its clear and draw captures are separate copies, so an undrawn target can't pass as all-sentinel.
  • Stale-SRV control: it binds placed[0] (the input). It must fail the positive oracle and match its own predicted colours, so the observer really reads the buffer it names.
  • Python check: it asserts the stage order on stdout, both identity pairs and both argument snapshots. Debug-layer messages of severity error or above fail the run.
  • Scope: only tests and docs change, and the docs extend the existing slot-67 section.

What I ran. I built d3d12_xs_shim startup_stream_consumer startup_indirect_dispatch in dev and release, then ran:

ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R '^(startup_slot67_indirect_dispatch_warp|startup_compute_dispatch[a-z0-9_]*_warp|startup_compute_root_srv_dispatch_warp|startup_indirect_dispatch_warp|stream_root_srv_warp)$'
python .agentic\scripts\with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(startup_slot67_indirect_dispatch_hardware|startup_compute_dispatch_hardware|startup_indirect_dispatch_hardware)$'
  • Results: in both Debug and Release /O2, 13 of 14 WARP tests pass and 3 of 3 hardware tests pass, with no skips.
  • The one failure is not from this PR. startup_compute_dispatch_native_warp fails with "the native route left ['revision.txt'] in the cache", and it fails the same way on main fad97f47.
  • Hardware coverage: startup_slot67_indirect_dispatch_hardware matched all five pixel cases on the RTX 5090:
    • 8/32 and 20/32 pixels changed for X=2 and X=5;
    • 0/32 for the zero record and for the omitted writer;
    • the stale-SRV case was rejected by the positive oracle;
    • the debug-layer queue reported no errors.
  • Negative control: on main fad97f47, the PR's startup_slot67_indirect_dispatch_check.py against main's startup_stream_consumer fails at the first pixel case (('2', 'compute output mismatch')). The dispatch-indirect-pixel-* modes don't exist there.

Mutants in src/startup_stubs/d3d12_compute_dispatch.inl. For each, I rebuilt in dev and ran startup_slot67_indirect_dispatch_warp:

Mutant Result
ExecuteIndirect argument offset one DWORD late killed
CPU Dispatch(x, y, z) instead of the GPU-read arguments killed

Restored and rebuilt afterwards; git diff --quiet is clean.

Non-blocking.

  • The new stage on its own: both runtime mutants would also be caught by the existing 320-word output check. What the new stage adds on its own is the fence split, the two argument snapshots and the pixel observer, whose distinguishing control is the stale SRV.
  • Pixel coverage: the observer reads only the first 8 output words (position.x, repeated over 4 rows). A word whose low 24 bits are zero would look like the clear colour. No word in the fixture has that pattern, and the 320-word compare covers the rest.

Verdict: approve on 3228f8c9.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088 and WARP, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10; the observer's info queue was available on hardware.
CI: Build and test on Windows passes on 3228f8c9.

This reply was AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runtime: prove the GPU writer for indirect compute launch records

3 participants