This VSIX extension adds commands to the context menu of shader files (and folders containing shaders) that let's you quickly compile to them to SPIR-V and supports both GLSL and HLSL as source.
The extension requires a version of the glslang reference compiler to be in your path that supports SPIR-V:
- Install the LunartG Vulkan SDK (comes with a pre-built version)
- Built from the sources at https://github.com/KhronosGroup/glslang
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). Alternatively you can override this with an explicit location in the extensions' settings page.
For compiling from HLSL, the extension requires a version of the DirectX shader compiler to be in your path that supports SPIR-V:
- Install the LunartG Vulkan SDK (comes with a pre-built version)
- Built from the sources at https://github.com/microsoft/DirectXShaderCompiler/
The extension will search for the dxc.exe
using the paths from the following environment variables: PATH
, VK_SDK_PATH
and VULKAN_SDK
(set by the LunarG SDK). Alternatively you can override this with an explicit location in the extensions' settings page.
The extension supports all editions of Visual Studio 2015, 2017 and 2019.
The extension is available at the Visual Studio Marketplace and can be installed directly from the IDE.
The context menu entries will be displayed if the current file selection or folder includes at least one shader file with a file extension supported by the GLSL reference compiler:
.vert
(Vertex shader).tesc
(Tessellation control shader).tese
(Tessellation evaluation shader).geom
(Geometry shader).frag
(Fragment shader).comp
(Compute shader).mesh
(Mesh shader).task
(Task shader).rgen
(Ray generation shader).rint
(Ray intersection shader).rahit
(Ray any hit shader).rchit
(Ray closest hit shader).rmiss
(Ray miss shader).rcall
(Ray callable shader)
These are currently fixed, but future versions may add an options pane to adjust file extensions and how they are treated.
Compile all selected GLSL shader files to SPIR-V binary using Vulkan semantics (-V).
Compile all selected HLSL shader files to SPIR-V binary format using the SPIR-V back-end of the DirectX shader compiler.
Compile all selected shader files to SPIR-V binary using OpenGL semantics (-G).
Note: SPIR-V for OpenGL is supported with the GL_ARB_gl_spirv
extension and implemented as a binary shader format.
A C++ example for loading a binary SPIR-V shader with OpenGL can be found here.
This will output human readable SPIR-V (-H) using Vulkan semantics and displays it in a new document window.
Compile errors are added to the error list of Visual Studio and work like regular compile errors. Double clicking on an error will open that shader and jump to the line that the error has occured.
This is a very early version of this extension, some of the planned features are:
- Extension settings pane
- Add file extension mappings
- Custom binary SPIR-V output file name scheme (instead of a fixed output file scheme)
- Option to disable dialog boxes after compile
- Option to use a remapper (SPIR-V remap etc.)
- Save to text as hexadecimal numbers (-x)
- Generate include headers
- Language features (as soon as their support by the reference compiler is finished)
- Multiple main entry points
- Compile from HLSL
Issues and pull request for additional features are welcome :)