Add GL/ES VERSION defines

The dEQP does not use the standard GL or GLES headers, but instead
provides it's own type and enum definitions via glw.h.
However this was missing the GL_VERSION_* and GL_ES_VERSION_* defines
that are defined in the standard headers when the types are defined.
This change adds a new inlined include file 'glwVersions.inl' that
defines the GL_*VERSION* for the API versions that are currently
enabled.

VK-GL-CTS issue: 196
Components: OpenGL, Framework

Change-Id: Ie3f9a8e3958aee2cfdee4a4bc6de392bfeb13f1d
diff --git a/external/fetch_kc_cts.py b/external/fetch_kc_cts.py
index f4638fd..87b96c4 100644
--- a/external/fetch_kc_cts.py
+++ b/external/fetch_kc_cts.py
@@ -32,7 +32,7 @@
 from build.common import *
 
 EXTERNAL_DIR	= os.path.realpath(os.path.normpath(os.path.dirname(__file__)))
-SHA1 = "c07dea78a63893d7303b5acfe5085a8835e37f51"
+SHA1 = "b5ecd80c67b0d4862ff24a191b3e31252ad84134"
 
 PACKAGES = [
 	GitRepo(
diff --git a/framework/opengl/wrapper/glw.h b/framework/opengl/wrapper/glw.h
index b3d8726..c7cefaf 100644
--- a/framework/opengl/wrapper/glw.h
+++ b/framework/opengl/wrapper/glw.h
@@ -38,6 +38,9 @@
 /* Enumeration values. */
 #include "glwEnums.inl"
 
+/* API Versions. */
+#include "glwVersions.inl"
+
 /* Functions. */
 #include "glwApi.inl"
 
diff --git a/framework/opengl/wrapper/glwVersions.inl b/framework/opengl/wrapper/glwVersions.inl
new file mode 100644
index 0000000..c8611bc
--- /dev/null
+++ b/framework/opengl/wrapper/glwVersions.inl
@@ -0,0 +1,27 @@
+/* WARNING: This is auto-generated file. Do not modify, since changes will
+ * be lost! Modify the generating script instead.
+ *
+ * Generated from Khronos GL API description (gl.xml) revision db2965fc26513b254e2f964171f79e416a05fe29.
+ */
+#define GL_ES_VERSION_2_0	1
+#define GL_ES_VERSION_3_0	1
+#define GL_ES_VERSION_3_1	1
+#define GL_ES_VERSION_3_2	1
+#define GL_VERSION_1_0		1
+#define GL_VERSION_1_1		1
+#define GL_VERSION_1_2		1
+#define GL_VERSION_1_3		1
+#define GL_VERSION_1_4		1
+#define GL_VERSION_1_5		1
+#define GL_VERSION_2_0		1
+#define GL_VERSION_2_1		1
+#define GL_VERSION_3_0		1
+#define GL_VERSION_3_1		1
+#define GL_VERSION_3_2		1
+#define GL_VERSION_3_3		1
+#define GL_VERSION_4_0		1
+#define GL_VERSION_4_1		1
+#define GL_VERSION_4_2		1
+#define GL_VERSION_4_3		1
+#define GL_VERSION_4_4		1
+#define GL_VERSION_4_5		1
diff --git a/scripts/khr_util/registry.py b/scripts/khr_util/registry.py
index 58dab52..7b0e050 100644
--- a/scripts/khr_util/registry.py
+++ b/scripts/khr_util/registry.py
@@ -239,6 +239,7 @@
 		self.enums = set()
 		self.types = set()
 		self.commands = set()
+		self.versions = set()
 
 	def addComponent(self, eComponent):
 		if eComponent.tag == 'require':
@@ -271,6 +272,7 @@
 			if not force: return
 			warnElem(eFeature, 'API %s is not supported', api)
 		self.addComponents(eFeature, api, profile)
+		self.versions.add(eFeature.get('name'))
 
 	def addExtension(self, eExtension, api=None, profile=None, force=False):
 		if not extensionSupports(eExtension, api, profile):
@@ -359,7 +361,8 @@
 	enums = NameIndex(map(createEnum, spec.enums),
 					  createMissing=Enum, kind="enum")
 	commands = NameIndex(map(createCommand, spec.commands),
-						 createMissing=Command, kind="command")
+						createMissing=Command, kind="command")
+	versions = sorted(spec.versions)
 
 	# This is a mess because the registry contains alias chains whose
 	# midpoints might not be included in the interface even though
@@ -380,7 +383,8 @@
 		types=sortedIndex(types),
 		enums=sortedIndex(enums),
 		groups=sortedIndex(groups),
-		commands=sortedIndex(commands))
+		commands=sortedIndex(commands),
+		versions=versions)
 
 
 def spec(registry, api, version=None, profile=None, extensionNames=[], protects=[], force=False):
diff --git a/scripts/opengl/gen_all.py b/scripts/opengl/gen_all.py
index c012ba0..7ca0ce1 100644
--- a/scripts/opengl/gen_all.py
+++ b/scripts/opengl/gen_all.py
@@ -23,6 +23,7 @@
 from src_util import getGLRegistry, getHybridInterface
 from gen_call_log_wrapper import genCallLogWrapper
 from gen_enums import genEnums
+from gen_versions import genVersions
 from gen_es31_wrapper import genES31WrapperFuncs
 from gen_es_direct_init import genESDirectInit
 from gen_es_static_library import genESStaticLibrary
@@ -39,6 +40,7 @@
 	iface = getHybridInterface()
 	genCallLogWrapper(iface)
 	genEnums(iface)
+	genVersions(iface)
 	genES31WrapperFuncs(registry)
 	genESDirectInit(registry)
 	genESStaticLibrary(registry)
diff --git a/scripts/opengl/gen_versions.py b/scripts/opengl/gen_versions.py
new file mode 100644
index 0000000..64a9d48
--- /dev/null
+++ b/scripts/opengl/gen_versions.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
+import os
+import string
+
+from src_util import *
+
+def apiVersionDefinition(version):
+	return "#define %s\t1" % (version)
+
+def genVersions (iface):
+	src = indentLines(map(apiVersionDefinition, iface.versions))
+	writeInlFile(os.path.join(OPENGL_INC_DIR, "glwVersions.inl"), src)
+
+if __name__ == "__main__":
+	import logging, sys
+	logging.basicConfig(stream=sys.stderr, level=logging.INFO)
+	genVersions(getHybridInterface())