Skip to content

Commit

Permalink
Merge pull request #70 from hsimpson/fix/#68-detection-of-shaders-in-…
Browse files Browse the repository at this point in the history
…string-literals

fix: shader detection of string literals
  • Loading branch information
hsimpson authored Sep 4, 2023
2 parents 5a956e7 + 52917e3 commit 3c81393
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 14 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.17.1
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to the "vscode-glsllint" extension will be documented in thi

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [1.8.1]

### Fixed

- Detection of shaders in string literals does not work with some strings [#68](https://github.com/hsimpson/vscode-glsllint/issues/68)

## [1.8.x]

### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-glsllint",
"version": "1.8.0",
"version": "1.8.1",
"publisher": "dtoplak",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/features/glsllintProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class GLSLLintingProvider {
}

private getShaderLiterals(literals: StringLiteral[]): StringLiteral[] {
const isShaderRegex = /main\s*\(.*\)\s*\{/gm;
const isShaderRegex = /main(.*|\s)\((.*|\s)\)/gm;

const shaderLiterals = literals.filter((literal) => {
// check if this literal is a shader
Expand Down
22 changes: 11 additions & 11 deletions test/test_shaders/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"glsllint.additionalStageAssociations": {
".fragment.fx": "frag",
".vertex.fx": "vert"
},
"glsllint.glslifyAutoOpenOnError": true,
"glsllint.glslifyOptions": {
// "glsllint.additionalStageAssociations": {
// ".fragment.fx": "frag",
// ".vertex.fx": "vert"
// },
// "glsllint.glslifyAutoOpenOnError": true,
// "glsllint.glslifyOptions": {
// "basedir": "G:\\src\\vscodeextensions\\vscode-glsllint\\test\\test_shaders\\GLSLIFY\\chunks"
},
// },
// "glsllint.glslangValidatorArgs": "--target-env vulkan1.1",
"glsllint.glslifyUseCurrentFileAsBasedir": true,
"glsllint.linkShader": false,
"glsllint.glslangValidatorArgs": "-V",
"glsllint.fallBackStage": "comp"
// "glsllint.glslifyUseCurrentFileAsBasedir": true,
// "glsllint.linkShader": false,
// "glsllint.glslangValidatorArgs": "-V",
// "glsllint.fallBackStage": "comp"
}
13 changes: 13 additions & 0 deletions test/test_shaders/GLSL_ES_3.00/pass_through.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#version 300 es

precision highp float;

// input from vertex shader
in vec3 vColor;
out vec4 outPutColor;


void main()
{
outPutColor = vec4(vec3(vColor), 1.0);
}
14 changes: 14 additions & 0 deletions test/test_shaders/GLSL_ES_3.00/pass_through.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#version 300 es

uniform mat4 u_projectionMatrix;
uniform mat4 u_viewMatrix;
uniform mat4 u_modelMatrix;

in vec3 a_position;

out vec4 v_color;

void main() {
v_color = vec4(1.0, 0.0, 0.0, 1.0);
gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * vec4( a_position, 1.0 );
}
2 changes: 1 addition & 1 deletion test/test_shaders/STRINGLITERALS/script-pragmas.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function bar(param) {
const another_shader = `
#version 460 core
#pragma vscode_glsllint_stage : frag
#pragma vscode_glsllint_stage: frag
out vec4 FragColor;
Expand Down
20 changes: 20 additions & 0 deletions test/test_shaders/STRINGLITERALS/simple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const vertexShaderSource = `#version 300 es
#pragma vscode_glsllint_stage: vert
void main()
{
gl_Position = vec4(0.0,0.0,0.0,1.0);
}`;

const fregmentShderSource = `
#version 300 es
#pragma vscode_glsllint_stage: frag
main() ERROR HERE FOR TRIGER THE VALIDATOR
{
gl_FragColor = vec4(1.0,0.0,0.0,1.0);
}`;

const c = document.querySelector('canvas');
const gl = c.getContext('webgl2');
const program = gl.createProgram();
gl.useProgram(program);

0 comments on commit 3c81393

Please sign in to comment.