/*
* Given a display pointer and screen number, determine the name of
- * the DRI driver for the screen. (I.e. "r128", "tdfx", etc).
+ * the DRI driver for the screen (i.e., "i965", "radeon", "nouveau", etc).
* Return True for success, False for failure.
*/
static Bool
drm_handle_t hFB;
int junk;
const __DRIconfig **driver_configs;
- struct glx_config *visual;
+ struct glx_config *visual, *configs = NULL, *visuals = NULL;
/* DRI protocol version. */
dri_version.major = driDpy->driMajor;
goto handle_error;
}
- /* Get device name (like "tdfx") and the ddx version numbers.
+ /* Get device name (like "radeon") and the ddx version numbers.
* We'll check the version in each DRI driver's "createNewScreen"
* function. */
if (!XF86DRIGetClientDriverName(dpy, scrn,
goto handle_error;
}
- psc->base.configs =
- driConvertConfigs(psc->core, psc->base.configs, driver_configs);
- psc->base.visuals =
- driConvertConfigs(psc->core, psc->base.visuals, driver_configs);
+ configs = driConvertConfigs(psc->core, psc->base.configs, driver_configs);
+ visuals = driConvertConfigs(psc->core, psc->base.visuals, driver_configs);
+
+ if (!configs || !visuals)
+ goto handle_error;
+
+ glx_config_destroy_list(psc->base.configs);
+ psc->base.configs = configs;
+ glx_config_destroy_list(psc->base.visuals);
+ psc->base.visuals = visuals;
psc->driver_configs = driver_configs;
return psp;
handle_error:
+ if (configs)
+ glx_config_destroy_list(configs);
+ if (visuals)
+ glx_config_destroy_list(visuals);
+
if (pSAREA != MAP_FAILED)
drmUnmap(pSAREA, SAREA_MAX);
struct dri_context *pcp = (struct dri_context *) context;
struct dri_screen *psc = (struct dri_screen *) context->psc;
- if (context->xid)
- glx_send_destroy_context(psc->base.dpy, context->xid);
+ driReleaseDrawables(&pcp->base);
if (context->extensions)
XFree((char *) context->extensions);
- GarbageCollectDRIDrawables(context->psc);
-
(*psc->core->destroyContext) (pcp->driContext);
XF86DRIDestroyContext(psc->base.dpy, psc->base.scr, pcp->hwContextID);
pdraw = (struct dri_drawable *) driFetchDrawable(context, draw);
pread = (struct dri_drawable *) driFetchDrawable(context, read);
+ driReleaseDrawables(&pcp->base);
+
if (pdraw == NULL || pread == NULL)
return GLXBadDrawable;
DRI_glXUseXFont,
NULL,
NULL,
+ NULL, /* get_proc_address */
};
static struct glx_context *
return NULL;
if (shareList) {
+ /* If the shareList context is not a DRI context, we cannot possibly
+ * create a DRI context that shares it.
+ */
+ if (shareList->vtable->destroy != dri_destroy_context) {
+ return NULL;
+ }
+
pcp_shared = (struct dri_context *) shareList;
shared = pcp_shared->driContext;
}
}
static const struct glx_screen_vtable dri_screen_vtable = {
- dri_create_context
+ dri_create_context,
+ NULL
};
static struct glx_screen *
return NULL;
memset(psc, 0, sizeof *psc);
- if (!glx_screen_init(&psc->base, screen, priv))
- return NULL;
-
- if (!driGetDriverName(priv->dpy, screen, &driverName)) {
+ if (!glx_screen_init(&psc->base, screen, priv)) {
Xfree(psc);
return NULL;
}
+ if (!driGetDriverName(priv->dpy, screen, &driverName)) {
+ goto cleanup;
+ }
+
psc->driver = driOpenDriver(driverName);
Xfree(driverName);
- if (psc->driver == NULL) {
- Xfree(psc);
- return NULL;
- }
+ if (psc->driver == NULL)
+ goto cleanup;
extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
if (extensions == NULL) {
ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
- Xfree(psc);
- return NULL;
+ goto cleanup;
}
for (i = 0; extensions[i]; i++) {
psc->legacy = (__DRIlegacyExtension *) extensions[i];
}
- if (psc->core == NULL || psc->legacy == NULL) {
- Xfree(psc);
- return NULL;
- }
+ if (psc->core == NULL || psc->legacy == NULL)
+ goto cleanup;
pdp = (struct dri_display *) priv->driDisplay;
psc->driScreen =
CallCreateNewScreen(psc->base.dpy, screen, psc, pdp);
- if (psc->driScreen == NULL) {
- dlclose(psc->driver);
- Xfree(psc);
- return NULL;
- }
+ if (psc->driScreen == NULL)
+ goto cleanup;
extensions = psc->core->getExtensions(psc->driScreen);
driBindExtensions(psc, extensions);
psp->getSwapInterval = driGetSwapInterval;
return &psc->base;
+
+cleanup:
+ CriticalErrorMessageF("failed to load driver: %s\n", driverName);
+
+ if (psc->driver)
+ dlclose(psc->driver);
+ glx_screen_cleanup(&psc->base);
+ Xfree(psc);
+
+ return NULL;
}
/* Called from __glXFreeDisplayPrivate.