Mesa (master): mesa: add env var to force enable the KHR_no_error ctx flag

Timothy Arceri tarceri at kemper.freedesktop.org
Wed Apr 19 07:20:33 UTC 2017


Module: Mesa
Branch: master
Commit: a0ed0eb3424df32c6ef4cf01f665e24d8fc4a41b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a0ed0eb3424df32c6ef4cf01f665e24d8fc4a41b

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Wed Apr 12 15:08:01 2017 +1000

mesa: add env var to force enable the KHR_no_error ctx flag

V2: typo know -> known
V3: add security check (Suggested by Nicolai)

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 653736565e..a064f569c8 100644
--- a/docs/envvars.html
+++ b/docs/envvars.html
@@ -46,6 +46,9 @@ sometimes be useful for debugging end-user issues.
 <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
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 8876ca2e24..984c9e00bb 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1208,6 +1208,12 @@ _mesa_initialize_context(struct gl_context *ctx,
    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)




More information about the mesa-commit mailing list