Skip to content

runtime: bind 1D, 2D-array and 3D texture SRVs for published native compute - #3306

Merged
pigalot merged 2 commits into
R0Y00:mainfrom
JB2WIN:native/compute-texture-srv-kinds
Nov 28, 2026
Merged

pigalot merged 2 commits into
R0Y00:mainfrom
JB2WIN:native/compute-texture-srv-kinds

Conversation

@JB2WIN

@JB2WIN JB2WIN commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Change

A published native compute manifest (compile_dxil --requests) can now name 1D, 2D-array and 3D texture SRVs: srv N tex1d|tex2da|tex3d table R B, for texture_srv with array_count 1. The stand-in Dispatch binds the title's view for them, or refuses with a named reason. tex2d behaves as before.

Refs #3224 (the texture SRV part I claimed there; typed buffers stay with @Not-Saii).

  • Writer (src/direct_compute_cache.cpp): image_dimension 0/2/5 now publish. Cube (3) and MSAA keep their view-shape refusal from compute: name why a compiled program gets no runtime manifest #3268.
  • Reader and Dispatch (d3d12_compute_dispatch.inl): the new dims need a recorded title view description whose ViewDimension matches the line, and the view must pass address_view_fits (same format or typeless parent, mips/slices inside the texture, MinLODClamp 0). Otherwise the dispatch is refused with "has no recorded view description", "view is not " or "view does not fit its texture". This is stricter than the draw path, which binds null on a mismatch; the docs say so.
  • The catch-all reader refusal now reads "a resource that is not a raw table buffer or a 1D/2D/2D-array/3D texture" (the root-SRV check is updated).

Cube is left for a follow-up: the translator declares cube samples as TextureCubeArray, so the SRV needs a TEXTURECUBE → TEXTURECUBEARRAY view.

Verification

Build of this branch on main 6c5f4ed. Windows 11 26200, RTX 3080 (32.0.16.2124) and WARP, DXC 1.8.2502.11.

ctest --test-dir <build> -j1 -R "startup_compute|native_compile_dxil|direct_compute|compute_manifest"

170/170 passed. The 2 skips (startup_compute_descriptor_scc_warp, startup_compute_dispatch_native_warp) also skip on main.

New tests:

  • native_compute_manifest_reasons: exact published lines for 1d, 2d-array and 3d; image_dimension 3 still gets "SRV kind texture_srv cube".
  • startup_compute_dispatch_texture_dims_{warp,hardware}: one program per dim (1D image_sample_lz, 2D-array slice > 0 and 3D z > 0 image_load) writing to a raw UAV. On both adapters 320 words match the texel and 288 written words change. Each control is refused with the output untouched: a view of another dimension, no view description, a view that does not fit, and the manifest line rewritten to tex2d or another dim. Debug layer on, no error message.
  • Revert check: without the runtime change, the new tests fail.

Impact on a local capture (2,689 compute requests, same build, only the writer swapped back to main): 751 compile in both. Published manifests went from 301 to 350. All 49 new ones carry a new line (51 tex2da, 30 tex3d, 6 tex1d), and the 301 existing manifests are byte-identical. That capture data stays local; the public fixtures are synthetic.

Evidence and follow-up

  • Follow-up: cube SRVs. On an older main build of the same capture, 31 programs were blocked only on a cube SRV.
  • address_view_fits keeps D3D12's casting rule (a view may only reinterpret the format of a typeless resource), so a title view that relies on console-only format casting is refused, not bound.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EF3hKGcUDvQ6pxjDDMrvbn

JB2WIN and others added 2 commits November 28, 2026 05:28
…ompute

The published compute manifest now carries `srv N tex1d|tex3d|tex2da table R B`
for texture SRVs of those dimensions (cube and multisampled ones keep their
named refusal). The Dispatch reader takes the name as the slot's dimension; for
1D, 2D-array and 3D it needs the title's described view of that dimension that
fits its texture (address_view_fits: same or typeless-family format, mips and
slices inside, no LOD clamp), otherwise the Dispatch is refused by name.

An accepted tex2d line binds as before. The refusal text for an srv line that
is not read now names the new dimensions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EF3hKGcUDvQ6pxjDDMrvbn
@pigalot

pigalot commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

I merged main c3204a9c into this branch as e59c5042 (a merge commit on top of 03c22974; no rebase and no force-push). Against main, the branch still changes the same 10 files.

Conflict and how I resolved it. Only src/startup_stubs/d3d12_compute_dispatch.inl conflicted, with main's typed half-buffer outputs (uav <i> bufhalf ...) and resource-heap ranges (resheap):

  • Header comment: kept main's bufhalf output line and this branch's srv <i> tex1d|tex2d|tex2da|tex3d input line.
  • ComputeTranslation::Slot: kept both new fields, srv_dimension and half_buffer_bytes. Both come after channels and are assigned after push_back, so the existing positional initialisers mean the same.
  • Manifest parser: this branch's srv <i> <kind> table branch, then main's resheap branch.
  • Fallback refusals: this branch's SRV text (a resource that is not a raw table buffer or a 1D/2D/2D-array/3D texture, which tests/startup_compute_root_srv_dispatch_check.py expects) and main's generic UAV text (an unsupported compute output view), since outputs now include bufhalf too.

src/direct_compute_cache.cpp, docs/startup-runtime.md and tests/startup_stream_consumer.cpp merged without conflicts.

What I ran. I built the whole tree in dev and release, then ran:

ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R '^(startup_compute_.*|native_compute_.*|startup_stream_(check|consumer.*)|direct_compute.*)$' -E '(_hardware$|startup_audio_)'
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(startup_compute_.*)_hardware$'
  • Without _hardware: 104 of 104 pass in Debug and in Release /O2, including startup_compute_dispatch_texture_dims_warp, startup_compute_root_srv_dispatch_warp, native_compute_manifest_reasons and startup_compute_half_buffer_uav_controls. Four report capability skips (77) on WARP: startup_compute_descriptor_scc_warp, native_compute_implicit_lod_warp, startup_compute_dispatch_native_warp and startup_compute_half_buffer_uav_warp.
  • _hardware: 75 of 75 pass in Debug and Release on an RTX 5090, including startup_compute_dispatch_texture_dims_hardware and startup_compute_half_buffer_uav_hardware. The debug layer was off.

git diff --check origin/main...HEAD is clean.

This needs a review from someone other than me before it can be merged.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088 and WARP 10.0.26100.9818, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10.

This reply was AI-assisted.

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Thanks for this. I reviewed head e59c5042 by reading it and doing a compile-only check (no Wine, no GPU). I found nothing blocking, only the nits below. Once you've had a look at them, it looks ready from our side.

  • Merge: pigalot's resolution of d3d12_compute_dispatch.inl matches one I made independently: git merge-tree --write-tree of 03c22974 into main c3204a9c, then the union of its 4 hunks. The only difference is the order of the two default-initialized Slot fields, srv_dimension and half_buffer_bytes. The other 9 files have the same added and removed lines as 03c22974.
  • Kinds: dx_kind[]{1, 2, 4, 5, 6, 7, 3, 8} in gfx1013_direct_compute.inl declares dims 0, 2 and 5 as Texture1D, Texture3D and Texture2DArray. These are the view dimensions the Dispatch now requires.
  • On the resolved tree, the Linux platform-independent Python job passes. direct_compute_cache.cpp, d3d12_xs_device.cpp, startup_stream_consumer.cpp and native_compute_manifest_reasons.cpp compile (clang-cl cross build, rc=0).
  • CI on e59c5042 passed (Windows build/test, gfx1013 fixtures, Linux Python). Its ctest --preset pr (100% tests passed out of 73) includes none of the new or edited tests: grep -c texture_dims on the job log gives 0. So the runtime evidence is your run plus pigalot's WARP and RTX 5090 run.

Nits (none blocking):

  1. The new "an input texture view has a packed format" refusal for 1D, 2D-array and 3D views is not reached by any test (git grep -l 'has a packed format' -- tests finds nothing). The existing 2D one isn't reached by any test either.
  2. In the writer, the 1D-array (4) and MSAA (6/7) refusals are not pinned. published[] and the cube case cover only 0, 1, 2, 3 and 5. The name ternary maps every other dimension to "tex2da", so if the guard were widened, dim 4 would be published as a 2D array and no test would fail.
  3. The comment above view_shape in direct_compute_cache.cpp still uses "SRV kind texture_srv 3d" as its example, but that kind now publishes. cube would work as the example.
  4. Docs: "a cube or multisampled one does not" in native-compile-dxil-refusals.md leaves out 1D arrays. The "Fits" sentence in startup-compute-native-dispatch.md leaves out three of the checks in address_view_fits: component mapping, depth formats, and the refusal of a typeless view format.

This comment was AI-assisted.

@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 e59c5042 on Windows (your change plus b's merge of main). It does what the description says, and the tests are solid, so I'm approving.

Merge of main. git show --remerge-diff e59c5042 shows one conflicted file, src/startup_stubs/d3d12_compute_dispatch.inl. All three hunks keep both sides: the header comment lists the bufhalf output and the new SRV names; the ComputeTranslation slot holds both srv_dimension and half_buffer_bytes; and the reader keeps your SRV line next to main's resheap line, with your SRV catch-all message and main's "an unsupported compute output view". A trial merge over current main (c3204a9c) is clean, and git diff --cached --check reports no problems.

What I checked in the code.

  • The writer publishes tex1d/tex2d/tex3d/tex2da for image dimensions 0/1/2/5 with array_count 1 only. Cube (3) and the array-count case still get their view-shape refusal.
  • The reader takes the name with %15s into the 16-byte name buffer and accepts it only when it maps to an SRV dimension. Any other name, buf included, falls through to the later branches as before.
  • For the three new dimensions, Dispatch requires a recorded description, the manifest's ViewDimension, and address_view_fits. address_view_fits also checks the resource's dimension (1D needs a 1D resource with DepthOrArraySize 1, and 3D needs a 3D resource), so a view is never created over a resource of another dimension. The 2D path is unchanged.

Testing on the trial merge, ctest --test-dir out/build/<preset> --no-tests=error -R '^(startup_compute.*|native_compile_dxil.*|direct_compute.*|.*compute_manifest.*)$':

  • dev and release: 100 of 103 pass in each. The 3 capability skips are startup_compute_descriptor_scc_warp, startup_compute_dispatch_native_warp and startup_compute_half_buffer_uav_warp.
  • The _hardware variants, under a GPU lock with -j 1 and X2W_TEST_DEBUG_LAYER=1: 75 of 75 pass in each preset, including startup_compute_dispatch_texture_dims_hardware.
  • Full non-hardware suite in dev: 2052 of 2052 pass.

Mutants, each rebuilt in dev and run against native_compute_manifest_reasons, startup_compute_dispatch_texture_dims_warp and startup_compute_dispatch_texture_warp:

Mutant Result
writer names dimension 0 tex2d killed (native_compute_manifest_reasons)
writer drops dimension 2 (3D) killed (native_compute_manifest_reasons)
writer ignores array_count killed (native_compute_manifest_reasons)
writer also publishes cube as tex2da killed (native_compute_manifest_reasons)
reader maps tex2da to 2D killed (_dims_warp: 288 words differ)
reader drops tex3d killed (_dims_warp: the tex3d control refused as an unknown resource)
reader never stores the dimension killed (_dims_warp and the existing startup_compute_dispatch_texture_warp)
no "no recorded view description" check killed (_dims_warp)
no ViewDimension check killed (_dims_warp: the mismatch control dispatched)
no address_view_fits check killed (_dims_warp: the clamped control dispatched)
new branch removed (every SRV treated as 2D) killed (_dims_warp)
packed-format check in the new branch removed survives

Non-blocking. The packed-format refusal in the new branch has no case. The 2D path's packed check is marked as a shortcut until its first user, so this matches it. A one-line control with a packed view format on one of the new dimensions would pin it, if you want to add one here or later.

Verdict: approve at e59c5042.

Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; NVIDIA GeForce RTX 5090, driver 32.0.16.1088, D3D12 debug layer on for the hardware runs; WARP for the _warp tests.

This reply was AI-assisted.

@pigalot
pigalot merged commit 1f07b2c into R0Y00:main Nov 28, 2026
5 checks passed
Not-Saii added a commit to Not-Saii/Xbox2Windows that referenced this pull request Nov 28, 2026
Conflicts resolved by hand:

- src/startup_stubs/d3d12_compute_dispatch.inl, translate_compute_natively:
  main's exact-width typed outputs (R0Y00#3243, exact_texture_uav_channels and
  slot.channels) are kept beside R0Y00#3049's four-channel float outputs,
  2D texture inputs and scalar buffer inputs. Each side keeps its own
  dimension mapping. A 2D texture input sets slot.srv_dimension, which the
  dispatch path reads since R0Y00#3306.
- tests/startup_stream_consumer.cpp, texture_slot67: main's texture-exact-*
  modes and R0Y00#3049's native input modes are both volume modes.
- docs/startup-runtime.md: R0Y00#3049's list of bound views, with main's
  sentence on published 1D, 2D-array and 3D texture SRVs.

AI-assisted.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
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.

3 participants