startup: lower compute image_store to 1D and 3D texture UAVs (Part of #2022) #2902
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2902"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-26T18:12:27Z.
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 #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.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-26T20:37:56Z.
Review: COMMENTED
PR #2902 — Review Notes
✅ What looks good
1. Translator is clean and conservative (
tools/startup/gfx2hlsl.py)shapesdictionary approach is nice — it keeps 2D/2D-array for all stages and adds 1D/3D only for compute (self.kind == 'cs')supportedstring'only 2D images'→'only 1D, 2D, 2D-array and 3D images'2. Runtime validation is thorough (
d3d12_compute_dispatch.inl)volume_uav_range_error()helper correctly validates:FirstWSlice >= depth,WSize == 0, orWSize > remaining slicesWSize == ~0ucase (selects remaining slices)resource.MipLevels3. 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)4. Documentation is clear
docs/experiments/startup-compute-volume-line-uav.mdexplains the featurestartup-runtime.mdupdate fits the existing pattern⚠️ Issues to consider
1. Code duplication:
volume_uav_range_error()exists in two filesThis function appears in both
d3d12_compute_dispatch.inl(for manifest loading) andd3d12_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.pydeletion 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
volume_uav_range_error()duplication doesn't need consolidationWSize == ~0u(selects remaining slices) for the 3D caseOverall 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.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-26T20:42:33Z.
Thanks for the review.
volume_uav_range_error()has a single definition, insrc/startup_stubs/d3d12_compute_dispatch.inl.d3d12_xs_device.cppincludes that file (#include "startup_stubs/d3d12_compute_dispatch.inl") before slot 19 calls it, so both callers are in the same translation unit and share the one definition.startup_compute_image_store_d16_check.pywere a control asserting that a d16 store to a 3D image is refused withonly 2D images. That is intentional: with the full mask, d16 now takes the same packed-half path for 3D and 1D as for 2D, and partial masks, with or without d16, stay refused. You are right that nothing checked the accepted case, so I added it in4d99af0e:tests/startup_gfx2hlsl_image_store_3d1d_check.pynow asserts the d16 full-mask store for the tuple, NSA and 1D forms. A mutant that drops thef16tof32unpack fails it.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T05:45:55Z.
Review: COMMENTED
What works
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).
arraybool withuav_dimension = D3D12_UAV_DIMENSION_enum inComputeTranslation. This removes ambiguity for 1D wherearraypreviously had no meaning.
volume(3D VGPR tuple),volume-nsa(3D NSA list), andline(1D) forms are all tested,with readback verification against a CPU reference.
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
d3d12_compute_dispatch.inl, theuav_dimensionlambdarecognizes tex1d/tex2d/tex2da/tex3d in the manifest output line.
The
if constexprpath in dispatch uses the dimension to choosethe 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.
volume_uav_range_errorfunction is defined inside aconst char* block -- make sure this placement is intentional and
not accidentally scoped to a local function or if block.
startup_compute_image_store_check.pynow expectsonly 1D, 2D, 2D-array and 3D imagesas the refusal reason forcube. 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
the slice window) in addition to the out-of-range slice test.
with WSize validation in case 1D views are extended later.
volume_uav_range_errorfunction might benefit from acomment 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_dimensionrefactor isa welcome improvement. Approvable after the message-matching concern
is confirmed (issue 3).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T06:00:20Z.
Review: COMMENTED
Integration check for
4d99af0e: current main6aa59440conflicts indocs/startup-runtime.md,src/startup_stubs/d3d12_compute_dispatch.inl, andtools/startup/gfx2hlsl.py. A separate merge trial with #2975 conflicts intests/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.Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-27T06:16:54Z.
Merged
main6aa59440into this PR and resolved the three conflicts:d3d12_compute_dispatch.inl: the UAV slot keeps this PR'suav_dimension, and #2953'srootfield and root SRV paths stay as they are. The header comment lists both thesrv <i> buf root <param>inputs and the 1D/3D outputs. The manifest retry from #2925 is untouched.gfx2hlsl.pyimage_store: #2661's partial pixel-stage stores and this PR's 1D/3D compute stores are both kept.arrayis derived from the shape (tex2da), the view type comes from the shape, and 1D uses a scalaruintindex. The sparse rule (pixel 2D only) is unchanged.docs/startup-runtime.md: both bullets.After the merge,
ctest -R "startup_compute|startup_pixel_image_store|startup_manifest_retry|image_store|compute_root_srv|startup_gfx2hlsl_compute"passed 235 of 235 (Release, RTX 5080 and WARP). This merge does not resolve the conflicts with #2975 (based oncpp-migration). Its branch conflicts with this one intests/startup_compute_dispatch_texture_check.py, and withmainind3d12_compute_dispatch.inl. Both come up whenmainis merged intocpp-migrationonce the two PRs have landed. I will resolve them then, keeping both the Python and thecompile_dxilroutes in the test.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T06:28:54Z.
Review: APPROVED
Independent integration review of
ea94c5a4on currentmain98e4a2ee(83776998locally). 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_consumerandd3d12_xs_shimin bothdevandrelease(/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
/O2job skipped and local/O2passed. As discussed, keep the two compiler routes when reconciling the shared texture fixture with #2975 oncpp-migration. I also found overlap with #2882 in the texture fixture and stream consumer. I will record the required reconciliation on that PR.