Skip to content

startup: translated compute Dispatch with 2D texture views, static samplers and a per-key census - #2490

Open
NiiRoZz wants to merge 47 commits into
R0Y00:mainfrom
NiiRoZz:startup/compute-dispatch-textures
Open

NiiRoZz wants to merge 47 commits into
R0Y00:mainfrom
NiiRoZz:startup/compute-dispatch-textures

Conversation

@NiiRoZz

@NiiRoZz NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Depends on #2470 (stacked on its branch, which itself carries #1803, #1974 and #1975); the new code is the last seven commits.

Why

A run of a console package with the first slice recorded no translated Dispatch. Its log and shader cache, counted
offline (counts only):

  • the cache holds 61 compute translations for 2,689 current compute requests;
  • none of the 61 manifests was loadable by the first slice: 53 name a 2D texture output, 44 a 2D texture input,
    40 a raw buffer input, 9 a static sampler, 6 the stride and descword3 entry values, 48 declare no entry
    value, 8 have no view at all, and none has a raw buffer output;
  • the run dispatched at least 7 of those 61 programs (their refusal is logged at the first Dispatch); all 7 store to 2D textures (up to four), 4 read a 2D texture, 4 read a
    raw buffer, 6 declare no entry value, none uses a sampler;
  • the per-call refusal lines share one small budget, so the log names a single dispatching key and cannot rank
    keys by Dispatch count.

What changes

  1. Census (8e14a74b). Each key keeps its Dispatch count, the calls recorded, and the reason and table
    descriptor of its first refusal. The periodic totals line gains not modelled <n> (a manifest exists but holds
    a line the runtime does not bind, counted apart from an absent manifest) and is followed by the refused calls
    per reason and every dispatched key by call count.
  2. 2D texture outputs (f2f7bfcc). uav <i> tex2d float table <param> <byte> channels 4 is bound from the
    token of the unordered access view the caller created (device slot 19). Refused, each with its own reason: an
    entry that is no such token, a view the desktop did not create, a view that is not 2D, a packed view format, a format a float4
    store cannot target (integer, typeless), a texture that is also an input of the same call. Programs
    without entry values, inputs or outputs now load: the translated root no longer emits an empty range, and keeps
    its table when only outputs exist.
  3. 2D texture inputs and static samplers (15e8b7ab). srv <i> tex2d table <param> <byte> is bound from the
    token of a shader resource view (device slot 18) through the texture the draw path samples for that resource,
    uploaded first when the caller filled it in memory. smp lines become static samplers. Refused: no such token,
    no desktop texture, a view that is not 2D, a packed view format, a failed upload.

No view is bound null. A refused call records no Dispatch and binds nothing; the upload of an input texture the
caller filled in memory may already be recorded, which only syncs content.

With these line forms, 55 of the 61 manifests load, including all 7 the run dispatched (offline count against the
manifest text; the 6 others need stride and descword3).

Not in this change

  • stride and descword3 entry values (6 manifests, none among the 7 dispatched).
  • Buffer inputs in plain memory that no GPU-backed range covers (the copy the draw path makes). Nothing measured
    says a dispatched program needs it; the census of the next run will.
  • Sampler heaps, comparison samplers, texture kinds other than 2D, integer-typed outputs, one texture as input and
    output of the same call (a mip chain pass), packed view formats.

Evidence

Commit under test: d0b9e774 for the four tests below; d3c396cc for the neighbouring run (the commits between them throttle a device check, drop a liveness test, narrow the same-texture refusal to input against output, refuse packed output formats by name and print every census key). Windows 11 build 26300.

cmake --build --preset dev
ctest --preset dev --no-tests=error -R "^startup_compute_dispatch_" -V
Test Adapter, driver Debug layer Result
startup_compute_dispatch_warp Microsoft Basic Render Driver, 10.0.26100.10068 enabled, no error message passed
startup_compute_dispatch_texture_warp Microsoft Basic Render Driver, 10.0.26100.10068 enabled, no error message passed
startup_compute_dispatch_hardware NVIDIA GeForce RTX 5090, 32.0.16.2135 enabled, no error message passed
startup_compute_dispatch_texture_hardware NVIDIA GeForce RTX 5090, 32.0.16.2135 enabled, no error message passed
  • Texture output: a source-built gfx1013 program stores to a 32x8 RGBA16_FLOAT texture; the 1024 halves are read
    back through CopyTextureRegion on the stand-in's list. Expected: mip 0 of the fixture's CPU reference (64 halves
    changed). Negative controls, same run: before the offline translation, without a Dispatch, and with a texture
    that has no unordered access, every half keeps its sentinel and the refusal is logged once.
  • Texture input: the raw buffer program with a level-zero sample of a 1x1 RGBA8 texture XORed into each stored
    word. Expected: the case's 288 written words XOR the bits of 1.0f, the 32 others untouched. Negative control: no
    view at the table entry, the dispatch is refused and every word keeps its sentinel.
  • No entry values: the texture output program bound under a manifest edited to ud 0.
  • Census: the raw buffer check asserts the census lines of each run.

Neighbouring tests, ctest --preset dev --no-tests=error -R '^startup_|sampler|list_copy|compute' -j 6: 864 selected, 860 passed, 0 failed. Capability skips, reported apart (4): startup_view_heap_warp, startup_small_texture_4k_addrlib, startup_logical_view_warp, startup_run_sh.

Limits and open points

  • The sampling fixture uses a 1x1 texture: it proves the view and a sampler are bound, not which filter or address
    mode the static sampler has.
  • The instruction that XORs the sampled value is derived by hand from an assembled instruction of the same form
    (one register field changed); the check asserts that the translation reads it as written, llvm-mc did not
    assemble it here.
  • The ud 0 case uses an edited manifest on a program compiled with three unused entry values.
  • That a console package's compute table holds view tokens for its textures is the model of the draw path, not
    something measured for compute; the census prints the first refused descriptor per key to settle it.
  • The 8 manifests without any view store nothing the runtime can observe; they are dispatched, and no read-back
    can show that this is right.
  • Two outputs on one texture (two mips) are allowed and not covered by a fixture.
  • Each dispatch takes its views from the descriptor ring of the draw path (262,144 entries). At the measured rate
    of about 1,500 Dispatch calls per frame and a few views each, the ring wraps after tens of frames; that a
    recorded list never outlives a wrap is the draw path's assumption, not re-measured for compute.
  • The census is printed with the periodic totals (every 300 frames); calls after the last print are not in it.
  • Which share of all Dispatch calls waits for a translation rather than for the runtime is not known from the
    measured run: its log names 8 dispatching keys (7 that waited for the runtime, 1 whose translation failed) and
    no per-key count. The census answers it on the next run.

🤖 Generated with Claude Code

tedin7 and others added 28 commits November 24, 2026 19:53
…33 and 35)

Header-only state in list_compute_root.h with a Linux-testable check. Dispatch (slot 14) is not handled here; the state is exposed through ready() and table() for it. Refs R0Y00#870.
Compute root constants are kept per list next to the graphics ones, in a shared 16 x 8 word store that refuses parameter >= 16 and offset >= 8. A new compute root signature clears them.
Part of R0Y00#870. Forward Dispatch only with a desktop compute pipeline and root
bound and group counts within 65535 per axis; refuse otherwise.
…t against the bound root

Slot 43 clears a parameter's binding when a replacement is rejected, slot 33 clears all bindings, and the compute pipeline records its root so a mismatched pair is refused.
Compute root constants are kept per list next to the graphics ones, in a shared 16 x 8 word store that refuses parameter >= 16 and offset >= 8. A new compute root signature clears them.
Part of R0Y00#870. Forward Dispatch only with a desktop compute pipeline and root
bound and group counts within 65535 per axis; refuse otherwise.
…t against the bound root

Slot 43 clears a parameter's binding when a replacement is rejected, slot 33 clears all bindings, and the compute pipeline records its root so a mismatched pair is refused.
Conflicts in d3d12_xs_device.cpp and docs/experiments.md resolved by keeping both sides: the pipeline root
out-parameter of the stream builder next to the cached-mesh root, the bound root SRV mask next to the recorded
upload SRV addresses, and both table entries and document sections.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Conflicts in d3d12_draw.inl and d3d12_xs_device.cpp resolved by keeping both sides: graphics root constants
go through the shared store and still mark the words a slot 40 call set.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A device slot 67 placeholder keeps the key of its published request. At
list slot 14 the stand-in loads the stage cs manifest and compiled
program for that key and records the dispatch: raw buffer inputs and
outputs from hardware descriptors in the recorded compute tables, entry
values from the recorded compute root constants. Other manifest lines
leave the pipeline untranslated; a dispatch that cannot be bound
completely is refused with one logged reason and records nothing.

startup_compute_dispatch_{warp,hardware} drives a source-built program
through the stand-in list and reads the output back, with controls
before translation, without a Dispatch and for a refused output.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Dispatches that arrive before the offline translation no longer use up
the lines kept for refusals at bind time.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The per-call refusal lines share one small budget, so a run cannot rank
keys by dispatch count. Each key now keeps its Dispatch count, the calls
recorded and the reason and table descriptor of its first refusal; the
periodic totals are followed by the refused dispatches per reason and the
40 keys with the most dispatches. A manifest that exists but cannot be
bound is counted apart from an absent one ("not modelled").

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A `uav <i> tex2d float table <param> <byte> channels 4` manifest line is
bound from the token of the unordered access view the title created in
its descriptor memory. Everything else is refused with its own reason: an
entry that is no such token, a view the desktop did not create, a view
that is not 2D, a format a float4 store cannot target, and a texture
bound to two slots of one dispatch. Programs without entry values, inputs
or outputs load too: the translated root no longer emits an empty range
or drops the table when only outputs exist.

The fixture stores through the stand-in's own list into a 32x8
RGBA16_FLOAT texture and reads it back with CopyTextureRegion.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A `srv <i> tex2d table <param> <byte>` manifest line is bound from the
token of the shader resource view the title created, through the texture
the draw path samples for that resource, uploaded first when the title
filled it in memory. `smp` lines become static samplers of the translated
root. A dispatch is refused, never bound to a null view, when the entry
is no such token, the resource has no desktop texture, the view is not 2D
or names a packed format, or the upload fails. Sampler heaps, comparison
samplers and other texture kinds keep the translation unavailable.

The fixture samples a 1x1 texture into the stored words of the raw buffer
case; without a view the dispatch is refused and the output is untouched.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s test

The device check drains the debug layer; a draw runs it on every 64th call
and the queue's execute drains the rest. A view token whose resource the
caller released is the caller's misuse, as on the draw path.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…puts, print every census key

A texture is refused only when the same call reads and writes it; two
outputs of one texture share the unordered access state. A packed output
view format gets its own refusal reason. The census prints every
dispatched key instead of the first 40, and the wording on refused calls
says what may already be recorded (an input texture upload).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
RavenCurseBurg and others added 5 commits November 25, 2026 21:47
…egins

The slot 67 cache owns desktop COM objects until module teardown. During process termination, the driver can already be shut down when static destructors run. Keep normal reference release on explicit unload and skip driver calls only during process termination.

AI-assisted with Codex (GPT-6.2 Astra, xhigh).
…led texture to NON_PIXEL_SHADER_RESOURCE only

sampled_state gives pixel-shader (and depth-read) states, which a compute list rejects at Close.
dispatch-sampled-compute records the sampling fixture on a compute list and queue. The smp manifest
line no longer scans two fields into one variable.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ifest version, stage, output also an input

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@NiiRoZz

NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Head 76ce41bc, with the reworked #2470 (1f5fb5e4) merged in.

P1, compute list barrier. Fixed at the call site by list type: on a COMPUTE list a sampled texture input is transitioned to NON_PIXEL_SHADER_RESOURCE only; a direct list keeps sampled_state(...) | NON_PIXEL_SHADER_RESOURCE. sampled_state has one other caller, the draw path, which only runs on direct lists. New mode dispatch-sampled-compute records the sampling fixture on a compute list and a compute queue and must give the same 320 words with no debug-layer error.

Refusals that were not pinned. Four fixtures in startup_compute_dispatch_texture_check.py, each requiring the one logged reason and an untouched texture: an RGBA16_UINT view (texture-store-uint), manifest version, stage, and the output texture also named as an input (texture-store-self, with a shader resource view of the same texture and a manifest line added by the check).

Minor. The smp manifest line no longer scans two fields into one variable.

Mutants (each applied alone, stand-in rebuilt, startup_compute_dispatch_texture_warp rerun; not committed)

Mutant Result
compute list uses the pixel-shader state again red: dispatch-sampled-compute: consumer exit 75 (the list's Close fails)
integer-format refusal off red at texture-store-uint (no refusal logged)
same-texture refusal off red at texture-store-self
manifest version check off red at manifest version
stage check off red at not a compute manifest

Measured

ctest --preset dev --no-tests=error -R '^startup_compute_dispatch_'

4/4 passed, no skip: startup_compute_dispatch_{warp,hardware} and startup_compute_dispatch_texture_{warp,hardware}. WARP: Microsoft Basic Render Driver 10.0.26100.10068. Hardware: NVIDIA GeForce RTX 5090, driver 32.0.16.2135. Windows build 26300.10075, debug layer enabled, no error or corruption message. Before the pins were added, the wider filter (...|startup_root_constant_store|startup_list_dispatch|startup_compute_root|startup_stream) passed 30/30 on this branch except the then-new texture-store-self fixture on WARP, which used a table offset that is not a descriptor boundary there; it now uses byte 0. That wider filter was not rerun after this last fixture change.

Not done

  • The bound render target is not restored after a translated dispatch.
  • A typeless texture still gets a null view description.
  • The two-mip follow-up stays with @RonLogic.

🤖 Generated with Claude Code

R0Y00 commented Nov 25, 2026

Copy link
Copy Markdown
Owner

@MasterDomino I independently ran 76ce41bc in Windows Release. Both the direct raw-buffer CTests and the texture Dispatch CTests passed on WARP and RTX 4060 Laptop (4/4). The latter exercise the updated COMPUTE-list shader-resource transition. Please recheck your previous request at this head when you can. This remains stacked on #2470, whose earlier recorded-state slice must land first.

@MasterDomino MasterDomino 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.

Re-review of 76ce41bc (stacked on #2470 1f5fb5e4). The P1 is fixed and the guards I listed are pinned.

P1: texture input on a COMPUTE list (resolved)

  • On a COMPUTE list a sampled texture is now transitioned to NON_PIXEL_SHADER_RESOURCE only (d3d12_compute_dispatch.inl:292). dispatch-sampled-compute records the sampling fixture on a compute list and queue, and gives all 320 words with no debug-layer error on WARP and the RX 9070 XT.
  • With the fix reverted, that mode fails on both adapters: ResourceBarrier: D3D12_RESOURCE_STATES has invalid flags (0x80) for compute command list (id 537), then list Close failed 0x80070057, consumer exit 75. So the fixture guards the fix.
  • DEPTH_READ can't arise on that path: a compute list never tracks it, and sampled_state is no longer called there.

Runs (Windows 11 build 26300; RX 9070 XT, driver 32.0.32029.2010; WARP 10.0.26100.9818; debug layer enabled)

ctest --preset dev --no-tests=error -j1 -R '^startup_compute_dispatch_(texture_)?(warp|hardware)$' -V
ctest --preset dev --no-tests=error -j1 -R 'startup_list_dispatch|startup_compute|startup_root_constant|startup_gfx2hlsl_compute|startup_indirect|era_heap|desktop_root_signature|startup_stream|docs_links|startup_draw|startup_logical'
  • New tests: 4/4 pass, with no debug messages.
  • Neighbour filter: 184 selected, 182 passed, 0 failed, 2 capability skips (startup_logical_view_*).

Mutants (one line each, rebuilt, restored; startup_compute_dispatch_texture_warp)

mutant result
compute list uses the pixel-shader state again caught on WARP and hardware (Close fails)
return "manifest version"; → return nullptr; caught
any manifest version accepted caught
return "not a compute manifest"; → return nullptr; caught
any stage accepted caught
same-texture input/output refusal off caught (texture-store-self)
float/normalized output-format refusal off caught (texture-store-uint)

Thanks for pinning @ChazY11's two guards as well.

Still open (acknowledged in your note; not blocking for this slice)

  • A texture that is a bound render target isn't moved back to RENDER_TARGET after a translated Dispatch.
  • An undescribed SRV on a typeless resource still gets a null description.
  • The description still names d0b9e774 and doesn't mention the compute-list transition; worth refreshing.

Merge readiness

  • This merges cleanly against main and lands after #2470, in the order @R0Y00 set there.
  • No title start-up progress is claimed: the 55 of 61 figure is an offline count over manifest text.
  • Translated Dispatch isn't opt-in in render mode, so the final candidate needs an executable run before merge.
  • The x2w_d3d12_compute_census export is an interface addition for the maintainer to accept.

AI-assisted; commands listed were executed locally.

@MasterDomino
MasterDomino dismissed their stale review November 25, 2026 21:33

Resolved at 76ce41b: the COMPUTE-list transition is fixed and guarded, and the unpinned refusals are pinned. See my re-review on this head.

NiiRoZz and others added 2 commits November 25, 2026 22:38
…shots

list_compute_root cleared compute_srv_bound and recomputed
compute_root_has_arguments twice; the second copy came from the second
R0Y00#1974 snapshot merge and changed nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ute-dispatch-textures

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NiiRoZz

NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Merged the current #2470 head (f5b03039) into this branch. Head 190e00a1.

Changed

Measured (Windows 11 build 26300.10075, debug layer on, no error or corruption message)

cmake --build --preset dev --target startup_stream_consumer
ctest --preset dev --no-tests=error -j1 -R "^startup_compute_dispatch_" -V
  • 4/4 passed, no skips: startup_compute_dispatch_{warp,hardware} and startup_compute_dispatch_texture_{warp,hardware}.
  • WARP: Microsoft Basic Render Driver 10.0.26100.10068.
  • Hardware: NVIDIA GeForce RTX 5090, driver 32.0.16.2135.
  • startup_compute_dispatch_hardware was run 10 times in a row: 10/10 passed, so all 100 consumer processes exited 0.

Not rerun

  • The wider neighbour filter.
  • No executable run.

Still open (not in this slice)

  • A texture that is a bound render target is not moved back to RENDER_TARGET after a translated Dispatch.
  • An SRV on a typeless resource that has no view description still gets a null description.
  • The description still names d0b9e774 and does not mention the COMPUTE-list transition. It will be refreshed with the startup: dispatch translated compute programs with raw table buffers #2470 trim.
  • The x2w_d3d12_compute_census export is a new interface; accepting it is up to the maintainer.

@NiiRoZz

NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

On the two remaining notes:

  • SRV on a typeless resource without a view description. I tried a fix and a fixture for it, then dropped both. With a null description on a typeless resource, view creation itself is already invalid on desktop D3D12: in the fixture the device is removed at the caller's own view creation, before any Dispatch. The texture the translated Dispatch samples is created with the caller's own format, so a caller that passes a valid view never reaches this case. That makes it caller misuse rather than a form the stand-in should model, so there is no change here.
  • Bound render target not moved back to its target state after a translated Dispatch. Confirmed, but the translated draw path has the same gap, so I would rather fix both in one separate change than cover only compute here.

🤖 Generated with Claude Code

@MasterDomino

Copy link
Copy Markdown
Collaborator

Thanks, @NiiRoZz. Both answers work for me, so neither note blocks this PR:

  • Typeless resource without a view description: agreed. Desktop D3D12 needs a description to create a view of a typeless resource, so a caller that reaches this already made an invalid call before any Dispatch. There's nothing for the stand-in to model.
  • Bound render target left in SRV/UAV state: agreed that one change covering both the translated draw and Dispatch paths is better than a compute-only fix. Could you open an issue for it, so it's tracked once this lands?

Still waiting on: the order #1803 → #1974 → #1975 → trimmed #2470, an executable run on the final candidate, and @R0Y00 accepting the x2w_d3d12_compute_census export.

AI-assisted.

NiiRoZz and others added 2 commits November 25, 2026 23:50
Upstream now records the compute root and tables (slots 33 and 35) and has its own
DllMain with x2w_startup::d3d12_process_terminating, so this branch's flag and DllMain go.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@NiiRoZz
NiiRoZz force-pushed the startup/compute-dispatch-textures branch from 63875b3 to 1991fd0 Compare November 25, 2026 22:53
NiiRoZz and others added 2 commits November 26, 2026 01:23
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

@NiiRoZz @MasterDomino #2532 was squash-merged into main as de75613fb, and it was stacked on this branch: its history includes "Merge pr2470 (origin/main) into pr2490". Comparing this head with current main (git merge-tree --write-tree origin/main <head>, then git diff origin/main <tree> --stat), the texture-view Dispatch path is already on main. Of about 930 added lines, about 19 are not on main, and those are small form changes (for example the 32-byte texture/entry fields of Slot).

Is anything here still needed beyond what landed? If not, this PR could be closed as superseded by #2532. Any leftover tweak could go as a small follow-up against main. If you would rather keep this one open for that, just say so here.

Thanks for the work on this stack.

AI-assisted; commands listed were executed locally.

@MasterDomino

MasterDomino commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Thanks, @tedin7. Confirmed on main (8016c393): the texture-view Dispatch path, the COMPUTE-list transition fix, dispatch-sampled-compute and the census export came in with #2532. Closing this as superseded is fine with me once @NiiRoZz confirms the remaining small differences aren't needed. I've followed up on the open gates (slot 35 controls, the matched title run, the census export) in #2470: #2470 (comment)

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.

7 participants