Instead of manually compiling my GLSL shaders to SPIR-V, I want Visual Studio to automatically detect changes to shader files and run glslangValidator as a build step. I am using Premake to generate the Visual Studio solution/project.
One solution that partly worked was declaring in premake5.lua
:
--prebuildcommands [[for %%i in (..\data\shaders\*) do (..\libs\vulkan\glslangValidator.exe -V -o "%%~dpibin\%%~nxi.spv" %%i)]]
and then right-click shader in solution explorer -> properties -> General -> Item Type -> Custom Build Tool
.
There are some downsides to this approach:
- All shaders recompile when only one changes
- I had to manually change the VS project settings
The closest thing I could find in the premake documentation was: Custom Build Commands. I think the idea is to use a filter on shader files and generate build commands, but I just couldn't get anything to work. Maybe someone else has an idea?