GLXscreenConfigs is badly named and a dumping ground for a lot of stuff.
This patch creates private screen structs for the dri drivers and moves
some of their fields over there.
const __DRIextension *loader_extensions[4];
};
+struct dri2_screen {
+ __GLXscreenConfigs base;
+
+ __GLXDRIscreen driScreen;
+ const __DRIdri2Extension *dri2;
+ const __DRIcoreExtension *core;
+ void *driver;
+ int fd;
+};
+
struct dri2_context
{
__GLXDRIcontext base;
};
static void
-dri2DestroyContext(__GLXDRIcontext * context,
- __GLXscreenConfigs * psc, Display * dpy)
+dri2DestroyContext(__GLXDRIcontext *context,
+ __GLXscreenConfigs *base, Display *dpy)
{
struct dri2_context *pcp = (struct dri2_context *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct dri2_screen *psc = (struct dri2_screen *) base;
- (*core->destroyContext) (pcp->driContext);
+ (*psc->core->destroyContext) (pcp->driContext);
Xfree(pcp);
}
static Bool
-dri2BindContext(__GLXDRIcontext * context,
- __GLXDRIdrawable * draw, __GLXDRIdrawable * read)
+dri2BindContext(__GLXDRIcontext *context,
+ __GLXDRIdrawable *draw, __GLXDRIdrawable *read)
{
struct dri2_context *pcp = (struct dri2_context *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct dri2_screen *psc = (struct dri2_screen *) pcp->psc;
- return (*core->bindContext) (pcp->driContext,
- draw->driDrawable, read->driDrawable);
+ return (*psc->core->bindContext) (pcp->driContext,
+ draw->driDrawable, read->driDrawable);
}
static void
-dri2UnbindContext(__GLXDRIcontext * context)
+dri2UnbindContext(__GLXDRIcontext *context)
{
struct dri2_context *pcp = (struct dri2_context *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct dri2_screen *psc = (struct dri2_screen *) pcp->psc;
- (*core->unbindContext) (pcp->driContext);
+ (*psc->core->unbindContext) (pcp->driContext);
}
static __GLXDRIcontext *
-dri2CreateContext(__GLXscreenConfigs * psc,
+dri2CreateContext(__GLXscreenConfigs *base,
const __GLcontextModes * mode,
GLXContext gc, GLXContext shareList, int renderType)
{
struct dri2_context *pcp, *pcp_shared;
+ struct dri2_screen *psc = (struct dri2_screen *) base;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
__DRIcontext *shared = NULL;
if (pcp == NULL)
return NULL;
- pcp->psc = psc;
+ pcp->psc = &psc->base;
pcp->driContext =
- (*psc->dri2->createNewContext) (psc->__driScreen,
+ (*psc->dri2->createNewContext) (psc->base.__driScreen,
config->driConfig, shared, pcp);
gc->__driContext = pcp->driContext;
static void
dri2DestroyDrawable(__GLXDRIdrawable *pdraw)
{
- const __DRIcoreExtension *core = pdraw->psc->core;
+ struct dri2_screen *psc = (struct dri2_screen *) pdraw->psc;
__GLXdisplayPrivate *dpyPriv;
struct dri2_display *pdp;
pdp = (struct dri2_display *)dpyPriv->dri2Display;
__glxHashDelete(pdp->dri2Hash, pdraw->xDrawable);
- (*core->destroyDrawable) (pdraw->driDrawable);
- DRI2DestroyDrawable(pdraw->psc->dpy, pdraw->xDrawable);
+ (*psc->core->destroyDrawable) (pdraw->driDrawable);
+ DRI2DestroyDrawable(psc->base.dpy, pdraw->xDrawable);
Xfree(pdraw);
}
static __GLXDRIdrawable *
-dri2CreateDrawable(__GLXscreenConfigs * psc,
- XID xDrawable,
- GLXDrawable drawable, const __GLcontextModes * modes)
+dri2CreateDrawable(__GLXscreenConfigs *base, XID xDrawable,
+ GLXDrawable drawable, const __GLcontextModes * modes)
{
struct dri2_drawable *pdraw;
+ struct dri2_screen *psc = (struct dri2_screen *) base;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
__GLXdisplayPrivate *dpyPriv;
struct dri2_display *pdp;
pdraw->base.destroyDrawable = dri2DestroyDrawable;
pdraw->base.xDrawable = xDrawable;
pdraw->base.drawable = drawable;
- pdraw->base.psc = psc;
+ pdraw->base.psc = &psc->base;
pdraw->bufferCount = 0;
pdraw->swap_interval = 1; /* default may be overridden below */
pdraw->have_back = 0;
- if (psc->config)
- psc->config->configQueryi(psc->__driScreen, "vblank_mode", &vblank_mode);
+ if (psc->base.config)
+ psc->base.config->configQueryi(psc->base.__driScreen,
+ "vblank_mode", &vblank_mode);
switch (vblank_mode) {
case DRI_CONF_VBLANK_NEVER:
break;
}
- DRI2CreateDrawable(psc->dpy, xDrawable);
+ DRI2CreateDrawable(psc->base.dpy, xDrawable);
- dpyPriv = __glXInitialize(psc->dpy);
+ dpyPriv = __glXInitialize(psc->base.dpy);
pdp = (struct dri2_display *)dpyPriv->dri2Display;;
/* Create a new drawable */
pdraw->base.driDrawable =
- (*psc->dri2->createNewDrawable) (psc->__driScreen,
+ (*psc->dri2->createNewDrawable) (psc->base.__driScreen,
config->driConfig, pdraw);
if (!pdraw->base.driDrawable) {
- DRI2DestroyDrawable(psc->dpy, xDrawable);
+ DRI2DestroyDrawable(psc->base.dpy, xDrawable);
Xfree(pdraw);
return NULL;
}
if (__glxHashInsert(pdp->dri2Hash, xDrawable, pdraw)) {
(*psc->core->destroyDrawable) (pdraw->base.driDrawable);
- DRI2DestroyDrawable(psc->dpy, xDrawable);
+ DRI2DestroyDrawable(psc->base.dpy, xDrawable);
Xfree(pdraw);
return None;
}
* drawable.
*/
if (pdp->swapAvailable)
- DRI2SwapInterval(psc->dpy, xDrawable, pdraw->swap_interval);
+ DRI2SwapInterval(psc->base.dpy, xDrawable, pdraw->swap_interval);
#endif
return &pdraw->base;
static void
-dri2DestroyScreen(__GLXscreenConfigs * psc)
+dri2DestroyScreen(__GLXscreenConfigs *base)
{
+ struct dri2_screen *psc = (struct dri2_screen *) base;
+
/* Free the direct rendering per screen data */
- (*psc->core->destroyScreen) (psc->__driScreen);
+ (*psc->core->destroyScreen) (psc->base.__driScreen);
close(psc->fd);
- psc->__driScreen = NULL;
+ base->__driScreen = NULL;
+ Xfree(psc);
}
/**
dri2_release_tex_image,
};
-static __GLXDRIscreen *
-dri2CreateScreen(__GLXscreenConfigs * psc, int screen,
- __GLXdisplayPrivate * priv)
+static __GLXscreenConfigs *
+dri2CreateScreen(int screen, __GLXdisplayPrivate * priv)
{
const __DRIconfig **driver_configs;
const __DRIextension **extensions;
const struct dri2_display *const pdp = (struct dri2_display *)
priv->dri2Display;
+ struct dri2_screen *psc;
__GLXDRIscreen *psp;
char *driverName, *deviceName;
drm_magic_t magic;
int i;
- psp = Xmalloc(sizeof *psp);
- if (psp == NULL)
+ psc = Xmalloc(sizeof *psc);
+ if (psc == NULL)
return NULL;
- if (!DRI2Connect(psc->dpy, RootWindow(psc->dpy, screen),
+ memset(psc, 0, sizeof *psc);
+ if (!glx_screen_init(&psc->base, screen, priv))
+ return NULL;
+
+ if (!DRI2Connect(priv->dpy, RootWindow(priv->dpy, screen),
&driverName, &deviceName)) {
- XFree(psp);
+ XFree(psc);
return NULL;
}
goto handle_error;
}
- if (!DRI2Authenticate(psc->dpy, RootWindow(psc->dpy, screen), magic)) {
+ if (!DRI2Authenticate(priv->dpy, RootWindow(priv->dpy, screen), magic)) {
ErrorMessageF("failed to authenticate magic %d\n", magic);
goto handle_error;
}
/* If the server does not support the protocol for
* DRI2GetBuffersWithFormat, don't supply that interface to the driver.
*/
- psc->__driScreen =
+ psc->base.__driScreen =
psc->dri2->createNewScreen(screen, psc->fd,
(const __DRIextension **)
&pdp->loader_extensions[0],
&driver_configs, psc);
- if (psc->__driScreen == NULL) {
+ if (psc->base.__driScreen == NULL) {
ErrorMessageF("failed to create dri screen\n");
goto handle_error;
}
- driBindCommonExtensions(psc);
- dri2BindExtensions(psc);
+ extensions = psc->core->getExtensions(psc->base.__driScreen);
+ driBindCommonExtensions(&psc->base, extensions);
+ dri2BindExtensions(&psc->base, extensions);
- psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
- psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+ psc->base.configs =
+ driConvertConfigs(psc->core, psc->base.configs, driver_configs);
+ psc->base.visuals =
+ driConvertConfigs(psc->core, psc->base.visuals, driver_configs);
- psc->driver_configs = driver_configs;
+ psc->base.driver_configs = driver_configs;
+ psp = &psc->driScreen;
+ psc->base.driScreen = psp;
psp->destroyScreen = dri2DestroyScreen;
psp->createContext = dri2CreateContext;
psp->createDrawable = dri2CreateDrawable;
psp->getSwapInterval = dri2GetSwapInterval;
#endif
#if defined(X_DRI2GetMSC) && defined(X_DRI2WaitMSC) && defined(X_DRI2SwapInterval)
- __glXEnableDirectExtension(psc, "GLX_OML_sync_control");
+ __glXEnableDirectExtension(&psc->base, "GLX_OML_sync_control");
#endif
}
/* DRI2 suports SubBuffer through DRI2CopyRegion, so it's always
* available.*/
psp->copySubBuffer = dri2CopySubBuffer;
- __glXEnableDirectExtension(psc, "GLX_MESA_copy_sub_buffer");
+ __glXEnableDirectExtension(&psc->base, "GLX_MESA_copy_sub_buffer");
- psc->direct_context_vtable = &dri2_context_vtable;
+ psc->base.direct_context_vtable = &dri2_context_vtable;
Xfree(driverName);
Xfree(deviceName);
- return psp;
+ return &psc->base;
handle_error:
Xfree(driverName);
Xfree(deviceName);
- XFree(psp);
+ XFree(psc);
/* FIXME: clean up here */
/* Bind DRI1 specific extensions */
_X_HIDDEN void
-driBindExtensions(__GLXscreenConfigs *psc)
+driBindExtensions(__GLXscreenConfigs *psc, const __DRIextension **extensions)
{
- const __DRIextension **extensions;
int i;
- extensions = psc->core->getExtensions(psc->__driScreen);
-
for (i = 0; extensions[i]; i++) {
#ifdef __DRI_SWAP_CONTROL
/* No DRI2 support for swap_control at the moment, since SwapBuffers
/* Bind DRI2 specific extensions */
_X_HIDDEN void
-dri2BindExtensions(__GLXscreenConfigs *psc)
+dri2BindExtensions(__GLXscreenConfigs *psc,
+ const __DRIextension **extensions)
{
- const __DRIextension **extensions;
int i;
- extensions = psc->core->getExtensions(psc->__driScreen);
-
for (i = 0; extensions[i]; i++) {
#ifdef __DRI_TEX_BUFFER
if ((strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) {
/* Bind extensions common to DRI1 and DRI2 */
_X_HIDDEN void
-driBindCommonExtensions(__GLXscreenConfigs *psc)
+driBindCommonExtensions(__GLXscreenConfigs *psc,
+ const __DRIextension **extensions)
{
- const __DRIextension **extensions;
int i;
- extensions = psc->core->getExtensions(psc->__driScreen);
-
for (i = 0; extensions[i]; i++) {
#ifdef __DRI_COPY_SUB_BUFFER
if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) {
extern void *driOpenDriver(const char *driverName);
-extern void driBindExtensions(__GLXscreenConfigs * psc);
-extern void dri2BindExtensions(__GLXscreenConfigs * psc);
-extern void driBindCommonExtensions(__GLXscreenConfigs * psc);
+extern void driBindExtensions(__GLXscreenConfigs * psc,
+ const __DRIextension **extensions);
+extern void dri2BindExtensions(__GLXscreenConfigs * psc,
+ const __DRIextension **extensions);
+extern void driBindCommonExtensions(__GLXscreenConfigs * psc,
+ const __DRIextension **extensions);
#endif /* _DRI_COMMON_H */
int driPatch;
};
+struct dri_screen
+{
+ __GLXscreenConfigs base;
+
+ __GLXDRIscreen driScreen;
+ const __DRIlegacyExtension *legacy;
+ const __DRIcoreExtension *core;
+ void *driver;
+ int fd;
+};
+
struct dri_context
{
__GLXDRIcontext base;
* the client-side driver on success, or \c NULL on failure.
*/
static void *
-CallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc,
+CallCreateNewScreen(Display *dpy, int scrn, struct dri_screen *psc,
struct dri_display * driDpy)
{
void *psp = NULL;
goto handle_error;
}
- psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
- psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+ psc->base.configs =
+ driConvertConfigs(psc->core, psc->base.configs, driver_configs);
+ psc->base.visuals =
+ driConvertConfigs(psc->core, psc->base.visuals, driver_configs);
- psc->driver_configs = driver_configs;
+ psc->base.driver_configs = driver_configs;
/* Visuals with depth != screen depth are subject to automatic compositing
* in the X server, so DRI1 can't render to them properly. Mark them as
* non-conformant to prevent apps from picking them up accidentally.
*/
- for (visual = psc->visuals; visual; visual = visual->next) {
+ for (visual = psc->base.visuals; visual; visual = visual->next) {
XVisualInfo template;
XVisualInfo *visuals;
int num_visuals;
static void
driDestroyContext(__GLXDRIcontext * context,
- __GLXscreenConfigs * psc, Display * dpy)
+ __GLXscreenConfigs *base, Display * dpy)
{
struct dri_context *pcp = (struct dri_context *) context;
+ struct dri_screen *psc = (struct dri_screen *) base;
(*psc->core->destroyContext) (pcp->driContext);
- XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID);
+ XF86DRIDestroyContext(psc->base.dpy, psc->base.scr, pcp->hwContextID);
Xfree(pcp);
}
static Bool
-driBindContext(__GLXDRIcontext * context,
- __GLXDRIdrawable * draw, __GLXDRIdrawable * read)
+driBindContext(__GLXDRIcontext *context,
+ __GLXDRIdrawable *draw, __GLXDRIdrawable *read)
{
struct dri_context *pcp = (struct dri_context *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct dri_screen *psc = (struct dri_screen *) pcp->psc;
- return (*core->bindContext) (pcp->driContext,
- draw->driDrawable, read->driDrawable);
+ return (*psc->core->bindContext) (pcp->driContext,
+ draw->driDrawable, read->driDrawable);
}
static void
driUnbindContext(__GLXDRIcontext * context)
{
struct dri_context *pcp = (struct dri_context *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct dri_screen *psc = (struct dri_screen *) pcp->psc;
- (*core->unbindContext) (pcp->driContext);
+ (*psc->core->unbindContext) (pcp->driContext);
}
static __GLXDRIcontext *
-driCreateContext(__GLXscreenConfigs * psc,
+driCreateContext(__GLXscreenConfigs *base,
const __GLcontextModes * mode,
GLXContext gc, GLXContext shareList, int renderType)
{
struct dri_context *pcp, *pcp_shared;
+ struct dri_screen *psc = (struct dri_screen *) base;
drm_context_t hwContext;
__DRIcontext *shared = NULL;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
- if (!psc || !psc->driScreen)
+ if (!psc->base.driScreen)
return NULL;
if (shareList) {
if (pcp == NULL)
return NULL;
- pcp->psc = psc;
- if (!XF86DRICreateContextWithConfig(psc->dpy, psc->scr,
+ pcp->psc = &psc->base;
+ if (!XF86DRICreateContextWithConfig(psc->base.dpy, psc->base.scr,
mode->visualID,
&pcp->hwContextID, &hwContext)) {
Xfree(pcp);
}
pcp->driContext =
- (*psc->legacy->createNewContext) (psc->__driScreen,
+ (*psc->legacy->createNewContext) (psc->base.__driScreen,
config->driConfig,
renderType, shared, hwContext, pcp);
if (pcp->driContext == NULL) {
- XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID);
+ XF86DRIDestroyContext(psc->base.dpy, psc->base.scr, pcp->hwContextID);
Xfree(pcp);
return NULL;
}
static void
driDestroyDrawable(__GLXDRIdrawable * pdraw)
{
- __GLXscreenConfigs *psc = pdraw->psc;
+ struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
(*psc->core->destroyDrawable) (pdraw->driDrawable);
- XF86DRIDestroyDrawable(psc->dpy, psc->scr, pdraw->drawable);
+ XF86DRIDestroyDrawable(psc->base.dpy, psc->base.scr, pdraw->drawable);
Xfree(pdraw);
}
static __GLXDRIdrawable *
-driCreateDrawable(__GLXscreenConfigs * psc,
+driCreateDrawable(__GLXscreenConfigs *base,
XID xDrawable,
GLXDrawable drawable, const __GLcontextModes * modes)
{
drm_drawable_t hwDrawable;
void *empty_attribute_list = NULL;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
+ struct dri_screen *psc = (struct dri_screen *) base;
/* Old dri can't handle GLX 1.3+ drawable constructors. */
if (xDrawable != drawable)
return NULL;
pdraw->drawable = drawable;
- pdraw->psc = psc;
+ pdraw->psc = &psc->base;
- if (!XF86DRICreateDrawable(psc->dpy, psc->scr, drawable, &hwDrawable)) {
+ if (!XF86DRICreateDrawable(psc->base.dpy, psc->base.scr,
+ drawable, &hwDrawable)) {
Xfree(pdraw);
return NULL;
}
/* Create a new drawable */
pdraw->driDrawable =
- (*psc->legacy->createNewDrawable) (psc->__driScreen,
+ (*psc->legacy->createNewDrawable) (psc->base.__driScreen,
config->driConfig,
hwDrawable,
GLX_WINDOW_BIT,
empty_attribute_list, pdraw);
if (!pdraw->driDrawable) {
- XF86DRIDestroyDrawable(psc->dpy, psc->scr, drawable);
+ XF86DRIDestroyDrawable(psc->base.dpy, psc->base.scr, drawable);
Xfree(pdraw);
return NULL;
}
driSwapBuffers(__GLXDRIdrawable * pdraw, int64_t unused1, int64_t unused2,
int64_t unused3)
{
- (*pdraw->psc->core->swapBuffers) (pdraw->driDrawable);
+ struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
+
+ (*psc->core->swapBuffers) (pdraw->driDrawable);
return 0;
}
}
static void
-driDestroyScreen(__GLXscreenConfigs * psc)
+driDestroyScreen(__GLXscreenConfigs *base)
{
+ struct dri_screen *psc = (struct dri_screen *) base;
+
/* Free the direct rendering per screen data */
- if (psc->__driScreen)
- (*psc->core->destroyScreen) (psc->__driScreen);
- psc->__driScreen = NULL;
+ if (psc->base.__driScreen)
+ (*psc->core->destroyScreen) (psc->base.__driScreen);
+ psc->base.__driScreen = NULL;
if (psc->driver)
dlclose(psc->driver);
}
NULL,
};
-static __GLXDRIscreen *
-driCreateScreen(__GLXscreenConfigs * psc, int screen,
- __GLXdisplayPrivate * priv)
+static __GLXscreenConfigs *
+driCreateScreen(int screen, __GLXdisplayPrivate *priv)
{
struct dri_display *pdp;
__GLXDRIscreen *psp;
const __DRIextension **extensions;
+ struct dri_screen *psc;
char *driverName;
int i;
- psp = Xcalloc(1, sizeof *psp);
- if (psp == NULL)
+ psc = Xcalloc(1, sizeof *psc);
+ if (psc == NULL)
return NULL;
+ memset(psc, 0, sizeof *psc);
+ if (!glx_screen_init(&psc->base, screen, priv))
+ return NULL;
+
if (!driGetDriverName(priv->dpy, screen, &driverName)) {
- Xfree(psp);
+ Xfree(psc);
return NULL;
}
psc->driver = driOpenDriver(driverName);
Xfree(driverName);
if (psc->driver == NULL) {
- Xfree(psp);
+ Xfree(psc);
return NULL;
}
extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
if (extensions == NULL) {
ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
- Xfree(psp);
+ Xfree(psc);
return NULL;
}
}
if (psc->core == NULL || psc->legacy == NULL) {
- Xfree(psp);
+ Xfree(psc);
return NULL;
}
pdp = (struct dri_display *) priv->driDisplay;
- psc->__driScreen = CallCreateNewScreen(psc->dpy, screen, psc, pdp);
- if (psc->__driScreen == NULL) {
+ psc->base.__driScreen =
+ CallCreateNewScreen(psc->base.dpy, screen, psc, pdp);
+ if (psc->base.__driScreen == NULL) {
dlclose(psc->driver);
- Xfree(psp);
+ Xfree(psc);
return NULL;
}
- driBindExtensions(psc);
- driBindCommonExtensions(psc);
+ extensions = psc->core->getExtensions(psc->base.__driScreen);
+ driBindExtensions(&psc->base, extensions);
+ driBindCommonExtensions(&psc->base, extensions);
- if (psc->driCopySubBuffer)
+ psp = &psc->driScreen;
+ psc->base.driScreen = psp;
+ if (psc->base.driCopySubBuffer)
psp->copySubBuffer = driCopySubBuffer;
psp->destroyScreen = driDestroyScreen;
psp->waitX = NULL;
psp->waitGL = NULL;
- psc->direct_context_vtable = &dri_context_vtable;
+ psc->base.direct_context_vtable = &dri_context_vtable;
- return psp;
+ return &psc->base;
}
/* Called from __glXFreeDisplayPrivate.
__GLXscreenConfigs *psc;
};
+struct drisw_screen
+{
+ __GLXscreenConfigs base;
+
+ __GLXDRIscreen driScreen;
+ const __DRIcoreExtension *core;
+ const __DRIswrastExtension *swrast;
+ void *driver;
+};
+
struct drisw_drawable
{
__GLXDRIdrawable base;
*/
static void
-driDestroyContext(__GLXDRIcontext * context,
- __GLXscreenConfigs * psc, Display * dpy)
+driDestroyContext(__GLXDRIcontext *context,
+ __GLXscreenConfigs *base, Display *dpy)
{
struct drisw_context *pcp = (struct drisw_context *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct drisw_screen *psc = (struct drisw_screen *) base;
- (*core->destroyContext) (pcp->driContext);
+ (*psc->core->destroyContext) (pcp->driContext);
Xfree(pcp);
}
static Bool
driBindContext(__GLXDRIcontext * context,
- __GLXDRIdrawable * draw, __GLXDRIdrawable * read)
+ __GLXDRIdrawable * draw, __GLXDRIdrawable * read)
{
struct drisw_context *pcp = (struct drisw_context *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct drisw_screen *psc = (struct drisw_screen *) pcp->psc;
- return (*core->bindContext) (pcp->driContext,
- draw->driDrawable, read->driDrawable);
+ return (*psc->core->bindContext) (pcp->driContext,
+ draw->driDrawable, read->driDrawable);
}
static void
driUnbindContext(__GLXDRIcontext * context)
{
struct drisw_context *pcp = (struct drisw_context *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct drisw_screen *psc = (struct drisw_screen *) pcp->psc;
- (*core->unbindContext) (pcp->driContext);
+ (*psc->core->unbindContext) (pcp->driContext);
}
static __GLXDRIcontext *
-driCreateContext(__GLXscreenConfigs * psc,
- const __GLcontextModes * mode,
- GLXContext gc, GLXContext shareList, int renderType)
+driCreateContext(__GLXscreenConfigs *base,
+ const __GLcontextModes *mode,
+ GLXContext gc, GLXContext shareList, int renderType)
{
struct drisw_context *pcp, *pcp_shared;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
- const __DRIcoreExtension *core;
+ struct drisw_screen *psc = (struct drisw_screen *) base;
__DRIcontext *shared = NULL;
- if (!psc || !psc->driScreen)
+ if (!psc->base.driScreen)
return NULL;
- core = psc->core;
-
if (shareList) {
pcp_shared = (struct drisw_context *) shareList->driContext;
shared = pcp_shared->driContext;
if (pcp == NULL)
return NULL;
- pcp->psc = psc;
+ pcp->psc = &psc->base;
pcp->driContext =
- (*core->createNewContext) (psc->__driScreen,
- config->driConfig, shared, pcp);
+ (*psc->core->createNewContext) (psc->base.__driScreen,
+ config->driConfig, shared, pcp);
if (pcp->driContext == NULL) {
Xfree(pcp);
return NULL;
driDestroyDrawable(__GLXDRIdrawable * pdraw)
{
struct drisw_drawable *pdp = (struct drisw_drawable *) pdraw;
- const __DRIcoreExtension *core = pdraw->psc->core;
+ struct drisw_screen *psc = (struct drisw_screen *) pdp->base.psc;
- (*core->destroyDrawable) (pdraw->driDrawable);
+ (*psc->core->destroyDrawable) (pdraw->driDrawable);
XDestroyDrawable(pdp, pdraw->psc->dpy, pdraw->drawable);
Xfree(pdp);
}
static __GLXDRIdrawable *
-driCreateDrawable(__GLXscreenConfigs * psc,
- XID xDrawable,
- GLXDrawable drawable, const __GLcontextModes * modes)
+driCreateDrawable(__GLXscreenConfigs *base, XID xDrawable,
+ GLXDrawable drawable, const __GLcontextModes * modes)
{
__GLXDRIdrawable *pdraw;
struct drisw_drawable *pdp;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
+ struct drisw_screen *psc = (struct drisw_screen *) base;
+
const __DRIswrastExtension *swrast = psc->swrast;
/* Old dri can't handle GLX 1.3+ drawable constructors. */
pdraw = &(pdp->base);
pdraw->xDrawable = xDrawable;
pdraw->drawable = drawable;
- pdraw->psc = psc;
+ pdraw->psc = &psc->base;
- XCreateDrawable(pdp, psc->dpy, xDrawable, modes->visualID);
+ XCreateDrawable(pdp, psc->base.dpy, xDrawable, modes->visualID);
/* Create a new drawable */
pdraw->driDrawable =
- (*swrast->createNewDrawable) (psc->__driScreen, config->driConfig, pdp);
+ (*swrast->createNewDrawable) (psc->base.__driScreen,
+ config->driConfig, pdp);
if (!pdraw->driDrawable) {
- XDestroyDrawable(pdp, psc->dpy, xDrawable);
+ XDestroyDrawable(pdp, psc->base.dpy, xDrawable);
Xfree(pdp);
return NULL;
}
driSwapBuffers(__GLXDRIdrawable * pdraw,
int64_t target_msc, int64_t divisor, int64_t remainder)
{
+ struct drisw_drawable *pdp = (struct drisw_drawable *) pdraw;
+ struct drisw_screen *psc = (struct drisw_screen *) pdp->base.psc;
+
(void) target_msc;
(void) divisor;
(void) remainder;
- (*pdraw->psc->core->swapBuffers) (pdraw->driDrawable);
+ (*psc->core->swapBuffers) (pdraw->driDrawable);
return 0;
}
static void
-driDestroyScreen(__GLXscreenConfigs * psc)
+driDestroyScreen(__GLXscreenConfigs *base)
{
+ struct drisw_screen *psc = (struct drisw_screen *) base;
+
/* Free the direct rendering per screen data */
- (*psc->core->destroyScreen) (psc->__driScreen);
- psc->__driScreen = NULL;
+ (*psc->core->destroyScreen) (psc->base.__driScreen);
+ psc->base.__driScreen = NULL;
if (psc->driver)
dlclose(psc->driver);
}
return driver;
}
-static __GLXDRIscreen *
-driCreateScreen(__GLXscreenConfigs * psc, int screen,
- __GLXdisplayPrivate * priv)
+static __GLXscreenConfigs *
+driCreateScreen(int screen, __GLXdisplayPrivate *priv)
{
__GLXDRIscreen *psp;
const __DRIconfig **driver_configs;
const __DRIextension **extensions;
+ struct drisw_screen *psc;
int i;
- psp = Xcalloc(1, sizeof *psp);
- if (psp == NULL)
+ psc = Xcalloc(1, sizeof *psc);
+ if (psc == NULL)
return NULL;
+ memset(psc, 0, sizeof *psc);
+ if (!glx_screen_init(&psc->base, screen, priv))
+ return NULL;
+
psc->driver = driOpenSwrast();
if (psc->driver == NULL)
goto handle_error;
for (i = 0; extensions[i]; i++) {
if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
- psc->core = (__DRIcoreExtension *) extensions[i];
+ psc->core = (__DRIcoreExtension *) extensions[i];
if (strcmp(extensions[i]->name, __DRI_SWRAST) == 0)
- psc->swrast = (__DRIswrastExtension *) extensions[i];
+ psc->swrast = (__DRIswrastExtension *) extensions[i];
}
if (psc->core == NULL || psc->swrast == NULL) {
goto handle_error;
}
- psc->__driScreen =
- psc->swrast->createNewScreen(screen,
- loader_extensions, &driver_configs, psc);
- if (psc->__driScreen == NULL) {
+ psc->base.__driScreen =
+ psc->swrast->createNewScreen(screen, loader_extensions,
+ &driver_configs, psc);
+ if (psc->base.__driScreen == NULL) {
ErrorMessageF("failed to create dri screen\n");
goto handle_error;
}
- driBindExtensions(psc);
- driBindCommonExtensions(psc);
+ extensions = psc->core->getExtensions(psc->base.__driScreen);
+ driBindExtensions(&psc->base, extensions);
+ driBindCommonExtensions(&psc->base, extensions);
- psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
- psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+ psc->base.configs =
+ driConvertConfigs(psc->core, psc->base.configs, driver_configs);
+ psc->base.visuals =
+ driConvertConfigs(psc->core, psc->base.visuals, driver_configs);
- psc->driver_configs = driver_configs;
+ psc->base.driver_configs = driver_configs;
+ psp = &psc->driScreen;
+ psc->base.driScreen = psp;
psp->destroyScreen = driDestroyScreen;
psp->createContext = driCreateContext;
psp->createDrawable = driCreateDrawable;
psp->waitX = NULL;
psp->waitGL = NULL;
- return psp;
+ return &psc->base;
handle_error:
- Xfree(psp);
+ Xfree(psc);
if (psc->driver)
dlclose(psc->driver);
__GLXDRIdrawable *pdraw;
__GLXscreenConfigs *psc;
- psc = &priv->screenConfigs[fbconfig->screen];
+ psc = priv->screenConfigs[fbconfig->screen];
if (psc->driScreen == NULL)
return;
int screen;
__GLXdisplayPrivate *const priv = __glXInitialize(dpy);
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
- __GLXscreenConfigs *psc = &priv->screenConfigs[screen];
+ __GLXscreenConfigs *psc = priv->screenConfigs[screen];
if (pdraw != NULL) {
if (destroy_xdrawable)
*/
void (*destroyDisplay) (__GLXDRIdisplay * display);
- __GLXDRIscreen *(*createScreen) (__GLXscreenConfigs * psc, int screen,
- __GLXdisplayPrivate * priv);
+ __GLXscreenConfigs *(*createScreen)(int screen, __GLXdisplayPrivate * priv);
};
struct __GLXDRIscreenRec {
* Per screen direct rendering interface functions and data.
*/
__DRIscreen *__driScreen;
- const __DRIcoreExtension *core;
- const __DRIlegacyExtension *legacy;
- const __DRIswrastExtension *swrast;
- const __DRIdri2Extension *dri2;
__glxHashTable *drawHash;
Display *dpy;
- int scr, fd;
- void *driver;
+ int scr;
__GLXDRIscreen *driScreen;
* Also, per screen data which now includes the server \c GLX_EXTENSION
* string.
*/
- __GLXscreenConfigs *screenConfigs;
+ __GLXscreenConfigs **screenConfigs;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
/**
#endif
};
+extern int
+glx_screen_init(__GLXscreenConfigs *psc,
+ int screen, __GLXdisplayPrivate * priv);
+
extern __GLXDRIdrawable *
dri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id);
return NULL;
for (i = 0; i < screen_count; i++) {
- psc = &priv->screenConfigs[i];
+ psc = priv->screenConfigs[i];
if (psc->drawHash == NULL)
continue;
return (priv
&& priv->screenConfigs !=
- NULL) ? &priv->screenConfigs[scrn] : NULL;
+ NULL) ? priv->screenConfigs[scrn] : NULL;
}
}
/* Check to see if the GL is supported on this screen */
- *ppsc = &((*ppriv)->screenConfigs[scrn]);
+ *ppsc = (*ppriv)->screenConfigs[scrn];
if ((*ppsc)->configs == NULL) {
/* No support for GL on this screen regardless of visual */
return GLX_BAD_VISUAL;
if (priv != NULL) {
for (i = 0; i < num_screens; i++) {
- for (modes = priv->screenConfigs[i].configs; modes != NULL;
+ for (modes = priv->screenConfigs[i]->configs; modes != NULL;
modes = modes->next) {
if (modes == (__GLcontextModes *) config) {
return (__GLcontextModes *) config;
__GLXscreenConfigs *psc;
__GLcontextModes *modes;
- psc = &priv->screenConfigs[vis->screen];
+ psc = priv->screenConfigs[vis->screen];
if (psc->driScreen == NULL)
break;
modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
int screen;
__GLXdisplayPrivate *const priv = __glXInitialize(dpy);
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, glxpixmap, &screen);
- __GLXscreenConfigs *psc = &priv->screenConfigs[screen];
+ __GLXscreenConfigs *psc = priv->screenConfigs[screen];
if (pdraw != NULL) {
(*pdraw->destroyDrawable) (pdraw);
*nelements = 0;
if (priv && (priv->screenConfigs != NULL)
&& (screen >= 0) && (screen <= ScreenCount(dpy))
- && (priv->screenConfigs[screen].configs != NULL)
- && (priv->screenConfigs[screen].configs->fbconfigID
+ && (priv->screenConfigs[screen]->configs != NULL)
+ && (priv->screenConfigs[screen]->configs->fbconfigID
!= (int) GLX_DONT_CARE)) {
unsigned num_configs = 0;
__GLcontextModes *modes;
- for (modes = priv->screenConfigs[screen].configs; modes != NULL;
+ for (modes = priv->screenConfigs[screen]->configs; modes != NULL;
modes = modes->next) {
if (modes->fbconfigID != (int) GLX_DONT_CARE) {
num_configs++;
if (config != NULL) {
*nelements = num_configs;
i = 0;
- for (modes = priv->screenConfigs[screen].configs; modes != NULL;
+ for (modes = priv->screenConfigs[screen]->configs; modes != NULL;
modes = modes->next) {
if (modes->fbconfigID != (int) GLX_DONT_CARE) {
config[i] = modes;
#ifdef GLX_DIRECT_RENDERING
pdraw = GetGLXDRIDrawable(dpy, drawable, &i);
#endif
- psc = &priv->screenConfigs[i];
+ psc = priv->screenConfigs[i];
#if defined(__DRI_SWAP_BUFFER_COUNTER) && defined(__DRI_MEDIA_STREAM_COUNTER)
if (pdraw && psc->sbc && psc->msc)
if (priv == NULL)
return NULL;
- psc = &priv->screenConfigs[gc->screen];
+ psc = priv->screenConfigs[gc->screen];
if (psc->drawHash == NULL)
return NULL;
GLint i, screens;
/* Free screen configuration information */
- psc = priv->screenConfigs;
screens = ScreenCount(priv->dpy);
- for (i = 0; i < screens; i++, psc++) {
+ for (i = 0; i < screens; i++) {
+ psc = priv->screenConfigs[i];
if (psc->configs) {
_gl_context_modes_destroy(psc->configs);
if (psc->effectiveGLXexts)
psc->driver_configs = NULL;
}
if (psc->driScreen) {
- psc->driScreen->destroyScreen(psc);
__glxHashDestroy(psc->drawHash);
- XFree(psc->driScreen);
+ psc->driScreen->destroyScreen(psc);
psc->driScreen = NULL;
+ } else {
+ Xfree(psc);
}
+#else
+ Xfree(psc);
#endif
}
XFree((char *) priv->screenConfigs);
}
static GLboolean
-getVisualConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen)
+getVisualConfigs(__GLXscreenConfigs *psc,
+ __GLXdisplayPrivate *priv, int screen)
{
xGLXGetVisualConfigsReq *req;
- __GLXscreenConfigs *psc;
xGLXGetVisualConfigsReply reply;
+ Display *dpy = priv->dpy;
LockDisplay(dpy);
- psc = priv->screenConfigs + screen;
psc->visuals = NULL;
GetReq(GLXGetVisualConfigs, req);
req->reqType = priv->majorOpcode;
}
static GLboolean
-getFBConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen)
+getFBConfigs(__GLXscreenConfigs *psc, __GLXdisplayPrivate *priv, int screen)
{
xGLXGetFBConfigsReq *fb_req;
xGLXGetFBConfigsSGIXReq *sgi_req;
xGLXVendorPrivateWithReplyReq *vpreq;
xGLXGetFBConfigsReply reply;
- __GLXscreenConfigs *psc;
+ Display *dpy = priv->dpy;
- psc = priv->screenConfigs + screen;
psc->serverGLXexts =
__glXQueryServerString(dpy, priv->majorOpcode, screen, GLX_EXTENSIONS);
return psc->configs != NULL;
}
+_X_HIDDEN Bool
+glx_screen_init(__GLXscreenConfigs *psc,
+ int screen, __GLXdisplayPrivate * priv)
+{
+ /* Initialize per screen dynamic client GLX extensions */
+ psc->ext_list_first_time = GL_TRUE;
+ psc->scr = screen;
+ psc->dpy = priv->dpy;
+ psc->drawHash = __glxHashCreate();
+ if (psc->drawHash == NULL)
+ return GL_FALSE;
+
+ getVisualConfigs(psc, priv, screen);
+ getFBConfigs(psc, priv, screen);
+
+ return GL_TRUE;
+}
+
+static __GLXscreenConfigs *
+createIndirectScreen()
+{
+ __GLXscreenConfigs *psc;
+
+ psc = Xmalloc(sizeof *psc);
+ memset(psc, 0, sizeof *psc);
+
+ return psc;
+}
+
/*
** Allocate the memory for the per screen configs for each screen.
** If that works then fetch the per screen configs data.
** First allocate memory for the array of per screen configs.
*/
screens = ScreenCount(dpy);
- psc = (__GLXscreenConfigs *) Xmalloc(screens * sizeof(__GLXscreenConfigs));
- if (!psc) {
+ priv->screenConfigs = Xmalloc(screens * sizeof *priv->screenConfigs);
+ if (!priv->screenConfigs)
return GL_FALSE;
- }
- memset(psc, 0, screens * sizeof(__GLXscreenConfigs));
- priv->screenConfigs = psc;
priv->serverGLXversion =
__glXQueryServerString(dpy, priv->majorOpcode, 0, GLX_VERSION);
}
for (i = 0; i < screens; i++, psc++) {
- getVisualConfigs(dpy, priv, i);
- getFBConfigs(dpy, priv, i);
-
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- psc->scr = i;
- psc->dpy = dpy;
- psc->drawHash = __glxHashCreate();
- if (psc->drawHash == NULL)
- continue;
-
- /* Initialize per screen dynamic client GLX extensions */
- psc->ext_list_first_time = GL_TRUE;
-
if (priv->dri2Display)
- psc->driScreen = (*priv->dri2Display->createScreen) (psc, i, priv);
-
- if (psc->driScreen == NULL && priv->driDisplay)
- psc->driScreen = (*priv->driDisplay->createScreen) (psc, i, priv);
-
- if (psc->driScreen == NULL && priv->driswDisplay)
- psc->driScreen = (*priv->driswDisplay->createScreen) (psc, i, priv);
-
- if (psc->driScreen == NULL) {
+ psc = (*priv->dri2Display->createScreen) (i, priv);
+ if (psc == NULL && priv->driDisplay)
+ psc = (*priv->driDisplay->createScreen) (i, priv);
+ if (psc == NULL && priv->driswDisplay)
+ psc = (*priv->driswDisplay->createScreen) (i, priv);
+ if (psc == NULL)
+ psc = createIndirectScreen (i, priv);
+
+ if (psc == NULL) {
__glxHashDestroy(psc->drawHash);
psc->drawHash = NULL;
}
#endif
+ priv->screenConfigs[i] = psc;
}
SyncHandle();
return GL_TRUE;