From 27151efa71445b2e13d177837c5ab978bd21ffc8 Mon Sep 17 00:00:00 2001
From: John Kessenich <cepheus@frii.com>
Date: Fri, 13 Dec 2013 19:26:54 +0000
Subject: [PATCH] Tessellation:  Smaller changes: Take tessellation control
 output arrayness into account in location overlap testing, better error
 message for redeclaring a built-in with size to be unsized.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24522 e7fa87d3-cd2b-0410-9028-fcbf551c1848
---
 Test/400.tese                               | 12 ++++++++++++
 Test/baseResults/150.geom.out               |  2 +-
 Test/baseResults/400.tese.out               |  5 ++++-
 glslang/Include/revision.h                  |  4 ++--
 glslang/MachineIndependent/ParseHelper.cpp  | 13 +++++++++----
 glslang/MachineIndependent/linkValidate.cpp |  5 +++--
 6 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/Test/400.tese b/Test/400.tese
index f99452dc8..20f52bbf1 100644
--- a/Test/400.tese
+++ b/Test/400.tese
@@ -48,3 +48,15 @@ smooth patch in vec4 badp1;         // ERROR
 flat patch in vec4 badp2;           // ERROR
 noperspective patch in vec4 badp3;  // ERROR
 patch sample in vec3 badp4;         // ERROR
+
+#extension GL_ARB_separate_shader_objects : enable
+
+in gl_PerVertex
+{
+float gl_ClipDistance[1];
+} gl_in[];                          // ERROR, no size
+
+in gl_PerVertex
+{
+float gl_ClipDistance[1];
+} gl_in[gl_MaxPatchVertices];
diff --git a/Test/baseResults/150.geom.out b/Test/baseResults/150.geom.out
index 7d47594cc..ab9c71efa 100644
--- a/Test/baseResults/150.geom.out
+++ b/Test/baseResults/150.geom.out
@@ -23,7 +23,7 @@ ERROR: 0:78: 'invocations' : not supported for this version or the enabled exten
 ERROR: 0:78: 'invocations' : can only apply to a standalone qualifier 
 ERROR: 0:79: 'max_vertices' : can only apply to a standalone qualifier 
 ERROR: 0:80: 'triangle_strip' : can only apply to a standalone qualifier 
-ERROR: 0:83: 'lines' : does not only apply to output 
+ERROR: 0:83: 'lines' : does not apply to output 
 ERROR: 0:85: 'triangles' : cannot change previously set input primitive 
 ERROR: 0:86: 'triangles_adjacency' : cannot change previously set input primitive 
 ERROR: 0:88: 'invocations' : not supported for this version or the enabled extensions 
diff --git a/Test/baseResults/400.tese.out b/Test/baseResults/400.tese.out
index 4aa9ca685..763ca3190 100644
--- a/Test/baseResults/400.tese.out
+++ b/Test/baseResults/400.tese.out
@@ -12,7 +12,9 @@ ERROR: 0:47: 'patch' : cannot use interpolation qualifiers with patch
 ERROR: 0:48: 'patch' : cannot use interpolation qualifiers with patch 
 ERROR: 0:49: 'patch' : cannot use interpolation qualifiers with patch 
 ERROR: 0:50: '' : can only have one auxiliary qualifier (centroid, patch, and sample) 
-ERROR: 12 compilation errors.  No code generated.
+ERROR: 0:54: 'gl_PerVertex' : block already declared with size, can't redeclare as unsized 
+ERROR: 0:59: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use 
+ERROR: 14 compilation errors.  No code generated.
 
 
 input primitive = quads
@@ -117,6 +119,7 @@ ERROR: node is still EOpNull!
 0:?     'badp2' (flat patch in 4-component vector of float)
 0:?     'badp3' (noperspective patch in 4-component vector of float)
 0:?     'badp4' (patch sample in 3-component vector of float)
+0:?     'gl_in' (in 32-element array of block{gl_ClipDistance})
 
 
 Linked tessellation evaluation stage:
diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h
index 096b2511d..d5b74afda 100644
--- a/glslang/Include/revision.h
+++ b/glslang/Include/revision.h
@@ -9,5 +9,5 @@
 // source have to figure out how to create revision.h just to get a build
 // going.  However, if it is not updated, it can be a version behind.
 
-#define GLSLANG_REVISION "24486"
-#define GLSLANG_DATE     "2013/12/11 18:25:37"
+#define GLSLANG_REVISION "24518"
+#define GLSLANG_DATE     "2013/12/13 11:38:43"
diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp
index 6e01da571..0f4e6d7b0 100644
--- a/glslang/MachineIndependent/ParseHelper.cpp
+++ b/glslang/MachineIndependent/ParseHelper.cpp
@@ -2371,10 +2371,14 @@ void TParseContext::redeclareBuiltinBlock(TSourceLoc loc, TTypeList& newTypeList
         error(loc, "block redeclaration has extra members", blockName.c_str(), "");
     if (type.isArray() != (arraySizes != 0))
         error(loc, "cannot change arrayness of redeclared block", blockName.c_str(), "");
-    else if (type.isArray() && type.getArraySize() > 0 && type.getArraySize() != arraySizes->getSize())
-        error(loc, "cannot change array size of redeclared block", blockName.c_str(), "");
-    else if (type.isArray() && type.getArraySize() == 0 && arraySizes->getSize() > 0)
-        type.changeArraySize(arraySizes->getSize());
+    else if (type.isArray()) {
+        if (type.getArraySize() > 0 && arraySizes->getSize() == 0)
+            error(loc, "block already declared with size, can't redeclare as unsized", blockName.c_str(), "");
+        else if (type.getArraySize() > 0 && type.getArraySize() != arraySizes->getSize())
+            error(loc, "cannot change array size of redeclared block", blockName.c_str(), "");
+        else if (type.getArraySize() == 0 && arraySizes->getSize() > 0)
+            type.changeArraySize(arraySizes->getSize());
+    }
 
     symbolTable.insert(*block);
 
@@ -4004,3 +4008,4 @@ TIntermNode* TParseContext::addSwitch(TSourceLoc loc, TIntermTyped* expression,
 }
 
 } // end namespace glslang
+// TODO: geometry and tessellation: make sure all inputs/outputs that should have extra level of arrayness do have the extra level of arrayness
\ No newline at end of file
diff --git a/glslang/MachineIndependent/linkValidate.cpp b/glslang/MachineIndependent/linkValidate.cpp
index 802bb2499..3e4b1fd47 100644
--- a/glslang/MachineIndependent/linkValidate.cpp
+++ b/glslang/MachineIndependent/linkValidate.cpp
@@ -500,8 +500,9 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ
         else
             size = 1;
     } else {
-        if (language == EShLangGeometry && qualifier.isPipeInput()) {
-            assert(type.isArray());
+        if (type.isArray() && 
+            (language == EShLangGeometry && qualifier.isPipeInput() ||
+            (language == EShLangTessControl && qualifier.isPipeOutput() && ! qualifier.patch))) {
             TType elementType(type, 0);
             size = computeTypeLocationSize(elementType);
         } else
-- 
GitLab