Skip to content

runtime: render-target views of a multisample texture array's slice range - #754

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
rafaelpssz:d3d-rtv-ms-array
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
rafaelpssz:d3d-rtv-ms-array

Conversation

@rafaelpssz

Copy link
Copy Markdown
Contributor

Item: new D3D item, claimed in #634 (#634 (comment)). Follow-up to #683, suggested by @Derpbeat there.

Change

CreateRenderTargetView refused D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY, so after #683 a multisample array could be a depth target but not a colour target. The view is {resource, mip 0, FirstArraySlice, ArraySize}, as for the DSV in #683. The replay already checks the range against the image and clears through a view of those layers, so nothing else changes.

docs/d3d12_vulkan.md: the RTV/DSV bullet now lists TEXTURE2DMSARRAY for both.

Test

d3d12_vulkan_device_test, after #683's DSV case: a 4-layer 4x R8G8B8A8_UNORM target.

  • Cleared red through a whole-array view, then green through a view of slices 1-2 (whose descriptor captures exactly that range).
  • Every slice is resolved into a single-sample 4-layer texture and read back, 8x8 texels per slice: slices 0 and 3 must be red, 1 and 2 green. Unlike the depth case, colour can be resolved, so this checks the pixels, not just the replay result.
  • A view of slices 3-4 is refused at execute (invalid_subresource).

Without the change the test fails at the captured-range check (line 1774); with it the whole test passes.

Tested on Windows 11, RTX 3060 (NVIDIA 616.64), clang-cl 23 + lld-link against the MSVC 14.44 CRT and Windows SDK 10.0.26100, on main 67204bf: ctest 23/23. No game files.

By @rafaelpssz, with Claude Code (AI-assisted).

…ange

CreateRenderTargetView refused D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY, so after the DSV change in
ItsNotRexed#683 a multisample array could be a depth target but not a colour target (found by @Derpbeat on
ItsNotRexed#683). The view is {resource, mip 0, FirstArraySlice, ArraySize}, as for the DSV; the replay
already checks the range and clears through a view of those layers.

d3d12_vulkan_device_test: a 4-layer 4x RGBA8 target is cleared red through a whole-array view and
green through a view of slices 1-2; every slice is resolved and read back, so slices 0 and 3 must
stay red and 1-2 green. A view of slices 3-4 is refused at execute (invalid_subresource). Without
the change the test fails at the captured-range check.

docs/d3d12_vulkan.md: the RTV/DSV bullet lists TEXTURE2DMSARRAY for both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Verified rectangle clears and reuse of one CPU RTV descriptor on 276a9e9. RTX 5080, driver 616.92, Windows 11, Khronos validation enabled. The stock device test passed.

In a source-built extension of the 4× MSAA RGBA8 test I cleared the four 8×8 slices red, then recorded a green [1,6) × [2,7) clear using slices 1–2. Before submitting that command list, I rewrote the same CPU RTV handle to slices 2–3 and recorded a blue [3,7) × [0,5) clear. Each slice was resolved and copied to readback. All 256 pixels, including alpha, matched their expected positions.

Slice Red Green Blue
0 64 0 0
1 39 25 0
2 28 16 20
3 44 0 20

Omitting just the descriptor rewrite made exactly 40/256 pixels differ: the 20 blue pixels landed on slice 1 instead of slice 3. This exercises the rectangular attachment-clear path and confirms the first command retained its original layer range after the handle was reused. Validation reported no errors in the passing run.

@rafaelpssz

Copy link
Copy Markdown
Contributor Author

Thanks @Vonsek. The handle-rewrite case is a good addition: it confirms the recorded clear keeps the TargetView it captured (command_list.h: views are captured by value while recording), and the rectangle clears cover the attachment-clear path that the in-tree test, with whole-slice clears, doesn't reach.

@ismailchaka1

Copy link
Copy Markdown
Contributor

Tested 276a9e9 on an NVIDIA GeForce RTX 4070 SUPER, driver 32.0.16.1088, Windows 11, MSVC 2022 (Ninja, RelWithDebInfo), LEONIDA_VK_VALIDATION=1: pass.

PR head as-is, no game files. AI-assisted.

@ItsNotRexed
ItsNotRexed merged commit 69ed76d into ItsNotRexed:main Nov 22, 2026
8 of 9 checks passed
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.

4 participants