Closed kayru closed 4 years ago
Good thing. What do you think about enabling the current path of the file to lint as an include path. Maybe as an opt-in setting?
Adding the current file path to include path list will likely do the trick, though I don't know how exactly glslangValidator searches for includes. Worth a try.
I will try to implement it will it be possible to attach some example shader files with includes?
Sure. Trivial example: https://gist.github.com/kayru/f619234dc40fedb077f2f60730961c48
Next version (0.0.13) will have 2 new options, both are enabled by default:
glsllint.linkShader
: Link all input files together to form a single module ('-l' option for glslangValidator, used for includes)glsllint.useIncludeDirOfFile
: Add -I[DIR_OF_FILE]
to the glslangValidator command
It is not uncommon for
#include
directives to use paths relative to the current file. However, as glsllint provides input source code to glslangValidator via stdin and sets cwd tovscode.workspace.rootPath
, file-relative includes do not work.It is possible to work around the issue by using project-specific
glsllint.glslangValidatorArgs
with-I<rootPath-relative-directory>
flag, however this does not work in larger projects with multiple directories that may contain shader files.It would be very welcome if
#include "<relative-path>"
worked out-of-the-box with this extension. Perhaps as an opt-in via settings, off by default.