Repository navigation
runtime: bind table buffers, 2D texture inputs and texture outputs on the in-process compute route - #2993
runtime: bind table buffers, 2D texture inputs and texture outputs on the in-process compute route#2993Leyukaka wants to merge 7 commits into
Conversation
…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
left a comment
There was a problem hiding this comment.
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_manifestswitch: Replacing theimage_dimension == 1 || image_dimension == 5guard with aswitchover 0/1/2/5 mapping totex1d/tex2d/tex3d/tex2dageneralizes cleanly to all existing dimensions. Thedefault: return std::nulloptcatches unsupported values.- Manifest parsing unification:
%15scaptures the dimension name string for all UAV types, thenuav_dimension()lambda maps it. This replaces two separatesscanfpatterns with one — a real simplification. ComputeTranslation::uavsfield rename:bool array→D3D12_UAV_DIMENSION uav_dimensionis a meaningful upgrade: the old code only expressed "is this 2D array?", but the new code carries the full dimension enum, which is exactly whatCreateUnorderedAccessViewneeds.volume_uav_range_errorhelper: Validatesview.MipSlice < resource.MipLevelsandFirstWSlice/WSizeagainst 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()checksD3D12_FEATURE_D3D12_OPTIONS1.WaveOps,WaveLaneCountMinandWaveLaneCountMax— 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
-
uav_dimension()lambda scope: The lambda is defined insideload_compute_translationand captures nothing. It usesstd::strcmpwhich is available via<cstring>. The lambda is called immediately after definition, so its scope is fine. However, consider whether this would benefit from being astatichelper or a member function ofComputeTranslationif the pattern is reused for SRV dimension lookup (which currently usessscanf("srv %u tex2d table ...")with a hardcoded "tex2d" string). -
Mip slice depth computation:
(std::max)(1u, UINT{resource.DepthOrArraySize} >> (std::min)(view.MipSlice, 15u))— the>> (std::min)(view.MipSlice, 15u)handlesMipSlice >= 16by 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. -
volume_uav_range_errorreturn for WSize == 0: Whenview.WSize == 0, the condition!view.WSizetriggers 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 whereD3D12_TEX3D_UAV::WSizeof 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. -
half4_texture_uavslot code sharing: The PR mentions thathalf4_texture_uavshares slot code withtexture_uavin the formatter. The switch informat_compute_runtime_manifestmapshalf4_texture_uavto the sametex*strings astexture_uav. This is correct if both kinds produce the same UAV dimension values at runtime. Verify thathalf4_texture_uavindeed setsimage_dimensionto one of 0/1/2/5 and not a distinct value. -
CMake
texture_native_argsvariable: Theunset(texture_native_args)before the conditional is good practice to avoid leaking from previous test definitions. However, ifcompile_dxilor 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 usingif(texture_native_args)in the nextadd_testcall 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.
|
Thanks for the review. On item 3: refusing
AI-assisted. |
R0Y00
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
|
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
New cases in
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.
Order agreed: #2975 first, then I will rebase this PR and retest. AI-assisted. |
KelboLive
left a comment
There was a problem hiding this comment.
What works
- 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. - 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. - 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. - 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
ComputeTranslationstruct changes:arraymember renamed to
uav_dimensionwith typeD3D12_UAV_DIMENSION. The oldarrayflag
for 2D-array was used in specific paths. This rename should be verified
against all callers -- the diff doesn't show every reference.- 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). volume_uav_range_error()for 3D usesresource.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~0ucase 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
arrayfield 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
left a comment
There was a problem hiding this comment.
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.
|
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. |
|
I opened PR #3049 on |
|
Thanks for the fix round. On
This comment was AI-assisted. |
…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.
|
Merged the updated #2975 branch (8364ecd, which carries Conflicts (
Tests on d36d56c, 21 selected, 0 failed: Mutation: Not covered: the consumer's packed-table branch ( |
|
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). |
pigalot
left a comment
There was a problem hiding this comment.
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_nativelynow givestexture_uavandhalf4_texture_uava four-channel float output slot for image dimensions 0, 1, 2 and 5 (1D, 2D, 3D, 2D array), wheremaintook onlytexture_uavat dimension 2. Any other dimension leavesfloat4_outputfalse and falls into the existing "view kind N is not bound" refusal. The dispatch-time checks for each dimension aremain's and are unchanged.format_compute_runtime_manifestwritestex1d/tex2d/tex3d/tex2dafor both kinds, and itsdefault:keepsrefuse(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 failedreason. - I read both merge resolutions (
git show --remerge-diff d36d56c2and8364ecd1). In the.inlthe resolution keepsmain's binding loop and replaces only itsvolumecase with the dimension switch. In the consumer,main's literalcpu + 64/cpu + 128/cpu + 32handles 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_warpandnative_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 zeroWSizecontrol 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):
.inldimension 0 ->TEXTURE2D, 1 ->TEXTURE2DARRAY, 2 ->TEXTURE2D, 5 ->TEXTURE2D: each failsstartup_compute_dispatch_native_hardwarewith the matching "is not 2D" / "is not a 2D array" refusal.half4_texture_uavdropped from the switch, andtexture_uavdropped from it: both end inrefused: 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)): failsstartup_compute_dispatch_texture_warp. - formatter dimension 0 ->
tex2dand 2 ->tex2d: failstartup_compute_dispatch_texture_{warp,hardware}on the manifest line. - formatter
default:->return std::nullopt: failsnative_compute_manifest_reasons.
- Survives (1): dropping
WaveLaneCountMin <= 32fromadapter_32_lane_waves(). This condition ismain's, only moved into the helper, and no adapter here has a minimum above 32. - Equivalent: none.
Non-blocking notes.
- Not exercised by any fixture:
half4_texture_uavat dimensions 0, 2 and 5 (in-process and in the manifest; the formatter onmainrefused half4 at dimension 2), and a plaintexture_uavat 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, butdocs/startup-runtime.mdsays a program is accepted "only with the bindings a fixture has run through it", and that sentence is no longer exact. docs/experiments/startup-compute-native-dispatch.mdstill lists "a scalar buffer load" as refused (lines 19 and 85). That is JohnConnorNPC's item 4 and is still open;mainalready has the same stale text, so it can be a follow-up.- 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. - The new docs section "Offline compute manifests for 3D and 1D UAVs" says the runtime half "is ported to
cpp-migration"; this PR targetsmain.
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.
Part 2 of #2974 (step 3). It also covers
half4_texture_uav, beyond the issue's list, because the offline formatter pairs it withtexture_uav. Part of #2935. Target branchmain. 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 onlyraw_vector_srvandraw_buffer_uav. It now also fills theComputeTranslationslots that the manifest reader fills for these kinds:buffer_srvsrv N buf table P OFFtexture_srvsrv N tex2d table P OFFtexture_uav,half4_texture_uavuav N tex1d/tex2d/tex2da/tex3d float table P OFF channels 4format_compute_runtime_manifestuses, so both routes use the same slot for these kinds. The in-process route stays narrower: no samplers, nobyte_window_srv, and array count 1 for every view.byte_window_srv, which the offline formatter also writes assrv 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_hardwarepassed 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 atexture-volume-native-inputsmode that provides the buffer descriptor and the 2D SRV token.image_sample_lzin place of the load adds a sampler, is refused with "not translated natively: a sampler, ..." and leaves the volume untouched.startup_compute_dispatch_native_warpexits 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_hardwareand_warpstill pass.half4_texture_uavand the 1D, 2D and 2D-array outputs. They share the slot code with the 3D case. The code comment anddocs/startup-runtime.mdno longer limit the route to the kinds a fixture has run through.Mutation checks, run by hand; each fails the hardware check:
buffer_srvunbound (the buffer holds a value the store fixture never writes);texture_srvunbound;AI-assisted.