Shader validatorThis is a vscode extension allowing syntax highlighting, linting & symbol providing for HLSL / GLSL / WGSL shaders. It is using shader-language-server, a shader language server written in Rust to lint shaders using common validator API & parse symbols for some code inspection. It is mostly intended to be used with big shader codebase used in production by providing interesting features such as region selection and a shader variant entry point selection for quickly switching between two entry point context with decent performances. This make it also quite reliable for small shader codebase. Currently, it support some features and languages:
FeaturesSyntax highlightingThis extension provide improved syntax highlighting for HLSL, GLSL & WGSL than the base one in VS code. DiagnosticsYou cant lint your code in real time through this extension:
AutocompletionThe extension will suggest you symbols from your file and intrinsics as you type. SignatureView available signatures for your function as you type it. HoverView informations relative to a symbol by hovering it. GotoGo to your declaration definition by clicking on it. FormattingFormat your code using clang-format, configurable with .clang-format. clang-format need to be available in path. Inlay hintsAdd inlay hints to your function calls.
VariantsSwap shader variant on the fly to change entry point & macro definition. This allow you to define and easily change between the one you have set, affecting regions. For example when you have a lot of entry point in a single shader file, splitted using macros, or want to see the content from your dependencies with the context passed from you main entry point. You can then access these variants directly from the dedicated window and then access them by clicking on them. A neat feature for big shader codebase with lot of entry point everywhere ! You can add one with the dedicated window or using the command RegionsGrey out inactive regions depending on currently declared preprocessor & filter symbols. And much moreThis extension also support some features such as document symbols, workspace symbols... Extension SettingsThis extension contributes the following settings:
HLSL specific settings:
GLSL specific settings:
Platform supportThis extension is supported on every platform, but some limitations are to be expected on some:
Web supportThis extension run on the web on vscode.dev. It is relying on the WebAssembly Execution engine. Because of this restriction, we can't use dxc on the web as it does not compile to WASI and instead rely on glslang, which is more limited in linting (Only support some basic features of SM 6.0, while DXC support all newly added SM (current 6.8)). Questions and answersMy shader entry point is hidden behind an inactive region and does not display symbols.You can use shader variant to declare the entry point and the necessary macro without having to pass through global defines which might impact global state. It will also speed up validation by setting a stage and entry point. Request are really slow on big HLSL filesYou can use shader variant and specify an entry point to speed up things. By default the extension is using the dxc lib profile which is quite a heavy process with big files with a lot of includes. By setting an entry point along a stage, it will speed up validation, but dxc might still have a hard time. Letting the server know where your code start can help it cache everything to the right place ! How to check the logs ?If you encounter an issue with the extension, you might want to check the log to see what is happening. You can simply go to the output tab of the terminal and use the scrolling menu to select Shader Language Server. Make sure you have set setting CreditsThis extension is based on a heavily modified version of PolyMeilex vscode-wgsl |