mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 04:20:18 +01:00
dri: Get rid of __DRIbackgroundCallableExtension
This was originally needed to bind the context to the background thread for DRI2 because it needs to be able to get buffers from the X server. With DRI3 and Wayland, however, it's not needed. All the DRI3 code gets everything it needs from the drawable and only uses the context for flushes and blits, which always come from GLX itself, not the render thread. Now that we've deleted all the DRI2 code, let's delete this, too. Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Eric Engestrom <eric@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36123>
This commit is contained in:
parent
eb48921b8e
commit
56ed5cf1bb
13 changed files with 2 additions and 149 deletions
|
|
@ -91,41 +91,12 @@ static const enum pipe_format dri2_pbuffer_visuals[] = {
|
|||
PIPE_FORMAT_B5G6R5_UNORM,
|
||||
};
|
||||
|
||||
static void
|
||||
dri_set_background_context(void *loaderPrivate)
|
||||
{
|
||||
_EGLContext *ctx = _eglGetCurrentContext();
|
||||
_EGLThreadInfo *t = _eglGetCurrentThread();
|
||||
|
||||
_eglBindContextToThread(ctx, t);
|
||||
}
|
||||
|
||||
static void
|
||||
dri2_gl_flush()
|
||||
{
|
||||
CALL_Flush(GET_DISPATCH(), ());
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
dri_is_thread_safe(UNUSED void *loaderPrivate)
|
||||
{
|
||||
/* loader_dri3_blit_context_get creates a context with
|
||||
* loaderPrivate being NULL. Enabling glthread for a blitting
|
||||
* context isn't useful so return false.
|
||||
*/
|
||||
if (!loaderPrivate)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const __DRIbackgroundCallableExtension background_callable_extension = {
|
||||
.base = {__DRI_BACKGROUND_CALLABLE, 2},
|
||||
|
||||
.setBackgroundContext = dri_set_background_context,
|
||||
.isThreadSafe = dri_is_thread_safe,
|
||||
};
|
||||
|
||||
static void
|
||||
dri2_get_pbuffer_drawable_info(struct dri_drawable *draw, int *x, int *y, int *w,
|
||||
int *h, void *loaderPrivate)
|
||||
|
|
|
|||
|
|
@ -436,7 +436,6 @@ dri2_egl_error_unlock(struct dri2_egl_display *dri2_dpy, EGLint err,
|
|||
}
|
||||
|
||||
extern const __DRIimageLookupExtension image_lookup_extension;
|
||||
extern const __DRIbackgroundCallableExtension background_callable_extension;
|
||||
extern const __DRIswrastLoaderExtension swrast_pbuffer_loader_extension;
|
||||
extern const __DRIkopperLoaderExtension kopper_pbuffer_loader_extension;
|
||||
|
||||
|
|
|
|||
|
|
@ -208,7 +208,6 @@ static const __DRIimageLoaderExtension image_loader_extension = {
|
|||
|
||||
static const __DRIextension *image_loader_extensions[] = {
|
||||
&image_loader_extension.base, &image_lookup_extension.base,
|
||||
&background_callable_extension.base, NULL,
|
||||
};
|
||||
|
||||
static const __DRIextension *swrast_loader_extensions[] = {
|
||||
|
|
|
|||
|
|
@ -1240,7 +1240,6 @@ dri2_initialize_x11_swrast(_EGLDisplay *disp)
|
|||
static const __DRIextension *dri3_image_loader_extensions[] = {
|
||||
&dri3_image_loader_extension.base,
|
||||
&image_lookup_extension.base,
|
||||
&background_callable_extension.base,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -60,8 +60,6 @@ dri_create_context(struct dri_screen *screen,
|
|||
__DRIVER_CONTEXT_ATTRIB_PRIORITY |
|
||||
__DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR |
|
||||
__DRIVER_CONTEXT_ATTRIB_NO_ERROR;
|
||||
const __DRIbackgroundCallableExtension *backgroundCallable =
|
||||
screen->dri2.backgroundCallable;
|
||||
const struct driOptionCache *optionCache = &screen->dev->option_cache;
|
||||
|
||||
/* This is effectively doing error checking for GLX context creation (by both
|
||||
|
|
@ -231,19 +229,8 @@ dri_create_context(struct dri_screen *screen,
|
|||
enable_glthread = user_enable_glthread;
|
||||
}
|
||||
/* Do this last. */
|
||||
if (enable_glthread) {
|
||||
bool safe = true;
|
||||
|
||||
/* This is only needed by X11/DRI2, which can be unsafe. */
|
||||
if (backgroundCallable &&
|
||||
backgroundCallable->base.version >= 2 &&
|
||||
backgroundCallable->isThreadSafe &&
|
||||
!backgroundCallable->isThreadSafe(loaderPrivate))
|
||||
safe = false;
|
||||
|
||||
if (safe)
|
||||
_mesa_glthread_init(ctx->st->ctx);
|
||||
}
|
||||
if (enable_glthread)
|
||||
_mesa_glthread_init(ctx->st->ctx);
|
||||
|
||||
*error = __DRI_CTX_ERROR_SUCCESS;
|
||||
return ctx;
|
||||
|
|
|
|||
|
|
@ -601,11 +601,6 @@ dri_set_background_context(struct st_context *st,
|
|||
struct util_queue_monitoring *queue_info)
|
||||
{
|
||||
struct dri_context *ctx = (struct dri_context *)st->frontend_context;
|
||||
const __DRIbackgroundCallableExtension *backgroundCallable =
|
||||
ctx->screen->dri2.backgroundCallable;
|
||||
|
||||
if (backgroundCallable)
|
||||
backgroundCallable->setBackgroundContext(ctx->loaderPrivate);
|
||||
|
||||
if (ctx->hud)
|
||||
hud_add_queue_for_monitoring(ctx->hud, queue_info);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ struct dri_screen
|
|||
|
||||
struct {
|
||||
const __DRIimageLookupExtension *image;
|
||||
const __DRIbackgroundCallableExtension *backgroundCallable;
|
||||
} dri2;
|
||||
|
||||
struct {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ setupLoaderExtensions(struct dri_screen *screen,
|
|||
{
|
||||
static const struct dri_extension_match matches[] = {
|
||||
{__DRI_IMAGE_LOOKUP, 1, offsetof(struct dri_screen, dri2.image), true},
|
||||
{__DRI_BACKGROUND_CALLABLE, 1, offsetof(struct dri_screen, dri2.backgroundCallable), true},
|
||||
{__DRI_SWRAST_LOADER, 1, offsetof(struct dri_screen, swrast_loader), true},
|
||||
{__DRI_IMAGE_LOADER, 1, offsetof(struct dri_screen, image.loader), true},
|
||||
{__DRI_MUTABLE_RENDER_BUFFER_LOADER, 1, offsetof(struct dri_screen, mutableRenderBuffer.loader), true},
|
||||
|
|
|
|||
|
|
@ -895,56 +895,6 @@ typedef struct {
|
|||
void (*destroyLoaderImageState)(void *loaderPrivate);
|
||||
} __DRIimageLoaderExtension;
|
||||
|
||||
/**
|
||||
* Background callable loader extension.
|
||||
*
|
||||
* Loaders expose this extension to indicate to drivers that they are capable
|
||||
* of handling callbacks from the driver's background drawing threads.
|
||||
*/
|
||||
#define __DRI_BACKGROUND_CALLABLE "DRI_BackgroundCallable"
|
||||
|
||||
typedef struct {
|
||||
__DRIextension base;
|
||||
|
||||
/**
|
||||
* Indicate that this thread is being used by the driver as a background
|
||||
* drawing thread which may make callbacks to the loader.
|
||||
*
|
||||
* \param loaderPrivate is the value that was passed to to the driver when
|
||||
* the context was created. This can be used by the loader to identify
|
||||
* which context any callbacks are associated with.
|
||||
*
|
||||
* If this function is called more than once from any given thread, each
|
||||
* subsequent call overrides the loaderPrivate data that was passed in the
|
||||
* previous call. The driver can take advantage of this to re-use a
|
||||
* background thread to perform drawing on behalf of multiple contexts.
|
||||
*
|
||||
* It is permissible for the driver to call this function from a
|
||||
* non-background thread (i.e. a thread that has already been bound to a
|
||||
* context using __DRIcoreExtension::bindContext()); when this happens,
|
||||
* the \c loaderPrivate pointer must be equal to the pointer that was
|
||||
* passed to the driver when the currently bound context was created.
|
||||
*
|
||||
* This call should execute quickly enough that the driver can call it with
|
||||
* impunity whenever a background thread starts performing drawing
|
||||
* operations (e.g. it should just set a thread-local variable).
|
||||
*/
|
||||
void (*setBackgroundContext)(void *loaderPrivate);
|
||||
|
||||
/**
|
||||
* Indicate that it is multithread safe to use glthread. For GLX/EGL
|
||||
* platforms using Xlib, that involves calling XInitThreads, before
|
||||
* opening an X display.
|
||||
*
|
||||
* Note: only supported if extension version is at least 2.
|
||||
*
|
||||
* \param loaderPrivate is the value that was passed to to the driver when
|
||||
* the context was created. This can be used by the loader to identify
|
||||
* which context any callbacks are associated with.
|
||||
*/
|
||||
unsigned char (*isThreadSafe)(void *loaderPrivate);
|
||||
} __DRIbackgroundCallableExtension;
|
||||
|
||||
/**
|
||||
* The loader portion of EGL_KHR_mutable_render_buffer.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -339,21 +339,6 @@ dri3_flush_swap_buffers(struct dri_drawable *driDrawable, void *loaderPrivate)
|
|||
loader_dri3_swapbuffer_barrier(draw);
|
||||
}
|
||||
|
||||
static void
|
||||
dri_set_background_context(void *loaderPrivate)
|
||||
{
|
||||
__glXSetCurrentContext(loaderPrivate);
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
dri_is_thread_safe(void *loaderPrivate)
|
||||
{
|
||||
/* Unlike DRI2, DRI3 doesn't call GetBuffers/GetBuffersWithFormat
|
||||
* during draw so we're safe here.
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/* The image loader extension record for DRI3
|
||||
*/
|
||||
static const __DRIimageLoaderExtension imageLoaderExtension = {
|
||||
|
|
@ -364,16 +349,8 @@ static const __DRIimageLoaderExtension imageLoaderExtension = {
|
|||
.flushSwapBuffers = dri3_flush_swap_buffers,
|
||||
};
|
||||
|
||||
static const __DRIbackgroundCallableExtension dri3BackgroundCallable = {
|
||||
.base = { __DRI_BACKGROUND_CALLABLE, 2 },
|
||||
|
||||
.setBackgroundContext = dri_set_background_context,
|
||||
.isThreadSafe = dri_is_thread_safe,
|
||||
};
|
||||
|
||||
static const __DRIextension *loader_extensions[] = {
|
||||
&imageLoaderExtension.base,
|
||||
&dri3BackgroundCallable.base,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -737,25 +737,6 @@ out:
|
|||
return e ? e->config : NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
driSetBackgroundContext(void *loaderPrivate)
|
||||
{
|
||||
__glXSetCurrentContext(loaderPrivate);
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
driIsThreadSafe(void *loaderPrivate)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const __DRIbackgroundCallableExtension driBackgroundCallable = {
|
||||
.base = { __DRI_BACKGROUND_CALLABLE, 2 },
|
||||
|
||||
.setBackgroundContext = driSetBackgroundContext,
|
||||
.isThreadSafe = driIsThreadSafe,
|
||||
};
|
||||
|
||||
Bool
|
||||
dri_bind_context(struct glx_context *context, GLXDrawable draw, GLXDrawable read)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,8 +88,6 @@ dri_common_create_context(struct glx_screen *base,
|
|||
struct glx_context *shareList,
|
||||
int renderType);
|
||||
|
||||
extern const __DRIbackgroundCallableExtension driBackgroundCallable;
|
||||
|
||||
Bool
|
||||
dri_bind_context(struct glx_context *context, GLXDrawable draw, GLXDrawable read);
|
||||
void
|
||||
|
|
|
|||
|
|
@ -430,7 +430,6 @@ static const __DRIextension *loader_extensions_noshm[] = {
|
|||
static const __DRIextension *kopper_extensions_noshm[] = {
|
||||
&swrastLoaderExtension.base,
|
||||
&kopperLoaderExtension.base,
|
||||
&driBackgroundCallable.base,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue