From ef8ae2e34594676d78c92de5208fbe741c476cd7 Mon Sep 17 00:00:00 2001
From: John Kessenich <cepheus@frii.com>
Date: Wed, 27 Feb 2013 19:02:52 +0000
Subject: [PATCH] Allow gl_FragColor and gl_FragData in non-forward-compatible
 contexts for non-ES versions 150 - 410. Also add deprecation message for
 attribute/varying for core profile.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20714 e7fa87d3-cd2b-0410-9028-fcbf551c1848
---
 Test/330.frag                             | 12 ++++++++++++
 Test/330comp.frag                         | 12 ++++++++++++
 Test/testlist                             |  2 ++
 glslang/MachineIndependent/Initialize.cpp |  5 +++--
 glslang/MachineIndependent/glslang.y      |  3 ++-
 5 files changed, 31 insertions(+), 3 deletions(-)
 create mode 100644 Test/330.frag
 create mode 100644 Test/330comp.frag

diff --git a/Test/330.frag b/Test/330.frag
new file mode 100644
index 000000000..b81b79b21
--- /dev/null
+++ b/Test/330.frag
@@ -0,0 +1,12 @@
+#version 330
+
+in vec4 inVar;
+out vec4 outVar;
+
+varying vec4 varyingVar;
+
+void main()
+{
+    gl_FragColor = varyingVar;
+    gl_FragData[1] = inVar;
+}
diff --git a/Test/330comp.frag b/Test/330comp.frag
new file mode 100644
index 000000000..50b037da6
--- /dev/null
+++ b/Test/330comp.frag
@@ -0,0 +1,12 @@
+#version 330 compatibility
+
+in vec4 inVar;
+out vec4 outVar;
+
+varying vec4 varyingVar;
+
+void main()
+{
+    gl_FragColor = varyingVar;
+    gl_FragData[1] = inVar * gl_ModelViewMatrix;
+}
diff --git a/Test/testlist b/Test/testlist
index dd697584a..0921ddd6a 100644
--- a/Test/testlist
+++ b/Test/testlist
@@ -22,3 +22,5 @@ array100.frag
 comment.frag
 300.vert
 300.frag
+330.frag
+330comp.frag
diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp
index bf2fecc8c..0cc4e4f04 100644
--- a/glslang/MachineIndependent/Initialize.cpp
+++ b/glslang/MachineIndependent/Initialize.cpp
@@ -44,6 +44,7 @@
 #include "Initialize.h"
 
 const int FirstProfileVersion = 150;
+const bool ForwardCompatibility = false;
 
 TBuiltIns::TBuiltIns()
 {
@@ -1284,7 +1285,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
             symbolTable.insert(*new TVariable(NewPoolTString("gl_PointCoord"),  TType(EbtFloat, EvqPointCoord, pq, 2)));
         }
 
-        if (version < FirstProfileVersion || profile == ECompatibilityProfile) {
+        if (version < FirstProfileVersion || profile == ECompatibilityProfile || (! ForwardCompatibility && profile != EEsProfile && version < 420)) {
             pq = profile == EEsProfile ? EpqMedium : EpqNone;
             symbolTable.insert(*new TVariable(NewPoolTString("gl_FragColor"),   TType(EbtFloat, EvqFragColor, pq, 4)));
         }
@@ -1413,7 +1414,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
 
     case EShLangFragment:
         // Set up gl_FragData based on current array size.
-        if (version < FirstProfileVersion || profile == ECompatibilityProfile) {
+        if (version < FirstProfileVersion || profile == ECompatibilityProfile || (! ForwardCompatibility && profile != EEsProfile && version < 420)) {
             TPrecisionQualifier pq = profile == EEsProfile ? EpqMedium : EpqNone;
             TType fragData(EbtFloat, EvqFragColor, 4);
             TArraySizes arraySizes = NewPoolTArraySizes();
diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y
index 81ceb4803..b807650f8 100644
--- a/glslang/MachineIndependent/glslang.y
+++ b/glslang/MachineIndependent/glslang.y
@@ -1699,7 +1699,7 @@ storage_qualifier
     }
     | ATTRIBUTE {
         parseContext.requireStage($1.line, EShLangVertexMask, "attribute");
-
+        parseContext.checkDeprecated($1.line, ECoreProfile, 150, "attribute");
         parseContext.checkDeprecated($1.line, ENoProfile, 140, "attribute");
         parseContext.requireNotRemoved($1.line, ECoreProfile, 420, "attribute");
         parseContext.requireNotRemoved($1.line, EEsProfile, 300, "attribute");
@@ -1712,6 +1712,7 @@ storage_qualifier
     }
     | VARYING {
         parseContext.checkDeprecated($1.line, ENoProfile, 140, "varying");
+        parseContext.checkDeprecated($1.line, ECoreProfile, 150, "varying");
         parseContext.requireNotRemoved($1.line, ECoreProfile, 420, "varying");
         parseContext.requireNotRemoved($1.line, EEsProfile, 300, "varying");
         
-- 
GitLab