Skip to content

shader: lower image_store on SQ_RSRC_IMG_2D_ARRAY in gfx2hlsl #2742

Done

Description

@triggered02

op_image_store in tools/startup/gfx2hlsl.py only lowers dim:SQ_RSRC_IMG_2D; the 2D array form is refused even though other image operations in the same translator already handle it. From a diagnostic translate log (counts only), this is the refusal for 20 compute programs:

image_store on SQ_RSRC_IMG_2D_ARRAY: only 2D images are lowered

Where it is refused

op_image_store (~line 6257 at fd033046):

if dims[0] != 'SQ_RSRC_IMG_2D':
    raise Unsupported('%s on %s: only 2D images are lowered' % (name, dims[0]))
...
if len(cs) != 2:
    raise Unsupported('%s with %d address registers: x and y expected' % (name, len(cs)))
...
image = self.pipe.uav(key, 'tex2d')
body = '%s[uint2(%s, %s)] = %s;' % (image, self.u(cs[0]), self.u(cs[1]), value)

The neighbours already do the array case: image_sample_c* accepts ('SQ_RSRC_IMG_2D', 'SQ_RSRC_IMG_2D_ARRAY') with array = dim == 'SQ_RSRC_IMG_2D_ARRAY', three address registers and tex2da; image_store/image_load mip forms accept both dims as well (line ~6104). Only the plain store is 2D-only.

What the fix should do

  • Accept dim:SQ_RSRC_IMG_2D_ARRAY in op_image_store, with three address registers (x, y, layer) instead of two.
  • Bind the resource as tex2da and store through uint3(x, y, layer):
    image[uint3(x, y, slice)] = value;
  • Keep every existing restriction: dmask:0xf only, four data VGPRs (two for the d16 compute form), integer coordinates, the per-lane exec guard, the compute fixed-table path and the pixel descriptor path.
  • SQ_RSRC_IMG_1D/3D/CUBE stay refused with the same message.

Synthetic repro and acceptance

tests/startup_compute_image_store_check.py already encodes a 2D image_store and evaluates the emitted HLSL; add the 2D-array case (three address registers, a non-zero slice in the middle of the range, a non-zero slice at the end) and pin the emitted statement shape plus the value-evaluation result. Proposed selection:

python -B tests/startup_compute_image_store_check.py
ctest --preset dev --no-tests=error -R '^startup_compute_image_store'

NOT established

  • Whether the guest ever passes a slice that needs bounds handling; the lowering should assume the bound view's array size is the limit, exactly as the sample path does.
  • The runtime view type for a 2D-array UAV is created by the caller's descriptor; this issue is about the translation only and makes no claim about the runtime side.
  • The remaining 2D-array refusals in the same census are separate: image_store with a partial dmask and the image_load array forms.

Refs #1545 (compute image_store/atomics tracking).

Activity

  1. R0Y00 commented on Nov 26, 2026

    @R0Y00
    Owner

    The current startup path needs an array UAV manifest as well as a translator change. ComputePipeline.manifest and load_compute_translation currently use the tex2d float form, and the pixel UAV path also has a 2D-only binding. The array SRV support is a useful reference for naming the shape.

    A first PR can take the full-mask FP32 compute case and keep the existing packed-half and pixel array paths refused until separately verified. Emit RWTexture2DArray with an integer x/y/layer index, preserve the per-lane EXEC guard, and bind a compatible array UAV through the existing fixed-table path. A source-built texture should give each slice a distinct sentinel. Use a view with nonzero FirstArraySlice, write the middle and last selected slices, and read back every slice after the fence. Pin the wrong-layer and dropped-EXEC controls and confirm a plain 2D view refuses the array binding before dispatch. Reuse tests/startup_compute_image_store_check.py for the encoded instruction and retain its existing 2D regression. The 20 reported programs are candidates for later runtime verification. Array UAV descriptor

  2. R0Y00 commented on Nov 26, 2026

    @R0Y00
    Owner

    The full-mask compute FP32 array translator and manifest portion is on main via #2744 (624f592). Its source-built DXC dispatch matched all 5,376 words for each array case on WARP and RTX 4060 Laptop, and omission and wrong-layer controls differed at 64 and 128 words. The startup runtime still needs to consume tex2da and resolve a real tracked UAV view. Please reuse this shader and the existing slot-67 compute fixture for the nonzero FirstArraySlice, wrong-layer, dropped-EXEC and 2D-view refusal checks above. #2742 remains open for that integration. Pixel and packed D16 arrays keep their current refusals.

  3. xiaoqi72665 commented on Nov 26, 2026

    @xiaoqi72665
    Contributor

    I'd like to take the remaining startup runtime binding for the full-mask FP32 compute array store, following the merged translator-only #2744. This is the follow-up to my collaboration comment.

    I have a local, reviewed candidate based directly on main at 624f592 (d378c2d): production tex2da UAV binding, nonzero FirstArraySlice, complete fenced readback of all six physical slices, full/partial EXEC, wrong-layer and dropped-EXEC controls, and pre-dispatch refusal of an incompatible 2D view. WARP and RX 7900 XT passed all four positive cases per adapter and the negative controls; 30/30 related CTests passed on an identical source tree, and 4/4 core tests passed after rebuilding the exact candidate. Pixel and packed D16 array stores remain refused. The local D3D12 debug layer is unavailable; the unchanged encoded shader fixture passed LLVM 15 in the upstream #2744 CI, not locally.

    I'll keep this as a narrowly scoped runtime-only follow-up and preserve the merged translator contribution. AI-assisted; source-built fixtures only. Please let me know if there is any overlapping work or a preferred adjustment to the scope.

  4. R0Y00 commented on Nov 26, 2026

    @R0Y00
    Owner

    The fixed-table FP32 compute path is now on main with #2744 (translator) and #2777 (runtime binding, 96a7b4f). The source-built dispatch uses FirstArraySlice=1, checks all six physical slices after the fence, and covers partial EXEC. WARP and RX 7900 XT matched all positive cases on d378c2d. The wrong-layer and dropped-EXEC controls differed by 128 and 32 words, and an incompatible 2D view was refused before dispatch.

    The packed D16 compute and pixel descriptor paths from the original scope still need separate proofs. The D16 case needs nonzero half values, relative layer and masked-lane controls through the tracked array UAV. The pixel case needs its own production descriptor binding and fenced readback. Please check #2755 for shared pixel work before claiming that slice. The issue stays open for these remaining forms.

  5. xiaoqi72665 commented on Nov 26, 2026

    @xiaoqi72665
    Contributor

    Thanks for the review and merge of #2777 (96a7b4f), and thanks @tedin7 for the independent WARP verification. This completes my fixed-table FP32 compute runtime-binding slice. I understand that the packed D16 compute and pixel descriptor paths remain open for separate proofs. I'll check existing claims and related PRs before taking any follow-up work.

  6. xiaoqi72665 commented on Nov 26, 2026

    @xiaoqi72665
    Contributor

    Following #2777, I would like to take only the remaining full-mask packed D16 compute 2D-array image_store proof. I plan to reuse the existing two-VGPR f16tof32 lowering and the tracked tex2da fixed-table binding, without changing the manifest or pixel path. The production slot-67/slot-14 fixture will use RGBA16_FLOAT, six physical slices, FirstArraySlice=1, relative layers 1/3, full/partial EXEC, wrong-layer/half-order/register-order/omitted-store controls, and refusal of a plain 2D UAV. I will verify LLVM 15 encodings and WARP/RX 7900 XT on Windows. #2755 is separate pixel D16 work; I will preserve its changes and coordinate any overlap in op_image_store. Refs #2742. AI-assisted; source-built fixtures only.

  7. R0Y00 commented on Nov 26, 2026

    @R0Y00
    Owner

    #2787 landed as 564f9ba. Fixed-table packed D16 compute now shares the existing tex2da runtime binding. On exact candidate 06574c9, all 12 selected CTests passed per Windows Debug/Release configuration. WARP and RTX 4060 Laptop verified 6,144 raw halfwords for each positive case with FirstArraySlice=1 and both full and partial EXEC. The wrong layer, dropped EXEC, packed-half order, and incompatible 2D view controls still distinguish failures.

    That completes the packed D16 compute slice of #2742. The pixel array descriptor and store path remains open. Please coordinate with #2755 before extending its scope.

  8. R0D4X commented on Nov 26, 2026

    @R0D4X
    Contributor

    I'd like to take the remaining open slice of #2742: the full-mask FP32 pixel-stage image_store on SQ_RSRC_IMG_2D_ARRAY (translator + startup runtime pixel array UAV descriptor binding and fenced readback).

    Plan:

    • ools/startup/gfx2hlsl.py: allow dim:SQ_RSRC_IMG_2D_ARRAY in pixel-stage op_image_store (emitting RWTexture2DArray, uint3(x, y, layer), and uav N tex2da table P O), keeping d16 compute-only and keeping 1D/3D/cube and partial dmask refused.
    • src/startup_stubs/d3d12_draw.inl: extend PixelUav,
      ead_pixel_uav_line, and pixel_uav_view to accept ex2da manifest lines and validate explicit D3D12_UAV_DIMENSION_TEXTURE2DARRAY views (bounds-checked FirstArraySlice/ArraySize, mip 0, plane 0, float-typed UAV store support, and SRV/RT conflict checks), refusing plain 2D views for ex2da and keeping ex2d behavior unchanged.
    • ests/startup_pixel_image_store_check.py, ests/startup_pixel_uav.cpp, and ests/startup_pixel_uav_check.py: add source-built 6-slice array fixtures (FirstArraySlice=1, ArraySize=4, relative layers 1 and 3, full and �_cmpx partial EXEC), complete fenced readback of all 6 physical slices and both mips, plus wrong-layer, dropped-EXEC, plain-2D-view, out-of-range array view, and manifest refusal controls.
    • Verify locally on Windows x64 (dev and
      elease, debug layer on and off) on WARP and RTX 5080, plus Python/neighbor/lint checks. Since shader: lower pixel-stage image_store with d16 in gfx2hlsl #2755 was withdrawn, there is no overlapping PR on the pixel path.

    AI-assisted; source-built fixtures only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions