I have run into an issue with slang spirv output failing spirv validation checks in newly updated source builds of slang and the vulkan validation layers:
Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-08737 ] | MessageID = 0xa5625282 | vkCreateShaderModule(): pCreateInfo->pCode (spirv-val produced an error):
ID '36' decorated with Flat multiple times is not allowed.
%vo_a = OpVariable %_ptr_Input_int Input
. The Vulkan spec states: If pCode is a pointer to SPIR-V code, pCode must adhere to the validation rules described by the Validation Rules within a Module section of the SPIR-V Environment appendix (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkShaderModuleCreateInfo-pCode-08737)
Note: This only occurs when a is an integer (I tried with int and uint). No double annotation or spirv error occurs when a is a float.
Inspecting spirv-assembly generated using the same compile options led to the following output
I have run into an issue with slang spirv output failing spirv validation checks in newly updated source builds of slang and the vulkan validation layers:
slang commit: https://github.com/shader-slang/slang/commit/9a23a9aab3721828526c921db1e779008e133e8f validation layers commit: https://github.com/KhronosGroup/Vulkan-ValidationLayers/commit/f34c751cbffb7287101e8d8682305a9b805892e3
The following shader
produces the following validation error
Note: This only occurs when
a
is an integer (I tried withint
anduint
). No double annotation or spirv error occurs whena
is afloat
.Inspecting spirv-assembly generated using the same compile options led to the following output
where
Flat
is being applied twiceThe same double annotations occurs with the more minimal set of compile options building just the
Fragment
entry pointNote: This only occurs when code is generated for the Fragment entry point. Generating Vertex results in only a single
Flat
decoration. Note: After commit https://github.com/shader-slang/slang/commit/f1de1817ca10e34ec6a844100f10f0de3340c9f2 this repro works without-emit-spirv-directly
as it is now selected by default.The first validation layers commit that started catching this was https://github.com/KhronosGroup/Vulkan-ValidationLayers/commit/a9b3f651c1b8a6515ec876f25a570f6572dc2516 which updated the SPIRV-Tools dependency to commit https://github.com/KhronosGroup/SPIRV-Tools/commit/02470f606fe1571de808cb773d8c521ab201aaff in which
* Disallow duplicate decorations generally
would be relevant here.A recent commit (latest as of this issue being made) https://github.com/shader-slang/slang/commit/9a23a9aab3721828526c921db1e779008e133e8f seems to address some duplicate decorations, but not
OpDecorate ... Flat
From bisecting, I believe the first commit that introduced this double decoration was https://github.com/shader-slang/slang/commit/6f8a20688e0c4b989db152b4d06aeab04fac0567 (which was made before the validation check was added to
spirv-val
)Happy to provide any more context if necessary.