Skip to content

runtime: bind table buffers, 2D texture inputs and texture outputs on the in-process compute route - #2993

Closed
Leyukaka wants to merge 7 commits into
R0Y00:mainfrom
Leyukaka:native-bind
Closed

Leyukaka wants to merge 7 commits into
R0Y00:mainfrom
Leyukaka:native-bind

Conversation

@Leyukaka

@Leyukaka Leyukaka commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Part 2 of #2974 (step 3). It also covers half4_texture_uav, beyond the issue's list, because the offline formatter pairs it with texture_uav. Part of #2935. Target branch main. Builds on #2975: this branch contains its commits, so please merge #2975 first; I will rebase afterwards.

Change (src/startup_stubs/d3d12_compute_dispatch.inl): translate_compute_natively, the in-process route of #2958 (X2W_NATIVE_SHADERS), bound only raw_vector_srv and raw_buffer_uav. It now also fills the ComputeTranslation slots that the manifest reader fills for these kinds:

Binding Image dimension Same slot as the manifest line
buffer_srv - srv N buf table P OFF
texture_srv 1 (2D) srv N tex2d table P OFF
texture_uav, half4_texture_uav 0 / 1 / 5 / 2 uav N tex1d / tex2d / tex2da / tex3d float table P OFF channels 4
  • The kind and image-dimension rules are the ones format_compute_runtime_manifest uses, so both routes use the same slot for these kinds. The in-process route stays narrower: no samplers, no byte_window_srv, and array count 1 for every view.
  • The register-order, array-count, root-parameter and size checks are unchanged. Samplers and every other kind stay refused with the existing messages.
  • Not included: byte_window_srv, which the offline formatter also writes as srv N buf table. It can follow if wanted.

Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on #2975 (e18549ca) plus this commit.

  • startup_compute_dispatch_native_hardware passed with a new case: a scalar buffer read (buffer_srv) and a 2D image load (texture_srv) feed a 3D image store (texture_uav). The whole volume matches a CPU reference. The consumer gains a texture-volume-native-inputs mode that provides the buffer descriptor and the 2D SRV token.
  • Control: the same program with image_sample_lz in place of the load adds a sampler, is refused with "not translated natively: a sampler, ..." and leaves the volume untouched.
  • startup_compute_dispatch_native_warp exits 77 as before: WARP has no 32-lane waves, and the new case checks the refusal by that name with the volume untouched.
  • startup_compute_dispatch_texture_hardware and _warp still pass.
  • Not exercised on the in-process route: half4_texture_uav and the 1D, 2D and 2D-array outputs. They share the slot code with the 3D case. The code comment and docs/startup-runtime.md no longer limit the route to the kinds a fixture has run through.

Mutation checks, run by hand; each fails the hardware check:

  • leaving buffer_srv unbound (the buffer holds a value the store fixture never writes);
  • leaving texture_srv unbound;
  • mapping image dimension 2 to a 2D UAV instead of 3D.

AI-assisted.

…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.
…1D UAV fixture

After a published compute translation fails PSO creation, the stand-in
checks the adapter's wave capabilities (the same OPTIONS1 test the
native route uses) and logs "pipeline creation failed: the adapter has
no 32-lane waves" when they rule out a WaveSize(32) module. The texture
check skips the native 3D/1D dispatch cases on WARP only for that
reason; any other PSO failure fails it. Portable 3D and 1D cases
compile a cs_6_0 store with dxc and a hand-written manifest, so the
binding path is checked on WARP and hardware independently of the C++
compiler.

AI-assisted.
…ility beside it

A failed published compute PSO stays "pipeline creation failed". The
stand-in adds the adapter's 32-lane wave capability as observed:
"(adapter has no 32-lane waves)" or "(adapter wave capability query
failed)". The manifest records no wave size, so the runtime does not
claim the shader needed one. Only the texture check, whose native
modules declare WaveSize(32), skips its native cases on WARP for the
no-waves observation.

AI-assisted.
… 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.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good extension of the in-process compute route — the unified UAV dimension dispatch table, the manifest parsing unification (%15s format), and the wave-32 capability tracking are all clean.

Findings

✅ What works well

  • format_compute_runtime_manifest switch: Replacing the image_dimension == 1 || image_dimension == 5 guard with a switch over 0/1/2/5 mapping to tex1d/tex2d/tex3d/tex2da generalizes cleanly to all existing dimensions. The default: return std::nullopt catches unsupported values.
  • Manifest parsing unification: %15s captures the dimension name string for all UAV types, then uav_dimension() lambda maps it. This replaces two separate sscanf patterns with one — a real simplification.
  • ComputeTranslation::uavs field rename: bool array → D3D12_UAV_DIMENSION uav_dimension is a meaningful upgrade: the old code only expressed "is this 2D array?", but the new code carries the full dimension enum, which is exactly what CreateUnorderedAccessView needs.
  • volume_uav_range_error helper: Validates view.MipSlice < resource.MipLevels and FirstWSlice/WSize against the mip slice depth. The (std::max)(1u, UINT{depth} >> (std::min)(view.MipSlice, 15u)) depth computation matches D3D12 mip level math.
  • Wave capability tracking: adapter_32_lane_waves() checks D3D12_FEATURE_D3D12_OPTIONS1.WaveOps, WaveLaneCountMin and WaveLaneCountMax — correct. The return values (-1 for query fail, 0 for no 32-lane, 1 for yes) cleanly propagate into the refusal message.
  • Doc update to startup-runtime.md: Accurately reflects the expanded set: buffer_srv, raw_vector_srv, raw_buffer_uav, texture_srv (1D/2D), texture_uav / half4_texture_uav (1D/2D/2D-array/3D).

⚠️ Issues / observations

  1. uav_dimension() lambda scope: The lambda is defined inside load_compute_translation and captures nothing. It uses std::strcmp which is available via <cstring>. The lambda is called immediately after definition, so its scope is fine. However, consider whether this would benefit from being a static helper or a member function of ComputeTranslation if the pattern is reused for SRV dimension lookup (which currently uses sscanf("srv %u tex2d table ...") with a hardcoded "tex2d" string).

  2. Mip slice depth computation: (std::max)(1u, UINT{resource.DepthOrArraySize} >> (std::min)(view.MipSlice, 15u)) — the >> (std::min)(view.MipSlice, 15u) handles MipSlice >= 16 by capping the shift at 15, which gives depth=1 for very large mip slices. This prevents undefined behavior from shifting by ≥32 bits. Good defensive code.

  3. volume_uav_range_error return for WSize == 0: When view.WSize == 0, the condition !view.WSize triggers early return with a non-null error. This means "WSize must be nonzero" is enforced. Is this the intended behavior, or should 0 mean "full extent" (matching D3D12 semantics where D3D12_TEX3D_UAV::WSize of 0 means the full remaining depth)? If 0 should mean full, the check needs adjustment. If 0 is intentionally refused, add a comment explaining why.

  4. half4_texture_uav slot code sharing: The PR mentions that half4_texture_uav shares slot code with texture_uav in the formatter. The switch in format_compute_runtime_manifest maps half4_texture_uav to the same tex* strings as texture_uav. This is correct if both kinds produce the same UAV dimension values at runtime. Verify that half4_texture_uav indeed sets image_dimension to one of 0/1/2/5 and not a distinct value.

  5. CMake texture_native_args variable: The unset(texture_native_args) before the conditional is good practice to avoid leaking from previous test definitions. However, if compile_dxil or its DLLs are not found, ${texture_native_args} is empty but the variable still exists (as empty). ${adapter} ${texture_native_args} would expand to just ${adapter} — correct, but consider using if(texture_native_args) in the next add_test call for clarity.

Recommendation

With the one important question around WSize == 0 semantics (item 3), this is ready to land. Otherwise well-structured and well-tested.

🏷 Long-term: if the in-process route expands further (samplers, byte_window_srv, typed views), consider whether the refusal message pattern ("not translated natively: ...") could be generalized into a dedicated error classification instead of accumulating string literals.

@Leyukaka

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. On item 3: refusing WSize == 0 is intended.

AI-assisted.

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

Independent Release /O2 run at 917c124dfa3ee0c6ce735286ffc1617dec851b01, on Windows 11 build 26200.9974 with SDK 10.0.26100. The RTX 4060 Laptop (32.0.16.1656) passed startup_compute_dispatch_native_hardware: the scalar table buffer and 2D SRV fed the 3D output and all 6,144 words matched, with the sampler refusal control and no debug-layer error. Both startup_compute_dispatch_texture_* entries passed. startup_compute_dispatch_native_warp failed with consumer exit 2173, not a capability skip, on WARP 10.0.26100.9818. I reproduced it running only table_views: with the D3D12 debug layer enabled, the last log is creation of the 1×1 input resource and the child exits before the expected no-wave refusal. With the layer disabled, both isolated refusal cases complete. Please preserve the debug-layer path and investigate the input view setup before treating WARP as 77. Git confirms #2975 e18549ca is an ancestor of this head; please land it first and retest this PR after rebasing.

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

Follow-up on 917c124d. Independent Debug (dev, embedded /Z7 to work around the local PDB toolchain) reproduced the Release result: texture/WARP and both hardware entries passed, while native/WARP exited 2173. A direct descriptor query measured CBV/SRV/UAV increments of 64 bytes on this WARP versus 32 on the RTX 4060 Laptop. The new consumer writes the input SRV at fixed cpu + 32. In a local fixture-only probe, using slot 15's increment for the two descriptor creation handles changed Release native/WARP from failure to the expected 77, with the debug layer still enabled. Separately, I set Texture3D.WSize=0 in the native volume fixture on RTX: native translation succeeded, Dispatch refused, and all 6,144 words retained their sentinels. Please carry both cases into the fixture. The in-process 1D and 2D-array descriptor paths and half4 output still lack direct readback. Targeted cases for those branches matter more than duplicating the full dimension/format matrix; published/offline coverage does not exercise their native binding path.

…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.
@Leyukaka

Copy link
Copy Markdown
Collaborator Author

Thanks for finding the stride. Both cases and the targeted readbacks are in the new commit.

Descriptor increment. The fixture now queries the CBV/SRV/UAV increment (device slot 15) and creates the SRV and UAV at cpu + 1 * increment and cpu + 2 * increment.

  • Slots 18 and 19 write a 32-byte token at the stride-aligned title handle.
  • The translated Dispatch reads the table at the literal guest byte offsets the manifest names (0, 32 and 64).
  • So with a 32-byte increment nothing moves. With a wider one, the fixture copies the tokens into a packed region of the same heap, at those guest offsets, and binds that region's base.
  • X2W_D3D12_DEBUG stays set for every case; no debug-layer code changed.

New cases in startup_compute_dispatch_native_check.py, against a CPU reference or the untouched sentinels:

Case Checked
Texture3D.WSize = 0 translated natively, Dispatch refused with "an output 3D texture W range is outside the mip", all 6,144 words untouched
1D float output (image dimension 0) all 128 words
2D-array output (dimension 5), relative layer 1 all 6,144 words
half4 output (D16 store, round to nearest even) all 1,024 halves

On adapters without 32-lane waves, each case checks the no-wave refusal with the output untouched.

Results. The setup was Windows 11 with an RTX 5080 and DXC from the Windows SDK 10.0.26100.

  • Hardware: native passed with all new cases; texture passed.
  • WARP: native exits 77 after the refusals; texture passed.
  • This machine has no D3D12 SDK layers, so I could not reproduce the debug-layer exit 2173 or confirm the fix under the layer here. Your probe covers that.
  • I did not measure the increment of my local WARP. The packed-table path of the native-inputs mode is not exercised past the no-wave refusal on any adapter I have: WARP has no 32-lane waves, and the hardware has a 32-byte increment.
  • Three manual mutants each fail the hardware check:
    • accepting WSize == 0;
    • mapping image dimension 5 to a 2D UAV;
    • leaving half4_texture_uav unbound.

Order agreed: #2975 first, then I will rebase this PR and retest.

AI-assisted.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What works

  1. Comprehensive expansion of the in-process compute route (#2958) to
    bind buffer_srv, texture_srv (2D), texture_uav (1D, 2D, 2D-array,
    3D) alongside the existing raw_vector_srv and raw_buffer_uav.
    The manifest formatter correctly maps image_dimension values to tex1d
    /tex2d/tex2da/tex3d output keywords in direct_compute_cache.cpp.
  2. volume_uav_range_error() correctly checks 3D UAV mip slice against
    MipLevels and W range against depth -- the first 16-refusal path will
    log proper reasons instead of silent failures.
  3. view_slot() changes: the renamed record_refused_uav flag and the new
    1D UAV mip slice check at slot 19 add consistency between creation and
    dispatch refusal paths.
  4. Clean build-dependency handling in CMakeLists.txt: the texture_native
    test now passes compile_dxil and DXC bin dir as extra args when
    available.

Issues

  1. ComputeTranslation struct changes: array member renamed to
    uav_dimension with type D3D12_UAV_DIMENSION. The old array flag
    for 2D-array was used in specific paths. This rename should be verified
    against all callers -- the diff doesn't show every reference.
  2. build on the dependency on #2975 (the PR title says this builds on
    #2975; reviewers should review #2975 first or be aware of that
    dependency).
  3. volume_uav_range_error() for 3D uses resource.DepthOrArraySize
    shifted by the mip slice, but for 3D resources the mip slice can go
    up to 15 (the (std::min)(view.MipSlice, 15u) handles that).
    This is correct. However, the ~0u case for WSize means 'full depth
    minus first_w_slice' -- this is the standard default in most UAV
    descs and is handled correctly.

Recommendations

  • Verify all existing uses of the array field in
    d3d12_compute_dispatch.inl were migrated to the uav_dimension field.
  • Consider adding a specific test for the 1D UAV mip slice refusal at
    the view creation (slot 19) path.

Overall

Well-scoped expansion of the native compute route with proper manifest
mapping and refusal reasons. The 3D UAV range validation is correct.
Approvable after verifying the array->uav_dimension migration.

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

Reviewed a5d118336bc18f44eb5d2bc8ae8f253bebd5bd91. Exact-head Debug and Release /O2 runs of ctest --preset <dev|release> --no-tests=error -V -R '^startup_compute_dispatch_(texture|native)_(warp|hardware)$' each gave 3 passes and one explicit WARP capability skip (77). Windows 11 26200.9974, SDK 10.0.26100, Microsoft WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. The debug layer stayed enabled. WARP now reaches the wave32 refusal with sentinels intact. RTX matched all words for the table-buffer/2D-SRV-fed 3D store, 128 values for 1D, 6,144 for the 2D array, and 1,024 half values for the packed D16 case. The sampler and WSize=0 controls left the volume unchanged. The packed-table path on wider heaps is covered by WARP descriptor creation and portable dispatch; a native wide-increment success run is still unavailable. #2975 e18549ca remains an ancestor. Please land it first, then rebase #2993 and rerun the focused suite before merging.

@R0Y00
R0Y00 changed the base branch from cpp-migration to main November 27, 2026 11:09
sydney-0o added a commit to sydney-0o/Xbox2Windows that referenced this pull request Nov 27, 2026
@R0Y00

R0Y00 commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Retargeted to main. The current head is stacked on #2975. It merged cleanly on top of my local #2975/main integration, and the synthetic Debug dispatch and root-SRV regressions gave five passes and one WARP capability skip. #3049 now carries both changes on main. Please coordinate there before rebasing this branch separately. Keep the WSize=0 sentinel check, 1D/2D-array/D16 readbacks and the WARP capability result when comparing candidates.

@sydney-0o

Copy link
Copy Markdown
Contributor

I opened PR #3049 on main with the remaining #2975 manifest work and the in-process bindings from this PR. The empty-cache native dispatch fixture passed on a GTX 1080 Ti with app-local Agility SDK 1.620.2, including mixed buffer/2D texture inputs, 1D/2D-array/3D stores, the packed-half store and the zero-W and sampler refusal controls. The original commits retain your authorship.

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Thanks for the fix round. On a5d11833 the descriptor increment, the WSize=0 refusal and the 1D/2D-array/half4 readbacks are all in, and the head has an approval. A few things are left before it can land:

  1. Conflicts. git merge-tree --write-tree origin/main a5d11833 (main at c3204a9c) exits 1 with conflicts in src/startup_stubs/d3d12_compute_dispatch.inl, tests/startup_compute_dispatch_texture_check.py and tests/startup_stream_consumer.cpp. gh pr view 2975 --json mergeable returns CONFLICTING for the base too. The maintainer asked for coordination in runtime: bind native compute table buffers and texture views #3049 before this branch is rebased on its own. The rebase has to keep both sides of the native-route hunks: main's stride_srvs (Compute descriptor stride SCC from bound buffer metadata #3227) and exact_texture_uav_channels (compute: store prefix-mask images at their exact width in direct compute #3243), plus this PR's 4-channel/half4 kinds and its 0/1/2/5 dimension switch.
  2. Lost refusal reason (please fix). In the auto-merged src/direct_compute_cache.cpp, the new texture_uav/half4_texture_uav switch ends in default: return std::nullopt; (git show <merged tree>:src/direct_compute_cache.cpp | grep -n 'default: return std::nullopt' → 832). On main that branch returns refuse(view_shape("UAV", b)), which compute: name why a compiled program gets no runtime manifest #3268 (a166a753) added. After the merge, dimensions 3/4/6/7 are still refused but no longer say why. Suggested: default: return refuse(view_shape("UAV", b));. runtime: bind native compute table buffers and texture views #3049 has the same line (773) and doesn't include compute: name why a compiled program gets no runtime manifest #3268 yet (git merge-base --is-ancestor a166a753 1356e232 → false).
  3. CI coverage. The Windows job ran ctest --preset pr (100% tests passed out of 40). grep -c on its log gives 0 for both startup_compute_dispatch_native and startup_compute_dispatch_texture, so all the results so far come from hardware runs. After the rebase, could you rerun the focused suite? Could you also add mutants for the dimension 0 → TEXTURE1D mapping and for the texture_srv && image_dimension == 1 restriction?
  4. Stale doc. docs/experiments/startup-compute-native-dispatch.md still says "Accepted: root constants, a raw table buffer loaded per lane and a raw table buffer stored to" and "a texture, a sampler and the typed, half and indexed views are refused". The PR only edits docs/startup-runtime.md (git diff --name-only main...a5d11833 -- docs).
  5. Minor: negative controls for texture_srv with image_dimension != 1 and for texture outputs at dimension 3/4/6/7 would pin down the new refusals.

This comment was AI-assisted.

Leyukaka added a commit to Leyukaka/Xbox2Windows that referenced this pull request Nov 29, 2026
…te route

Takes over R0Y00#3049, which carried R0Y00#2975 and R0Y00#2993, onto current main.

- In-process route: four-channel float texture UAVs in 1D, 2D and 2D-array and packed half4
  texture UAVs in 1D, 2D, 2D-array and 3D, next to main's exact-width channels (R0Y00#3243); exact-width
  kinds outside 2D, 2D-array and 3D are refused instead of bound as 2D; native 2D texture inputs
  set srv_dimension (R0Y00#3306); an adapter below shader model 6.6 is refused by name.
- C++ manifest: texture_uav and half4_texture_uav at dimension 0 publish tex1d, half4_texture_uav
  at dimension 2 publishes tex3d; other dimensions keep R0Y00#3268's refusal.
- On the published route a PSO failure stays the reason, with the adapter's wave32 or shader model
  shortfall beside it.
- Fixtures use the adapter's descriptor increment, accept revision.txt in the cache, and cover the
  zero-W, 1D, 2D-array and half4 cases.

Co-authored-by: sydney-0o <215686885+sydney-0o@users.noreply.github.com>
Main now carries the 3D/1D dispatch path, the consumer volume and line
modes and the gfx2hlsl 3D/1D store fixtures (R0Y00#2902). Kept from this
branch: the C++ formatter's tex1d/tex3d lines for float and half4 UAVs,
the 32-lane wave note on PSO failures and the native compile_dxil cases,
now driven by main's store_3d1d and V.FORMS. The hand-written portable
fixture is dropped in favour of main's translated one.
Main now binds 2D texture inputs, constant samplers, scalar buffer
windows, exact-width typed outputs and float 3D outputs on the native
route. Kept from this branch: four-channel float 1D, 2D, 2D-array and
3D outputs for texture_uav and half4_texture_uav, the adapter-increment
packed guest table in the consumer (now also for the second mip view and
the sampled input token), and the table-view and texture-output native
cases. The sampler control of the table-view case is dropped: main
translates constant samplers, and its memory-sampler case covers the
refusal.
@Leyukaka

Copy link
Copy Markdown
Collaborator Author

Merged the updated #2975 branch (8364ecd, which carries main a99e05f) into this branch; new head d36d56c. A merge rather than a rebase, so the approved commits stay as they are and only the resolution is new (git show --remerge-diff d36d56c2). The approval is on a5d1183, so the new head needs a re-review.

Conflicts (main now binds 2D texture inputs, constant samplers, cbv-window buffer_srv and exact-width outputs natively):

  • src/startup_stubs/d3d12_compute_dispatch.inl: kept main's binding loop; its volume case (texture_uav, 3D only) is replaced by our 1D/2D/2D-array/3D switch for texture_uav and half4_texture_uav. Our separate supported check is dropped: main's accepts_cbv_window already takes buffer_srv.
  • tests/startup_compute_dispatch_native_check.py: kept main's step 5 (constant samplers); ours are now steps 6 (table views) and 7 (texture outputs), built on main's V.program/V.group/V.VALUES. Our sampler control is dropped: main translates constant samplers, and its memory-sampler case covers the refusal.
  • tests/startup_stream_consumer.cpp: main's modes plus our zero_w/native_inputs. The heap is table_slot + views (views = dual ? 5 : 4); the second mip view goes to cpu + 4 * increment and the sampled SRV copy to table_cpu + 32, which are main's addresses at a 32-byte increment.
  • docs/startup-runtime.md: main's paragraph plus buffer_srv and the four-channel float UAV sentence; "a scalar buffer load" is removed from the refused list.

Tests on d36d56c, 21 selected, 0 failed: startup_compute_dispatch_native_hardware passes (table views match and the zero WSize control leaves the volume untouched; texture-line 128, texture-array 6144 and texture-store 1024 values match the CPU reference), as do native_image_store_exact_width_hardware_{r,rg,rgb,array,volume,rgba,sparse}, startup_compute_dispatch_texture_{warp,hardware}, startup_compute_dispatch_two_mips_{warp,hardware}, native_compute_manifest_reasons and native_image_store_exact_width_warp_sparse. Skipped with 77 on WARP (no 32-lane waves): startup_compute_dispatch_native_warp and native_image_store_exact_width_warp_{r,rg,rgb,array,volume,rgba}.

Mutation: case 0: float4_dimension = D3D12_UAV_DIMENSION_TEXTURE1D -> TEXTURE2D in the .inl fails startup_compute_dispatch_native_hardware at assert len(lines(result, f'{TEXTURE_DISPATCH} translated')) == 1, with Dispatch(2, 1, 1) refused: an output texture view is not 2D.

Not covered: the consumer's packed-table branch (table_slot != 0) runs only where the descriptor increment is not 32 bytes; the increment of the hardware adapter was not recorded, so that branch may not have run. git merge-tree --write-tree of d36d56c with current main (1a0120b) is clean; the tests ran with a99e05f merged, not 1a0120b.

@Leyukaka

Copy link
Copy Markdown
Collaborator Author

Closing in favour of #3398, which carries this PR's changes: four-channel float and half4 texture UAVs (1D, 2D, 2D-array, 3D) bound as outputs on the in-process compute route, and the fixture (scalar buffer and 2D texture inputs feeding a 3D store, zero-size W control, adapter descriptor increment, 1D/2D-array/half4 readbacks).
#3398 also refuses adapters that report a shader model below 6.6. This branch and #3398 conflict, so only one can merge.

@Leyukaka Leyukaka closed this Nov 29, 2026

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

Independently reviewed d36d56c2 integrated over main a30437f7 (tree 43b81448). The trial merge is clean and git diff --check is clean. This is my first review of this PR.

What I traced. Against current main, the runtime change left in this PR is small, because main already binds buffer_srv (through accepts_cbv_window), 2D texture inputs and the 3D texture_uav output on the in-process route:

  • translate_compute_natively now gives texture_uav and half4_texture_uav a four-channel float output slot for image dimensions 0, 1, 2 and 5 (1D, 2D, 3D, 2D array), where main took only texture_uav at dimension 2. Any other dimension leaves float4_output false and falls into the existing "view kind N is not bound" refusal. The dispatch-time checks for each dimension are main's and are unchanged.
  • format_compute_runtime_manifest writes tex1d/tex2d/tex3d/tex2da for both kinds, and its default: keeps refuse(view_shape("UAV", b)), so the #3268 reason JohnConnorNPC asked about is not lost at this head.
  • From #2975 (an ancestor of this head): the published route adds the adapter's 32-lane wave capability to a pipeline creation failed reason.
  • I read both merge resolutions (git show --remerge-diff d36d56c2 and 8364ecd1). In the .inl the resolution keeps main's binding loop and replaces only its volume case with the dimension switch. In the consumer, main's literal cpu + 64 / cpu + 128 / cpu + 32 handles become increment-based handles plus a packed copy, which are the same addresses at a 32-byte increment.

Tests. Built the full dev and release presets, then ran, with X2W_TEST_DEBUG_LAYER=1 and under one GPU job:
ctest --test-dir out/build/<dev|release> --no-tests=error -j 1 -V -R '^(startup_compute_dispatch_.*|native_image_store_exact_width_.*|native_compute_manifest_reasons|startup_slot67_.*)$'

  • Debug and Release /O2: 41 selected, 34 passed, 0 failed, 7 capability skips (77) in each.
  • The 7 skips are startup_compute_dispatch_native_warp and native_image_store_exact_width_warp_{r,rg,rgb,array,volume,rgba}: this WARP has no 32-lane waves. They are skips, not passes.
  • startup_compute_dispatch_native_hardware: the table-view volume matches and the zero WSize control leaves it untouched; texture-line 128, texture-array 6,144 and texture-store 1,024 values match the CPU reference.
  • startup_compute_dispatch_texture_hardware: native volume and volume-nsa 6,144 words and native line 128 words match, with the incompatible views refused. On WARP the three native cases take the named no-wave path and the rest of the test passes.
  • No debug-layer error line in either log.

Mutation checks (12, each rebuilt in dev):

  • Killed (11):
    • .inl dimension 0 -> TEXTURE2D, 1 -> TEXTURE2DARRAY, 2 -> TEXTURE2D, 5 -> TEXTURE2D: each fails startup_compute_dispatch_native_hardware with the matching "is not 2D" / "is not a 2D array" refusal.
    • half4_texture_uav dropped from the switch, and texture_uav dropped from it: both end in refused: no translation. These double as the negative control for the new cases: without the binding they fail.
    • texture flag left false for the new outputs: a raw buffer writer was bound to a non-buffer UAV.
    • wave note inverted (if (waves)): fails startup_compute_dispatch_texture_warp.
    • formatter dimension 0 -> tex2d and 2 -> tex2d: fail startup_compute_dispatch_texture_{warp,hardware} on the manifest line.
    • formatter default: -> return std::nullopt: fails native_compute_manifest_reasons.
  • Survives (1): dropping WaveLaneCountMin <= 32 from adapter_32_lane_waves(). This condition is main's, only moved into the helper, and no adapter here has a minimum above 32.
  • Equivalent: none.

Non-blocking notes.

  1. Not exercised by any fixture: half4_texture_uav at dimensions 0, 2 and 5 (in-process and in the manifest; the formatter on main refused half4 at dimension 2), and a plain texture_uav at dimension 1 on the in-process route. The 2D case that runs is the half4 one. They share the switch, so I am not asking for the full matrix, but docs/startup-runtime.md says a program is accepted "only with the bindings a fixture has run through it", and that sentence is no longer exact.
  2. docs/experiments/startup-compute-native-dispatch.md still lists "a scalar buffer load" as refused (lines 19 and 85). That is JohnConnorNPC's item 4 and is still open; main already has the same stale text, so it can be a follow-up.
  3. I did not measure the descriptor increment of either adapter, so I cannot say whether the consumer's packed-table branch (table_slot != 0) ran here. If WARP's increment is above 32 bytes it ran for the portable texture, two-mips and array tests, which pass.
  4. The new docs section "Offline compute manifests for 3D and 1D UAVs" says the runtime half "is ported to cpp-migration"; this PR targets main.

Title run. prwatch ran the head against the baseline (job 31): pass.

Merge. I approve this head and I am not merging it. The PR body and R0Y00's review on a5d11833 both ask for #2975 to land first, and #2975 is still open at 8364ecd1. This branch contains all of #2975, so merging it now would land #2975 here instead.

Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; NVIDIA GeForce RTX 5090 driver 32.0.16.1088 and Microsoft WARP; D3D12 debug layer requested with X2W_TEST_DEBUG_LAYER=1.
CI: Build and test on Windows passed on d36d56c2.

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.

6 participants