Closed alexgg-developer closed 4 years ago
It was a problem related with the extension. I was using .vs and .fs and it only seems to work with .frag and .vert
Unfortunately the glslangValidator only supports a few extensions: https://github.com/KhronosGroup/glslang/blob/master/StandAlone/StandAlone.cpp#L1290
I will ad them all and also add some error handling when the glslangValidator is called wrong
Hi, the support of glsl
extension seems still problematic. I have some shader files like xxx.vert.glsl
and xxx.frag.glsl
, I can directly use glslangValidator
in the command line, but the extension will throw errors when handling them.
The error pop-ups are
GLSL Lint: Wrong parameters when starting glslangValidator.
Arguments: -l --stdin -S stderr:
It's the same even I disabled glsllint.useIncludeDirOfFile
and glsllint.linkShader
. And
GLSL Lint: GLSL Lint: failed to map extension: '.glsl', you can add it to the extension setting 'glsllint.additionalStageAssociations'
I tried to add .frag.glsl
and .glsl
to glsllint.additionalStageAssociations
, but no luck.
Is it possible to attach your shader files and your glsllint config object here? Then I can debug the problem. If there are some secret algorithms in the shader files you could remove them ;-)
There's nothing secret, just the re-implementation of some common algorithms.
The config entries are
"glsllint.linkShader": false,
"glsllint.useIncludeDirOfFile": false,
"glsllint.additionalStageAssociations": {
".frag.glsl": "frag",
".glsl": "frag"
},
The shader file is as below, the validator should complain at line 45, where the function CastRay
should have a return value. The original file name is SSGR.frag.glsl
.
#version 460
in vec2 uv;
out vec4 posSSGR;
out vec3 normSSGR;
out vec4 colorSSGR;
out float blendSSGR;
uniform sampler2D posRTT, normRTT, colorRTT, reflRTT;
uniform mat4 p; // Projection matrix
uniform int width, height;
/// Convert view position to uv, z and w are kept
vec4 ToUV(vec3 posView) {
vec4 posProjection = p * vec4(posView, 1);
posProjection.xy = (posProjection.xy / posProjection.w + 1) / 2; // Range [0, 1]
return posProjection;
}
vec3 BinarySearch(vec3 origin, vec3 direction, int limit) {
float depthDelta;
while (limit-- > 0) {
depthDelta = origin.z - texture(posRTT, ToUV(origin).xy).z;
origin += depthDelta > 0 ? direction : -direction;
direction /= 2;
}
return origin;
}
// bool CastRay(vec3 origin, vec3 direction, out vec3 posHitView, out vec2 posHitUV) {
// const float sizeStep = 0.1;
// direction *= sizeStep; // Step size
// for (int i = 0; i < 350; i++) {
// origin += direction;
// float depthActual = texture(posRTT, ToUV(origin).xy).z;
// if (0 < depthActual - origin.z && depthActual - origin.z < 2 * sizeStep) {
// posHitView = BinarySearch(origin, direction, 20);
// posHitUV = ToUV(posHitView).xy;
// return clamp(posHitUV, 0, 1) == posHitUV;
// }
// }
// return false;
// }
// By default in view space
bool CastRay(vec3 origin, vec3 direction, out vec3 posHit, out vec2 posHitUV) {
const int numMaxStep = 100;
float numStep = origin.z + direction.z * numMaxStep < 0 ? -origin.z / direction.z : numMaxStep;
vec3 target = origin + direction * numStep;
vec4 originUV = ToUV(origin);
vec4 targetUV = ToUV(target);
}
void main() {
if (texture(reflRTT, uv).r == 0) discard;
vec3 pos = texture(posRTT, uv).xyz;
vec3 norm = texture(normRTT, uv).xyz;
vec4 color = texture(colorRTT, uv);
vec3 direction = normalize(reflect(normalize(pos), norm));
vec3 posHitView;
vec2 posHitUV;
if (CastRay(pos, direction, posHitView, posHitUV)) {
posSSGR = vec4(posHitView, 1);
colorSSGR = texture(colorRTT, posHitUV);
blendSSGR = clamp(distance(pos, posHitView) / 10, 0, 1);
} else discard;
}
This problem is fixed with the latest release 1.0.0
Hi, the support of
glsl
extension seems still problematic. I have some shader files likexxx.vert.glsl
andxxx.frag.glsl
, I can directly useglslangValidator
in the command line, but the extension will throw errors when handling them.The error pop-ups are
GLSL Lint: Wrong parameters when starting glslangValidator. Arguments: -l --stdin -S stderr:
It's the same even I disabled
glsllint.useIncludeDirOfFile
andglsllint.linkShader
. AndGLSL Lint: GLSL Lint: failed to map extension: '.glsl', you can add it to the extension setting 'glsllint.additionalStageAssociations'
I tried to add
.frag.glsl
and.glsl
toglsllint.additionalStageAssociations
, but no luck.
This looks very similar to what I am experiencing. I attempted to add '.vertex.fx' and '.fragment.fx' like so:
"glsllint.additionalStageAssociations": {
".fragment.fx": "frag",
".vertex.fx": "vert"
}
and get the following errors:
GLSL Lint: GLSL Lint: failed to map extension: '.fx', you can add it to the extension setting 'glsllint.additionalStageAssociations'
and
GLSL Lint: Wrong parameters when starting glslangValidator. Arguments: -l --stdin -S stderr:
running version 1.1.1
I will debug this and try to reproduce the problem
@cptSwing I have created a fix and there is a testing release .vsix file in https://github.com/hsimpson/vscode-glsllint/releases (v1.2.0) could you test this on your site. If everything works, I will publish to the VSCode Marketplace next week.
Hey, please excuse the late reply!
It does work. No errors when it recognizes a GLSL file (I had to manually set fragment.fx and vertex.fx to GLSL in files.associations or it'd open as HLSL), and it seems to be parsing fine!
A different error is this: When it finds errors, it underlines the very first character (first line and first column) for all of them..
That seems to have fixed itself to underlining the first char on the actual errors' line, at least. Might be intended this way?
Hey, please excuse the late reply!
no Problem ;-)
It does work. No errors when it recognizes a GLSL file (I had to manually set fragment.fx and vertex.fx to GLSL in files.associations or it'd open as HLSL), and it seems to be parsing fine!
Yes this was intended because .fx is not in the default mappings. So then I will publish next week to Marketplace
That seems to have fixed itself to underlining the first char on the actual errors' line, at least. Might be intended this way?
Yes this is because glslangValidator does not provide a column when there is a issue detected. Only line.
This problem is occurring again for me with .glsl files.
This problem is occurring again for me with .glsl files.
Could you post your shader, or at least a part of it, if there is some code you will not show.
All code is shown correctly (and also seems to be highlighted) - its just that the linting (error highlighting and other features) don't work correctly.
All code is shown correctly (and also seems to be highlighted) - its just that the linting (error highlighting and other features) don't work correctly.
It looks like your file is only called bloom
without any extension. To lint the shader I must know the type of the shader (Vertex, Fragment, Compute, etc...). If you want to use .glsl
as the extension you should name your files with the compound extensions like .vert.glsl
or .frag.glsl
.
In this case .glsl is a fragment shader. Since in my current project I only use fragment shaders (besides a single vertex shader), and using a double extension would break parts of the codebase (as extension management to include the shaders would fail ) - Is there a way to simply override it to use fragment mode in shaders without an extension ?
In this case .glsl is a fragment shader. Since in my current project I only use fragment shaders (besides a single vertex shader), and using a double extension would break parts of the codebase (as extension management to include the shaders would fail ) - Is there a way to simply override it to use fragment mode in shaders without an extension ?
Hm, damn ;-)
Could you use .frag
as an extension? The Problem is that .glsl
always needs another extension before.
No extension would also not work, because this case was never supported (I have debugged it)
So as a workaround you can use whatever extension you want and map it to stage frag
in glsllint.additionalStageAssociations
Otherwise I have to make some changes, like if the stage could not be deducted to use an optional fallback stage.
I can try using .frag, however this may require me to rebuild parts of the deployment and compilation pipeline... So a fallback stage would be appreciated ! Oddly enough this issue is new though, I haven't actually had it before, only since a good month or so.
Hello,
I have just installed glsl lint and configured the path to the glsl validator but it does not seem to show any errors for the glsl code.
Info:
Version 1.30.1 GLSL Lint 0.0.4 OS: Windows 10.0.17134 Path used: C:\glslValidator\bin\glslangValidator.exe downloaded from : https://github.com/KhronosGroup/glslang/releases/tag/master-tot (release x64)