0
\$\begingroup\$

Trying to compile my pixel shader,and a warning generated:

D:\CS\ComputerGraphics\vulkan\WindowsProject1>D:\ProgrammingTools\vulkan\Bin\glslc shader.frag -o frag.spv shader.frag:3: warning: '#extension' : extension not supported: GL_KHR_vulkan_glsl 1 warning generated.

The following is my pixel shade code:

#version 460
#extension GL_ARB_separate_shader_objects : enable
#extension GL_KHR_vulkan_glsl : enable
#extension GL_EXT_debug_printf : enable
//Input
layout(location = 0) in vec3 fragColor;
layout(location = 1) in vec2 fragTexCoord;
//Output
layout(location = 0) out vec4 outColor;
//uniform
layout(set = 0,binding = 2) uniform sampler2D texSampler;
void main() {
    outColor = texture(texSampler, fragTexCoord);
}

how do I fix this?

\$\endgroup\$
1
\$\begingroup\$

It's just a warning!(ummm...it's good to see someone care about those) and doesn't cause any issues in rendering, it just makes sure the shader adhers that glsl is being used to produce spir-v and any shader without this will be rejected by the glsl compiler, moreover glslc has many built-in features to detect such incompatible shaders so I don't think this is necessary. The following below text is from the official docs, you can read more about this extension and probably glslc documentation to see why this is being caused, for now you can safely remove #extension GL_KHR_vulkan_glsl : enable and compile with 0 warnings.

This extension is not enabled with a #extension as other extensions are.
It is also not enabled through use of a profile or #version.  The intended
level of GLSL/ESSL features, independent from Vulkan-specific usage, comes
from the traditional use of #version, profile, and #extension.


Instead, use of this extension is an effect of using a GLSL front-end in a
mode that has it generate SPIR-V for Vulkan.  Such tool use is outside the
scope of using the Vulkan API and outside the definition of GLSL and this
extension. See the documentation of the compiler to see how to request
generation of SPIR-V for Vulkan.


When a front-end is used to accept this extension, it must error check and
reject shaders not adhering to this specification, and accept those that
do.  Implementation-dependent maximums and capabilities are supplied to, or
part of, the front-end, so it can do error checking against them.

source : https://github.com/KhronosGroup/GLSL/blob/ab928c80851b96f3889f1287d4ce0003a9bb86e4/extensions/khr/GL_KHR_vulkan_glsl.txt#L100-L114

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.