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