A script that scans a folder and its subfolders for shaders and compiles them using slangc.
Tested on Windows 10. Should work fine on other platforms but no guarantee.
-in_dir directory path | input directory (Required).
-out_dir directory path | output directory1 (Optional).
-slangc file path | slangc path (Required).
-max_batch_size uint | maximum amount of shaders compiling at once2 (Optional).
-no_wait | skips waiting for user input once finished (Optional).
-slangc_target slangc target | slangc compile target3 (Required).
-slangc_in_ext file extension(s) | file extension(s) to search for (Required).
-slangc_out_ext file extension | file extension for the outputted shader files (Required).
-slangc_args slangc argument(s) | passes custom arguments to slangc3,4 (Optional).
1The output directory defaults to the directory of the inputted shader file if no argument is provided.
2Max amount of slangc instances compiling shaders at once.
Larger values use more memory.
Defaults to 10 if no argument is provided.
3Slangc command arguments can be found here.
4An input path, output path -o, and target -target are already passed to slangc by the script. I would not recommend passing them using -slangc_args.
-in_dir ./ -slangc "C:\VulkanSDK\1.4.304.1\Bin\slangc.exe" -slangc_target spirv -slangc_in_ext "slang glsl hlsl" -slangc_out_ext spv -slangc_args "-matrix-layout-row-major -fvk-use-entrypoint-name"
- Requires .Net SDK 8.0 or higher.
- Build it like any basic C# console application.