This extension uses shaderc to lint and compile GLSL, and optionally output SPIRV. The aim is to provide a nice way to edit, lint, and compile GLSL shaders targeted at Vulkan, but it may work for other purposes. It has full support for the #include directive. It also adds build commands which output SPIRV files.
You will need a copy of the glslc executable/binary, which is available pre-built in the LunarG Vulkan SDK, or on github
Commands to Build and Build All are made available when you are editing glsl files. These commands will export the compiled SPIRV result from shadrec to a configurable directory. 'Build All' will compile and save out SPIRV for all glsl files in your workspace. By default these commands are bound to ctrl+B and ctrl+shift+B (cmd+B/cmd+shift+B on macOS).
This extension now tracks #include dependencies, so when you build a file, all files in the workspace that #include that file will also be compiled.
If you name files with the extensions '.frag', '.vert', '.tesc', '.tese', '.geom', or '.comp', then everything should just work and shaderc will determine the stage for you. Otherwise, you will need to add the glsl file association for your custom extension in your VSCode settings.json, and provide the shader stage using #pragma shader_stage() as documented here.
Shaderc Linter offers the following settings:
shaderc-lint.glslcPath
: (required) Set this to the path of the glslc executable on your systemshaderc-lint.glslcArgs
: Additional arguments for the glslc executableshaderc-lint.shadercOutputDir
: Output directory for compiled shaders. By default .spv files will be saved alongside your glsl files.shaderc-lint.buildOnSave
: Build and output SPV every time you save a file. If not enabled, you will need to use the Build command to output the compile SPIRV.shaderc-lint.requireSaveToLint
: By default, linting will occur with every text change. Enable this option to only lint when you save the file.shaderc-lint.includeSupport
: Added support for #include. This treats linker errors generated by files with a missing entry point as a warning only. You will also need to specify defaultGLSLVersion to supress linting errors with included files.shaderc-lint.defaultGLSLVersion
: Passed to glslc with -std=. Assigns the GLSL version. Overwrites #version directives, gives a warning if they don't match.