diff options
author | Ilia Mirkin <[email protected]> | 2016-06-12 18:56:43 -0400 |
---|---|---|
committer | Ilia Mirkin <[email protected]> | 2016-07-23 13:48:04 -0400 |
commit | e483cb9a3add01dc552bd2a42763aff4be5808fc (patch) | |
tree | 2acfcf3ca3d2e39bb836a7fa66f3c343dc164548 /src/mesa/main | |
parent | 9253dcde585042242614c4b6677d8f2b13bd2237 (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')
-rw-r--r-- | src/mesa/main/extensions.c | 33 | ||||
-rw-r--r-- | src/mesa/main/extensions.h | 1 | ||||
-rw-r--r-- | src/mesa/main/extensions_table.c | 51 |
3 files changed, 59 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; diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h index 43ef6aa6451..efef1be4751 100644 --- a/src/mesa/main/extensions.h +++ b/src/mesa/main/extensions.h @@ -89,6 +89,7 @@ enum { #define EXT(name_str, ...) MESA_EXTENSION_##name_str, #include "extensions_table.h" #undef EXT +MESA_EXTENSION_COUNT }; 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 +}; |