[Mesa-dev] [PATCH 02/14] mesa: add env var to force enable the KHR_no_error ctx flag

Nicolai Hähnle nhaehnle at gmail.com
Wed Apr 19 06:24:16 UTC 2017


On 19.04.2017 02:37, Timothy Arceri wrote:
> V2: typo know -> known
> V3: add security check (Suggested by Nicolai)

Thanks for the update.

Patches 1 & 2:

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

> ---
>  docs/envvars.html       | 3 +++
>  src/mesa/main/context.c | 6 ++++++
>  2 files changed, 9 insertions(+)
>
> diff --git a/docs/envvars.html b/docs/envvars.html
> index 6537365..a064f56 100644
> --- a/docs/envvars.html
> +++ b/docs/envvars.html
> @@ -39,20 +39,23 @@ sometimes be useful for debugging end-user issues.
>
>
>
>  <h2>Core Mesa environment variables</h2>
>
>  <ul>
>  <li>MESA_NO_ASM - if set, disables all assembly language optimizations
>  <li>MESA_NO_MMX - if set, disables Intel MMX optimizations
>  <li>MESA_NO_3DNOW - if set, disables AMD 3DNow! optimizations
>  <li>MESA_NO_SSE - if set, disables Intel SSE optimizations
> +<li>MESA_NO_ERROR - if set error checking is disabled as per KHR_no_error.
> +   This will result in undefined behaviour for invalid use of the api, but
> +   can reduce CPU use for apps that are known to be error free.</li>
>  <li>MESA_DEBUG - if set, error messages are printed to stderr.  For example,
>     if the application generates a GL_INVALID_ENUM error, a corresponding error
>     message indicating where the error occurred, and possibly why, will be
>     printed to stderr.<br>
>
>     For release builds, MESA_DEBUG defaults to off (no debug output).
>
>     MESA_DEBUG accepts the following comma-separated list of named
>     flags, which adds extra behaviour to just set MESA_DEBUG=1:
>     <ul>
> diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
> index 8876ca2..984c9e0 100644
> --- a/src/mesa/main/context.c
> +++ b/src/mesa/main/context.c
> @@ -1201,20 +1201,26 @@ _mesa_initialize_context(struct gl_context *ctx,
>        shared = _mesa_alloc_shared_state(ctx);
>        if (!shared)
>           return GL_FALSE;
>     }
>
>     _mesa_reference_shared_state(ctx, &ctx->Shared, shared);
>
>     if (!init_attrib_groups( ctx ))
>        goto fail;
>
> +   /* KHR_no_error is likely to crash, overflow memory, etc if an application
> +    * has errors so don't enable it for setuid processes.
> +    */
> +   if (getenv("MESA_NO_ERROR") && geteuid() == getuid())
> +      ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR;
> +
>     /* setup the API dispatch tables with all nop functions */
>     ctx->OutsideBeginEnd = _mesa_alloc_dispatch_table();
>     if (!ctx->OutsideBeginEnd)
>        goto fail;
>     ctx->Exec = ctx->OutsideBeginEnd;
>     ctx->CurrentClientDispatch = ctx->CurrentServerDispatch = ctx->OutsideBeginEnd;
>
>     ctx->FragmentProgram._MaintainTexEnvProgram
>        = (getenv("MESA_TEX_PROG") != NULL);
>
>


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list