summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/extensions.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.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.c')
-rw-r--r--src/mesa/main/extensions.c33
1 files changed, 7 insertions, 26 deletions
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index fa50cb68cca..62a731675d7 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -48,26 +48,7 @@ static char *extra_extensions = NULL;
*/
#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
-};
-
-static bool disabled_extensions[ARRAY_SIZE(_mesa_extension_table)];
+static bool disabled_extensions[MESA_EXTENSION_COUNT];
/**
* Given an extension name, lookup up the corresponding member of struct
@@ -85,7 +66,7 @@ name_to_index(const char* name)
if (name == 0)
return -1;
- for (i = 0; i < ARRAY_SIZE(_mesa_extension_table); ++i) {
+ for (i = 0; i < MESA_EXTENSION_COUNT; ++i) {
if (strcmp(name, _mesa_extension_table[i].name) == 0)
return i;
}
@@ -107,7 +88,7 @@ override_extensions_in_context(struct gl_context *ctx)
(GLboolean*) &_mesa_extension_override_disables;
GLboolean *ctx_ext = (GLboolean*)&ctx->Extensions;
- for (i = 0; i < ARRAY_SIZE(_mesa_extension_table); ++i) {
+ for (i = 0; i < MESA_EXTENSION_COUNT; ++i) {
size_t offset = _mesa_extension_table[i].offset;
assert(!enables[offset] || !disables[offset]);
@@ -447,7 +428,7 @@ _mesa_make_extension_string(struct gl_context *ctx)
/* Compute length of the extension string. */
count = 0;
- for (k = 0; k < ARRAY_SIZE(_mesa_extension_table); ++k) {
+ for (k = 0; k < MESA_EXTENSION_COUNT; ++k) {
const struct mesa_extension *i = _mesa_extension_table + k;
if (i->year <= maxYear &&
@@ -478,7 +459,7 @@ _mesa_make_extension_string(struct gl_context *ctx)
* expect will fit into that buffer.
*/
j = 0;
- for (k = 0; k < ARRAY_SIZE(_mesa_extension_table); ++k) {
+ for (k = 0; k < MESA_EXTENSION_COUNT; ++k) {
if (_mesa_extension_table[k].year <= maxYear &&
_mesa_extension_supported(ctx, k)) {
extension_indices[j++] = k;
@@ -516,7 +497,7 @@ _mesa_get_extension_count(struct gl_context *ctx)
if (ctx->Extensions.Count != 0)
return ctx->Extensions.Count;
- for (k = 0; k < ARRAY_SIZE(_mesa_extension_table); ++k) {
+ for (k = 0; k < MESA_EXTENSION_COUNT; ++k) {
if (_mesa_extension_supported(ctx, k))
ctx->Extensions.Count++;
}
@@ -532,7 +513,7 @@ _mesa_get_enabled_extension(struct gl_context *ctx, GLuint index)
size_t n = 0;
unsigned i;
- for (i = 0; i < ARRAY_SIZE(_mesa_extension_table); ++i) {
+ for (i = 0; i < MESA_EXTENSION_COUNT; ++i) {
if (_mesa_extension_supported(ctx, i)) {
if (n == index)
return (const GLubyte*) _mesa_extension_table[i].name;