Skip to content

runtime: bind native compute table buffers and texture views - #3049

Open
sydney-0o wants to merge 4 commits into
R0Y00:mainfrom
sydney-0o:codex/native-compute-bindings
Open

sydney-0o wants to merge 4 commits into
R0Y00:mainfrom
sydney-0o:codex/native-compute-bindings

Conversation

@sydney-0o

@sydney-0o sydney-0o commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Refs #2974 and #2935. Combines the remaining work from #2975 and #2993 on main after #3039. The original commits retain Leyukaka's authorship. #2902 supplies the existing runtime view validation.

Changes

  • Publish native offline manifests for four-channel 1D and 3D texture UAVs.
  • Bind scalar table buffer SRVs, 2D texture SRVs, and 1D, 2D, 2D-array and 3D texture UAVs on the first native Dispatch. The in-process and published paths use the same dispatch binding code.
  • Reuse the 1D/3D fixtures from startup: lower compute image_store to 1D and 3D texture UAVs (Part of #2022) #2902 and keep the Python-published and C++-published checks separate. The native fixtures cover invalid mip and W ranges, incompatible views, a zero-size W range, and sampler refusal.
  • Report the adapter's wave32 and shader model capabilities when they explain a native capability skip.

Validation

Tested e56cb78d (Debug, MSVC 19.31, Windows 10 Pro build 19045, DXC from Windows SDK 10.0.26100). Hardware was an NVIDIA GeForce GTX 1080 Ti with driver 32.0.15.8278. WARP was Microsoft Basic Render Driver 10.0.19041.5794.

cmake --build --preset dev --target d3d12_xs_shim startup_stream_consumer compile_dxil
ctest --preset dev --no-tests=error -R '^(startup_compute_dispatch_((texture_)?native_)?(warp|hardware)|startup_gfx2hlsl_image_store_3d1d)$' -V

In-box D3D12 gave 3 passes, 4 capability skips. Both adapters compiled the three native offline requests and verified their manifests. WARP reported 4-lane waves. The GTX 1080 Ti reported wave32 and Shader Model 6.5. Both portable device checks passed with the debug layer enabled and no error messages.

I also built the same targets in out/build/agility. The consumer exported D3D12SDKVersion = 620 and D3D12SDKPath = ".\\D3D12\\" from a test-only source file and loaded the app-local Agility SDK 1.620.2 binaries from that directory. The tracked files and runtime shim used the same commit. This configuration exposed Shader Model 6.6 and wave32 on the same GTX 1080 Ti.

ctest --test-dir out/build/agility --no-tests=error -R '^startup_compute_dispatch_(texture_)?native_hardware$' -V

2 passed. The native offline 3D and 3D NSA cases each matched all 6,144 words. The 1D case matched all 128. The in-process test matched the mixed buffer/texture 3D output and the 1D, 2D-array and packed-half outputs. The refusal controls left the sentinels intact. The in-process run reported the D3D12 debug layer enabled and no errors.

The broader WARP texture suite's existing dispatch-sampled failure (consumer exit 2173) also reproduced with the clean base. The startup stall discussed in #2975 still needs its separate before/after run. This PR provides the combined patch and source-built evidence for review.

AI-assisted.

Leyukaka and others added 4 commits November 27, 2026 16:06
…e manifest (R0Y00#2974)

The stand-in's manifest reader and Dispatch path took only 2D and 2D
array output textures, so a compute program storing to a 3D or 1D image
could not run on cpp-migration. The runtime half of R0Y00#2902 (open on main)
is taken here unchanged: `uav N tex3d|tex1d float table P OFF channels
C` lines, TEXTURE3D/TEXTURE1D UAV views from the title's view record,
and the mip and W range checks, also for slot 19. For the offline route,
format_compute_runtime_manifest now writes those lines for 3D and 1D
texture UAVs, so compile_dxil publishes a manifest the runtime accepts.

AI-assisted.

(cherry picked from commit fb53abd)
… the in-process compute route

translate_compute_natively (X2W_NATIVE_SHADERS) bound only raw_vector_srv
and raw_buffer_uav. It now also fills the ComputeTranslation slots the
manifest reader fills for buffer_srv (srv buf table), texture_srv with
a 2D image (srv tex2d table) and texture_uav/half4_texture_uav with a
1D, 2D, 2D array or 3D image (uav tex1d/tex2d/tex2da/tex3d float table
channels 4), with the same kind and image-dimension rules as
format_compute_runtime_manifest. Samplers and other kinds stay refused.

The native check gains a case where a scalar buffer read and a 2D
image load feed a 3D image store, compared with a CPU reference; the
same program with a sample instead of the load must be refused with
the volume untouched.

AI-assisted.

(cherry picked from commit 917c124)
…ture; add zero-W, 1D, 2D-array and half4 native cases

The texture-volume-native-inputs mode created its SRV and UAV at fixed
32-byte offsets, which is mid-descriptor on adapters with a wider
CBV/SRV/UAV increment (64 bytes on WARP). It now queries the increment
(device slot 15) for the creation handles. On a wider heap the 32-byte
tokens are copied into a packed table at the guest byte offsets the
program reads, and that table's base is bound.

The native check gains a Texture3D.WSize = 0 control (translated
natively, Dispatch refused, output untouched) and in-process readbacks
for a 1D float output, a 2D-array output on a non-zero layer and a
half4 (D16) output, each against a CPU reference.

AI-assisted.

(cherry picked from commit a5d1183)
@R0Y00

R0Y00 commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Independent validation of e56cb78 on main e04217f (GitHub integration commit 8a0e4cf). I confirmed that this draft retains Leyukaka's commits and builds on the 1D/3D runtime validation already in #2902. It also keeps Python-published and native offline tests separate.

ctest --preset <dev|release> --no-tests=error -V -R '^(startup_compute_dispatch_(texture_)?native_(warp|hardware)|startup_manifest_retry|startup_gfx2hlsl_image_store_3d1d)$'

Debug (/Z7) and Release (/O2) each gave four passes and two WARP capability skips. On the RTX 4060 Laptop (driver 32.0.16.1656, Windows 11 26200.9974, SDK 10.0.26100), the native offline volume and NSA fixtures each matched all 6,144 words, and the 1D case matched all 128. In-process dispatch matched the 320-word slot 67 control, and the additional 1D, array and packed-half fixtures matched 128, 6,144 and 1,024 values. The zero-WSize and sampler controls kept their sentinels. The in-process fixture reported the D3D12 debug layer enabled with no errors. WARP 10.0.26100.9818 compiled and checked the offline manifests, then skipped native dispatch because it reports 4 lanes.

This is the combined review candidate for #2975 and #2993. The original-program startup observation with injected manifests still needs a controlled before/after run on the new main baseline.

Copy link
Copy Markdown
Contributor Author

when merging?

R0Y00 commented Nov 27, 2026

Copy link
Copy Markdown
Owner

The independent synthetic review is complete at e56cb78d; the remaining merge blocker is the original-program startup stall reported in #2975. Please compare current main against current main plus #3049 using fresh copies of the same cache and the same scripted inputs, with and without the injected 1D/3D manifests. Record whether file-open progress stalls after excluding shader-cache paths and whether the three implicated dispatches are translated or refused. Counts and diagnostics are enough. Once that separates a reproducible regression from the earlier observation, we can make the merge decision on the current head.

@SimSalabimse

Copy link
Copy Markdown
Contributor

Compared #3049 (head e56cb78d merged locally onto current main 35f7197e, not pushed, built with X2W_WITH_OPUS=ON) to a 300 s Opus-enabled run of that same 35f7197e base. Both runs are of a retail title and both ended with the normal timeout (no crash). Environment (the Windows test PC): RTX 4070 Ti, driver 621.35, Windows 11 25H2 (build 26200), MSVC 19.44, cmake --preset dev.

The before log dir is the 35f7197e tree; the after log dir is the local merge. Last present heartbeats are at 288.3 s (before) and 290.7 s (after), because a thread dump was taken around 280 s.

Shader-cache caveat

Both runs published a fresh shader-cache request set: 2,689 published, 0 already present, 0 failed. That makes this a fair before/after pair (neither run was warm). Publication finished at 93.3 s before and 85.5 s after.

Presents / fps (the early startup stall)

  • Before (35f7197e): 7,242 presents in 288.3 s, 25.1 fps overall. 0–30 s is 22–30 fps. Then a deep dip from about 41–77 s: interval fps falls to 1.6–4.2 (51.6–56.6 s is 1.60 fps with 0 ms slept). About 41–77 s averages 2.8 fps. It recovers to 30 fps from about 82 s. 90–190 s: 29.7 fps. 190–290 s: 30.0 fps.
  • After (runtime: bind native compute table buffers and texture views #3049 merge): 8,086 presents in 290.7 s, 27.8 fps overall. The first 5 s already has 135 presents (27.0 fps) against 119 (23.8 fps) on the base. The same 41–77 s window stays much healthier: it averages 19.0 fps, and the lowest 5 s slice is 13.9 fps at 50–55 s (still sleeping 574 ms in that slice). It is at 30 fps from about 86 s. 90–190 s: 29.9 fps. 190–290 s: 29.9 fps.

The early startup stall that held #2975 is substantially reduced on #3049. It is not completely gone (there is still a milder dip around 45–70 s). The later 190–300 s window is 30 fps on both runs, so this is not the manifest-retry stall #2925 already addressed. First present is in the first few seconds on both; the first surface readback is a 3840x2160 plane with mean level 0.00/255 on both.

Compute dispatches / native compile

  • Before at 283 s: 0 translated, 13,879 refused, 0 no-translation, 0 not modelled. Every keyed census refusal is an input is in a placed buffer that does not alias title memory.
  • After at 291 s: 1 translated, 22,201 refused, 38 no-translation, 0 not modelled. The same placed-buffer refusal still dominates. New in this run, and only reported at the last census (~291 s): one key with 1 dispatch and first refusal: none (the single translated dispatch), plus five keys with 38 dispatches marked no translation.
  • No view-contract or “descriptor does not satisfy” refusals showed up in either log. Builder-gate refusals stay 0.

The higher after refusal count follows in part from more runtime after the early stall and from a steeper rise after ~216 s. Offline translation of the published request set is essentially unchanged: 239 ok on both, 2,467 vs 2,468 unsupported, same reason set.

Slot 70 memory SRV refusals

  • Before at 283 s: 31,269 (mostly unsupported_description 15,203 and buffer_unavailable 14,863; also null_address 739, texture_unavailable 372, overlapping_resource 88).
  • After at 286 s: 52,548 (buffer_unavailable 24,753, unsupported_description 16,054, null_address 7,032, texture_unavailable 3,542, overlapping_resource 1,163).

Both jump in the ~216–250 s window. This PR is about native texture/buffer views, so the higher after counts (especially texture_unavailable and null_address) are noted, not treated as a slot-70 fix.

Other late-run differences

Around 200–250 s both runs start uploading textures and growing pipeline / deferral counts, but they do not line up:

  • Textures uploaded: before reaches 1,126 (about 4,543,028 KiB) by 253 s and stays there. After reaches 38 (47,708 KiB) by 216 s and stays there.
  • Null bindings: 0 on the base; 2,045 on after, all token, starting at 226 s and climbing through the end.
  • Pipelines: before 14 translated / 3 missing; after 12 translated / 6 missing.
  • Heap-indexed roots deferred: 15,412 before vs 29,309 after.
  • Translated draws: 48,198 before (53,170 not drawn) vs 57,840 after (43,396 not drawn).

Stand-in / threads

During the 41–77 s stall the base spends almost the whole interval inside present and barely sleeps (for example 0 ms slept at 1.60 fps). After still does a lot of list/pipeline work in that window, but it keeps presenting and sleeps 0.6–2.6 s per slice. Once both are at 30 fps they sleep about 4.8 s per 5 s (pacing). Thread dumps at 200 s, 280 s and the timeout show 110 threads on both runs, almost all in ntdll waits. No thread is in read_text / load_compute_translation or CreateFileW.

Audio, asserts, errors

Startup audio matches: heap, 350 XMA context slots allocated (still no XMA decoder), AcpHal connect, XApuConnect, and 24 XApuEnqueueCommand (the log cap). No AcpHal type-5 no-op submits or XDspActivate in either 300 s window.

No crash. One title soft-assert was continued on both, at the same site. First-chance access violations in the stand-in are the same kind on both runs, but the counts differ: 498 before vs 8,986 after. Both have an early cluster in the first 10 s (128 each). After then has a large burst in the last ~15 s (8,518 between 285 s and 300 s) that the base did not; the base’s late cluster is 334 around 260–262 s and then quiet. Four network opens were refused on both. No new error message classes appeared, aside from the new no translation / translated compute census lines above.

AI-Assisted

R0Y00 commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Thanks for running the matched cold-cache comparison. It shows that #3049 improved the early present cadence on that baseline, while the late differences still need attribution before merge. In particular, the test saw 498 versus 8,986 first-chance access violations and 1,126 versus 38 texture uploads. Could you repeat with fresh copies of the same inputs and log the leading exception sites as module+RVA and access type (counts only), aligned by the same startup event? Please also run the original injected-manifest control, with and without those manifests on the same baseline, and report the three implicated dispatch keys and non-cache file-open progress. That would tell us whether a newly enabled native dispatch or a different execution path accounts for the late divergence.

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.

4 participants