Skip to content

GLSL edit in Visual Studio

Hilderin edited this page Nov 17, 2023 · 5 revisions

Plugin installation

We suggest you install the "GLSL language integration (for VS2017, 2019 and 2022)" extension so you can fully edit your shader files with validations and syntax highligthing.

  • Install the extension: GLSL language integration (for VS2017, 2019 and 2022)
  • By default, it does not support Vulkan shaders. You must activate the external compiler: Tools > Options > GLSL language integration
  • Set "External compiler executable file path" to glslangValidator.exe on your computer.
  • Set "Arguments for the external compiler" to: --target-env vulkan1.2
  • Resave your shader file and the validation should now be ok for your Vulkan shader files.

Exemple: image

Includes

GLSL does not support include by default but MiniEngine does it for you. You can use #include "path" in your shader code and at compile time, the engine will fusion all the included files into one large shader code file and compile it into spirv binary code.

Exemple:

my_structs.glsl:

//? #version 450

struct scene_data
{
    mat4 matrix_vp;
};

Note the first line //? #version 450. With //? you tell the Visual Studio plugin to include the '#version' only when compiling this file alone. This way the glsl validator knowns the glsl version but when this file is included, this line is kept as a comment and we don't have '#version' in the middle of the large shade code file generated.

In your shader file:

#version 450

#include "my_structs.glsl"

layout(binding = 1) readonly uniform _scene {
    scene_data scene;
};

Clone this wiki locally