Repository navigation
startup: lower compute image_store to 1D and 3D texture UAVs (Part of #2022) - #2902
Conversation
A compute image_store with dmask 0xf on SQ_RSRC_IMG_3D or SQ_RSRC_IMG_1D now lowers to a store into RWTexture3D<float4> (a three-component address, as a VGPR tuple or an NSA list) or RWTexture1D<float4> (one component), on the same terms as the 2D path: format, unorm, data registers and the fixed table descriptor. The manifest names the output uav N tex3d|tex1d. Partial dmasks, d16 with a partial dmask and 1D/3D stores in the pixel stage stay refused. At Dispatch the runtime parses tex1d and tex3d outputs, keeps the title's own view description, and checks the view and resource dimensions, the mip and, for 3D, the W range against the depth at that mip. Slot 19 records a 3D view with an out-of-range W selection as refused instead of creating it, so Dispatch reports that reason. Refused requests are retried by --pending, so the compute cache revision is unchanged. AI-assisted.
… view Device slot 19 checked only 3D views before calling the desktop CreateUnorderedAccessView, so a 1D view whose mip is outside the resource reached D3D12 with an invalid description, and Dispatch reported the mip reason only if that view was recorded as created. Slot 19 now records such a 1D view as refused, and Dispatch checks the 1D mip before the created test, as it does for 3D. The dispatch check adds a texture-line-bad-mip case. Found in an independent review. AI-assisted.
KelboLive
left a comment
There was a problem hiding this comment.
PR #2902 — Review Notes
✅ What looks good
1. Translator is clean and conservative (tools/startup/gfx2hlsl.py)
- The
shapesdictionary approach is nice — it keeps 2D/2D-array for all stages and adds 1D/3D only for compute (self.kind == 'cs') - Pixel stage correctly still refuses 1D/3D with the updated
supportedstring - Refused error messages updated:
'only 2D images'→'only 1D, 2D, 2D-array and 3D images'
2. Runtime validation is thorough (d3d12_compute_dispatch.inl)
- The
volume_uav_range_error()helper correctly validates:- 3D mip vs resource mip levels
- 3D W-range:
FirstWSlice >= depth,WSize == 0, orWSize > remaining slices - Also handles the special
WSize == ~0ucase (selects remaining slices)
- 1D validation checks mip against
resource.MipLevels - Distinguishes between resource/view dimension mismatch and range errors
3. Tests are well-designed
startup_gfx2hlsl_image_store_3d1d_check.pycovers 3 forms: volume (3D tuple address), volume-nsa (3D NSA), line (1D scalar address)- Mutation checks: dropping 3rd coordinate, mapping 1D to 2D, partial dmasks
- The dispatch test correctly checks:
- Mip-one readback with correct expected values
- Refusals for 2D-view-in-place-of-3D, out-of-range W, 1D-view past last mip
- Refused dispatch leaves texels sentinel-unchanged
4. Documentation is clear
- New
docs/experiments/startup-compute-volume-line-uav.mdexplains the feature startup-runtime.mdupdate fits the existing pattern
⚠️ Issues to consider
1. Code duplication: volume_uav_range_error() exists in two files
This function appears in both d3d12_compute_dispatch.inl (for manifest loading) and d3d12_xs_device.cpp (for slot-19 view creation). Maintenance risk — consider consolidating into a shared utility or making it inline/static accessible to both translation units.
2. The startup_compute_image_store_d16_check.py deletion shows the test no longer refuses 3D in the d16 path. Is this intentional — does the d16 path support 3D as well, or was the old refusal test simply removed because it's no longer relevant? If it's intentional, a brief comment would help future maintainers.
🏷 Recommendations
| Priority | Action |
|---|---|
| Medium | Check that the volume_uav_range_error() duplication doesn't need consolidation |
| Low | Consider adding a test case where WSize == ~0u (selects remaining slices) for the 3D case |
| Info | The census data at the end is useful — 291→317 translated, 0 refusals remaining |
Overall verdict
Clean, well-tested PR. The translator and runtime changes are conservative (refusals when expected), the mutation checks validate correctness, and the documentation matches the code. Ready for merge pending the duplicate function check.
The d16 path with dmask 0xf unpacks two data registers into the four channels, low half first, for 3D and 1D images as it does for 2D. The 3D/1D check now asserts that store for the tuple, NSA and 1D forms. AI-assisted.
|
Thanks for the review.
AI-assisted. |
KelboLive
left a comment
There was a problem hiding this comment.
What works
- Clear feature progression: this PR correctly extends the 2D
image_store path to 1D and 3D, part of the tracked #2022 effort.
Translator lowering is clean -- full-channel (dmask:0xf) stores on
both dimensions are lowered with proper address computation (VGPR
tuple for 3D, scalar uint or NSA list for 1D). - Good design choice replacing the
arraybool with
uav_dimension = D3D12_UAV_DIMENSION_enum in
ComputeTranslation. This removes ambiguity for 1D wherearray
previously had no meaning. - Test coverage is thorough:
volume(3D VGPR tuple),
volume-nsa(3D NSA list), andline(1D) forms are all tested,
with readback verification against a CPU reference. - The volume_uav_range_error() in d3d12_compute_dispatch.inl is
correct -- it checks MipSlice against MipLevels and validates
FirstWSlice/WSize for the 3D case, using the same pattern as the
existing resource-type checks in view_slot().
Issues
- In
d3d12_compute_dispatch.inl, theuav_dimensionlambda
recognizes tex1d/tex2d/tex2da/tex3d in the manifest output line.
Theif constexprpath in dispatch uses the dimension to choose
the correct resource desc (e.g., DepthOrArraySize for 3D). Verify
that the manifest for 1D UAVs doesn't accidentally set arrays when
the title expects a contiguous 1D view. - The
volume_uav_range_errorfunction is defined inside a
const char* block -- make sure this placement is intentional and
not accidentally scoped to a local function or if block. - Updated
startup_compute_image_store_check.pynow expects
only 1D, 2D, 2D-array and 3D imagesas the refusal reason for
cube. This is an API-visible change to the refusal message --
ensure any downstream consumers parse the message string or match
by keyword, not by exact equality.
Recommendations
- Consider adding a test for a mismatched 3D W range (wrote beyond
the slice window) in addition to the out-of-range slice test. - The 1D validation only checks MipSlice. Consider future-proofing
with WSize validation in case 1D views are extended later. - The
volume_uav_range_errorfunction might benefit from a
comment noting that WSize of all ones means 'remaining slices'.
Overall
Solid, well-scoped feature extension. The design is clean, test
coverage is good, and the array -> uav_dimension refactor is
a welcome improvement. Approvable after the message-matching concern
is confirmed (issue 3).
R0Y00
left a comment
There was a problem hiding this comment.
Integration check for 4d99af0e: current main 6aa59440 conflicts in docs/startup-runtime.md, src/startup_stubs/d3d12_compute_dispatch.inl, and tools/startup/gfx2hlsl.py. A separate merge trial with #2975 conflicts in tests/startup_compute_dispatch_texture_check.py. Please keep the existing root-SRV and manifest-retry paths when updating this PR. The Python translator/offline and native C++ fixtures can share the accepted shape while retaining their separate compiler routes and WARP capability reporting.
# Conflicts: # docs/startup-runtime.md # src/startup_stubs/d3d12_compute_dispatch.inl # tools/startup/gfx2hlsl.py
|
Merged
After the merge, AI-assisted. |
R0Y00
left a comment
There was a problem hiding this comment.
Independent integration review of ea94c5a4 on current main 98e4a2ee (83776998 locally). The earlier three conflicts are resolved. The reconciled code retains the root-SRV and manifest-retry paths and the existing 2D/2D-array and partial pixel-store behavior.
I rebuilt startup_stream_consumer and d3d12_xs_shim in both dev and release (/O2). In each preset, ctest --preset <preset> --no-tests=error -R '^(startup_compute_dispatch_texture_(warp|hardware)|startup_gfx2hlsl_image_store_3d1d|startup_compute_image_store(_d16)?|startup_compute_root_srv_dispatch_(warp|hardware))$' passed all seven tests in two invocations, with no skips. The texture cases checked the 1D/3D mip-one readback plus the wrong-view, bad-W and bad-mip refusals. The root-SRV cases retained the nonzero-offset readback and rejection controls. Windows 11 build 26200.9974, RTX 4060 Laptop driver 32.0.16.1656, WARP 10.0.26100.9818, D3D12 debug layer enabled for the GPU fixtures.
Hosted Windows, Linux Python and gfx1013 fixture checks are green. The hosted /O2 job skipped and local /O2 passed. As discussed, keep the two compiler routes when reconciling the shared texture fixture with #2975 on cpp-migration. I also found overlap with #2882 in the texture fixture and stream consumer. I will record the required reconciliation on that PR.
…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)
Part of #2022 (claim). The runtime half takes over the
tex3d/tex1dpart of the "Texture UAVs" item in #2274 (NiiRoZz), as announced there.Translator (
tools/startup/gfx2hlsl.py): a computeimage_storewithdmask:0xflowers to:RWTexture3D<float4>onSQ_RSRC_IMG_3D, with a three-component address given as a VGPR tuple or an NSA list;RWTexture1D<float4>onSQ_RSRC_IMG_1D, with one component.It is accepted on the same terms as the 2D path: format,
unorm, data registers, fixed table descriptor. The manifest names the outputuav N tex3d|tex1d float table P O channels 4. Partial dmasks (with or withoutd16) and 1D/3D stores in the pixel stage stay refused.Runtime (
src/startup_stubs/d3d12_compute_dispatch.inl,d3d12_xs_device.cpp):tex1dandtex3doutputs. The slot'sarrayflag becomes a UAV dimension, and 2D and 2D-array behave as before.WSizeall ones selects the remaining slices).--pending(and by the first--watchpass), so the compute cache revision is unchanged (as in shader: lower image_store on SQ_RSRC_IMG_2D_ARRAY in gfx2hlsl #2744).Tests (Windows 11, Python 3.14, DXC from the Windows SDK 10.0.26100, on main
6ee878d8plus this commit):tests/startup_gfx2hlsl_image_store_3d1d_check.py: ok. It checks:d16.tests/startup_compute_dispatch_texture_check.py <startup_stream_consumer> <dxc> warpandhardware: ok on WARP (Microsoft Basic Render Driver) and an NVIDIA GeForce RTX 5080. New cases:startup_compute_image_store_check,startup_compute_image_store_d16_check,startup_gfx2hlsl_compute_check,startup_pixel_image_store_check,startup_translator_check,startup_gfx2hlsl_refusals_check,startup_compute_request_offline_check,docs_links_check,bidi_controls_check.Mutation checks, run by hand:
Measured on a local capture (counts and instruction shape only):
b505c32, 291 requests translate. With this branch on6ee878d8(b505c32..6ee878d8does not touchgfx2hlsl.py), 317 translate and noimage_store on SQ_RSRC_IMG_3D|1Drefusal remains.6ee878d8, three compute pipelines dispatch with no translation 16,798, 687 and 687 times. Their first refusal is this store. With this branch all three translate and compile with DXC. Their manifests use only forms the runtime binds: raw buffers, one 2D texture input and the new 3D or 1D output.Prior art in the offline
tools/compute_store_aot.py: 3D stores (#1649) and the 1D slice (#1545).AI-assisted.