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 <tarceri@itsqueeze.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14701>
This commit is contained in:
parent
047992821b
commit
06504fb9e2
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue