Skip to content

runtime: allow explicit Texture1D SRVs on 1D texture arrays to select slice 0 - #1851

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
al3xar:fix/d3d12-srv-texture1d-on-array
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
al3xar:fix/d3d12-srv-texture1d-on-array

Conversation

@al3xar

@al3xar al3xar commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to 017d2604:

  • ID3D12Device::CreateShaderResourceView and image_descriptor() (runtime/shims/d3d12_vulkan_device.cpp):
    • CreateShaderResourceView previously omitted view.layer_count = 1 in case D3D12_SRV_DIMENSION_TEXTURE1D: (unlike D3D12_SRV_DIMENSION_TEXTURE2D and D3D12_SRV_DIMENSION_TEXTURE2DMS), and image_descriptor() rejected line && desc.DepthOrArraySize != 1.
    • In D3D12, an explicit D3D12_SRV_DIMENSION_TEXTURE1D view on a 1D texture array (DepthOrArraySize > 1) views array slice 0 (FirstArraySlice = 0, ArraySize = 1), just as D3D12_SRV_DIMENSION_TEXTURE2D and D3D12_SRV_DIMENSION_TEXTURE2DMS view slice 0 of a 2D texture array.
    • Set view.layer_count = 1 for single-layer 1D SRVs (D3D12_SRV_DIMENSION_TEXTURE1D and default nullptr SRVs on non-array 1D textures) and check line && view.layer_count != 1 in image_descriptor(), while keeping default (nullptr) SRVs on 1D texture arrays rejected until 1D-array SRV bindings land.
  • runtime/test/d3d12_descriptor_test.cpp:
    • Verify that a default (nullptr) SRV on a 3-layer 1D texture array writes a null descriptor, while an explicit D3D12_SRV_DIMENSION_TEXTURE1D SRV encodes a 1-layer ImageType::image_1d T# for slice 0 and registers its VK_IMAGE_VIEW_TYPE_1D view in set 0.

Verification

  • Built with MSVC 19.44.35230.0 (Visual Studio 2022 Build Tools x64) on Windows 11, NVIDIA GeForce RTX 3060 (driver 621.24, Vulkan 1.4.357).
  • LEONIDA_VK_VALIDATION=1 .\runtime\build\d3d12_descriptor_test.exe: passed (0 validation errors).
  • Synthetic tests only; no game data used.
  • AI-assisted.

@nightsale

Copy link
Copy Markdown
Contributor

Tested 57f57a8 on NVIDIA GeForce RTX 3060 (driver 32.0.16.2124, Windows, LEONIDA_VK_VALIDATION=1): pass — d3d12_descriptor_test and ctest -R ^(d3d12_com|d3d12_vulkan_device|d3d12_descriptor|d3d12_set0_compute)$ passed (4/4), 0 validation errors.

@Serrambi

Copy link
Copy Markdown
Contributor

Tested 57f57a82 on NVIDIA GeForce RTX 5070 Ti, driver 610.88, Windows 11 Pro (MSVC 19.50.35719.0, Vulkan SDK 1.4.363.0): pass

  • d3d12_descriptor_test.exe (default): passed (1D SRVs (default, mip 1, min LOD 2, missing): 64/64 64/64 64/64 64/64 texels matched)
  • d3d12_descriptor_test.exe (LEONIDA_VK_VALIDATION=1): passed, 0 Vulkan validation errors
  • ctest --test-dir runtime/build --output-on-failure -R "d3d12_descriptor|descriptor_table|d3d12_com": 4/4 passed (descriptor_table, d3d12_com, d3d12_descriptor, d3d12_compute)

Code review looks clean too: clamping view.layer_count = 1 for explicit D3D12_SRV_DIMENSION_TEXTURE1D and selecting the arrayed descriptor path in image_descriptor() with (line && view.layer_count != 1) gives slice 0 a valid VK_IMAGE_VIEW_TYPE_1D view over arrayLayers > 1 images while preserving nullptr default descriptors.

@RobertPattinson007

Copy link
Copy Markdown
Contributor

Tested 57f57a8 on NVIDIA GeForce RTX 3070 Ti (driver 617.42) and AMD Radeon Graphics, Ryzen 7 7800X3D iGPU (driver 32.0.21045.29003), Windows 11 build 26300, MSVC 19.44, Ninja, RelWithDebInfo: pass.

  • d3d12_descriptor with LEONIDA_VK_VALIDATION=1: passes on both GPUs (AMD selected with VK_DRIVER_FILES).
  • Full ctest on the RTX 3070 Ti: 102 of 103 run passed. The one failure is d3d12_draw (bundle blend), the known failure on 003e7812.
  • The PR's d3d12_descriptor_test.cpp built against the base 003e7812 fails at the new check (line 732, the explicit TEXTURE1D SRV on the 3-layer array), so the test catches the old refusal.

One overlap to be aware of: #1916 (opened after this one) also changes CreateShaderResourceView for 1D textures. It gives a default (nullptr) SRV on a 1D array an image_1d_array view, where this PR's test expects that case to stay a null descriptor. Whichever lands second will need its test adjusted.

Synthetic inputs only. AI-assisted.

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

Code review + verification on 57f57a82: approve.

  • runtime/shims/d3d12_vulkan_device.cpp: setting view.layer_count = 1 for D3D12_SRV_DIMENSION_TEXTURE1D (with first_layer zero-initialized) and relaxing image_descriptor() to (line && view.layer_count != 1) lets an explicit 1D SRV select slice 0 of a 1D texture array (mapping cleanly to VK_IMAGE_VIEW_TYPE_1D with layerCount = 1), while default (nullptr) SRVs on 1D arrays remain null descriptors.
  • runtime/test/d3d12_descriptor_test.cpp: covers both the nullptr null-descriptor check on a 3-layer 1D array and the decoded image_1d (first_mip = 1, mip_count = 1, first_layer = 0, layer_count = 1) + bindless_hash_lookup check (CreateUnorderedAccessView 1D / TEXTURE1DARRAY remain separate and out of scope).
  • Tested on NVIDIA GeForce RTX 5070 Ti (driver 610.88, Windows 11 Pro, MSVC 19.50.35719.0, Vulkan SDK 1.4.363.0): d3d12_descriptor_test.exe passed cleanly both default (1D SRVs: 64/64 64/64 64/64 64/64) and under LEONIDA_VK_VALIDATION=1 (0 validation errors), and ctest -R "d3d12_descriptor|descriptor_table|d3d12_com" passed 4/4.

@ItsNotRexed
ItsNotRexed merged commit 667dbc7 into ItsNotRexed:main Nov 22, 2026
@sanakontorov-sys

Copy link
Copy Markdown

Tested 57f57a8 on NVIDIA GeForce RTX 5060 (Blackwell, driver 617.42, Vulkan 1.4.351), Windows 11 Pro build 26300, MSVC (VS 2026), scripts\build_runtime.ps1, then ctest -j 4: pass for this change. d3d12_descriptor passes; 102 of 103 run tests pass. The one failure is d3d12_draw ("fence signal 4 is not above 30"), which fails the same way on main 003e781 on this machine and is fixed by #1807, so it is unrelated to this PR.

(Run with an AI coding agent.)

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