Skip to content

d3d12: 1D render targets and depth buffers (created as the host does, 1D attachment views) - #4454

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
gabsilvs:agent/d3d12-1d-render-targets
Nov 23, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
gabsilvs:agent/d3d12-1d-render-targets

Conversation

@gabsilvs

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: new D3D item "1D render targets and depth buffers on the layer", #4257 (comment)

What and why

CreateCommittedResource refused every TEXTURE1D with ALLOW_RENDER_TARGET or ALLOW_DEPTH_STENCIL ("1D texture cannot be an attachment", runtime/shims/d3d12_vulkan_device.cpp). The PC runtime creates them. A differential sweep on this PC (64-texel 1D textures, formats 1..191) shows the AMD adapter and WARP both accept 64 color formats as 1D render targets and 20 formats as 1D depth-stencils. The layer refused all of them, so the TEXTURE1D/TEXTURE1DARRAY RTV and DSV code already on main (#1916) could never be reached. Derpbeat noted this on #684.

Lifting the refusal alone isn't enough. VulkanBackend::view (runtime/src/vulkan_backend.h) made every attachment view VK_IMAGE_VIEW_TYPE_2D_ARRAY, and a VK_IMAGE_TYPE_1D image can't take that view type (VUID-VkImageViewCreateInfo-subResourceRange-01021). This already breaks on main: a 1D UAV texture gets color-attachment usage for rectangle UAV clears, and with LEONIDA_VK_VALIDATION=1 its rectangle clear reports that VUID. The fix:

Tests:

  • New d3d12_texture1d_target_test (registered in CTest, exit 77 without a Vulkan GPU or under Wine). Part 1 covers 10 color formats with ALLOW_RENDER_TARGET and 4 depth formats with ALLOW_DEPTH_STENCIL, each as one texture and as a 6-layer array with a full mip chain. Wherever the host adapter and WARP both create one and the Vulkan device can make that 1D attachment image, the layer must create it, and GetResourceAllocationInfo must return a size. Part 2 runs clears and reads every subresource back against WARP, byte for byte: through TEXTURE1D and TEXTURE1DARRAY RTVs (seeded per subresource, a whole clear of one mip, rectangle clears on a slice range and on ArraySize = -1), through DSVs (whole and a rectangle), and a rectangle clear through a 1D UAV. Clear values avoid UNORM 0.5 ties, so NVIDIA's tie rounding can't cause a mismatch. A device without a 1D D32 depth attachment skips the depth clears.
  • d3d12_typeless_families_test now runs its 8 host-compared draws (GLSL stand-ins vs HLSL on the host) on a 4-texel 1D target as well as on the 4x4 2D one.
  • d3d12_vulkan_device_test expected the old refusal of a 1D render target. It now expects the texture to be created.

Tested

AMD Radeon RX 6750 XT (RDNA2), AMD driver 26.11.2, Vulkan 1.4.315, Windows 11 26300, MSVC 14.44, Vulkan SDK 1.4.363.0. "Before" means clean main 03b09a0 with only the test changes applied (a separate worktree). "After" means this branch (head c43942f, based on 03b09a0).

Check Before (main + tests) After (this branch)
d3d12_texture1d_target_test FAIL: 28 of 28 descriptions refused, color and depth clears impossible; with validation the 1D UAV rectangle clear also reports VUID-01021 PASS: 28 created, 3 of 3 readbacks equal to WARP (also PASS with LEONIDA_VK_VALIDATION=1, 0 messages)
d3d12_typeless_families_test FAIL: first 1D draw, the layer refuses the texture PASS: 82 clears and 16 draws (8 of them 1D) equal to the host, validation on, 0 messages
d3d12_vulkan_device_test FAIL at the new 1D render-target expectation PASS, with and without validation
ctest --test-dir runtime/build -j 4 154/154 on main before the new test 155/155
scripts/run_gpu_tests.py (default) 195/210 passed, 15 skipped 195/210 passed, 15 skipped
11 more D3D12 tests with LEONIDA_VK_VALIDATION=1 (texture1d, uav_clear, short_uav_clear, typeless_rtv, clear, resource_desc, draw, msaa_draw, m3_frame, subresource_copy, depth_resolve) not run PASS, 0 validation messages
python -m compileall -q make_game.py tools tests scripts PASS
Format × flag sweep (local tool, not in this PR): formats 1..191 × 1D/2D/3D × {none, RT, DS, UAV, simultaneous}, layer vs AMD + WARP 215 combinations differ 146 differ; the 1D leftovers are a subset of the 2D ones (the depth-only formats with RT, non-depth formats with DS, D3D-392's typeless depth families, and so on)

Not tested: other vendors' GPUs (NVIDIA, Intel, Apple/MoltenVK), Linux/RADV, and a device that lacks 1D depth attachments. On such a device the depth clears skip and the creation check counts those formats as "not checked". Draws into a 1D depth buffer and MSAA aren't covered (D3D12 has no multisampled 1D textures). Placed 1D textures aren't covered either (#3351).

Notes:

  • The AMD D3D12 driver (26.11.2) crashed (access violation) on descriptions whose MipLevels exceeds the full chain: CreateCommittedResource for a 64x1 1D texture with 16 mips, and GetResourceAllocationInfo for 2D and 3D ones. WARP returned normally for the same calls. This is a host driver issue, not part of this PR.
  • The sweep also found layer/host differences outside this item (sRGB, D32 and D16 textures with ALLOW_UNORDERED_ACCESS, GetResourceAllocationInfo flag checks, CreateReservedResource buffers with ALLOW_CROSS_ADAPTER). They will be posted as finding: lines, not fixed here.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not applicable: no translator change.)

AI-assisted (Claude Code, Opus). The test results above are from real runs on the hardware listed.

🤖 Generated with Claude Code

https://claude.ai/code/session_015z45kpgzff6KvVjAnLtc4h

CreateCommittedResource refused every TEXTURE1D with ALLOW_RENDER_TARGET or
ALLOW_DEPTH_STENCIL ("1D texture cannot be an attachment"), although the PC
runtime creates them: on an RX 6750 XT the AMD adapter and WARP both accept
64 color formats as 1D render targets and 20 as 1D depth-stencils. The 1D
RTV/DSV code already on main was unreachable.

Accepting them also needs a valid attachment view: VulkanBackend::view made
every attachment view VK_IMAGE_VIEW_TYPE_2D_ARRAY, which a VK_IMAGE_TYPE_1D
image can't take (VUID-VkImageViewCreateInfo-subResourceRange-01021). That
already hit rectangle clears of 1D UAV textures on main, whose UAV images
get color-attachment usage. ResourceBinding now records a 1D image, and its
attachment views are 1D arrays. A driver without the 1D attachment image
still refuses through check_image_support.

d3d12_texture1d_target_test compares creation with the host adapter and
WARP, and reads back clears through 1D and 1D-array RTVs and DSVs (whole and
rectangles, mips, slice ranges) and a 1D UAV rectangle clear against WARP.
d3d12_typeless_families_test runs its draws on a 1D target too.
d3d12_vulkan_device_test expected the old refusal.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015z45kpgzff6KvVjAnLtc4h

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built and ran d3d12_texture1d_target_test at c43942fd on Windows 11, RTX 5070 Ti: exit 0 — 28 1D target descriptions created as the references do, 0 unchecked, 3 clear readbacks compared with WARP, 0 failures (2 references).

1D render targets and depth buffers are now created like the host's, with 1D attachment views, and the typeless/device tests still build. No blocking issue.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested c43942f on NVIDIA GeForce RTX 4090 (driver 32.0.16.2101) and on AMD Radeon(TM) Graphics (driver 32.0.21043.5001), Windows 11, MSVC 14.51: pass. The build has no validation layers.

ctest -C RelWithDebInfo -R "^(d3d12_texture1d_target|d3d12_texture1d|d3d12_typeless_families|d3d12_vulkan_device)$" --output-on-failure gives 4 of 4 passed on each GPU. The typeless test ran its clears; its optional draw shaders need glslangValidator, which this build does not have.
The new test accepts 28 resource descriptions on each GPU, and all three clear readbacks match WARP. It skips no description.

Extra case: I changed the width of the clear test from 5 to 257 texels and moved the color and UAV rectangles to [255, 257). This crosses the 256-texel boundary and covers the last texel. All three readbacks still match WARP on the two GPUs.

Negative control: the test object of this head, linked with the D3D12 libraries of the merge base 03b09a08, accepts 0 of 28 descriptions and reports 30 failures on each GPU.

I found no defect. AI-assisted.

@whattheflop

Copy link
Copy Markdown
Contributor

Added RTX 3080 committed-attachment coverage at c43942f. All 24 typed descriptions created, and four whole/rectangle color and depth clear cases matched WARP and the CPU reference byte-for-byte. Zero core or synchronization diagnostics. AI-assisted.

@justr4mzi

Copy link
Copy Markdown
Contributor

Verified c43942fd on Windows 11 25H2 + discrete AMD Radeon RX 6700 XT (gfx1031, Adrenalin 26.11.2, Vulkan 1.4.315, MSVC 19.44.35230.0 RelWithDebInfo), with LEONIDA_VK_VALIDATION=1 enabled (previous runs here did not enable validation layers).

Validation & hardware results

  • ctest -R "d3d12_texture1d_target|d3d12_typeless_families" --output-on-failure:
    • Standard: 2/2 passed (0.88 s, 1.96 s).
    • LEONIDA_VK_VALIDATION=1: 2/2 passed (0.42 s, 1.90 s).
  • Direct d3d12_texture1d_target_test.exe (both standard and LEONIDA_VK_VALIDATION=1 + VK_LAYER_KHRONOS_validation, 0 validation errors):
    • 1D targets: 28 descriptions created as the references do, 0 not checked (Vulkan device), 3 clear readbacks compared with WARP, 0 failures (2 references)
  • Direct d3d12_typeless_families_test.exe (LEONIDA_VK_VALIDATION=1, 0 validation errors):
    • 82 clears compared with AMD Radeon RX 6700 XT, 0 differ; 0 view formats skipped; WARP differs from the host in 0
    • 16 draws compared with AMD Radeon RX 6700 XT, 0 differ (all 1D draw cases match host & WARP)
  • Docs & hygiene checks: all 7 tests/test_docs_*.py suites passed (7/7), scripts/check_no_game_data.py (rc=0), git diff --check clean.

AI-assisted (Gemini, Antigravity).

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.

6 participants