summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/extensions_table.c
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2016-06-12 18:56:43 -0400
committerIlia Mirkin <[email protected]>2016-07-23 13:48:04 -0400
commite483cb9a3add01dc552bd2a42763aff4be5808fc (patch)
tree2acfcf3ca3d2e39bb836a7fa66f3c343dc164548 /src/mesa/main/extensions_table.c
parent9253dcde585042242614c4b6677d8f2b13bd2237 (diff)
glsl: reuse main extension table to appropriately restrict extensions
Previously we were only restricting based on ES/non-ES-ness and whether the overall enable bit had been flipped on. However we have been adding more fine-grained restrictions, such as based on compat profiles, as well as specific ES versions. Most of the time this doesn't matter, but it can create awkward situations and duplication of logic. Here we separate the main extension table into a separate object file, linked to the glsl compiler, which makes use of it with a custom function which takes the ES-ness of the shader into account (thus allowing desktop shaders to properly use ES extensions that would otherwise have been disallowed.) We can also now use this logic to generate #define's for all supported extensions automatically, removing the duplicate (and often inaccurate) list in glcpp. The effect of this change should be nil in most cases. However in some situations, extensions like GL_ARB_gpu_shader5 which were formerly available in compat contexts on the GLSL side of things will now become inaccessible. This regresses two ES CTS tests: ES3-CTS.shaders.shader_integer_mix.define ES31-CTS.shader_integer_mix.define however that is due to them using #version 100 instead of 300 es. As the extension is only defined for ES3, I believe this is the correct behavior. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> (v2) v2 -> v3: integrate glcpp defines into the same mechanism
Diffstat (limited to 'src/mesa/main/extensions_table.c')
-rw-r--r--src/mesa/main/extensions_table.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/mesa/main/extensions_table.c b/src/mesa/main/extensions_table.c
new file mode 100644
index 00000000000..1e37fbcc462
--- /dev/null
+++ b/src/mesa/main/extensions_table.c
@@ -0,0 +1,51 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "main/mtypes.h"
+#include "main/extensions.h"
+
+/**
+ * Given a member \c x of struct gl_extensions, return offset of
+ * \c x in bytes.
+ */
+#define o(x) offsetof(struct gl_extensions, x)
+
+/**
+ * \brief Table of supported OpenGL extensions for all API's.
+ */
+const struct mesa_extension _mesa_extension_table[] = {
+#define EXT(name_str, driver_cap, gll_ver, glc_ver, gles_ver, gles2_ver, yyyy) \
+ { .name = "GL_" #name_str, .offset = o(driver_cap), \
+ .version = { \
+ [API_OPENGL_COMPAT] = gll_ver, \
+ [API_OPENGL_CORE] = glc_ver, \
+ [API_OPENGLES] = gles_ver, \
+ [API_OPENGLES2] = gles2_ver, \
+ }, \
+ .year = yyyy \
+ },
+#include "extensions_table.h"
+#undef EXT
+};