From e553ace0491f3e9234e67af797b39249de0a9004 Mon Sep 17 00:00:00 2001 From: Rex Xu <rex.xu@amd.com> Date: Mon, 7 Dec 2015 19:07:17 +0800 Subject: [PATCH] Parser: Extension requirement of gl_PrimitiveID and gl_Layer should be checked only for ESSL instead of GLSL. --- Test/150.frag | 5 +++++ Test/440.frag | 5 +++++ Test/baseResults/150.frag.out | 10 ++++++++++ Test/baseResults/440.frag.out | 10 ++++++++++ glslang/MachineIndependent/Initialize.cpp | 7 +++++-- 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Test/150.frag b/Test/150.frag index de0905c11..16963afb0 100644 --- a/Test/150.frag +++ b/Test/150.frag @@ -43,3 +43,8 @@ void barWxyz() ivec4 t42 = texelFetch(ismsa, ivec3(2), samp); uvec4 t43 = texelFetch(usmsa, p3, samp); } + +int primitiveID() +{ + return gl_PrimitiveID; +} diff --git a/Test/440.frag b/Test/440.frag index f5e330add..4eb1a3ffd 100644 --- a/Test/440.frag +++ b/Test/440.frag @@ -146,3 +146,8 @@ void interp() interpolateAtCentroid(sampInArray[2].xy); interpolateAtSample(sampInArray[2].x.x, 2); } + +int layer() +{ + return gl_Layer; +} diff --git a/Test/baseResults/150.frag.out b/Test/baseResults/150.frag.out index f8a6fc879..73bd45a11 100644 --- a/Test/baseResults/150.frag.out +++ b/Test/baseResults/150.frag.out @@ -101,6 +101,11 @@ ERROR: node is still EOpNull! 0:44 'usmsa' (uniform usampler2DMSArray) 0:44 'p3' (flat in 3-component vector of int) 0:44 'samp' (flat in int) +0:47 Function Definition: primitiveID( (global int) +0:47 Function Parameters: +0:49 Sequence +0:49 Branch: Return with expression +0:49 'gl_PrimitiveID' (flat in int PrimitiveID) 0:? Linker Objects 0:? 'gl_FragCoord' (gl_FragCoord 4-component vector of float FragCoord) 0:? 'gl_FragCoord' (gl_FragCoord 4-component vector of float FragCoord) @@ -216,6 +221,11 @@ ERROR: node is still EOpNull! 0:44 'usmsa' (uniform usampler2DMSArray) 0:44 'p3' (flat in 3-component vector of int) 0:44 'samp' (flat in int) +0:47 Function Definition: primitiveID( (global int) +0:47 Function Parameters: +0:49 Sequence +0:49 Branch: Return with expression +0:49 'gl_PrimitiveID' (flat in int PrimitiveID) 0:? Linker Objects 0:? 'gl_FragCoord' (gl_FragCoord 4-component vector of float FragCoord) 0:? 'gl_FragCoord' (gl_FragCoord 4-component vector of float FragCoord) diff --git a/Test/baseResults/440.frag.out b/Test/baseResults/440.frag.out index 799ca2608..0d43981eb 100644 --- a/Test/baseResults/440.frag.out +++ b/Test/baseResults/440.frag.out @@ -77,6 +77,11 @@ ERROR: node is still EOpNull! 0:147 0 (const int) 0:147 Constant: 0:147 2 (const int) +0:150 Function Definition: layer( (global int) +0:150 Function Parameters: +0:152 Sequence +0:152 Branch: Return with expression +0:152 'gl_Layer' (flat in int Layer) 0:? Linker Objects 0:? 'a' (layout(location=4 component=2 ) smooth in 2-component vector of float) 0:? 'b' (layout(location=4 component=1 ) smooth in float) @@ -145,6 +150,11 @@ ERROR: node is still EOpNull! 0:147 0 (const int) 0:147 Constant: 0:147 2 (const int) +0:150 Function Definition: layer( (global int) +0:150 Function Parameters: +0:152 Sequence +0:152 Branch: Return with expression +0:152 'gl_Layer' (flat in int Layer) 0:? Linker Objects 0:? 'a' (layout(location=4 component=2 ) smooth in 2-component vector of float) 0:? 'b' (layout(location=4 component=1 ) smooth in float) diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index d05a67312..80f8ec179 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -3165,8 +3165,11 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, EShLanguage langua } symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &E_GL_EXT_frag_depth); - symbolTable.setVariableExtensions("gl_PrimitiveID", Num_AEP_geometry_shader, AEP_geometry_shader); - symbolTable.setVariableExtensions("gl_Layer", Num_AEP_geometry_shader, AEP_geometry_shader); + + if (profile == EEsProfile) { + symbolTable.setVariableExtensions("gl_PrimitiveID", Num_AEP_geometry_shader, AEP_geometry_shader); + symbolTable.setVariableExtensions("gl_Layer", Num_AEP_geometry_shader, AEP_geometry_shader); + } if (profile == EEsProfile) { symbolTable.setFunctionExtensions("imageAtomicAdd", 1, &E_GL_OES_shader_image_atomic); -- GitLab