diff --git a/Test/120.frag b/Test/120.frag index 98f5c1487b8558516aa070c8ab13fc65099ab52d..f0c454eeb2e6b31e6b04eee995a7c27d38d6d531 100644 --- a/Test/120.frag +++ b/Test/120.frag @@ -1,10 +1,10 @@ #version 120 -lowp vec3 a; -mediump float b; -highp int c; +float lowp; +float mediump; +float highp; -precision highp float; +float precision; in vec4 i; out vec4 o; diff --git a/Test/specExamples.frag b/Test/specExamples.frag index 3da05f43789c82ada262ff79265484b4baab2b9e..1877de13fca16f871e513eafc0b70cebaf204576 100644 --- a/Test/specExamples.frag +++ b/Test/specExamples.frag @@ -6,11 +6,11 @@ int a = 0xffffffff; // 32 bits, a gets the value -1 //int b = 0xffffffffU; // ERROR: can't convert uint to int uint c = 0xffffffff; // 32 bits, c gets the value 0xFFFFFFFF //uint d = 0xffffffffU; // 32 bits, d gets the value 0xFFFFFFFF -int e = -1; // the literal is ā1ā, then negation is performed, +int e = -1; // the literal is "1", then negation is performed, // and the resulting non-literal 32-bit signed // bit pattern of 0xFFFFFFFF is assigned, giving e // the value of -1. -//uint f = -1u; // the literal is ā1uā, then negation is performed, +//uint f = -1u; // the literal is "1u", then negation is performed, // and the resulting non-literal 32-bit unsigned // bit pattern of 0xFFFFFFFF is assigned, giving f // the value of 0xFFFFFFFF. @@ -58,20 +58,20 @@ light lights[]; const int numLights = 2; light lights[numLights]; -in vec3 normal; +in vec3 normal; centroid in vec2 TexCoord; invariant centroid in vec4 Color; noperspective in float temperature; flat in vec3 myColor; noperspective centroid in vec2 myTexCoord; -uniform vec4 lightPosition; +uniform vec4 lightPosition; uniform vec3 color = vec3(0.7, 0.7, 0.2); // value assigned at link time -in Material { - smooth in vec4 Color1; // legal, input inside in block - smooth vec4 Color2; // legal, 'in' inherited from 'in Material' - vec2 TexCoord; // legal, TexCoord is an input +in Material { + smooth in vec4 Color1; // legal, input inside in block + smooth vec4 Color2; // legal, 'in' inherited from 'in Material' + vec2 TexCoord; // legal, TexCoord is an input uniform float Atten; // illegal, mismatched storage qualifier }; @@ -80,8 +80,8 @@ in Light { vec4 LightPos; vec3 LightColor; }; -in ColoredTexture { - vec4 Color; +in ColoredTexture { + vec4 Color; vec2 TexCoord; } Material; // instance name vec3 Color; // different Color than Material.Color @@ -104,8 +104,8 @@ layout(location = 3, index = 1) out vec4 factor; layout(location = 2) out vec4 colors[3]; layout (depth_greater) out float gl_FragDepth; - -// redeclaration that changes nothing is allowed + +// redeclaration that changes nothing is allowed out float gl_FragDepth; // assume it may be modified in any way @@ -120,7 +120,7 @@ layout (depth_less) out float gl_FragDepth; // assume it will not be modified layout (depth_unchanged) out float gl_FragDepth; -in vec4 gl_Color; // predeclared by the fragment language +in vec4 gl_Color; // predeclared by the fragment language flat in vec4 gl_Color; // redeclared by user to be flat diff --git a/glslang/MachineIndependent/glslang.l b/glslang/MachineIndependent/glslang.l index cb9a035617fba76c7a473fc00fc7cdbccd4e756c..0719a6a48003cc116db539940232c736d0c630eb 100644 --- a/glslang/MachineIndependent/glslang.l +++ b/glslang/MachineIndependent/glslang.l @@ -69,6 +69,11 @@ LF [lL][fF] #include "ParseHelper.h" #include "glslang_tab.cpp.h" +int PaIdentOrReserved(bool reserved, TParseContext&, int line, char* text, YYSTYPE* pyylval); +int PaPrecisionKeyword(TParseContext&, int line, char* text, YYSTYPE* pyylval, int keyword); +int PaMatNxM(TParseContext&, int line, char* text, YYSTYPE* pyylval, int keyword); +int PaDMat(TParseContext&, int line, char* text, YYSTYPE* pyylval, int keyword); + /* windows only pragma */ #ifdef _MSC_VER #pragma warning(disable : 4102) @@ -101,19 +106,27 @@ TSourceLoc yylineno; "attribute" { pyylval->lex.line = yylineno; return(ATTRIBUTE); } "const" { pyylval->lex.line = yylineno; return(CONST); } -"patch" { pyylval->lex.line = yylineno; return(PATCH); } -"sample" { pyylval->lex.line = yylineno; return(SAMPLE); } "uniform" { pyylval->lex.line = yylineno; return(UNIFORM); } +"varying" { pyylval->lex.line = yylineno; return(VARYING); } "buffer" { pyylval->lex.line = yylineno; return(BUFFER); } "shared" { pyylval->lex.line = yylineno; return(SHARED); } + "coherent" { pyylval->lex.line = yylineno; return(COHERENT); } "volatile" { pyylval->lex.line = yylineno; return(VOLATILE); } "restrict" { pyylval->lex.line = yylineno; return(RESTRICT); } "readonly" { pyylval->lex.line = yylineno; return(READONLY); } "writeonly" { pyylval->lex.line = yylineno; return(WRITEONLY); } -"varying" { pyylval->lex.line = yylineno; return(VARYING); } + "layout" { pyylval->lex.line = yylineno; return(LAYOUT); } +"centroid" { pyylval->lex.line = yylineno; return(CENTROID); } +"flat" { pyylval->lex.line = yylineno; return(FLAT); } +"smooth" { pyylval->lex.line = yylineno; return(SMOOTH); } +"noperspective" { pyylval->lex.line = yylineno; return(NOPERSPECTIVE); } + +"patch" { pyylval->lex.line = yylineno; return(PATCH); } +"sample" { pyylval->lex.line = yylineno; return(SAMPLE); } + "break" { pyylval->lex.line = yylineno; return(BREAK); } "continue" { pyylval->lex.line = yylineno; return(CONTINUE); } "do" { pyylval->lex.line = yylineno; return(DO); } @@ -126,21 +139,19 @@ TSourceLoc yylineno; "if" { pyylval->lex.line = yylineno; return(IF); } "else" { pyylval->lex.line = yylineno; return(ELSE); } +"subroutine" { pyylval->lex.line = yylineno; return(SUBROUTINE); } + "in" { pyylval->lex.line = yylineno; return(IN); } "out" { pyylval->lex.line = yylineno; return(OUT); } "inout" { pyylval->lex.line = yylineno; return(INOUT); } -"centroid" { pyylval->lex.line = yylineno; return(CENTROID); } -"noperspective" { pyylval->lex.line = yylineno; return(NOPERSPECTIVE); } -"flat" { pyylval->lex.line = yylineno; return(FLAT); } -"smooth" { pyylval->lex.line = yylineno; return(SMOOTH); } "precise" { pyylval->lex.line = yylineno; return(PRECISE); } "invariant" { pyylval->lex.line = yylineno; return(INVARIANT); } -"precision" { pyylval->lex.line = yylineno; return(PRECISION); } -"highp" { pyylval->lex.line = yylineno; return(HIGH_PRECISION); } -"mediump" { pyylval->lex.line = yylineno; return(MEDIUM_PRECISION); } -"lowp" { pyylval->lex.line = yylineno; return(LOW_PRECISION); } +"highp" { return PaPrecisionKeyword(parseContext, yylineno, yytext, pyylval, HIGH_PRECISION); } +"mediump" { return PaPrecisionKeyword(parseContext, yylineno, yytext, pyylval, MEDIUM_PRECISION); } +"lowp" { return PaPrecisionKeyword(parseContext, yylineno, yytext, pyylval, LOW_PRECISION); } +"precision" { return PaPrecisionKeyword(parseContext, yylineno, yytext, pyylval, PRECISION); } "float" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(FLOAT); } "double" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DOUBLE); } @@ -153,50 +164,50 @@ TSourceLoc yylineno; "discard" { pyylval->lex.line = yylineno; return(DISCARD); } "return" { pyylval->lex.line = yylineno; return(RETURN); } -"subroutine" { pyylval->lex.line = yylineno; return(SUBROUTINE); } -"mat2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2); } -"mat3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT3); } -"mat4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT4); } - -"mat2x2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2X2); } -"mat2x3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2X3); } -"mat2x4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2X4); } -"mat3x2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT3X2); } -"mat3x3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT3X3); } -"mat3x4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT3X4); } -"mat4x2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT4X2); } -"mat4x3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT4X3); } -"mat4x4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT4X4); } -"dmat2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT2); } -"dmat3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT3); } -"dmat4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT4); } -"dmat2x2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT2X2); } -"dmat2x3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT2X3); } -"dmat2x4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT2X4); } -"dmat3x2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT3X2); } -"dmat3x3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT3X3); } -"dmat3x4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT3X4); } -"dmat4x2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT4X2); } -"dmat4x3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT4X3); } -"dmat4x4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT4X4); } "atomic_uint" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(ATOMIC_UINT); } -"vec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC2); } -"vec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC3); } -"vec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC4); } -"dvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC2); } -"dvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC3); } -"dvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC4); } -"ivec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC2); } -"ivec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC3); } -"ivec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC4); } -"uvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC2); } -"uvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC3); } -"uvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC4); } -"bvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC2); } -"bvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC3); } -"bvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC4); } +"mat2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2); } +"mat3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT3); } +"mat4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT4); } + +"mat2x2" { return PaMatNxM(parseContext, yylineno, yytext, pyylval, MAT2X2); } +"mat2x3" { return PaMatNxM(parseContext, yylineno, yytext, pyylval, MAT2X3); } +"mat2x4" { return PaMatNxM(parseContext, yylineno, yytext, pyylval, MAT2X4); } +"mat3x2" { return PaMatNxM(parseContext, yylineno, yytext, pyylval, MAT3X2); } +"mat3x3" { return PaMatNxM(parseContext, yylineno, yytext, pyylval, MAT3X3); } +"mat3x4" { return PaMatNxM(parseContext, yylineno, yytext, pyylval, MAT3X4); } +"mat4x2" { return PaMatNxM(parseContext, yylineno, yytext, pyylval, MAT4X2); } +"mat4x3" { return PaMatNxM(parseContext, yylineno, yytext, pyylval, MAT4X3); } +"mat4x4" { return PaMatNxM(parseContext, yylineno, yytext, pyylval, MAT4X4); } +"dmat2" { return PaDMat(parseContext, yylineno, yytext, pyylval, DMAT2); } +"dmat3" { return PaDMat(parseContext, yylineno, yytext, pyylval, DMAT3); } +"dmat4" { return PaDMat(parseContext, yylineno, yytext, pyylval, DMAT4); } +"dmat2x2" { return PaDMat(parseContext, yylineno, yytext, pyylval, DMAT2X2); } +"dmat2x3" { return PaDMat(parseContext, yylineno, yytext, pyylval, DMAT2X3); } +"dmat2x4" { return PaDMat(parseContext, yylineno, yytext, pyylval, DMAT2X4); } +"dmat3x2" { return PaDMat(parseContext, yylineno, yytext, pyylval, DMAT3X2); } +"dmat3x3" { return PaDMat(parseContext, yylineno, yytext, pyylval, DMAT3X3); } +"dmat3x4" { return PaDMat(parseContext, yylineno, yytext, pyylval, DMAT3X4); } +"dmat4x2" { return PaDMat(parseContext, yylineno, yytext, pyylval, DMAT4X2); } +"dmat4x3" { return PaDMat(parseContext, yylineno, yytext, pyylval, DMAT4X3); } +"dmat4x4" { return PaDMat(parseContext, yylineno, yytext, pyylval, DMAT4X4); } + +"vec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC2); } +"vec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC3); } +"vec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC4); } +"dvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC2); } +"dvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC3); } +"dvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC4); } +"ivec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC2); } +"ivec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC3); } +"ivec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC4); } +"uvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC2); } +"uvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC3); } +"uvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC4); } +"bvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC2); } +"bvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC3); } +"bvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC4); } "sampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1D; } "sampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2D; } @@ -283,6 +294,8 @@ TSourceLoc yylineno; "this" { PaReservedWord(); return 0; } "packed" { PaReservedWord(); return 0; } +"resource" { PaReservedWord(); return 0; } + "goto" { PaReservedWord(); return 0; } "inline" { PaReservedWord(); return 0; } @@ -299,6 +312,9 @@ TSourceLoc yylineno; "fixed" { PaReservedWord(); return 0; } "unsigned" { PaReservedWord(); return 0; } +"superp" { bool reserved = (parseContext.profile == EEsProfile || parseContext.version >= 130); + return PaIdentOrReserved(reserved, parseContext, yylineno, yytext, pyylval); } + "input" { PaReservedWord(); return 0; } "output" { PaReservedWord(); return 0; } @@ -309,7 +325,9 @@ TSourceLoc yylineno; "fvec3" { PaReservedWord(); return 0; } "fvec4" { PaReservedWord(); return 0; } -"sampler3DRect" { PaReservedWord(); return 0; } +"sampler3DRect" { PaReservedWord(); return 0; } + +"filter" { PaReservedWord(); return 0; } "sizeof" { PaReservedWord(); return 0; } "cast" { PaReservedWord(); return 0; } @@ -493,11 +511,11 @@ void yyerror(char *s) if (parseContext.AfterEOF) { if (cpp->tokensBeforeEOF == 1) { - GlobalParseContext->error(yylineno, "syntax error", "pre-mature EOF", s, ""); + GlobalParseContext->error(yylineno, "", "pre-mature EOF", s, ""); GlobalParseContext->recover(); } } else { - GlobalParseContext->error(yylineno, "syntax error", yytext, s, ""); + GlobalParseContext->error(yylineno, "", yytext, s, ""); GlobalParseContext->recover(); } } @@ -522,7 +540,56 @@ int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbo return IDENTIFIER; } -int PaParseComment(int &lineno, TParseContext& parseContextLocal) +int PaIdentOrReserved(bool reserved, TParseContext& parseContext, int line, char* text, YYSTYPE* pyylval) +{ + if (reserved) + PaReservedWord(); + + pyylval->lex.line = line; + pyylval->lex.string = NewPoolTString(text); + + return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol); +} + +int PaPrecisionKeyword(TParseContext& parseContext, int line, char* text, YYSTYPE* pyylval, int keyword) +{ + if (parseContext.profile == EEsProfile || parseContext.version >= 130) + return keyword; + + pyylval->lex.line = line; + pyylval->lex.string = NewPoolTString(text); + + return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol); +} + +int PaMatNxM(TParseContext& parseContext, int line, char* text, YYSTYPE* pyylval, int keyword) +{ + if (parseContext.version > 110) + return keyword; + + pyylval->lex.line = line; + pyylval->lex.string = NewPoolTString(text); + + return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol); +} + +int PaDMat(TParseContext& parseContext, int line, char* text, YYSTYPE* pyylval, int keyword) +{ + if (parseContext.profile == EEsProfile && parseContext.version >= 300) { + PaReservedWord(); + return 0; + } + + if (parseContext.profile != EEsProfile && parseContext.version >= 400) + return keyword; + + pyylval->lex.line = line; + pyylval->lex.string = NewPoolTString(text); + + return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol); +} + +int PaParseComment(int& lineno, TParseContext& parseContextLocal) { int transitionFlag = 0; int nextChar; diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y index f10d0c7be25c301484e887d0292dfb6218d307a5..2d362ea41898362c4152928c8d4974d0373a476b 100644 --- a/glslang/MachineIndependent/glslang.y +++ b/glslang/MachineIndependent/glslang.y @@ -73,6 +73,7 @@ Jutta Degener, 1995 #endif %} + %union { struct { TSourceLoc line; @@ -1664,6 +1665,7 @@ storage_qualifier parseContext.checkDeprecated($1.line, ENoProfile, 140, "attribute"); parseContext.requireNotRemoved($1.line, ECoreProfile, 420, "attribute"); + parseContext.requireNotRemoved($1.line, EEsProfile, 300, "attribute"); if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "attribute")) parseContext.recover(); @@ -1674,6 +1676,7 @@ storage_qualifier | VARYING { parseContext.checkDeprecated($1.line, ENoProfile, 140, "varying"); parseContext.requireNotRemoved($1.line, ECoreProfile, 420, "varying"); + parseContext.requireNotRemoved($1.line, EEsProfile, 300, "varying"); if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "varying")) parseContext.recover();