diff options
author | unknown <[email protected]> | 2010-02-10 10:55:01 -0700 |
---|---|---|
committer | unknown <[email protected]> | 2010-02-10 10:55:01 -0700 |
commit | b91bb45899a4c7fe2b1841c5907101beb4061df1 (patch) | |
tree | 84f53952b10b294b906e8e45da612ebe0f3a72f2 | |
parent | c3b62372dbf33c4dbf02439f3418194465738317 (diff) | |
parent | 3251f31d593129e772475f2219771c660c53bf4e (diff) |
Merge branch 'master' of git+ssh://git.freedesktop.org/git/mesa/mesa
-rw-r--r-- | src/glsl/pp/sl_pp_context.h | 1 | ||||
-rw-r--r-- | src/glsl/pp/sl_pp_extension.c | 20 | ||||
-rw-r--r-- | src/glsl/pp/sl_pp_if.c | 2 |
3 files changed, 22 insertions, 1 deletions
diff --git a/src/glsl/pp/sl_pp_context.h b/src/glsl/pp/sl_pp_context.h index 7b9f494f130..983a09c02af 100644 --- a/src/glsl/pp/sl_pp_context.h +++ b/src/glsl/pp/sl_pp_context.h @@ -45,6 +45,7 @@ struct sl_pp_extension { int name; /*< GL_VENDOR_extension_name */ + int enabled; }; struct sl_pp_predefined { diff --git a/src/glsl/pp/sl_pp_extension.c b/src/glsl/pp/sl_pp_extension.c index 630a7975c75..777e42d0fc9 100644 --- a/src/glsl/pp/sl_pp_extension.c +++ b/src/glsl/pp/sl_pp_extension.c @@ -32,6 +32,12 @@ #include "sl_pp_public.h" +/** + * Declare an extension to the preprocessor. This tells the preprocessor + * which extensions are supported by Mesa. + * The shader still needs to have a "#extension name: behavior" line to enable + * the extension. + */ int sl_pp_context_add_extension(struct sl_pp_context *context, const char *name) @@ -47,10 +53,18 @@ sl_pp_context_add_extension(struct sl_pp_context *context, return -1; } + ext.enabled = 0; + context->extensions[context->num_extensions++] = ext; + + assert(context->num_extensions <= sizeof(context->extensions)); + return 0; } +/** + * Process a "#extension name: behavior" directive. + */ int sl_pp_process_extension(struct sl_pp_context *context, const struct sl_pp_token_info *input, @@ -61,6 +75,7 @@ sl_pp_process_extension(struct sl_pp_context *context, int extension_name = -1; int behavior = -1; struct sl_pp_token_info out; + struct sl_pp_extension *extension = NULL; /* Grab the extension name. */ if (first < last && input[first].token == SL_PP_IDENTIFIER) { @@ -82,6 +97,7 @@ sl_pp_process_extension(struct sl_pp_context *context, for (i = 0; i < context->num_extensions; i++) { if (extension_name == context->extensions[i].name) { out.data.extension = extension_name; + extension = &context->extensions[i]; break; } } @@ -121,6 +137,7 @@ sl_pp_process_extension(struct sl_pp_context *context, return -1; } out.token = SL_PP_EXTENSION_REQUIRE; + extension->enabled = 1; } else if (behavior == context->dict.enable) { if (out.data.extension == -1) { /* Warning: the extension cannot be enabled. */ @@ -131,18 +148,21 @@ sl_pp_process_extension(struct sl_pp_context *context, return -1; } out.token = SL_PP_EXTENSION_ENABLE; + extension->enabled = 1; } else if (behavior == context->dict.warn) { if (out.data.extension == -1) { /* Warning: the extension is not supported. */ return 0; } out.token = SL_PP_EXTENSION_WARN; + extension->enabled = 0; } else if (behavior == context->dict.disable) { if (out.data.extension == -1) { /* Warning: the extension is not supported. */ return 0; } out.token = SL_PP_EXTENSION_DISABLE; + extension->enabled = 0; } else { strcpy(context->error_msg, "unrecognised behavior name"); return -1; diff --git a/src/glsl/pp/sl_pp_if.c b/src/glsl/pp/sl_pp_if.c index 3ddbcc84af8..272c3a23cce 100644 --- a/src/glsl/pp/sl_pp_if.c +++ b/src/glsl/pp/sl_pp_if.c @@ -40,7 +40,7 @@ _macro_is_defined(struct sl_pp_context *context, for (i = 0; i < context->num_extensions; i++) { if (macro_name == context->extensions[i].name) { - return 1; + return context->extensions[i].enabled; } } |