[Mesa-dev] [PATCH 2/4] mesa: introduce the equivalent of MESA_EXTENSION_OVERRIDE in drirc v2

Ilia Mirkin imirkin at alum.mit.edu
Tue Feb 3 08:27:51 PST 2015


On Tue, Feb 3, 2015 at 10:41 AM, Martin Peres
<martin.peres at linux.intel.com> wrote:
> When both MESA_EXTENSION_OVERRIDE and drirc's mesa_extension_override are
> set, the environment variable takes precedence.

Just a thought -- combine them instead of having one override the
other? (With the env var being processed second so that it can
override things in the drirc.)

OTOH drirc settings are also overridable via env var (as I recall), so
someone could use a mesa_extension_override env var (in addition to a
MESA_EXTENSION_OVERRIDE env var).

Anyways, just wanted to point out the possibility, in case you liked the idea.

Cheers,

  -ilia

>
> This will be used to fix Unigine Tropics and Sanctuary.
>
> v2:
> - change the name from mesa_extension_override to extension_override
> - make the presence of the environment variable enough to disable the
>   drirc-provided version
> - init all the constants in i915 before calling _mesa_initialize_context
> - make GLchar *ExtensionOverride in struct gl_constants constant
>
> Signed-off-by: Martin Peres <martin.peres at linux.intel.com>
> ---
>  src/gallium/include/state_tracker/st_api.h      |  1 +
>  src/gallium/state_trackers/dri/dri_screen.c     |  3 +++
>  src/mesa/drivers/dri/common/xmlpool/t_options.h |  4 ++++
>  src/mesa/drivers/dri/i915/intel_context.c       | 18 +++++++++++-------
>  src/mesa/drivers/dri/i915/intel_screen.c        |  1 +
>  src/mesa/drivers/dri/i965/brw_context.c         |  6 +++++-
>  src/mesa/drivers/dri/i965/intel_screen.c        |  1 +
>  src/mesa/main/context.c                         |  4 +++-
>  src/mesa/main/extensions.c                      |  6 +++++-
>  src/mesa/main/extensions.h                      |  2 +-
>  src/mesa/main/mtypes.h                          |  5 +++++
>  11 files changed, 40 insertions(+), 11 deletions(-)
>
> diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
> index 86fdc69..99872ce 100644
> --- a/src/gallium/include/state_tracker/st_api.h
> +++ b/src/gallium/include/state_tracker/st_api.h
> @@ -246,6 +246,7 @@ struct st_config_options
>     unsigned force_glsl_version;
>     boolean force_s3tc_enable;
>     boolean allow_glsl_extension_directive_midshader;
> +   char *extension_override;
>  };
>
>  /**
> diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
> index 9cdebf8..d1d1eb8 100644
> --- a/src/gallium/state_trackers/dri/dri_screen.c
> +++ b/src/gallium/state_trackers/dri/dri_screen.c
> @@ -70,6 +70,7 @@ const __DRIconfigOptionsExtension gallium_config_options = {
>           DRI_CONF_DISABLE_SHADER_BIT_ENCODING("false")
>           DRI_CONF_FORCE_GLSL_VERSION(0)
>           DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER("false")
> +         DRI_CONF_EXTENSION_OVERRIDE()
>        DRI_CONF_SECTION_END
>
>        DRI_CONF_SECTION_MISCELLANEOUS
> @@ -98,6 +99,8 @@ dri_fill_st_options(struct st_config_options *options,
>        driQueryOptionb(optionCache, "force_s3tc_enable");
>     options->allow_glsl_extension_directive_midshader =
>        driQueryOptionb(optionCache, "allow_glsl_extension_directive_midshader");
> +   options->extension_override =
> +      driQueryOptionstr(optionCache, "extension_override");
>  }
>
>  static const __DRIconfig **
> diff --git a/src/mesa/drivers/dri/common/xmlpool/t_options.h b/src/mesa/drivers/dri/common/xmlpool/t_options.h
> index 4e5a721..0c2e7d6 100644
> --- a/src/mesa/drivers/dri/common/xmlpool/t_options.h
> +++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h
> @@ -110,6 +110,10 @@ DRI_CONF_OPT_BEGIN_B(allow_glsl_extension_directive_midshader, def) \
>          DRI_CONF_DESC(en,gettext("Allow GLSL #extension directives in the middle of shaders")) \
>  DRI_CONF_OPT_END
>
> +#define DRI_CONF_EXTENSION_OVERRIDE(def) \
> +DRI_CONF_OPT_BEGIN(extension_override, string, def) \
> +        DRI_CONF_DESC(en,gettext("Allow enabling/disabling a list of GL extensions")) \
> +DRI_CONF_OPT_END
>
>
>  /**
> diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c
> index 12a1d2b..6357621 100644
> --- a/src/mesa/drivers/dri/i915/intel_context.c
> +++ b/src/mesa/drivers/dri/i915/intel_context.c
> @@ -419,13 +419,6 @@ intelInitContext(struct intel_context *intel,
>
>     intel->intelScreen = intelScreen;
>
> -   if (!_mesa_initialize_context(&intel->ctx, api, mesaVis, shareCtx,
> -                                 functions)) {
> -      *dri_ctx_error = __DRI_CTX_ERROR_NO_MEMORY;
> -      printf("%s: failed to init mesa context\n", __FUNCTION__);
> -      return false;
> -   }
> -
>     driContextPriv->driverPrivate = intel;
>     intel->driContext = driContextPriv;
>     intel->driFd = sPriv->fd;
> @@ -443,6 +436,10 @@ intelInitContext(struct intel_context *intel,
>
>     driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
>                         sPriv->myNum, "i915");
> +
> +   ctx->Const.ExtensionOverride =
> +         driQueryOptionstr(&intel->optionCache, "extension_override");
> +
>     intel->maxBatchSize = 4096;
>
>     /* Estimate the size of the mappable aperture into the GTT.  There's an
> @@ -487,6 +484,13 @@ intelInitContext(struct intel_context *intel,
>
>     ctx->Const.StripTextureBorder = GL_TRUE;
>
> +   if (!_mesa_initialize_context(&intel->ctx, api, mesaVis, shareCtx,
> +                                 functions)) {
> +      *dri_ctx_error = __DRI_CTX_ERROR_NO_MEMORY;
> +      printf("%s: failed to init mesa context\n", __FUNCTION__);
> +      return false;
> +   }
> +
>     /* reinitialize the context point state.
>      * It depend on constants in __struct gl_contextRec::Const
>      */
> diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c
> index e728979..850cab9 100644
> --- a/src/mesa/drivers/dri/i915/intel_screen.c
> +++ b/src/mesa/drivers/dri/i915/intel_screen.c
> @@ -75,6 +75,7 @@ DRI_CONF_BEGIN
>        DRI_CONF_FORCE_GLSL_EXTENSIONS_WARN("false")
>        DRI_CONF_DISABLE_GLSL_LINE_CONTINUATIONS("false")
>        DRI_CONF_DISABLE_BLEND_FUNC_EXTENDED("false")
> +      DRI_CONF_EXTENSION_OVERRIDE()
>
>        DRI_CONF_OPT_BEGIN_B(shader_precompile, "true")
>          DRI_CONF_DESC(en, "Perform code generation at shader link time.")
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index 7a61496..cac22d2 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -652,6 +652,9 @@ brw_process_driconf_options(struct brw_context *brw)
>
>     ctx->Const.AllowGLSLExtensionDirectiveMidShader =
>        driQueryOptionb(options, "allow_glsl_extension_directive_midshader");
> +
> +   ctx->Const.ExtensionOverride =
> +      driQueryOptionstr(options, "extension_override");
>  }
>
>  GLboolean
> @@ -738,6 +741,8 @@ brwCreateContext(gl_api api,
>     if (notify_reset)
>        functions.GetGraphicsResetStatus = brw_get_graphics_reset_status;
>
> +   brw_process_driconf_options(brw);
> +
>     struct gl_context *ctx = &brw->ctx;
>
>     if (!_mesa_initialize_context(ctx, api, mesaVis, shareCtx, &functions)) {
> @@ -772,7 +777,6 @@ brwCreateContext(gl_api api,
>
>     _mesa_meta_init(ctx);
>
> -   brw_process_driconf_options(brw);
>     brw_process_intel_debug_variable(brw);
>
>     if (brw->gen >= 8 && !(INTEL_DEBUG & DEBUG_VEC4VS))
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
> index ee22fe7..90f662b 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -82,6 +82,7 @@ DRI_CONF_BEGIN
>        DRI_CONF_DISABLE_GLSL_LINE_CONTINUATIONS("false")
>        DRI_CONF_DISABLE_BLEND_FUNC_EXTENDED("false")
>        DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER("false")
> +      DRI_CONF_EXTENSION_OVERRIDE()
>
>        DRI_CONF_OPT_BEGIN_B(shader_precompile, "true")
>          DRI_CONF_DESC(en, "Perform code generation at shader link time.")
> diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
> index 63d30a2..ed9918f 100644
> --- a/src/mesa/main/context.c
> +++ b/src/mesa/main/context.c
> @@ -397,7 +397,7 @@ one_time_init( struct gl_context *ctx )
>        assert( sizeof(GLint) == 4 );
>        assert( sizeof(GLuint) == 4 );
>
> -      _mesa_one_time_init_extension_overrides();
> +      _mesa_one_time_init_extension_overrides(ctx);
>
>        _mesa_get_cpu_features();
>
> @@ -1067,6 +1067,8 @@ _mesa_initialize_dispatch_tables(struct gl_context *ctx)
>   * Finally queries the \c MESA_DEBUG and \c MESA_VERBOSE environment variables
>   * for debug flags.
>   *
> + * Drivers should initialize ctx->Const before calling this function.
> + *
>   * \param ctx the context to initialize
>   * \param api the GL API type to create the context for
>   * \param visual describes the visual attributes for this context or NULL to
> diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
> index bfe7d99..7b65f3d 100644
> --- a/src/mesa/main/extensions.c
> +++ b/src/mesa/main/extensions.c
> @@ -595,7 +595,7 @@ free_unknown_extensions_strings(void)
>   * This should be called one time early during first context initialization.
>   */
>  void
> -_mesa_one_time_init_extension_overrides(void)
> +_mesa_one_time_init_extension_overrides(struct gl_context *ctx)
>  {
>     const char *env_const = getenv("MESA_EXTENSION_OVERRIDE");
>     char *env;
> @@ -603,6 +603,10 @@ _mesa_one_time_init_extension_overrides(void)
>     int len;
>     size_t offset;
>
> +   /* the environment variable takes precedence over drirc */
> +   if (!env_const)
> +      env_const = ctx->Const.ExtensionOverride;
> +
>     atexit(free_unknown_extensions_strings);
>
>     memset(&_mesa_extension_override_enables, 0, sizeof(struct gl_extensions));
> diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h
> index 595512a..e5e5748 100644
> --- a/src/mesa/main/extensions.h
> +++ b/src/mesa/main/extensions.h
> @@ -43,7 +43,7 @@ struct gl_extensions;
>
>  extern void _mesa_enable_sw_extensions(struct gl_context *ctx);
>
> -extern void _mesa_one_time_init_extension_overrides(void);
> +extern void _mesa_one_time_init_extension_overrides(struct gl_context *ctx);
>
>  extern void _mesa_init_extensions(struct gl_extensions *extentions);
>
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 81a7c0e..e2f211a 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -3506,6 +3506,11 @@ struct gl_constants
>     GLboolean AllowGLSLExtensionDirectiveMidShader;
>
>     /**
> +    * Allow enabling/disabling a list of GL extension.
> +    */
> +   const GLchar *ExtensionOverride;
> +
> +   /**
>      * Does the driver support real 32-bit integers?  (Otherwise, integers are
>      * simulated via floats.)
>      */
> --
> 2.2.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list