[Mesa-dev] [PATCH v3 3/3] mesa: allow MESA_GL_VERSION_OVERRIDE to override the API type

Chad Versace chad.versace at linux.intel.com
Tue Sep 25 16:57:47 PDT 2012


On 09/04/2012 09:00 PM, Jordan Justen wrote:
> Change the format to MAJOR.MINOR[FC]
> For example: 2.1, 3.0FC, 3.1
> 
> The FC suffix indicates a forward compatible context, and
> is only valid for versions >= 3.0.
> 
> Examples:
> 2.1:   GL Legacy/Compatibility context
> 3.0:   GL Legacy/Compatibility context
> 3.0FC: GL Core Profile context + Forward Compatible
> 3.1:   GL Core Profile context
> 3.1FC: GL Core Profile context + Forward Compatible
> 
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>



>  /**
> + * Override the context's version and/or API type if the
> + * environment variable MESA_GL_VERSION_OVERRIDE is set.
> + *
> + * Example uses of MESA_GL_VERSION_OVERRIDE:
> + *
> + * 3.0: Override version to 3.0, but don't change API type
> + * COMPAT: Override API type to API_OPENGL, but don't change the version
> + * CORE: Override API type to API_OPENGL_CORE, but don't change the version
> + * 3.2CORE: Override API type to API_OPENGL_CORE, and the version to 3.2
> + */
> +void
> +_mesa_override_gl_version(struct gl_context *ctx)
> +{
> +   const char *env_var = "MESA_GL_VERSION_OVERRIDE";
> +   const char *version;
> +   char *version_dup;
> +   int n;
> +   int major, minor;
> +   GLboolean fc_suffix;
> +
> +   version = getenv(env_var);
> +   if (!version) {
> +      return;
> +   }
> +
> +   version_dup = strdup(version);
> +   assert (version_dup != NULL);
> +
> +   fc_suffix = check_for_ending_and_remove(version_dup, "FC");
> +
> +   n = sscanf(version, "%u.%u", &major, &minor);
> +   if (n != 2) {
> +      fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version);
> +   } else {
> +      ctx->Version = major * 10 + minor;
> +      if (ctx->Version < 30 && fc_suffix) {
> +         fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version);
> +      } else {
> +         if (ctx->Version >= 30 && fc_suffix) {
> +            ctx->API = API_OPENGL_CORE;
> +            ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
> +         } else if (ctx->Version >= 31) {
> +            ctx->API = API_OPENGL_CORE;
> +         } else {
> +            ctx->API = API_OPENGL;
> +         }
> +         create_version_string(ctx, "");
> +      }
> +   }
> +
> +   free(version_dup);
> +}

This function's comment needs to be updated. Other than that,
Reviewed-by: Chad Versace <chad.versace at linux.intel.com>



More information about the mesa-dev mailing list