Use SPIR-V tools for Vulkan compliant shaders

Vulkan developers: Are you generating SPIR-V shaders from HLSL using glslangValidator built from https://github.com/KhronosGroup/glslang?

In order to guarantee that your SPIR-V is legal for Vulkan, you must now include spirv-tools when building glslang. This can be done by running update_glslang_sources.py located in the glslang home directory before the configuration cmake step. This clones the latest “known-good” version of spirv-tools into the glslang/External directory.

If spirv-tools is not included in glslang, a warning is printed during the configuration cmake call stating that illegal SPIR-V may be generated for HLSL shaders.

Starting with the next LunarG Vulkan SDK release, the glslangValidator executable included in the SDK will be built with spirv-tools included.

The SPIR-V is made legal by using spirv-opt, the optimizer from spirv-tools. The HLSL shading language requires certain optimizations to allow for generation of SPIR-V that is legal for Vulkan.

The optimizer in glslang can be disabled with the -Od option, although the resulting SPIR-V may not be legal for Vulkan if generated from HLSL.

Note that the optimizer in glslang is not invoked for GLSL shaders by default. If you wish to optimize SPIR-V for size, glslang now offers the -Os option. This can be invoked when compiling from both HLSL and GLSL shaders. This option is only available if spirv-tools was included during the glslang build.

Complete instructions for building glslang can be found in the README.md file in the glslang home directory.

Featured Post

  • All Posts
  • Announcements
  • Blog
  • Presentations
  • White Papers

Latest Posts

  • All Posts
  • Announcements
  • Blog
  • Presentations
  • White Papers

LunarG Email List

Join our email list to receive important news about Vulkan SDK releases, ecosystem surveys, and more.

You have been successfully subscribed! Oops! Something went wrong, please try again.
Edit Template

Partner with LunarG to do impossible things.

The complexity of GPU software development is relentless, but every “unsolvable” problem that comes up is really an opportunity to create a stronger product.

We believe collaboration is one of the great benefits and opportunities of being part of the visual computing community, and our strength is in our shared expertise. While we focus on your GPU coding issues, you can focus on creating unforgettable visual experiences.

Together, we’ll unlock the full power and potential of today’s GPU’s to surpass your customers’ expectations. 
Successful Software Project
Edit Template

GPU software development teams often run into roadblocks they can’t move on their own. LunarG is the industry’s leading problem-solving partner for GPU programming. We provide the tools, expertise, and passion you need to keep moving forward and deliver innovative, quality products. Let us know how we can help your next project succeed.

LunarG Email List

Join our email list to receive important news about Vulkan SDK releases, ecosystem surveys, and more.

You have been successfully subscribed! Oops! Something went wrong, please try again.

© 2025 LunarG, Inc. All Rights Reserved.   |   Privacy   |   Terms   |    Follow LunarG