__glxHashTable *dri2Hash;
- const __DRIextension *loader_extensions[4];
-};
-
-struct dri2_context
-{
- struct glx_context base;
- __DRIcontext *driContext;
+ const __DRIextension *loader_extensions[5];
};
struct dri2_drawable
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) {
*/
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 */
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;
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;
pcp->driContext =
(*psc->dri2->createContextAttribs) (psc->driScreen,
api,
- config->driConfig,
+ config ? config->driConfig : NULL,
shared,
num_ctx_attribs / 2,
ctx_attribs,
}
DRI2CreateDrawable(psc->base.dpy, xDrawable);
- pdp = (struct dri2_display *)dpyPriv->dri2Display;;
+ pdp = (struct dri2_display *)dpyPriv->dri2Display;
/* Create a new drawable */
pdraw->driDrawable =
(*psc->dri2->createNewDrawable) (psc->driScreen,
struct glx_context *gc = __glXGetCurrentContext();
struct dri2_context *dri2Ctx = (struct dri2_context *)gc;
- return dri2Ctx ? dri2Ctx->driContext : NULL;
+ return (gc != &dummyContext) ? dri2Ctx->driContext : NULL;
}
/**
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 },
.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)
{
.bind_tex_image = dri2_bind_tex_image,
.release_tex_image = dri2_release_tex_image,
.get_proc_address = NULL,
+ .interop_query_device_info = dri2_interop_query_device_info,
+ .interop_export_object = dri2_interop_export_object
};
static void
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");
psc->rendererQuery = (__DRI2rendererQueryExtension *) extensions[i];
__glXEnableDirectExtension(&psc->base, "GLX_MESA_query_renderer");
}
+
+ 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");
}
}
char *driverName = NULL, *loader_driverName, *deviceName, *tmp;
drm_magic_t magic;
int i;
+ unsigned char disable;
psc = calloc(1, sizeof *psc);
if (psc == NULL)
/* 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;
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;
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();