Search code examples
openglglslgpuspir-v

How could I simply compile GLSL to SPIR-V?


So I need to get the SPIR-V code of some GLSL

Every resource I can find on the topic involves setting up a whole enviroment for graphics and more.

In the simplest case when I have some GLSL code and I want to get the SPIR-V code, what would be the best way?


Solution

  • The Khronos group provide the Vulkan SDK, which is free to download. In that there is a command line tool glslc which you can call from the command line as so:

    VulkanSDK/x.x.x.x/Bin/glslc shader.vert -o vert.spv

    An example on how to use it also available in the vulkan tutorial. It's pretty plug and play, just download the SDK and run from a terminal.