Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/envvars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,21 @@ Hasvk driver environment variables
DRI environment variables
-------------------------

.. envvar:: MESA_DRI3_DISABLE_PRESENT_WAIT_FENCE

Controls the X11 Present wait-fence bridge and the shared KGSL
presentation-completion wait. For native Wayland EGL contexts the
default is ``true``, restoring the earlier nonblocking presentation
behavior. For X11 contexts, including XWayland and Termux:X11, the
default is ``false``, preserving the Present wait-fence bridge.

Set ``1`` to disable both presentation mechanisms, or ``0`` to keep
them enabled, including the conservative KGSL completion wait on
native Wayland. This does not disable resource submission, OpenGL
synchronization objects, or EGL native fences. Disabling the wait
does not add an asynchronous fence handoff to the compositor; visual
correctness still depends on the existing buffer synchronization.

.. envvar:: DRI_NO_MSAA

disable MSAA for GLX/EGL MSAA visuals
Expand Down
9 changes: 9 additions & 0 deletions src/egl/drivers/dri2/egl_dri2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,15 @@ dri2_create_context(_EGLDisplay *disp, _EGLConfig *conf,
if (!dri2_ctx->dri_context)
goto cleanup;

if (disp->Platform == _EGL_PLATFORM_WAYLAND) {
/* Native Wayland has no X11 Present wait-fence bridge. Keep its
* pre-bridge default, with the same environment override as DRI3.
* This is a context policy, so later attachment flushes agree too.
*/
dri_disable_present_wait_fence(dri2_ctx->dri_context,
debug_get_bool_option("MESA_DRI3_DISABLE_PRESENT_WAIT_FENCE", true));
}

mtx_unlock(&dri2_dpy->lock);

return &dri2_ctx->base;
Expand Down
3 changes: 3 additions & 0 deletions src/gallium/drivers/freedreno/freedreno_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ fd_set_context_param(struct pipe_context *pctx, enum pipe_context_param param,
case PIPE_CONTEXT_PARAM_EXPLICIT_PRESENT_FENCE:
ctx->explicit_present_fence = value;
break;
case PIPE_CONTEXT_PARAM_DISABLE_PRESENT_WAIT_FENCE:
ctx->disable_present_wait_fence = value;
break;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/gallium/drivers/freedreno/freedreno_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ struct fd_context {
* the window-system presentation path.
*/
bool explicit_present_fence;
bool disable_present_wait_fence;

/*
* Counter to keep track of batch's most recent update. Ie. the batch with
Expand Down
6 changes: 4 additions & 2 deletions src/gallium/drivers/freedreno/freedreno_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -770,9 +770,11 @@ fd_flush_resource(struct pipe_context *pctx, struct pipe_resource *prsc)
* If the window-system path is not carrying the next submission's native
* fence explicitly, wait here before handing the resource to an
* implicit-sync consumer. The explicit Present-fence path avoids this
* per-frame CPU stall.
* per-frame CPU stall. The compatibility opt-out restores the previous
* window-system behavior without changing resource submission or API fences.
*/
if (ctx->screen->is_kgsl && !ctx->explicit_present_fence)
if (ctx->screen->is_kgsl && !ctx->explicit_present_fence &&
!ctx->disable_present_wait_fence)
fd_resource_wait(ctx, rsc, FD_BO_PREP_READ);
}

Expand Down
14 changes: 14 additions & 0 deletions src/gallium/frontends/dri/dri_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "dri_screen.h"
#include "dri_drawable.h"
#include "dri_context.h"
#include "dri_util.h"
#include "frontend/drm_driver.h"

#include "pipe/p_context.h"
Expand All @@ -42,6 +43,16 @@
#include "util/u_memory.h"
#include "util/u_debug.h"

void
dri_disable_present_wait_fence(struct dri_context *ctx, bool disable)
{
struct pipe_context *pipe = ctx->st->pipe;
if (pipe->set_context_param)
pipe->set_context_param(pipe,
PIPE_CONTEXT_PARAM_DISABLE_PRESENT_WAIT_FENCE,
disable);
}

struct dri_context *
dri_create_context(struct dri_screen *screen,
struct st_context_attribs *attribs,
Expand Down Expand Up @@ -136,6 +147,9 @@ dri_create_context(struct dri_screen *screen,
if (!thread_safe)
enable_glthread = false;

dri_disable_present_wait_fence(ctx, debug_get_bool_option(
"MESA_DRI3_DISABLE_PRESENT_WAIT_FENCE", false));

/* Do this last. */
if (enable_glthread)
_mesa_glthread_init(ctx->st->ctx);
Expand Down
3 changes: 3 additions & 0 deletions src/gallium/frontends/dri/dri_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ dri_query_renderer_integer(struct dri_screen *_screen, int param,

PUBLIC void
dri_flush_drawable(struct dri_drawable *dPriv);
/* Set the window-system policy before the context is made current. */
PUBLIC void
dri_disable_present_wait_fence(struct dri_context *ctx, bool disable);
PUBLIC void
dri_flush(struct dri_context *cPriv,
struct dri_drawable *dPriv,
Expand Down
5 changes: 5 additions & 0 deletions src/gallium/include/pipe/p_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,11 @@ enum pipe_context_param
*/
PIPE_CONTEXT_PARAM_EXPLICIT_PRESENT_FENCE,

/* Compatibility policy for window-system presentation. Disable only the
* driver's additional CPU completion wait, not submission or API fences.
*/
PIPE_CONTEXT_PARAM_DISABLE_PRESENT_WAIT_FENCE,

/* The minification/magnification switch-over point, the constant c of the
* GL and ES specs. Value 1 selects c = 0.5, value 0 selects c = 0.
*
Expand Down
1 change: 1 addition & 0 deletions src/gallium/targets/dri/dri.sym.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
dri_query_renderer_string;
dri_query_renderer_integer;
dri_flush_drawable;
dri_disable_present_wait_fence;
dri_flush;
dri_invalidate_drawable;
dri2GalliumConfigQuery*;
Expand Down
Loading