Skip to content

Runtime: the standalone device enables the image features shaders declare - #2041

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
fearkov:runtime/enable-shader-image-features
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
fearkov:runtime/enable-shader-image-features

Conversation

@fearkov

@fearkov fearkov commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in #1902 as: #1902 (comment)

What and why

create_vulkan_device_standalone (the device D3D12XboxCreateDevice makes with LEONIDA_D3D12=vulkan) enables
what translated shaders declare, so their modules are valid: Int64, Float64, Int16, clip and cull distances. It
missed some capabilities the translator puts in the index's features for the stages this device builds (PS, CS,
VS):

Capability (translator) Feature Where it comes from
StorageImageWriteWithoutFormat shaderStorageImageWriteWithoutFormat every image_store (uses_store_views)
ImageGatherExtended shaderImageGatherExtended gather offsets (uses_img_offset)
MinLod shaderResourceMinLod image_sample*_cl (uses_minlod)
ShaderLayer, ShaderViewportIndex Vulkan 1.2 shaderOutputLayer, shaderOutputViewportIndex a VS that writes the layer or viewport

A module that declares one of these without the feature enabled breaks VUID-VkShaderModuleCreateInfo-pCode-08740.
Drivers that are lenient may build it anyway; the validation layer flags it, and a strict driver can refuse. Each is
now enabled where the GPU has it, the way the device already treats Int64 and Float64.
shaderStorageImageReadWithoutFormat is enabled the same way: the translator's feature table lists it for
StorageImageReadWithoutFormat.

The pixel-shader extensions (barycentrics, the POPS interlock, maintenance8) are #2186, stacked on this PR. Mesh and
geometry shaders are left out, since this device doesn't build those stages.

Commits:

  1. runtime/shims/d3d12_vulkan_device.cpp enables the four core features and the two 1.2 ones.
    VulkanDeviceInfo records the 1.2 pair (shader_output_layer, shader_output_viewport_index), and
    vulkan_device_info(ID3D12Device*) hands tests what a device was created with, next to the other
    For tests. accessors in d3d12_com.h.
  2. d3d12_vulkan_device_test, standalone-device section: each of the six is enabled exactly when
    vkGetPhysicalDeviceFeatures2 says the GPU has it.

Tested

I'm on Linux, where the D3D12 layer doesn't build (MSVC only), so the runs are other people's, on 503c55e, all
Windows 11 + MSVC (see the comments):

GPU d3d12_vulkan_device with LEONIDA_VK_VALIDATION=1 commit 1's enables removed
AMD Radeon RX 9070 XT (@towade) pass no validation errors fails at the new shaderStorageImageWriteWithoutFormat check
NVIDIA RTX 5070 Ti (@snrubrm) pass; both commits compile without new warnings no VUID messages (so no pCode-08740) fails at line 4913, the first new check
NVIDIA RTX 4070 (@itsonlysimbo) pass (ctest 109/110, d3d12_draw as on main, #1807)
NVIDIA RTX 5090 (@tumbione) pass 3/3; all six features true in vulkaninfo 0 VUIDs fails at line 4913, passes again restored

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.

…lare

Translated shaders declare StorageImageWriteWithoutFormat for every image store, ImageGatherExtended for gather offsets, MinLod for _cl samples, and ShaderLayer / ShaderViewportIndex when a vertex shader writes them. The device the Xbox path creates never enabled shaderStorageImageWriteWithoutFormat, shaderStorageImageReadWithoutFormat, shaderImageGatherExtended, shaderResourceMinLod or the Vulkan 1.2 shaderOutputLayer / shaderOutputViewportIndex, which VUID-VkShaderModuleCreateInfo-pCode-08740 requires. Each is now enabled where the GPU has it, like Int64 and Float64. vulkan_device_info gives tests what a device was created with.
@towade

towade commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 503c55e1 on Windows 11 26H2 (26300.10075), AMD Radeon RX 9070 XT (driver 32.0.32029.2010), MSVC 19.44 Release: pass.

LEONIDA_VK_DEVICE=9070 XT, LEONIDA_VK_VALIDATION=1, and ctest --output-on-failure -R '^d3d12_vulkan_device$': 1/1 passed, with no Vulkan validation errors. With the new feature enables removed and the PR's regression check retained, the test failed at the new shaderStorageImageWriteWithoutFormat assertion, as expected.

Synthetic test only. AI-assisted (Codex).

@snrubrm

snrubrm commented Nov 22, 2026

Copy link
Copy Markdown

Tested 503c55e on NVIDIA GeForce RTX 5070 Ti (Blackwell, subgroup 32..32), NVIDIA 621.01 (Vulkan 1.4.357), Windows 11 Pro 26300: pass, and the negative check fails as you predicted.

Runtime built from this head (based on main 4eb6155) with scripts\build_runtime.ps1: VS 2022 Build Tools 17.14 (MSVC), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0. Both commits compile cleanly; the only warnings are the existing C4456 ones in vulkan_replay.h.

  • ctest --test-dir runtime/build -R d3d12_vulkan_device with LEONIDA_VK_DEVICE=5070: passed (8.3 s).
  • d3d12_vulkan_device_test.exe directly with LEONIDA_VK_VALIDATION=1: exit 0, no VUID messages at all (so no pCode-08740).
  • Negative check: with commit 1's six enables removed from create_vulkan_device_standalone (the four core features and the shaderOutputLayer/shaderOutputViewportIndex pair; the vulkan_device_info accessor kept so the test still builds), the test fails at line 4913: on.shaderStorageImageWriteWithoutFormat == have.features.shaderStorageImageWriteWithoutFormat, the first new check. With the file restored and rebuilt, it passes again.

AI-assisted run (Claude Code).

@itsonlysimbo

Copy link
Copy Markdown
Contributor

Tested 503c55e1 on RTX 4070, NVIDIA 621.14, Windows 11 (10.0.26300), MSVC 19.44, Vulkan SDK 1.4.363: pass. This is an MSVC build, since the PR notes it could not be run on Linux.

AI-assisted (Claude Code).

@tumbione

Copy link
Copy Markdown
Contributor

Tested 503c55e1 on NVIDIA GeForce RTX 5090, driver 616.56, Windows 11 (10.0.26300): pass

Built with scripts/build_runtime.ps1 (MSVC, VS 2022 Build Tools, Ninja, RelWithDebInfo, Vulkan SDK 1.4.363.0); no warnings in the three changed files. vulkaninfo reports all six features as true on this GPU, so each new check compares against an enabled feature.

Run Result
d3d12_vulkan_device_test, 3 runs pass 3/3
Same, LEONIDA_VK_VALIDATION=1, implicit layers off pass, validation on, 0 VUIDs
Negative control: the four enable.shader... = chosen_features... lines commented out, test rebuilt fails at line 4913: on.shaderStorageImageWriteWithoutFormat == have.features.shaderStorageImageWriteWithoutFormat; passes again after restoring
Full ctest 1 failed of 116: d3d12_draw (fence signal 21 is not above 30, #1807), identical on main 4eb6155d here

No game data involved. AI-assisted (Claude Code): it built the tree and ran everything above on this machine.

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

The feature-query chain and device-create chain carry the four core bits and the two Vulkan 1.2 bits from queried support into enabled features. The test compares all six enabled values with the physical-device support values. I found no concrete issue in the reviewed diff; I did not run tests, and the requested Windows GPU run is still outstanding.

@VeTkN

VeTkN commented Nov 22, 2026

Copy link
Copy Markdown

Tested 503c55e on RTX 5070 (Blackwell), NVIDIA 621.24, Windows 11 Pro (10.0.26200), MSVC 19.51 (VS 2026 Build Tools): pass. vulkaninfo reports all six features as true; ctest -R d3d12_vulkan_device passes, also with LEONIDA_VK_VALIDATION=1. With the four enable.* lines removed and the two info.shader_output_* assignments set to false, it fails at line 4913 like the runs above.

AI-assisted (Claude).

@kapitche

Copy link
Copy Markdown
Contributor

Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51): no regression. RTX 4080 SUPER: 115/116. On the Intel UHD 770 (no shaderStorageImageReadWithoutFormat) nothing new fails. Not from this PR: d3d12_draw (the bundle-blend regression on main, fixed by #1995). The other Intel UHD 770 failures are known (#2078): d3d12_descriptor, d3d12_present, d3d12_m3_frame, d3d12_subgroup.

@NRXM

NRXM commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 503c55e (on main 4eb6155) on an NVIDIA RTX 4090 (621.24) and an AMD Radeon iGPU (Ryzen 7000, RDNA2 gfx1036, driver 26.11.2 / Vulkan 2.0.353), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363.0, RelWithDebInfo: pass for this PR.

(AI-assisted test run.)

@ItsNotRexed
ItsNotRexed merged commit 817de3d into ItsNotRexed:main Nov 22, 2026
8 of 9 checks passed
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.

10 participants