vkCreateGraphicsPipelines fails to compile SPIR-V shader

vkCreateGraphicsPipelines fails with:

NVVM compilation failed: 1
WARNING:
GENERAL [NVIDIA (2)] : CreatePipeline: failed to compile internal representation

WARNING:
GENERAL [NVIDIA (2)] : CreatePipeline: unexpected compilation failure

WARNING:
GENERAL [NVIDIA (2)] : CreateGraphicsPipeline: unexpected failure compiling SPIR-V shader

For shader code:

#version 460

#extension GL_EXT_shader_explicit_arithmetic_types : require
precision highp float;

layout (set = 0, binding = 0) uniform U {
    float16_t hue;
    float16_t _pad0;
    float _pad1;
    vec2 _pad2;
};

layout (location = 0) out mediump vec4 colour;

float16_t f(float16_t n, float16_t h, float16_t s, float16_t v) {
    float16_t k = mod(n + h / 60.0hf, 6.0hf);
    return fma(-v, s * max(0.0hf, min(k, min(4.0hf - k, 1.0hf))), v);
}

f16vec4 hsv2rgb(float16_t h, float16_t s, float16_t v) {
    return f16vec4(f(5.0hf, h, s, v), f(3.0hf, h, s, v), f(1.0hf, h, s, v), 1.0hf);
}

const f16vec2 A = f16vec2(0, 1);
const f16vec2 B = f16vec2(1, 1);
const f16vec2 C = f16vec2(0, 0);

void main() {
    f16vec2 sv = mix(mix(C,
                         B,
                         bvec2(gl_VertexIndex == 1)),
                      A,
                      bvec2(gl_VertexIndex == 0));

    gl_Position = vec4(vec3(0), 1);
    colour = hsv2rgb(hue, sv.x, sv.y);
}

Please fix.

Operating System: openSUSE Tumbleweed 20250618
Graphics Processor: NVIDIA GeForce RTX 2060 SUPER
Driver Version: 570.169
Vulkan Instance Version: 1.4.313

Your shader looks faulty

You’re mixing float16_t (from GL_EXT_shader_explicit_arithmetic_types) with built-in GLSL functions like mod, fma, and max that may not be overloaded for half floats.

You’re using gl_VertexIndex, but this variable is only valid in a vertex shader. Since you’re writing to gl_Position, I assume this is meant to be a vertex shader, but the use of out mediump vec4 colour; (which suggests a fragment output) introduces confusion.

If this is actually a vertex shader, then colour should be a vec4 varying going to the fragment shader, not a framebuffer output. If this is intended to be a fragment shader, then gl_VertexIndex is invalid.

mediump qualifiers like mediump vec4 aren’t part of desktop GLSL 460—they’re part of GLSL ES. If this is for Vulkan/SPIR-V using GLSL 460, you should remove mediump to avoid errors during SPIR-V generation.