Skip to content

Runtime: depth-stencil views of 1D and 1D-array textures (D3D-79) - #684

Closed
ismailchaka1 wants to merge 2 commits into
ItsNotRexed:mainfrom
ismailchaka1:d3d-79-dsv-dimensions
Closed

ismailchaka1 wants to merge 2 commits into
ItsNotRexed:mainfrom
ismailchaka1:d3d-79-dsv-dimensions

Conversation

@ismailchaka1

@ismailchaka1 ismailchaka1 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Item: D3D-79 (claimed in #374), the 1D part. The 2D multisample-array part became D3D-83 and is in #683 (@rafaelpssz), so it was dropped from this PR.
Depends on: #561 (1D textures)

CreateDepthStencilView handled TEXTURE2D, TEXTURE2DMS and TEXTURE2DARRAY only; TEXTURE1D and TEXTURE1DARRAY logged "depth-stencil view dimension not supported" and wrote an empty view. They now record the same TargetView ranges as their 2D forms, since a 1D texture is a one-row 2D image (#561's model):

  • TEXTURE1D: MipSlice, layer 0, one layer;
  • TEXTURE1DARRAY: MipSlice, FirstArraySlice, ArraySize.

Only runtime/shims/d3d12_vulkan_device.cpp changes (six lines).

Not tested yet: CreateCommittedResource refuses 1D textures on main until #561 lands, so there is no 1D depth texture to view. Draft until then; I'll add a test that creates a 1D depth array and clears a slice through these views once #561 merges.

Tested on an NVIDIA GeForce RTX 4070 SUPER, driver 32.0.16.1088, Windows 11, MSVC 2022: the runtime builds; ctest passes (27/27); d3d12_vulkan_device_test passes with LEONIDA_VK_VALIDATION=1, no validation errors. No game files used.

AI-assisted.

… textures (D3D-79)

CreateDepthStencilView refused TEXTURE1D, TEXTURE1DARRAY and
TEXTURE2DMSARRAY ("depth-stencil view dimension not supported") and wrote
an empty view. They now record the same TargetView ranges as their 2D
forms: mip and layer 0 for 1D, mip and layers for 1D arrays (a 1D texture
is a one-row 2D image), layers for multisample arrays.

d3d12_vulkan_device_test creates a 4x D32_FLOAT array of three layers,
checks a TEXTURE2DMSARRAY view of layers 1-2 in the DSV slot, and clears
it through the replay. 1D views are not tested here: 1D textures are
refused on main until D3D-63 (ItsNotRexed#561).
…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).
@ismailchaka1 ismailchaka1 changed the title Runtime: depth-stencil views of 1D, 1D-array and 2D multisample-array textures (D3D-79) Runtime: depth-stencil views of 1D and 1D-array textures (D3D-79) Nov 22, 2026
@ismailchaka1
ismailchaka1 marked this pull request as draft November 22, 2026 01:57
@Derpbeat

Copy link
Copy Markdown
Contributor

Reviewed 8bc3b54 and tested it with #561 (0067da5) merged locally on an NVIDIA GeForce RTX 4090 (driver 617.14), Windows 10 22H2, MSVC 19.39, Vulkan SDK 1.4.363.0, LEONIDA_VK_VALIDATION=1. The merge is clean and ctest passes 27/27. But #561 doesn't make these views reachable, so the test planned "once #561 merges" can't be written as things stand:

  1. d3d12: create 1D textures and 1D arrays #561 refuses 1D depth textures. Its CreateCommittedResource returns E_INVALIDARG for a TEXTURE1D with ALLOW_RENDER_TARGET or ALLOW_DEPTH_STENCIL ("1D texture cannot be an attachment"). A local experiment confirms it: a 3-layer 1D D32_FLOAT with ALLOW_DEPTH_STENCIL returns 0x80070057, so no resource can reach the new TEXTURE1D/TEXTURE1DARRAY branches.
  2. With that refusal lifted (locally, depth only), the clear path works: the resource is created, a TEXTURE1DARRAY DSV of slices 1-2 captures {mip 0, first 1, count 2}, and ClearDepthStencilView through it replays success with 0 validation messages.
  3. Draws would still be wrong (from reading the code, not tested): d3d12: create 1D textures and 1D arrays #561 creates 1D textures as VK_IMAGE_TYPE_1D, not as one-row 2D images as the comment in this PR says. But the attachment-view helper view() in runtime/src/vulkan_backend.h makes every attachment view VK_IMAGE_VIEW_TYPE_2D_ARRAY, which isn't a valid view type for a 1D image. So binding one of these DSVs with OMSetRenderTargets and drawing would fail image-view creation (or trip validation).
  4. The hardware isn't the limit: on this RTX 4090, vkGetPhysicalDeviceImageFormatProperties reports VK_IMAGE_TYPE_1D + DEPTH_STENCIL_ATTACHMENT as supported for D16, D32, D24S8 and D32S8 (maxArrayLayers 2048). Other vendors weren't measured.

For this PR to do something, I think it needs (a) #561 or a follow-up to accept ALLOW_DEPTH_STENCIL on 1D textures, and (b) attachment views of 1D images created as VK_IMAGE_VIEW_TYPE_1D_ARRAY (with a draw test). Also, the code comment "a 1D texture is a one-row 2D image (D3D-63)" doesn't match #561, which uses real 1D images.

AI-assisted (Claude Code); repository tests and a small vkGetPhysicalDeviceImageFormatProperties probe only, no game files.

@ismailchaka1

Copy link
Copy Markdown
Contributor Author

Closing as superseded: main now creates 1D textures and its CreateDepthStencilView handles D3D12_DSV_DIMENSION_TEXTURE1D and TEXTURE1DARRAY, which is all this draft added. Checked on main (1628210). AI-assisted.

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.

2 participants