Repository navigation
Conversation
kacper-serewis
left a comment
There was a problem hiding this comment.
At 422009e two valid read-only fragment modules can spuriously require fragmentStoresAndAtomics. A subpassInput has Sampled=2 but Dim=SubpassData; exclude input attachments from storage-image classification. Also honor NonWritable supplied through OpGroupDecorate. Both synthetic modules passed Vulkan 1.0 spirv-val. CPU suite and 108 stage/feature combinations passed. No GPU execution; standalone negotiation and COM HRESULT propagation inspected in source. AI-assisted.
|
Tested 422009e on Windows 11, RTX 5080 (driver 616.92) and AMD Radeon iGPU gfx1036 (driver 26.10.1):
No negative control run. AI-assisted. |
|
Tested 422009e (based on main f847748) on Windows 11 build 26300, MSVC 19.44, Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, with two GPUs picked by
AI-assisted (Claude Code). No game files. |
|
@kacper-serewis thank you, both are real false positives. Fixed in c1fe863:
@Vonsek, thank you for the RTX 5080 and gfx1036 runs. |
…cs; a PSO that needs it elsewhere is refused create_vulkan_device_standalone never enabled fragmentStoresAndAtomics or vertexPipelineStoresAndAtomics, so a pixel shader with a writable storage image (an image atomic: 1,018 corpus pixel shaders) broke VUID-RuntimeSpirv-NonWritable-06340 while CreateGraphicsPipelineState answered S_OK. The device enables both where the GPU has them. A graphics PSO whose stage declares writable storage (src/spirv_stores.h reads the declarations) on a device without the feature is refused with E_NOTIMPL and a log line. spirv_stores_test checks the rule on hand-built SPIR-V; d3d12_stores_atomics_test checks the refusal and the standalone device under the validation layer. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s LEONIDA_VK_VALIDATION=0 A malformed module whose array type names itself made the element walk spin inside CreateGraphicsPipelineState; it now stops after 16 levels, with a case in spirv_stores_test. d3d12_stores_atomics_test turns the validation layer on for itself only when the variable is unset. The docs say how the 1,018 of 1,038 figure is counted. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…decoration group counts An OpTypeImage with Sampled 2 and Dim SubpassData is a subpassInput, not a storage image, so a pixel shader reading an input attachment no longer needs fragmentStoresAndAtomics. NonWritable applied through OpDecorationGroup / OpGroupDecorate / OpGroupMemberDecorate is resolved like a direct decoration. spirv_stores_test covers both. Found in review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested
AI-assisted (Claude). No game files. |
c1fe863 to
cbdbafa
Compare
|
@requiemsnkrp thank you for the RTX 3060 run. The CMakeLists.txt conflict you hit is resolved: the branch is rebased onto |
|
128-byte software-device check of On Radeon RX 6750 XT (256 bytes), both tests passed before and after the patch. The external Vulkan device without |
|
Tested cbdbafa on an RX 9070 (RDNA4), AMD 26.11.1, Windows 11 (26300), VS 2022 Build Tools, RelWithDebInfo with SDL3: pass
AI-assisted |
Claim: #3574 (comment) (overlap note for #2058 in the comment after it)
The problem
The runtime's own Vulkan device (
create_vulkan_device_standalone, the oneD3D12XboxCreateDevicehands a title withLEONIDA_D3D12=vulkan) copies about twenty features from the chosen GPU and never enablesfragmentStoresAndAtomicsorvertexPipelineStoresAndAtomics.A translated pixel shader that stores to an image or does an image atomic declares that storage image without
NonWritable. Outside a compute shader Vulkan allows that only with the feature (VUID-RuntimeSpirv-NonWritable-06340for the fragment stage,-06341for vertex, tessellation and geometry). So on that device every such PSO was invalid, andCreateGraphicsPipelineStatestill answeredS_OK. How many shaders this is: closed #1578 counted 1,018 of the corpus's 1,038 image-atomic shaders as pixel shaders. That was recounted for this PR on a locally translated 1.0.2.1 corpus (26,503 index entries, 2 of them without a module in that folder): modules containing anOpImageTexelPointer(what every image atomic goes through), split by the stage inindex.json, give 1,038 = 1,018 pixel + 20 compute, none in a vertex, geometry or mesh shader. The translator commit of that folder was not recorded, so read it as a recount of #1578's figure, not a new measurement.Reproduced here before the fix, under the validation layer on an RTX 4090:
VUID-RuntimeSpirv-NonWritable-06340at pipeline creation,S_OKreturned.The change
VulkanDeviceInfo::featureslike the others.E_NOTIMPLfor such a PSO where it answeredS_OK; the full suite shows no existing test relied on the old answer) withE_NOTIMPLand a line naming the shader, the stage and the feature, in the place that already refuses a geometry shader withoutgeometryShader. Before, the pipeline was created anyway.runtime/src/spirv_stores.h: a storage image or storage texel buffer variable, or a storage buffer (either SPIR-V form), that is notNonWritable(on the variable, or on every member of the block). An input attachment (Sampled2 withDimSubpassData) is not counted, andNonWritableapplied through a decoration group (OpGroupDecorate,OpGroupMemberDecorate) counts like a direct one (third commit, c1fe863; both found by @kacper-serewis). That is the rule the VUID states; it does not look at whether an instruction writes. The translator's descriptor map isNonWritableon the variable, so shaders that only sample are unaffected.docs/d3d12_vulkan.md§3.2: one bullet next to the other feature notes.Not changed: compute pipelines (compute needs no feature), and the index's
featureslist is still not read.Overlap with #2058 (@opit80, D3D-251, 64-bit image atomics): #2058 sets the same two features in
create_vulkan_device_standalone, but only insideif (info.image_int64_atomics), for its 64-bit path, and checks them for shaders that use 64-bit atomics. This PR sets them wherever the GPU reports them, which the 32-bit image atomics need on a GPU without 64-bit image atomics as well, and its refusal covers any writable storage declaration. The two conflict on those two assignment lines; whichever lands second rebases.Tests
Windows 11, MSVC 14.44 (VS 2022), the CMake and Ninja that Visual Studio ships (3.31.6), SDK 10.0.26100, Vulkan SDK 1.4.363.0, RelWithDebInfo, NVIDIA RTX 4090 (driver 621.14). No game files.
spirv_stores_test(CPU, hand-built SPIR-V): a storage image, sized and runtime arrays of them,NonWritableones, sampled images; storage buffers asStorageBuffer+BlockandUniform+BufferBlock, with none, one and all members read-only and with the variable read-only; a uniform buffer; a wrong magic, a truncated instruction, a zero-length instruction; an array type that names itself (the walk through array types is bounded); an input attachment and an array of them;NonWritablethroughOpGroupDecorate(and a group aimed at another id) and throughOpGroupMemberDecorated3d12_stores_atomics_test, device 1: the test's own Vulkan device, which leavesfragmentStoresAndAtomicsoff. A VS+PS PSO whose pixel shader doesimageAtomicMaxon set 0 binding 4E_NOTIMPL; the same PSO with a pixel shader that has no storage image is created; validation errors: 0create_vulkan_device_standalone. Itsfeatures.fragmentStoresAndAtomicsandvertexPipelineStoresAndAtomicsequal the GPU's; the PSO with the atomic pixel shaderS_OK; validation errors: 0maindoes)VUID-RuntimeSpirv-NonWritable-06340is reported and the test failsspirv_stores_testfails the four new cases (two input-attachment, two decoration-group)ctestafter the rebase ontomain4c52ce2 (head cbdbafa, 156 tests)gameinputis disabled (no SDL3). The two failures are not this change:winhttp_offline(TEST-721, the known flake; passed 3 of 3 alone) andd3d12_fence_timing, which segfaults now and then when it runs in parallel with other GPU tests (passed 10 of 10 alone; in six parallel rounds with four other GPU tests it failed once onmain4c52ce2 itself and once on this branch).python -I tests/test_docs_links.py,test_docs_list_items.py,test_docs_repo_paths.py,test_docs_design_rows.pyUnlike the other tests, the GPU test turns the validation layer on for itself when
VK_LAYER_KHRONOS_validationis installed andLEONIDA_VK_VALIDATIONis not set. WithLEONIDA_VK_VALIDATION=0, or without the layer, it checks the HRESULTs and the feature bits only and says so. Run here both ways: variable unset (layer on, 0 errors) and=0(layer off); both pass. A machine with no layer installed was not available.Not tested:
fragmentStoresAndAtomics: the standalone half then expects the refusal, but I have no such GPU.AI-assisted (Claude Code).
🤖 Generated with Claude Code