Skip to content

Runtime: the standalone device enables the pixel-shader extensions shaders declare - #2186

Merged
ItsNotRexed merged 5 commits into
ItsNotRexed:mainfrom
fearkov:runtime/enable-ps-extensions
Nov 22, 2026
Merged

ItsNotRexed merged 5 commits into
ItsNotRexed:mainfrom
fearkov:runtime/enable-ps-extensions

Conversation

@fearkov

@fearkov fearkov commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in #2078 as: #2078 (comment)

Depends on: #2041. This branch is on top of it, so the first two commits are #2041's. They drop out once it lands.

What and why

#2041 makes the standalone device (create_vulkan_device_standalone, the path D3D12XboxCreateDevice takes with
LEONIDA_D3D12=vulkan) enable the core and Vulkan 1.2 features translated shaders declare. Three pixel-shader
extensions are still missing. runtime/test/vk_harness.cpp enables all three when the GPU has them, while this
device, which builds pixel shaders as well, enabled none:

Extension, feature A translated PS declares it for
VK_KHR_fragment_shader_barycentric, fragmentShaderBarycentric BaryCoordKHR / PerVertexKHR reads: computed I/J (SHADER-177) and per-vertex f16 inputs, FragmentBarycentricKHR in the index
VK_EXT_fragment_shader_interlock, fragmentShaderPixelInterlock the 10 POPS shaders (PixelInterlockOrderedEXT, docs/design.md "POPS" row)
VK_KHR_maintenance8, maintenance8 texel offsets outside gathers (the index's needs_maintenance8, "Texel offsets" row)

Using a capability whose extension isn't enabled makes the module invalid, and creating the pipeline is then
undefined. Each extension is now queried and enabled with its feature where the GPU has it, as minLod and
shaderFma already are. Only the pixel interlock is enabled, not the sample or shading-rate ones, because the
translator only declares that one. VulkanDeviceInfo records the three (fragment_shader_barycentric,
fragment_shader_interlock, maintenance8).

In #2041 I wrote that barycentrics and interlock were left out because this device doesn't build those stages.
That was wrong: both are pixel-shader features. Mesh and geometry shaders are the stages it doesn't build.

Commits (after #2041's two):

  1. runtime/shims/d3d12_vulkan_device.cpp and d3d12_com.h
  2. d3d12_vulkan_device_test, standalone-device section: each of the three is enabled exactly when the GPU offers
    the extension and its feature. A structure is chained into the query only when its extension is offered.
  3. the "Optional device features" row of docs/design.md says the runtime's device enables them too

Tested

Not run on my side: the D3D12 layer builds with MSVC only, and I'm on Linux. This PR's windows job compiles it.
A Windows + GPU run of ctest -R d3d12_vulkan_device would help, best with LEONIDA_VK_VALIDATION=1. With commit
1's three blocks removed, it should fail on a GPU that offers them. My RTX 2060 SUPER offers all three with their
features (vulkaninfo, Linux driver 620.70.06); on another GPU, vulkaninfo shows which ones it has.

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.
…aders declare

A translated PS can need VK_KHR_fragment_shader_barycentric (BaryCoordKHR / PerVertexKHR reads), VK_EXT_fragment_shader_interlock (the POPS shaders' PixelInterlockOrderedEXT) or VK_KHR_maintenance8 (texel offsets outside gathers, the index's needs_maintenance8). vk_harness enables all three; the device the Xbox path creates, which builds pixel shaders too, enabled none. Each is now queried and enabled with its feature where the GPU has it.
@lahlousaad4

Copy link
Copy Markdown
Contributor

Tested a53434ca on Windows 11 build 26200, MSVC 19.44, Windows SDK 10.0.26100, RTX 4060 driver 610.88, with Khronos validation 1.4.369.

Built d3d12_vulkan_device_test; ctest --test-dir runtime/build --output-on-failure -R '^d3d12_vulkan_device$' passed (1/1). The standalone-device assertions compare the barycentric, pixel-interlock and maintenance8 flags with the physical device's reported support. No Vulkan validation errors in the test log. The two existing C4456 warnings in vulkan_replay.h are tracked as RT-139. Synthetic tests only.

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

Reviewed the feature/extension queries, enable chain and standalone-device assertions. Each extension is only queried when offered and enabled only with its required feature; the runtime also enables the shader capabilities already used by translated modules. The reported Windows validation run covers the standalone device path. I found no blocking issue; I did not run tests. This remains stacked on #2041.

@KiryaAfimin

Copy link
Copy Markdown

Tested a53434c on Windows 11 with a GeForce RTX 4070 (NVIDIA driver 621.01). ctest -R d3d12_vulkan_device passed (1/1) with LEONIDA_VK_VALIDATION=1. No validation errors were reported.

vulkaninfo reports fragmentShaderBarycentric, fragmentShaderPixelInterlock and maintenance8 as true. I also rebuilt with the three feature-enable blocks removed. The same test then failed at line 4957 on the fragment_shader_barycentric check, as expected.

@ItsNotRexed
ItsNotRexed merged commit b3a5411 into ItsNotRexed:main Nov 22, 2026
4 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.

5 participants