Skip to content

D3D12.X: XCL_MESH_RECORDS reads back a mesh draw's records - #3641

Open
vasanex wants to merge 4 commits into
xcl-dev:mainfrom
vasanex:mesh-records
Open

vasanex wants to merge 4 commits into
xcl-dev:mainfrom
vasanex:mesh-records

Conversation

@vasanex

@vasanex vasanex commented Dec 2, 2026 •

Copy link
Copy Markdown

Stacked on #3640 (itself on #3509); only the top commit belongs here.

The pass-through mesh shader turns a triangle with the null bit, or with an index past the vertices, into a point without any message. With XCL_PIXEL_HISTORY and XCL_MESH_RECORDS=<hash>,<hash>, the first records of the direct two-pass draws with these console pixel shaders are copied after their mesh pass in the followed frames and logged: counts, triangle entries, positions, the triangles that draw nothing, the quads that are no parallelogram, and the triangles over the followed points with their winding and outputs. Off unless it is set.

What is in it

Tested

Regression run
main:

xcl-smoke v1
commit: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f
gpu: NVIDIA GeForce RTX 3080
title: aaa95fa3
seconds: 60
exit: 0x0
frames shown: 1608 (PresentX 1608)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 19911 MB

this PR's head:

xcl-smoke v1
commit: 5b78630f9f7d3036c3b9392571c9d4eb81fb3410
gpu: NVIDIA GeForce RTX 3080
title: aaa95fa3
seconds: 60
exit: 0x0
frames shown: 1697 (PresentX 1697)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18490 MB

Not tested

  • The GPU copy has no test of its own: the unit tests cover the decoding.
  • "Over the points" takes the draw's viewport to be the whole presented picture (said in the README): a draw into a part of its target, or into a target of another size, gets the wrong triangles named.
  • Draws in several slices or with their records in halves are left out.
  • The switch on a title on this head; the smoke runs with it unset.
  • AMD, Intel.

AI use

  • Claude Code with Claude Fable 5.2 (parts written earlier with Claude Opus 5.5): wrote the code, the tests and this description, and ran the tests.

🤖 Generated with Claude Code

https://claude.ai/code/session_014BCUJTMayV5qkgLPcQyNfr

…S (draws of named console pixel shaders left out)

PIX and Nsight captures do not replay a title under XCL. XCL_PIXEL_HISTORY=<x>,<y>[,<s>[,<frames>]]
(+ _ALSO, _SPACE, _CROP, _SLOTS): in the frames chosen, each draw on a direct list copies the texel at
the point of each bound render target before and after itself (1x1 CopyTextureRegion between
RENDER_TARGET <-> COPY_SOURCE transitions) into a readback buffer; a few presents later the changes are
logged with the draw's console VS / PS, the target, the values decoded and the slot's blend state, and
changes between two draws of a list with the dispatches in between. With _CROP a second round writes
crops of the draws that changed the point.

XCL_SKIP_PS=<hash>,...: draws (direct and indirect) whose translated pipeline's console PS is listed
are skipped as XCL_SKIP_CS skips dispatches, counted in the log.

Unset, each costs a draw one cached check. Documented in the README's diagnostics.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Dec 2, 2026
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Review (head c505f08, diff read, not a merge-check; draft, checks red):

  • "Over the points" ignores the draw's viewport and target. read_out (pixel_history.rs ~892) turns the followed points into NDC from the present size (c.space) alone, so for a draw whose viewport covers part of its target (dynamic resolution, atlases, shadow maps) or whose target does not line up with the present, the wrong triangles are listed under mesh checks … over the points, and quad_outputs, which uses the same test, prints the wrong quads' outputs with nothing in the log to say so.
  • Read-out cost grows with triangles × quads, on the present thread. For every triangle, quad_outputs (~663) copies the whole record and runs record_checks on it, which loops over all v / 4 quads and formats every quad that is not a parallelogram (~629), not only the 6 it prints. A 256-vertex, 256-triangle group whose vertices are not quads comes to 256 record copies and about 16k formatted strings, per group, up to 8 groups per draw, all in read_out from frame_end (present.rs), so the title can stall when the history is read. Testing each triangle against the points directly avoids it.
  • Checks and GPU path. The xcl-smoke blocks and suite counts are owed (the reason PR description is red), and the GPU copy in copy_records (~522), with its UAV → COPY_SOURCE → UAV transitions, has no test; only the CPU decoding is tested.

Fine: the record decoding matches the pass-through mesh shader (9-bit indices at 0/10/20, null bit 31, counts clamped as the shader does); the copy happens only on direct lists, for a single Records::Whole slice, after the plan's last UAV barrier; reads stay inside the record and RECORDS_BYTES; unset, it costs one Option check.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@vasanex
vasanex marked this pull request as ready for review December 2, 2026 03:19
@github-actions github-actions Bot added needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Dec 2, 2026
vasanex and others added 3 commits December 2, 2026 05:15
The history had no hooks at the two-pass DispatchMesh and the two-pass
ExecuteIndirect, so a texel they change showed up as "a clear, a copy or
a resolve" or not at all. Their console shaders' hashes are now kept for
it as well. Not covered: draws deferred with XCL_TWO_PASS_BATCH=2, rect
draws, and indirect and mesh draws passed on untranslated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014BCUJTMayV5qkgLPcQyNfr
A frame capture has no shader names for mesh pipelines, so a draw found
by the history could not be found again in a capture. Its lines now name
the group counts and the graphics root arguments (tables, root views and
constants), which the capture has too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014BCUJTMayV5qkgLPcQyNfr
The pass-through mesh shader turns a triangle with the null bit or with
an index past the vertices into a point, without any message. With
XCL_PIXEL_HISTORY and XCL_MESH_RECORDS, the first records of the direct
two-pass draws with the named pixel shaders are copied after their mesh
pass and logged: counts, triangle entries and positions. A second line
per group counts the triangles that draw nothing, names the quads that
are no parallelogram (one wrong corner shows) and names the triangles
over the followed points with their winding. For each quad with a
triangle over a followed point, a line shows its outputs after the
position, by vertex where they differ (a flat input of the pixel shader
comes from a triangle's first vertex).

Off unless it is set; draws in several slices or with their records in
halves are left out. Unit tests cover the decoding, not the GPU copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014BCUJTMayV5qkgLPcQyNfr
@github-actions github-actions Bot added needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Dec 2, 2026
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Follow-up review (head 5b78630, since c505f08, diff read, not a merge-check):

  • Read-out cost grows with triangles × quads: fixed. The geometry test is split out into triangles_over, quad_outputs calls it once per record instead of copying the record and running record_checks per triangle, and record_checks formats only the first 6 bad quads while counting the rest.
  • "Over the points" ignores the draw's viewport and target: partly fixed. The behaviour is unchanged, but the README now says it takes the viewport to be the whole presented picture and that for a draw into part of its target, or a target of another size, the triangles named are not the ones there; nothing in the log line says it.
  • Checks and GPU path: unchanged; the GPU copy in copy_records still has no test.

New: none.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@bmjask

bmjask commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

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

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants