X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglx%2Fdri2_glx.c;h=d8c5ba25f04e8533a916f21ec8150dadd8e642fe;hb=00af91ca463a2486c043c635d94d9958fb1e8700;hp=5c5630dbb4d4a49c0dc6bfdeb2ed2a5468b70115;hpb=e5d027ec7d5f507489c44124e668d788728f25dd;p=mesa.git diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 5c5630dbb4d..d8c5ba25f04 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -74,7 +74,7 @@ struct dri2_display __glxHashTable *dri2Hash; - const __DRIextension *loader_extensions[4]; + const __DRIextension *loader_extensions[5]; }; struct dri2_drawable @@ -247,7 +247,8 @@ dri2_create_context_attribs(struct glx_screen *base, uint32_t flags; unsigned api; int reset; - uint32_t ctx_attribs[2 * 5]; + int release; + uint32_t ctx_attribs[2 * 6]; unsigned num_ctx_attribs = 0; if (psc->dri2->base.version < 3) { @@ -259,7 +260,7 @@ dri2_create_context_attribs(struct glx_screen *base, */ if (!dri2_convert_glx_attribs(num_attribs, attribs, &major_ver, &minor_ver, &renderType, &flags, - &api, &reset, error)) + &api, &reset, &release, error)) goto error_exit; /* Check the renderType value */ @@ -277,7 +278,7 @@ dri2_create_context_attribs(struct glx_screen *base, goto error_exit; } - if (!glx_context_init(&pcp->base, &psc->base, &config->base)) + if (!glx_context_init(&pcp->base, &psc->base, config_base)) goto error_exit; ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MAJOR_VERSION; @@ -294,6 +295,11 @@ dri2_create_context_attribs(struct glx_screen *base, ctx_attribs[num_ctx_attribs++] = reset; } + if (release != __DRI_CTX_RELEASE_BEHAVIOR_FLUSH) { + ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR; + ctx_attribs[num_ctx_attribs++] = release; + } + if (flags != 0) { ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_FLAGS; @@ -311,7 +317,7 @@ dri2_create_context_attribs(struct glx_screen *base, pcp->driContext = (*psc->dri2->createContextAttribs) (psc->driScreen, api, - config->driConfig, + config ? config->driConfig : NULL, shared, num_ctx_attribs / 2, ctx_attribs, @@ -514,7 +520,7 @@ dri2GetCurrentContext() struct glx_context *gc = __glXGetCurrentContext(); struct dri2_context *dri2Ctx = (struct dri2_context *)gc; - return dri2Ctx ? dri2Ctx->driContext : NULL; + return (gc != &dummyContext) ? dri2Ctx->driContext : NULL; } /** @@ -946,6 +952,25 @@ dri2GetSwapInterval(__GLXDRIdrawable *pdraw) return priv->swap_interval; } +static void +driSetBackgroundContext(void *loaderPrivate) +{ + struct dri2_context *pcp = (struct dri2_context *) loaderPrivate; + __glXSetCurrentContext(&pcp->base); +} + +static GLboolean +driIsThreadSafe(void *loaderPrivate) +{ + struct dri2_context *pcp = (struct dri2_context *) loaderPrivate; + /* Check Xlib is running in thread safe mode + * + * 'lock_fns' is the XLockDisplay function pointer of the X11 display 'dpy'. + * It wll be NULL if XInitThreads wasn't called. + */ + return pcp->base.psc->dpy->lock_fns != NULL; +} + static const __DRIdri2LoaderExtension dri2LoaderExtension = { .base = { __DRI_DRI2_LOADER, 3 }, @@ -966,6 +991,13 @@ static const __DRIuseInvalidateExtension dri2UseInvalidate = { .base = { __DRI_USE_INVALIDATE, 1 } }; +static const __DRIbackgroundCallableExtension driBackgroundCallable = { + .base = { __DRI_BACKGROUND_CALLABLE, 2 }, + + .setBackgroundContext = driSetBackgroundContext, + .isThreadSafe = driIsThreadSafe, +}; + _X_HIDDEN void dri2InvalidateBuffers(Display *dpy, XID drawable) { @@ -1070,7 +1102,6 @@ dri2BindExtensions(struct dri2_screen *psc, struct glx_display * priv, extensions = psc->core->getExtensions(psc->driScreen); - __glXEnableDirectExtension(&psc->base, "GLX_SGI_video_sync"); __glXEnableDirectExtension(&psc->base, "GLX_SGI_swap_control"); __glXEnableDirectExtension(&psc->base, "GLX_MESA_swap_control"); __glXEnableDirectExtension(&psc->base, "GLX_SGI_make_current_read"); @@ -1144,6 +1175,14 @@ dri2BindExtensions(struct dri2_screen *psc, struct glx_display * priv, if (strcmp(extensions[i]->name, __DRI2_INTEROP) == 0) psc->interop = (__DRI2interopExtension*)extensions[i]; + + /* DRI2 version 3 is also required because + * GLX_ARB_control_flush_control requires GLX_ARB_create_context. + */ + if (psc->dri2->base.version >= 3 + && strcmp(extensions[i]->name, __DRI2_FLUSH_CONTROL) == 0) + __glXEnableDirectExtension(&psc->base, + "GLX_ARB_context_flush_control"); } } @@ -1167,6 +1206,7 @@ dri2CreateScreen(int screen, struct glx_display * priv) char *driverName = NULL, *loader_driverName, *deviceName, *tmp; drm_magic_t magic; int i; + unsigned char disable; psc = calloc(1, sizeof *psc); if (psc == NULL) @@ -1206,19 +1246,13 @@ dri2CreateScreen(int screen, struct glx_display * priv) /* If Mesa knows about the appropriate driver for this fd, then trust it. * Otherwise, default to the server's value. */ - loader_driverName = loader_get_driver_for_fd(psc->fd, 0); + loader_driverName = loader_get_driver_for_fd(psc->fd); if (loader_driverName) { free(driverName); driverName = loader_driverName; } - psc->driver = driOpenDriver(driverName); - if (psc->driver == NULL) { - ErrorMessageF("driver pointer missing\n"); - goto handle_error; - } - - extensions = driGetDriverExtensions(psc->driver, driverName); + extensions = driOpenDriver(driverName, &psc->driver); if (extensions == NULL) goto handle_error; @@ -1290,9 +1324,17 @@ dri2CreateScreen(int screen, struct glx_display * priv) psp->waitForSBC = dri2WaitForSBC; psp->setSwapInterval = dri2SetSwapInterval; psp->getSwapInterval = dri2GetSwapInterval; - __glXEnableDirectExtension(&psc->base, "GLX_OML_sync_control"); + if (psc->config->configQueryb(psc->driScreen, + "glx_disable_oml_sync_control", + &disable) || !disable) + __glXEnableDirectExtension(&psc->base, "GLX_OML_sync_control"); } + if (psc->config->configQueryb(psc->driScreen, + "glx_disable_sgi_video_sync", + &disable) || !disable) + __glXEnableDirectExtension(&psc->base, "GLX_SGI_video_sync"); + /* DRI2 supports SubBuffer through DRI2CopyRegion, so it's always * available.*/ psp->copySubBuffer = dri2CopySubBuffer; @@ -1393,10 +1435,10 @@ dri2CreateDisplay(Display * dpy) else pdp->loader_extensions[i++] = &dri2LoaderExtension.base; - pdp->loader_extensions[i++] = &systemTimeExtension.base; - pdp->loader_extensions[i++] = &dri2UseInvalidate.base; + pdp->loader_extensions[i++] = &driBackgroundCallable.base; + pdp->loader_extensions[i++] = NULL; pdp->dri2Hash = __glxHashCreate();