summaryrefslogtreecommitdiff
path: root/src/mesa/main/extensions.c
diff options
context:
space:
mode:
authorJordan Justen <jordan.l.justen@intel.com>2014-06-07 23:54:31 -0700
committerJordan Justen <jordan.l.justen@intel.com>2014-06-16 09:54:52 -0700
commitf5ca8c19727c76256785e1a9f44da058fdcfe891 (patch)
treebe86fc7786aaed9dcbc2dc95d5bfc93c88b59b25 /src/mesa/main/extensions.c
parent8be64fb570b15be1f2daf3545b5e9c3299704914 (diff)
main/extensions: Add early extension override structures
During the early one_time_init phase of context creation, we initialize two global gl_extensions structures. We read the MESA_EXTENSION_OVERRIDE environment variable, and store positive and negative overrides in two structures: * struct gl_extensions _mesa_extension_override_enables * struct gl_extensions _mesa_extension_override_disables These are filled before the driver initializes extensions and constants, therefore the driver can make adjustments based on the desired overrides. This can be useful during development of a new extension where the extension is only partially ready. The driver can't actually advertise support for the extension, but if it sees that the override is set for the extension, then it can expose more supported parts of the extension, such as upgrading context constants. Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Diffstat (limited to 'src/mesa/main/extensions.c')
-rw-r--r--src/mesa/main/extensions.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 5de6625b88..4659bac686 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -37,6 +37,9 @@
#include "macros.h"
#include "mtypes.h"
+struct gl_extensions _mesa_extension_override_enables;
+struct gl_extensions _mesa_extension_override_disables;
+
enum {
DISABLE = 0,
GLL = 1 << API_OPENGL_COMPAT, /* GL Legacy / Compatibility */
@@ -588,6 +591,54 @@ get_extension_override( struct gl_context *ctx )
/**
+ * \brief Initialize extension override tables.
+ *
+ * This should be called one time early during first context initialization.
+ */
+void
+_mesa_one_time_init_extension_overrides(void)
+{
+ const char *env_const = _mesa_getenv("MESA_EXTENSION_OVERRIDE");
+ char *env;
+ char *ext;
+ size_t offset;
+
+ memset(&_mesa_extension_override_enables, 0, sizeof(struct gl_extensions));
+ memset(&_mesa_extension_override_disables, 0, sizeof(struct gl_extensions));
+
+ if (env_const == NULL) {
+ return;
+ }
+
+ /* Copy env_const because strtok() is destructive. */
+ env = strdup(env_const);
+ for (ext = strtok(env, " "); ext != NULL; ext = strtok(NULL, " ")) {
+ int enable;
+ switch (ext[0]) {
+ case '+':
+ enable = 1;
+ ++ext;
+ break;
+ case '-':
+ enable = 0;
+ ++ext;
+ break;
+ default:
+ enable = 1;
+ break;
+ }
+
+ offset = set_extension(&_mesa_extension_override_enables, ext, enable);
+ if (offset != 0 && (offset != o(dummy_true) || enable != GL_FALSE)) {
+ ((GLboolean *) &_mesa_extension_override_disables)[offset] = !enable;
+ }
+ }
+
+ free(env);
+}
+
+
+/**
* \brief Initialize extension tables and enable default extensions.
*
* This should be called during context initialization.