Compile GLSL to SPIR-V

Hello Users,

I can’t find a way to compile my GLSL-shader to SPIR-V.

I would prefer converting them with a .bat (batch-file).

Unfortunatelly I can’t find any examples on this.

Thank’s for each answer in advance!

.black

If you want to convert using .bat use the glslang reference compiler from the LunarG SDK like this :

glslangvalidator -V shader.vert -o shader.vert.spv

The shader type (vertex, fragment, compute, etc.) is determined by it’s extension.

If you’re using Visual Studio you may want to take a look at my extension that adds menu entries for converting shader files from the IDE.

I already installed that extension.

As description to the extension there is: " The extension will search for the glslangvalidator.exe using the paths from the following environment variables: PATH, VK_SDK_PATH and VULKAN_SDK (set by the LunarG SDK)".

The output error of Visual Studio is: “Could not locate the glslang reference compiler (glslangvalidator.exe) in system path!”.

I can’t find a way how to set up that compiler… Actually I’m lost.

Easiest way is to install the Vulkan SDK from LunarG available at LunarXchange

It contains a version of the reference compiler that supports Vulkan and should set the paths that my extension relies on.

I reinstalled that Visual Studio extension into C drive.

Now following error occours: “C:\VulkanSDK\1.0.30.0\Bin\glslangvalidator.exe: Error unable to open input file (use -h for usage) S:\Developement Zone\ShadowEngine\DraftsCore\sample.frag”

on executing: Compile to SPIR-V (Vulkan)

This is a bug on the extension if your path contains a blank space. I’ll fix that for a future release. If you remove the blank space it should work. If that’s not an option, just call the glslang reference compiler from the command line using e.g. a .bat or prebuilt events of VS.

Okay. I deleted all the blank spaces in my path and it works.

Thank you very much for your plugin and your time.

Have a nice day :smiley: