danielscherzer / GLSL

VSIX Project that provides GLSL language integration.
258 stars 28 forks source link

using EnvVars in external compiler path #71

Closed spfuetzner closed 3 years ago

spfuetzner commented 4 years ago

It would be nice if you could use environment variables in the file path of the external compiler.

The external compiler is often used to support the Vulkan and Google include extensions and the required glslangValidator is usually installed with the LunarG Vulkan SDK. Unfortunately, the version number is in the path, so the option in the GLSL extension has to be adjusted with every update.

Possible spellings could be $(EnvVar) or %EnvVar%:

$(VULKAN_SDK)\Bin\glslangValidator.exe

%VULKAN_SDK%\Bin\glslangValidator.exe
danielscherzer commented 4 years ago

Hopefully this works as expected...

spfuetzner commented 4 years ago

I'm afraid not. The following is now in the log:

[09.30 11:23:16.197] Using external compiler 'C:\VulkanSDK\1.2.148.1\Bin\glslangValidator.exe' with arguments '-C -r -w --target-env vulkan1.1 --target-env vulkan1.2' on temporal shader file 'C:\Users\kiba\AppData\Local\Temp\shader.frag' 
[09.30 11:23:26.204] External compiler did take more than 10 seconds to finish. Aborting! 
[09.30 11:23:26.236] Dumping shader log:
Usage: glslangValidator [option]... [file]...

'file' can end in .<stage> for auto-stage classification, where <stage> is:
    .conf   to provide a config file that replaces the default configuration
            (see -c option below for generating a template)
    .vert   for a vertex shader

This is followed by the complete description as it is displayed when glslangValidator is started without parameters.

danielscherzer commented 4 years ago

Thanks for the quick reply. Too many quotes in my code... -> Update

spfuetzner commented 4 years ago

Fixed! Also using environment variables now works. Thank you!

One small problem is still left. In the "Message" tab of the Error List window there is always one message:

Could not parse line 'C:\Users\kiba\AppData\Local\Temp\shader.frag'

The log has no such warning.

danielscherzer commented 4 years ago

Even if there is no error in the code? For me this line only shows up, if I have errors. For example: Screenshot 2020-10-01 094341 Here the extension is reporting which lines it could not parse (all lines without error/warnings). If I remember correctly the line with only the filename was produced by glslangvalidator on the error output stream, while the log was on the standard output stream (or vice versa). Other shader compiler put there log onto the error output stream. I have to parse both to support most shader compilers. That could be the reason why you do not see this line in the log.

spfuetzner commented 4 years ago

Only with the external glslangValidator compiler, but then even for the simplest shader:

#version 460
void main() {}

It prints the message for line 1 in my shader. But it's not a big problem, most of the time informational messages are disabled anyway in the Error list.

danielscherzer commented 4 years ago

Currently my parser handles each line individually, which makes him simple (modeless) and robust in terms of additional lines without usable error information, like preambles or stats at the end. If I start to filter lines I think the parsing will become more error prone to changes in the shader compiler outputs. So I would argue for keeping the status quo.

danielscherzer commented 3 years ago

Can I close this issue?

spfuetzner commented 3 years ago

Can I close this issue?

Sure. And thanks!

danielscherzer commented 3 years ago

Thanks!