Skip to content

[DX] RWTexture2DArray follow-up (#1077)#1239

Draft
alsepkow wants to merge 8 commits into
llvm:mainfrom
alsepkow:alex/dx-tex-array-1077
Draft

[DX] RWTexture2DArray follow-up (#1077)#1239
alsepkow wants to merge 8 commits into
llvm:mainfrom
alsepkow:alex/dx-tex-array-1077

Conversation

@alsepkow

@alsepkow alsepkow commented May 27, 2026

Copy link
Copy Markdown
Collaborator

EXPERIMENTAL - NOT FOR REVIEW

AI-assisted exploration driving design discussion for llvm/wg-hlsl#400. Not intended for review/merge in current form.

Implements DX backend support for #1077 (Texture2DArray + RWTexture2DArray).

Texture2DArray Load support landed earlier in 4774832. This PR adds RWTexture2DArray UAV creation, per-slice upload, and bind/readback, plus unifies the NumSlices upload loop for both the SRV and UAV paths.

Tests: RWTexture2DArray.Store.test PASS on d3d12.

Remaining on parent #1077 (not in this PR):

  • VK parity: arrayLayers on the image, VK_IMAGE_VIEW_TYPE_2D_ARRAY, per-slice upload/readback.
  • Multi-mip Texture2DArray / RWTexture2DArray (per-slice mip chain, (mip, slice) subresource indexing).
  • Shared upload helper handling non-256-aligned widths via D3D12_TEXTURE_DATA_PITCH_ALIGNMENT.
  • Texture1DArray, TextureCubeArray, RWTextureCubeArray (tracked in [DRAFT] [DirectX] Texture1DArray + TextureCubeArray + RWTextureCubeArray support #1267).

Refs #1077


Assisted by Claude Opus 4.7.

alsepkow and others added 8 commits May 26, 2026 19:50
Adds a new `Texture2DArray` `ResourceKind` and wires it through the
DirectX backend so shaders can `Load` from layered SRVs:

* `OutputProperties` gains an `ArraySize` field (default 1) and the
  YAML size validation now accounts for it.
* `getResourceDescription` sets `DepthOrArraySize` from
  `ArraySize` for `Texture2DArray` resources and rejects mismatched
  uses of `ArraySize > 1` on non-array kinds.
* `getSRVDescription` emits a `TEXTURE2DARRAY` view covering all
  slices.
* The upload path enumerates slices via `CopyTextureRegion` with a
  per-slice `D3D12_PLACED_SUBRESOURCE_FOOTPRINT`; the host-side data
  layout is tightly packed slice-major (slice0 rows | slice1 rows |
  ...).

Vulkan and Metal switches gain `Texture2DArray` cases for build
completeness; their device implementations remain TODO and the new
test is gated `UNSUPPORTED: Vulkan || Metal`.

Adds `Feature/Textures/Texture2DArray.Load.test.yaml` exercising a
2x2x3 array with `Load(int4)` and offset variants. Verified passing
on d3d12 (NVIDIA RTX 5060 Ti) and warp-d3d12.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Picks up the DriverVer fix (upstream llvm#1228) so clang-tidy stops failing on Device.cpp.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Extends Texture2DArray support to RWTexture2DArray:

- Pipeline.h: add ResourceKind::RWTexture2DArray; update isTexture, isUAV, getDXKind, getDXDimension switches and YAML enum trait.

- Enums.h: API enum value.

- DX/Device.cpp: createUAV uses D3D12_UAV_DIMENSION_TEXTURE2DARRAY with FirstArraySlice=0 and ArraySize from OutputProperties. Multi-slice readback via per-slice CD3DX12_TEXTURE_COPY_LOCATION with placed footprint offset (note: requires Width*ElementSize to be 256-aligned; documented in issue plan).

- VK/Device.cpp, MTL/MTLDevice.cpp: llvm_unreachable placeholders.

Test: RWTexture2DArray.Store.test.yaml verifies a 16x4x2 compute write/readback round-trip.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fixes misc-const-correctness warnings-as-errors from clang-tidy in CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Clang HLSL does not yet implement the Texture2DArray / RWTexture2DArray
templates.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant