mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 07:20:10 +01:00
egl,glx: allow OpenGL with old libx11, but disable glthread if it's unsafe
pass bool thread_safe to the dri frontend, and enable glthread accordingly Reviewed-by: Eric Engestrom <eric@igalia.com> Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36378>
This commit is contained in:
parent
20f546d6c1
commit
ecbe35d878
11 changed files with 34 additions and 22 deletions
|
|
@ -2058,7 +2058,7 @@ dep_glproto_version = '>= 1.4.14'
|
|||
dep_xcb_dri3_version = '>= 1.13'
|
||||
dep_xcb_glx_version = '>= 1.8.1'
|
||||
dep_xcb_present_version = '>= 1.13'
|
||||
dep_xlib_version = '>= 1.8'
|
||||
dep_xlib_version = '>= 1.6' # RHEL8 has 1.6, RHEL9 has 1.7, U22.04 has 1.7
|
||||
dep_xlib_xrandr_version = '>= 1.3'
|
||||
dep_xshmfence_version = '>= 1.1'
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@
|
|||
#ifdef HAVE_X11_PLATFORM
|
||||
#include "X11/Xlibint.h"
|
||||
#include "x11_dri3.h"
|
||||
#include "x11_display.h"
|
||||
#endif
|
||||
|
||||
#include "GL/mesa_glinterop.h"
|
||||
|
|
@ -1235,9 +1236,16 @@ dri2_create_context(_EGLDisplay *disp, _EGLConfig *conf,
|
|||
&num_attribs))
|
||||
goto cleanup;
|
||||
|
||||
bool thread_safe = true;
|
||||
|
||||
#ifdef HAVE_X11_PLATFORM
|
||||
if (disp->Platform == _EGL_PLATFORM_X11)
|
||||
thread_safe = x11_xlib_display_is_thread_safe(disp->PlatformDisplay);
|
||||
#endif
|
||||
|
||||
dri2_ctx->dri_context = driCreateContextAttribs(
|
||||
dri2_dpy->dri_screen_render_gpu, api, dri_config, shared, num_attribs / 2,
|
||||
ctx_attribs, &error, dri2_ctx);
|
||||
ctx_attribs, &error, dri2_ctx, thread_safe);
|
||||
dri2_create_context_attribs_error(error);
|
||||
|
||||
if (!dri2_ctx->dri_context)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include "x11_dri3.h"
|
||||
#include "x11_display.h"
|
||||
#include "kopper_interface.h"
|
||||
#include "loader.h"
|
||||
#include "platform_x11.h"
|
||||
|
|
@ -1069,8 +1068,6 @@ dri2_get_xcb_connection(_EGLDisplay *disp, struct dri2_egl_display *dri2_dpy)
|
|||
screen = dri2_find_screen_for_display(disp, screen);
|
||||
} else if (disp->Platform == _EGL_PLATFORM_X11) {
|
||||
Display *dpy = disp->PlatformDisplay;
|
||||
if (!x11_xlib_display_is_thread_safe(dpy))
|
||||
return EGL_FALSE;
|
||||
dri2_dpy->conn = XGetXCBConnection(dpy);
|
||||
screen = DefaultScreen(dpy);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ dri_create_context(struct dri_screen *screen,
|
|||
const struct __DriverContextConfig *ctx_config,
|
||||
unsigned *error,
|
||||
struct dri_context *sharedContextPrivate,
|
||||
void *loaderPrivate)
|
||||
void *loaderPrivate,
|
||||
bool thread_safe)
|
||||
{
|
||||
struct dri_context *ctx = NULL;
|
||||
struct st_context *st_share = NULL;
|
||||
|
|
@ -228,6 +229,10 @@ dri_create_context(struct dri_screen *screen,
|
|||
}
|
||||
enable_glthread = user_enable_glthread;
|
||||
}
|
||||
|
||||
if (!thread_safe)
|
||||
enable_glthread = false;
|
||||
|
||||
/* Do this last. */
|
||||
if (enable_glthread)
|
||||
_mesa_glthread_init(ctx->st->ctx);
|
||||
|
|
|
|||
|
|
@ -101,7 +101,8 @@ dri_create_context(struct dri_screen *screen,
|
|||
const struct __DriverContextConfig *ctx_config,
|
||||
unsigned *error,
|
||||
struct dri_context *sharedContextPrivate,
|
||||
void *loaderPrivate);
|
||||
void *loaderPrivate,
|
||||
bool thread_safe);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -421,7 +421,8 @@ driCreateContextAttribs(struct dri_screen *screen, int api,
|
|||
unsigned num_attribs,
|
||||
const uint32_t *attribs,
|
||||
unsigned *error,
|
||||
void *data)
|
||||
void *data,
|
||||
bool thread_safe)
|
||||
{
|
||||
const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
|
||||
gl_api mesa_api;
|
||||
|
|
@ -594,27 +595,27 @@ driCreateContextAttribs(struct dri_screen *screen, int api,
|
|||
|
||||
struct dri_context *ctx = dri_create_context(screen, mesa_api,
|
||||
modes, &ctx_config, error,
|
||||
shared, data);
|
||||
shared, data, thread_safe);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static struct dri_context *
|
||||
driCreateNewContextForAPI(struct dri_screen *screen, int api,
|
||||
const struct dri_config *config,
|
||||
struct dri_context *shared, void *data)
|
||||
struct dri_context *shared, void *data, bool thread_safe)
|
||||
{
|
||||
unsigned error;
|
||||
|
||||
return driCreateContextAttribs(screen, api, config, shared, 0, NULL,
|
||||
&error, data);
|
||||
&error, data, thread_safe);
|
||||
}
|
||||
|
||||
struct dri_context *
|
||||
driCreateNewContext(struct dri_screen *screen, const struct dri_config *config,
|
||||
struct dri_context *shared, void *data)
|
||||
struct dri_context *shared, void *data, bool thread_safe)
|
||||
{
|
||||
return driCreateNewContextForAPI(screen, __DRI_API_OPENGL,
|
||||
config, shared, data);
|
||||
config, shared, data, thread_safe);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -119,7 +119,8 @@ driCreateContextAttribs(struct dri_screen *psp, int api,
|
|||
unsigned num_attribs,
|
||||
const uint32_t *attribs,
|
||||
unsigned *error,
|
||||
void *data);
|
||||
void *data,
|
||||
bool thread_safe);
|
||||
|
||||
extern uint32_t
|
||||
driImageFormatToSizedInternalGLFormat(uint32_t image_format);
|
||||
|
|
@ -140,7 +141,8 @@ driSwapBuffers(struct dri_drawable *drawable);
|
|||
PUBLIC void
|
||||
driSwapBuffersWithDamage(struct dri_drawable *drawable, int nrects, const int *rects);
|
||||
PUBLIC struct dri_context *
|
||||
driCreateNewContext(struct dri_screen *screen, const struct dri_config *config, struct dri_context *shared, void *data);
|
||||
driCreateNewContext(struct dri_screen *screen, const struct dri_config *config,
|
||||
struct dri_context *shared, void *data, bool thread_safe);
|
||||
PUBLIC int
|
||||
driCopyContext(struct dri_context *dest, struct dri_context *src, unsigned long mask);
|
||||
PUBLIC void
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ loader_dri3_blit_context_get(struct loader_dri3_drawable *draw)
|
|||
|
||||
if (!blit_context.ctx) {
|
||||
blit_context.ctx = driCreateNewContext(draw->dri_screen_render_gpu,
|
||||
NULL, NULL, NULL);
|
||||
NULL, NULL, NULL, true);
|
||||
blit_context.cur_screen = draw->dri_screen_render_gpu;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1060,7 +1060,7 @@ gbm_dri_bo_map(struct gbm_bo *_bo,
|
|||
dri->context = driCreateContextAttribs(dri->screen,
|
||||
__DRI_API_OPENGL,
|
||||
NULL, NULL, 0, NULL,
|
||||
&error, NULL);
|
||||
&error, NULL, true);
|
||||
}
|
||||
assert(dri->context);
|
||||
mtx_unlock(&dri->mutex);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
#include <xcb/xproto.h>
|
||||
#include "dri_util.h"
|
||||
#include "pipe-loader/pipe_loader.h"
|
||||
#include "x11/x11_display.h"
|
||||
|
||||
#define __ATTRIB(attrib, field) \
|
||||
{ attrib, offsetof(struct glx_config, field) }
|
||||
|
|
@ -887,7 +888,8 @@ dri_create_context_attribs(struct glx_screen *base,
|
|||
num_ctx_attribs / 2,
|
||||
ctx_attribs,
|
||||
error,
|
||||
pcp);
|
||||
pcp,
|
||||
x11_xlib_display_is_thread_safe(base->dpy));
|
||||
|
||||
*error = dri_context_error_to_glx_error(*error);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
#endif
|
||||
|
||||
#include "x11_dri3.h"
|
||||
#include "x11_display.h"
|
||||
#ifdef HAVE_LIBDRM
|
||||
#include "loader_dri3_helper.h"
|
||||
#endif
|
||||
|
|
@ -942,9 +941,6 @@ __glXInitialize(Display * dpy)
|
|||
struct glx_display *dpyPriv, *d;
|
||||
int i, majorVersion = 0;
|
||||
|
||||
if (!x11_xlib_display_is_thread_safe(dpy))
|
||||
return NULL;
|
||||
|
||||
_XLockMutex(_Xglobal_lock);
|
||||
|
||||
for (dpyPriv = glx_displays; dpyPriv; dpyPriv = dpyPriv->next) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue