Skip to content

d3d12: create 1D textures and 1D arrays - #561

Closed
Ayinaki wants to merge 1 commit into
ItsNotRexed:mainfrom
Ayinaki:d3d63-1d-textures
Closed

Ayinaki wants to merge 1 commit into
ItsNotRexed:mainfrom
Ayinaki:d3d63-1d-textures

Conversation

@Ayinaki

@Ayinaki Ayinaki commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

D3D-63, claimed on #374.

What this fixes

CheckFeatureSupport already reported TEXTURE1D, but every 1D CreateCommittedResource fell into the unsupported-dimension branch and returned E_INVALIDARG, so the reported support could not be used.

  • CreateCommittedResource now creates 1D images with a height-one extent and 1D arrays with the requested layer count. It rejects a non-unit height and the render-target/depth-stencil flags (D3D12 does not allow 1D attachments) with E_INVALIDARG.
  • GetCopyableFootprints uses a one-row footprint for 1D subresources, so mips and array layers get offsets that match the PC runtime.
  • GetResourceAllocationInfo accepts 1D and 1D arrays too; without this, code that asks for the allocation size before creating the resource would still fail. A 1D render-target description gets a size from allocation, as it does on the PC runtime, and is rejected at creation.

Tests

runtime/test/d3d12_vulkan_device_test.cpp now covers:

  • host GetResourceAllocationInfo comparisons for a mipmapped 1D texture, a 1D array, and a 1D render target, plus the invalid two-row 1D description;
  • host GetCopyableFootprints comparisons for a 4-mip 1D texture and a 3-layer 1D array;
  • creation assertions for dimension, height, array layers and the Vulkan image, and E_INVALIDARG for a two-row 1D texture and a 1D render target;
  • an upload/readback round trip through CopyTextureRegion for eight texels in a 1D texture and four texels in layer 1 of a 1D array.

Run on Windows 10.0.26200.9711, NVIDIA RTX 5070, driver 616.86, LEONIDA_VK_VALIDATION=1:

allocation info 1D 13 full chain: alignment 65536, size ours 65536 host 65536
allocation info 1D array 5x3: alignment 65536, size ours 65536 host 65536
allocation info 1D render target: alignment 65536, size ours 65536 host 65536
...
Vulkan device behind the Xbox-ABI proxy: ... GetCopyableFootprints and GetResourceTiling all matched
TEST_EXIT=0

No game files.

@Ayinaki

Ayinaki commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

The only red check is linux-gpu-tools: llvmpipe reports an 8-lane subgroup, and cs_wqm_w32 assumes 32 lanes. That is the known TEST-78 failure tracked in #555, unrelated to this 1D texture path. All other checks pass on b9db201.

@oVolkra

oVolkra commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested b9db201 on NVIDIA GeForce RTX 3060, driver 617.14, Windows 11: pass

Setup: Windows 11 Pro 24H2 (10.0.26100), RTX 3060 (Ampere), NVIDIA 617.14, MSVC 14.44.35207 + Windows SDK 10.0.26100, Ninja RelWithDebInfo, Khronos Vulkan-Headers 1.4.369, VK_LAYER_KHRONOS_validation 1.4.357. PR head built as-is (not rebased; it conflicts with main c432cdc now).

Build: 0 errors, 0 warnings. ctest: 24/24, also with LEONIDA_VK_VALIDATION=1.
d3d12_vulkan_device_test: exit 0. New lines compared with main: allocation info 1D 13 full chain, 1D array 5x3 and 1D render target, each with alignment 65536 and size 65536 for both ours and the host.
With LEONIDA_VK_VALIDATION=1: 0 messages from the validation layer (see below).
About the LEONIDA_VK_VALIDATION=1 exit code: on this machine the test prints "3 validation errors" and exits 1 on main c432cdc too. All three are Vulkan loader messages ("loader_get_json: Failed to open JSON file") for stale implicit-layer registry entries of uninstalled overlays, not messages from the validation layer. The validation layer itself reported 0 messages, the same as on main.

AI-assisted: the build and test runs were done with an AI coding assistant (Claude Code) on my machine; the numbers above are its unedited output.

@Ayinaki

Ayinaki commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased to 0067da5 on main c432cdc. All nine checks now pass, including linux-gpu-tools: cs_wqm_w32 and cs_w32_lane_wrap now skip on llvmpipe's 8-lane subgroup, so the earlier note is no longer current. The PR is clean and mergeable.

ismailchaka1 added a commit to ismailchaka1/Leonida that referenced this pull request Nov 22, 2026
…rs it

D3D-79 was split: multisample arrays are D3D-83 in ItsNotRexed#683. This PR keeps
the TEXTURE1D and TEXTURE1DARRAY views, which wait for 1D textures (ItsNotRexed#561).
ItsNotRexed pushed a commit that referenced this pull request Nov 22, 2026
…ange (D3D-79 part 1)

CreateDepthStencilView refused D3D12_DSV_DIMENSION_TEXTURE2DMSARRAY, so the descriptor held an
empty TargetView and any clear through it failed when the list was recorded. Multisample textures
have one mip, so the view is {resource, mip 0, FirstArraySlice, ArraySize}; the replay already
checks the range against the image and clears through a view of those layers.

d3d12_vulkan_device_test: a 4-layer 4x multisampled D32 texture, a view of slices 1-2 captures
that range and its clear replays; a view of slices 3-4 is refused at execute
(invalid_subresource). D3D12 can't copy a multisampled texture to a buffer, so the cleared
values are not read back. Without the change the test fails at the captured-range check.

docs/d3d12_vulkan.md: drop the duplicated RTV/DSV bullet and list the new dimension. The 1D and
1D-array DSVs need 1D textures first (D3D-63, #561).

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

Copy link
Copy Markdown
Contributor

Code review at 0067da5. The creation path now rejects TEXTURE1D with ALLOW_RENDER_TARGET or ALLOW_DEPTH_STENCIL, while the allocation-info path adds a unit-height and sample-count guard without the matching attachment-flags check. A 1D attachment description should be included in the native allocation-info comparison to check whether both entry points agree on that rejection. AI-assisted code review.

@Ayinaki

Ayinaki commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

The 1D attachment case is already in the host allocation comparison, and it passes on the rebased branch (caf3932):

allocation info 1D render target: alignment 65536, size ours 65536 host 65536

The PC runtime accepts the allocation for a 1D render target but CreateCommittedResource rejects the same description with E_INVALIDARG (the test logs 1D texture cannot be an attachment). That split is deliberate host matching, not a missing attachment-flags guard in GetResourceAllocationInfo. The branch is rebased onto current main 67204bf; the test passes with LEONIDA_VK_VALIDATION=1.

@Ayinaki

Ayinaki commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

CI note: 8/9 checks pass on the rebased caf3932. The remaining check job fails in Build rpf9dump because the pinned third_party/rpf9-explorer lacks ArchiveEntry.ResourceDrawableOffset; the same failure is on main and is fixed by #713. This PR does not touch the submodule.

@kotorvr

kotorvr commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested c7d5f8e on RTX 4090 (driver 621.14), Windows 11 26200, MSVC 19.44: pass (no regression against main).

  • Clean RelWithDebInfo Ninja build of runtime/ (Vulkan SDK 1.4.363.0), then ctest: 32/32 pass.
  • GPU tests with LEONIDA_VK_VALIDATION=1 and the Khronos validation layer: d3d12_com_test, d3d12_descriptor_test, d3d12_gcl8_test, d3d12_method_variants_test, d3d12_resource_desc_test, d3d12_sampler2_test, d3d12_state_map_test, d3d12_typeless_rtv_test, d3d12_uav_clear_test, d3d12_vulkan_device_test, vk_command_replay_test pass, with 0 validation messages (no VUIDs).
  • d3d12_clear_test fails, the same as on plain main 4a36bb1 on this GPU (NVIDIA rounds the 0.5 clear on 8-bit UNORM/SNORM down: Vulkan 7f, WARP 80, plus one depth-format-55 case that main shows too). This is not caused by this PR; Runtime: clears match WARP on every format class: tie rounding, and the SNORM/SINT/R8/R16 formats (D3D-45) #521 fixes the rounding.
  • d3d12_resource_desc_test goes from 25/26 descriptions matching the host on main to 26/26 with this PR, against both the 4090 and WARP.

The vk_* harness tests that need translated SPIR-V weren't run. No game files used. AI-assisted run (Claude Code).

CheckFeatureSupport already reported TEXTURE1D, but CreateCommittedResource
rejected the dimension. Create 1D images with a height-one extent, reject
non-unit heights and attachment flags, and teach GetCopyableFootprints and
GetResourceAllocationInfo the 1D shape. The device test now uploads and reads
back a 1D texture and a layer of a 1D array, and compares allocation and
footprint results with the PC runtime.

@quackottu quackottu 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.

Tested 2a66d3a on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1 and LEONIDA_D3D12=vulkan: pass

  • ctest -C RelWithDebInfo: 100% tests passed, 0 tests failed out of 32
  • d3d12_vulkan_device_test (changed here): exit=0 validation=0 | [rt] d3d12: upload heaps in VRAM (DEVICE_LOCAL | HOST_VISIBLE, Resizable BAR)
  • 33 test programs in the build pass with 0 validation errors
  • Not run (they take an input file, not covered here): vk_binary_occlusion_test
  • d3d12_clear_test fails (R8G8B8A8_UNORM/SNORM 0.5 ties and a D16 clear byte differ from WARP) exactly as on main 4a36bb1 here, so not from this PR; #521 addresses it

Implicit Vulkan layers (overlays) were off through an empty VK_IMPLICIT_LAYER_PATH.

@Ayinaki

Ayinaki commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Landed in main as c7d5f8e already. The branch head predates fbb991e and 072620b (the submit_and_wait refactor), which is where the conflict comes from - there is nothing left to merge, so closing this.

@Ayinaki Ayinaki closed this Nov 22, 2026
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.

5 participants