Repository navigation
d3d12: ArraySize -1 in 2D-array RTVs and DSVs is every slice from the first on (the layer nulled or refused such views) - #3835
Conversation
… first on
CreateRenderTargetView and CreateDepthStencilView stored ArraySize -1 of a
TEXTURE2DARRAY or TEXTURE2DMSARRAY view as the layer count, so the view was
nulled (typeless and castable RGBA8) or the list was refused at replay. The
host accepts it and clears the remaining slices. Resolve it at creation;
out-of-range views are refused as before. d3d12_view_slices_test compares
clears through such views with the host on the same adapter and WARP.
d3d12_typeless_rtv_test listed {first slice 1, ArraySize -1} on a four-slice
texture among the views the layer must reject; the host accepts that view, so
the entry now uses first slice 4, which the host refuses too.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
kacper-serewis
left a comment
There was a problem hiding this comment.
At 0fa95b9, 40 independent WARP descriptor controls and 18 clear/readback controls passed. UINT_MAX and explicit remaining counts addressed identical slices for single- and multisample RGBA8 RTVs and single-sample D32 DSVs. Multisample D32 coverage was descriptor validation only. No physical GPU. AI-assisted.
|
Tested 0fa95b9 on RTX 4070 Ti SUPER (driver 617.42, Windows 11, MSVC 14.42): pass. This is the physical-GPU run the review above didn't have.
Built with cl.exe at /W4 /permissive-, no warnings. Not run: AI-assisted. |
|
Tested 0fa95b9 merged onto main 03b09a0 on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:
AI-assisted (Claude Code). |
|
D3D-416/D3D-418: updated to Both view-slices and typeless-RTV tests pass with Vulkan validation enabled on Radeon (driver 32.0.21042.62) and RTX 3070 (NVIDIA 610.74), with zero validation errors. Each view-slices run checks 21 layer clears, 39 host/WARP clears and rejection of 42 invalid views, with zero failures. Three CPU tests and 23 registration/documentation tests also pass. The existing limitation remains: 4x depth uses descriptor/list checks rather than per-slice readback. No game files; synthetic inputs. AI-assisted (Codex). |
|
Tested db0dfa5 on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran AI-assisted. |
|
Tested db0dfa5 on NVIDIA GeForce RTX 3070 (Ampere), driver 610.88, Windows 11 Pro 10.0.26200: pass
Built with MSVC through |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Closing: everything here is on AI-assisted. |
Claimed in the coordination issue as: #3796 (comment) (new D3D item; found while checking #3594)
What and why
ArraySize= -1 (UINT_MAX) in aTEXTURE2DARRAYorTEXTURE2DMSARRAYrender-target or depth-stencil view means "every slice fromFirstArraySliceon".CreateRenderTargetViewandCreateDepthStencilViewstored the -1 as the layer count, so the view was never usable: a typeless or castable RGBA8 RTV was nulled at creation (ClosereturnedE_INVALIDARG), and every other RTV and DSV made the list fail at replay withinvalid_subresource, so nothing in thatExecuteCommandListswas submitted.The fix resolves -1 to the remaining slice count when the view is created (
view_slices, four call sites inruntime/shims/d3d12_vulkan_device.cpp). Nothing else changes: -1 with a first slice past the array, a count of 0, a count longer than what is left andUINT_MAX - 1are kept as given and refused exactly as before (an explicit over-long range still fails at replay, not at creation, whichd3d12_vulkan_device_testexpects).1D-array RTVs and DSVs (
line_target_view) and 3D RTVs (volume_rtv) already resolved -1, and SRVs and UAVs clamp the count; those are not touched.d3d12_typeless_rtv_testlisted{FirstArraySlice 1, ArraySize UINT_MAX}on a four-slice texture among the views the layer must reject. That expectation was never compared with the host, which accepts the view, so the entry now uses first slice 4 (past the array), which the host refuses too.Measured
Host, D3D12 debug layer, error messages per
Create*Viewcall (RTX 3070, Radeon iGPU and WARP give the same answers): -1 is accepted with first slice 0, 1 and 3 of 4 for RTV and DSVTEXTURE2DARRAY,TEXTURE2DMSARRAYandTEXTURE1DARRAY, at mip 0 and mip 1, typed and typeless. Refused with an error: first slice 4 orUINT_MAXwith -1,ArraySize0, 2 slices from slice 3, 5 slices from slice 0, andUINT_MAX - 1.Host, clear and readback (
d3d12_view_slices_test, same adapter as the layer and WARP): a clear through a view with -1 reaches every slice from the first on, in the view's mip only. 39 host clears per run match that (7 texture kinds x 3 first slices x 2 references, less the 3 that would need a depth resolve on WARP).Layer, before (
f847748c), both GPUs: all 21 clears through a -1 view fail. 6 (typeless RGBA8, 1x and 4x) withClose failed 0x80070057, 12 withthe layer refused the list (ReplayResult 3), and the 3 of the 4x depth array on the descriptor check.Layer, after, both GPUs: 21 of 21 pass, and the 42 out-of-range views (6 ranges x 7 texture kinds) are still refused.
d3d12_view_slicesbeforectest -R "^d3d12_"beforeThe only difference between the two ctest runs is the new test. Skipped in both:
d3d12_first_light(both GPUs) andd3d12_rgb9e5_rtv(RTX 3070).One thing the new test works around: the layer's 4x depth array is checked by its descriptor (the same bytes as the view that counts the remaining slices, and the list runs) instead of by readback. Read through the layer's depth resolve on the Radeon, every slice of such a texture shows slice 0, with a counted
ArraySizeas well (a clear of slice 0 alone reads back as all four slices, a clear of slice 1 alone as none); on the RTX 3070 the same readback is right. That is a separate problem in the multisampled depth clear or resolve path, not in the view, and is reported as a finding in the same coordination comment as the claim.Tested
Windows 11 (26200), MSVC 14.50 (VS 2026), Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Each command once with
LEONIDA_VK_DEVICE=radeonand once withLEONIDA_VK_DEVICE=3070,LEONIDA_HOST_ADAPTERunset.The new test built against the layer without the fix fails on both GPUs (21 failures, none on the host side). The unchanged
d3d12_typeless_rtv_testfails with the fix atline 263: list->Close() == E_INVALIDARG(run on the Radeon), which is the entry changed here.Checklist
docs/design.md, with how it was confirmed. (Not a translator rule.)Not checked: draws through a -1 view (only clears), stencil clears, the Xbox-ABI proxy, Wine, and any GPU other than the two above. SRV and UAV handling of -1 was read, not run.
AI-assisted.