Jacajack / vscode-glsl-linter

GLSL linter for Code
5 stars 1 forks source link

GLSL Linter: GLSL validator returned exit code 1! #4

Closed deanhopes closed 3 years ago

deanhopes commented 3 years ago

Hi, just wondering how I can fix this issue?

image

Jacajack commented 3 years ago

Hi,

Could you please provide more information when this error message pops up? What happens if you set "glsl-linter.validatorArgs": []? Error code 1 (at least in my version 10:11.0.0) means that there's something wrong with the way the validator is invoked.

Thanks for reporting this!

deanhopes commented 3 years ago

Okay thank you. I've added "glsl-linter.validatorArgs": [] into my settings.json and same exit code.

image

I'm pretty new to this. Could be a poor installation so I can give another go if you can't think of any quick fixes 👍

Jacajack commented 3 years ago

I think I know what's the issue. Your file is called vertex.glsl. The file type is obviously GLSL, so the linter attempts to validate it, but it can't work out the shader type from the extension. The whole point of glsl-linter.fileExtensions is to inform the linter of what extensions correspond to what shader types. This is because each shader type is validated differently.

To fix this, please try changing your shader naming scheme so that the extensions you use correspond to the ones you provided in fileExtensions. For instance, instead of vertex.glsl and fragment.glsl you could have myshader.vs.glsl and myshader.fs.glsl. I think it will make it easier for you to distinguish between the shaders as well.

If you want to stick with fragment.glsl and vertex.glsl you will need to put these in the fileExtensions, like this: "fragment.glsl": "frag". Then your shaders will have to be named like this: my_shader_vertex.glsl (there is no dot before "vertex").

deanhopes commented 3 years ago

Really well explained and I have learned something new. Thank you!

amozeng commented 3 years ago

Hi! I still have this error even after I changed my shader file name. Do you know how to fix it? Thanks! Screen Shot 2021-06-18 at 2 55 31 PM

Jacajack commented 3 years ago

Hi! Your filename looks fine indeed. Can you please share your settings?

It seems that I'll have to implement displaying the full error message from the validator in the error pop-up to make problems like this easier to troubleshoot. I might do that after the weekend, because I'm quite busy right now.

amozeng commented 3 years ago

Sure! There is my settings. Please take your time, it is not super urgent, hope this won't take too much of your time! image

Jacajack commented 3 years ago

@amozeng Okay, so it seems that you haven't set up the glsl-linter.fileExtensions setting which is null by default. This causes the linter to rely on shader recognition provided by glslangValidator, which expects to see extensions like .vert, .frag etc.

If you want to use "custom" extensions such as .fs.glsl, please try setting glsl-linter.fileExtensions. For reference, this is how mine looks like:

"glsl-linter.fileExtensions": {
    ".fs.glsl": "frag",
    ".fs": "frag",
    ".vs.glsl": "vert",
    ".vs": "vert",
    ".tes.glsl": "tese",
    ".tes": "tese",
    ".tcs.glsl": "tesc",
    ".tcs": "tesc",
    ".gs.glsl": "geom",
    ".gs": "geom",
}