Module: Mesa Branch: main Commit: 06504fb9e2382e43b889fd6ca642bb785b544d4d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=06504fb9e2382e43b889fd6ca642bb785b544d4d
Author: Dave Airlie <[email protected]> Date: Tue Jan 25 16:01:00 2022 +1000 mesa: consolidate setting no error state and checking suid. This makes MESA_NO_ERROR and mesa_no_error via drirc do the same thing. Reviewed-by: Timothy Arceri <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14701> --- src/gallium/frontends/dri/dri_context.c | 12 ++++++++++-- src/mesa/main/context.c | 12 +++--------- src/mesa/main/context.h | 1 + src/mesa/state_tracker/st_context.c | 9 +++------ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/gallium/frontends/dri/dri_context.c b/src/gallium/frontends/dri/dri_context.c index 55bfa224bcf..1b0dd9f569e 100644 --- a/src/gallium/frontends/dri/dri_context.c +++ b/src/gallium/frontends/dri/dri_context.c @@ -41,6 +41,7 @@ #include "state_tracker/st_context.h" #include "util/u_memory.h" +#include "util/debug.h" GLboolean dri_create_context(gl_api api, const struct gl_config * visual, @@ -155,8 +156,15 @@ dri_create_context(gl_api api, const struct gl_config * visual, ctx->cPriv = cPriv; ctx->sPriv = sPriv; - if (driQueryOptionb(&screen->dev->option_cache, "mesa_no_error")) - attribs.flags |= ST_CONTEXT_FLAG_NO_ERROR; + /* KHR_no_error is likely to crash, overflow memory, etc if an application + * has errors so don't enable it for setuid processes. + */ + if (env_var_as_boolean("MESA_NO_ERROR", false) || + driQueryOptionb(&screen->dev->option_cache, "mesa_no_error")) +#if !defined(_WIN32) + if (geteuid() == getuid()) +#endif + attribs.flags |= ST_CONTEXT_FLAG_NO_ERROR; attribs.options = screen->options; dri_fill_st_visual(&attribs.visual, screen, visual); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index baaa2a26da2..7ad1a9fb533 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -978,6 +978,7 @@ _mesa_initialize_dispatch_tables(struct gl_context *ctx) GLboolean _mesa_initialize_context(struct gl_context *ctx, gl_api api, + bool no_error, const struct gl_config *visual, struct gl_context *share_list, const struct dd_function_table *driverFunctions) @@ -1031,15 +1032,8 @@ _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 (env_var_as_boolean("MESA_NO_ERROR", false)) { -#if !defined(_WIN32) - if (geteuid() == getuid()) -#endif - ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR; - } + if (no_error) + 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(false); diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index f6bbb62796e..6e068f9dd7a 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -73,6 +73,7 @@ _mesa_initialize(const char *extensions_override); extern GLboolean _mesa_initialize_context( struct gl_context *ctx, gl_api api, + bool no_error, const struct gl_config *visual, struct gl_context *share_list, const struct dd_function_table *driverFunctions); diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 524e1f8028d..a71837abeb5 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -475,7 +475,7 @@ st_have_perfquery(struct st_context *ctx) static struct st_context * st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, - const struct st_config_options *options, bool no_error) + const struct st_config_options *options) { struct pipe_screen *screen = pipe->screen; uint i; @@ -551,9 +551,6 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, st->util_velems.velems[2].src_format = PIPE_FORMAT_R32G32_FLOAT; } - if (no_error) - ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR; - ctx->Const.PackedDriverUniformStorage = screen->get_param(screen, PIPE_CAP_PACKED_UNIFORMS); @@ -870,7 +867,7 @@ st_create_context(gl_api api, struct pipe_context *pipe, ctx->pipe = pipe; ctx->screen = pipe->screen; - if (!_mesa_initialize_context(ctx, api, visual, shareCtx, &funcs)) { + if (!_mesa_initialize_context(ctx, api, no_error, visual, shareCtx, &funcs)) { align_free(ctx); return NULL; } @@ -889,7 +886,7 @@ st_create_context(gl_api api, struct pipe_context *pipe, if (pipe->screen->get_param(pipe->screen, PIPE_CAP_INVALIDATE_BUFFER)) ctx->has_invalidate_buffer = true; - st = st_create_context_priv(ctx, pipe, options, no_error); + st = st_create_context_priv(ctx, pipe, options); if (!st) { _mesa_free_context_data(ctx, true); align_free(ctx);
