diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index c000139a74f..1c41f89454f 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -99,24 +99,22 @@ merge_counter(uint32_t hi, uint32_t lo) static void dri2_destroy_context(struct glx_context *context) { - struct dri2_context *pcp = (struct dri2_context *) context; struct dri2_screen *psc = (struct dri2_screen *) context->psc; - driReleaseDrawables(&pcp->base); + driReleaseDrawables(context); free((char *) context->extensions); - (*psc->core->destroyContext) (pcp->driContext); + (*psc->core->destroyContext) (context->driContext); - free(pcp); + free(context); } static Bool dri2_bind_context(struct glx_context *context, struct glx_context *old, GLXDrawable draw, GLXDrawable read) { - struct dri2_context *pcp = (struct dri2_context *) context; - struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc; + struct dri2_screen *psc = (struct dri2_screen *) context->psc; struct dri2_drawable *pdraw, *pread; __DRIdrawable *dri_draw = NULL, *dri_read = NULL; @@ -135,7 +133,7 @@ dri2_bind_context(struct glx_context *context, struct glx_context *old, else if (read != None) return GLXBadDrawable; - if (!(*psc->core->bindContext) (pcp->driContext, dri_draw, dri_read)) + if (!(*psc->core->bindContext) (context->driContext, dri_draw, dri_read)) return GLXBadContext; return Success; @@ -144,10 +142,9 @@ dri2_bind_context(struct glx_context *context, struct glx_context *old, static void dri2_unbind_context(struct glx_context *context, struct glx_context *new) { - struct dri2_context *pcp = (struct dri2_context *) context; - struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc; + struct dri2_screen *psc = (struct dri2_screen *) context->psc; - (*psc->core->unbindContext) (pcp->driContext); + (*psc->core->unbindContext) (context->driContext); } static struct glx_context * @@ -158,8 +155,7 @@ dri2_create_context_attribs(struct glx_screen *base, const uint32_t *attribs, unsigned *error) { - struct dri2_context *pcp = NULL; - struct dri2_context *pcp_shared = NULL; + struct glx_context *pcp = NULL; struct dri2_screen *psc = (struct dri2_screen *) base; __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base; __DRIcontext *shared = NULL; @@ -192,8 +188,7 @@ dri2_create_context_attribs(struct glx_screen *base, return NULL; } - pcp_shared = (struct dri2_context *) shareList; - shared = pcp_shared->driContext; + shared = shareList->driContext; } pcp = calloc(1, sizeof *pcp); @@ -202,7 +197,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, &psc->base, config_base)) goto error_exit; ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MAJOR_VERSION; @@ -227,7 +222,7 @@ dri2_create_context_attribs(struct glx_screen *base, if (dca.no_error) { ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_NO_ERROR; ctx_attribs[num_ctx_attribs++] = dca.no_error; - pcp->base.noError = GL_TRUE; + pcp->noError = GL_TRUE; } if (dca.flags != 0) { @@ -238,7 +233,7 @@ dri2_create_context_attribs(struct glx_screen *base, /* The renderType is retrieved from attribs, or set to default * of GLX_RGBA_TYPE. */ - pcp->base.renderType = dca.render_type; + pcp->renderType = dca.render_type; pcp->driContext = (*psc->dri2->createContextAttribs) (psc->driScreen, @@ -253,9 +248,9 @@ dri2_create_context_attribs(struct glx_screen *base, if (pcp->driContext == NULL) goto error_exit; - pcp->base.vtable = base->context_vtable; + pcp->vtable = base->context_vtable; - return &pcp->base; + return pcp; error_exit: free(pcp); @@ -428,9 +423,8 @@ static __DRIcontext * dri2GetCurrentContext() { struct glx_context *gc = __glXGetCurrentContext(); - struct dri2_context *dri2Ctx = (struct dri2_context *)gc; - return (gc != &dummyContext) ? dri2Ctx->driContext : NULL; + return (gc != &dummyContext) ? gc->driContext : NULL; } /** @@ -832,20 +826,19 @@ dri2GetSwapInterval(__GLXDRIdrawable *pdraw) static void driSetBackgroundContext(void *loaderPrivate) { - struct dri2_context *pcp = (struct dri2_context *) loaderPrivate; - __glXSetCurrentContext(&pcp->base); + __glXSetCurrentContext(loaderPrivate); } static GLboolean driIsThreadSafe(void *loaderPrivate) { - struct dri2_context *pcp = (struct dri2_context *) loaderPrivate; + struct glx_context *pcp = (struct glx_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; + return pcp->psc->dpy->lock_fns != NULL; } static const __DRIdri2LoaderExtension dri2LoaderExtension = { @@ -889,7 +882,6 @@ dri2_bind_tex_image(__GLXDRIdrawable *base, int buffer, const int *attrib_list) { struct glx_context *gc = __glXGetCurrentContext(); - struct dri2_context *pcp = (struct dri2_context *) gc; struct dri2_drawable *pdraw = (struct dri2_drawable *) base; struct dri2_screen *psc; @@ -898,13 +890,13 @@ dri2_bind_tex_image(__GLXDRIdrawable *base, if (psc->texBuffer->base.version >= 2 && psc->texBuffer->setTexBuffer2 != NULL) { - (*psc->texBuffer->setTexBuffer2) (pcp->driContext, + (*psc->texBuffer->setTexBuffer2) (gc->driContext, pdraw->base.textureTarget, pdraw->base.textureFormat, pdraw->driDrawable); } else { - (*psc->texBuffer->setTexBuffer) (pcp->driContext, + (*psc->texBuffer->setTexBuffer) (gc->driContext, pdraw->base.textureTarget, pdraw->driDrawable); } @@ -915,7 +907,6 @@ static void dri2_release_tex_image(__GLXDRIdrawable *base, int buffer) { struct glx_context *gc = __glXGetCurrentContext(); - struct dri2_context *pcp = (struct dri2_context *) gc; struct dri2_drawable *pdraw = (struct dri2_drawable *) base; struct dri2_screen *psc; @@ -924,7 +915,7 @@ dri2_release_tex_image(__GLXDRIdrawable *base, int buffer) if (psc->texBuffer->base.version >= 3 && psc->texBuffer->releaseTexBuffer != NULL) { - (*psc->texBuffer->releaseTexBuffer) (pcp->driContext, + (*psc->texBuffer->releaseTexBuffer) (gc->driContext, pdraw->base.textureTarget, pdraw->driDrawable); } diff --git a/src/glx/dri2_priv.h b/src/glx/dri2_priv.h index 8f3f980bc1f..bea1ac0c9c1 100644 --- a/src/glx/dri2_priv.h +++ b/src/glx/dri2_priv.h @@ -60,12 +60,6 @@ struct dri2_screen { int show_fps_interval; }; -struct dri2_context -{ - struct glx_context base; - __DRIcontext *driContext; -}; - _X_HIDDEN int dri2_query_renderer_integer(struct glx_screen *base, int attribute, unsigned int *value); diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c index ecfcdee1816..a8c20ce14bb 100644 --- a/src/glx/dri3_glx.c +++ b/src/glx/dri3_glx.c @@ -102,27 +102,25 @@ glx_dri3_in_current_context(struct loader_dri3_drawable *draw) if (!priv) return false; - struct dri3_context *pcp = (struct dri3_context *) __glXGetCurrentContext(); + struct glx_context *pcp = __glXGetCurrentContext(); struct dri3_screen *psc = (struct dri3_screen *) priv->base.psc; - return (&pcp->base != &dummyContext) && pcp->base.psc == &psc->base; + return (pcp != &dummyContext) && pcp->psc == &psc->base; } static __DRIcontext * glx_dri3_get_dri_context(struct loader_dri3_drawable *draw) { struct glx_context *gc = __glXGetCurrentContext(); - struct dri3_context *dri3Ctx = (struct dri3_context *) gc; - return (gc != &dummyContext) ? dri3Ctx->driContext : NULL; + return (gc != &dummyContext) ? gc->driContext : NULL; } static __DRIscreen * glx_dri3_get_dri_screen(void) { struct glx_context *gc = __glXGetCurrentContext(); - struct dri3_context *pcp = (struct dri3_context *) gc; - struct dri3_screen *psc = (struct dri3_screen *) pcp->base.psc; + struct dri3_screen *psc = (struct dri3_screen *) gc->psc; return (gc != &dummyContext && psc) ? psc->driScreen : NULL; } @@ -172,24 +170,22 @@ static const struct glx_context_vtable dri3_context_vtable; static void dri3_destroy_context(struct glx_context *context) { - struct dri3_context *pcp = (struct dri3_context *) context; struct dri3_screen *psc = (struct dri3_screen *) context->psc; - driReleaseDrawables(&pcp->base); + driReleaseDrawables(context); free((char *) context->extensions); - (*psc->core->destroyContext) (pcp->driContext); + (*psc->core->destroyContext) (context->driContext); - free(pcp); + free(context); } static Bool dri3_bind_context(struct glx_context *context, struct glx_context *old, GLXDrawable draw, GLXDrawable read) { - struct dri3_context *pcp = (struct dri3_context *) context; - struct dri3_screen *psc = (struct dri3_screen *) pcp->base.psc; + struct dri3_screen *psc = (struct dri3_screen *) context->psc; struct dri3_drawable *pdraw, *pread; __DRIdrawable *dri_draw = NULL, *dri_read = NULL; @@ -208,7 +204,7 @@ dri3_bind_context(struct glx_context *context, struct glx_context *old, else if (read != None) return GLXBadDrawable; - if (!(*psc->core->bindContext) (pcp->driContext, dri_draw, dri_read)) + if (!(*psc->core->bindContext) (context->driContext, dri_draw, dri_read)) return GLXBadContext; if (dri_draw) @@ -222,10 +218,9 @@ dri3_bind_context(struct glx_context *context, struct glx_context *old, static void dri3_unbind_context(struct glx_context *context, struct glx_context *new) { - struct dri3_context *pcp = (struct dri3_context *) context; - struct dri3_screen *psc = (struct dri3_screen *) pcp->base.psc; + struct dri3_screen *psc = (struct dri3_screen *) context->psc; - (*psc->core->unbindContext) (pcp->driContext); + (*psc->core->unbindContext) (context->driContext); } static struct glx_context * @@ -236,8 +231,7 @@ dri3_create_context_attribs(struct glx_screen *base, const uint32_t *attribs, unsigned *error) { - struct dri3_context *pcp = NULL; - struct dri3_context *pcp_shared = NULL; + struct glx_context *pcp = NULL; struct dri3_screen *psc = (struct dri3_screen *) base; __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base; __DRIcontext *shared = NULL; @@ -270,8 +264,7 @@ dri3_create_context_attribs(struct glx_screen *base, return NULL; } - pcp_shared = (struct dri3_context *) shareList; - shared = pcp_shared->driContext; + shared = shareList->driContext; } pcp = calloc(1, sizeof *pcp); @@ -280,7 +273,7 @@ dri3_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, &psc->base, config_base)) goto error_exit; ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MAJOR_VERSION; @@ -305,7 +298,7 @@ dri3_create_context_attribs(struct glx_screen *base, if (dca.no_error) { ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_NO_ERROR; ctx_attribs[num_ctx_attribs++] = dca.no_error; - pcp->base.noError = GL_TRUE; + pcp->noError = GL_TRUE; } if (dca.flags != 0) { @@ -313,7 +306,7 @@ dri3_create_context_attribs(struct glx_screen *base, ctx_attribs[num_ctx_attribs++] = dca.flags; } - pcp->base.renderType = dca.render_type; + pcp->renderType = dca.render_type; pcp->driContext = (*psc->image_driver->createContextAttribs) (psc->driScreen, @@ -329,9 +322,9 @@ dri3_create_context_attribs(struct glx_screen *base, if (pcp->driContext == NULL) goto error_exit; - pcp->base.vtable = base->context_vtable; + pcp->vtable = base->context_vtable; - return &pcp->base; + return pcp; error_exit: free(pcp); @@ -547,8 +540,7 @@ dri3_flush_swap_buffers(__DRIdrawable *driDrawable, void *loaderPrivate) static void dri_set_background_context(void *loaderPrivate) { - struct dri3_context *pcp = (struct dri3_context *)loaderPrivate; - __glXSetCurrentContext(&pcp->base); + __glXSetCurrentContext(loaderPrivate); } static GLboolean @@ -676,7 +668,6 @@ dri3_bind_tex_image(__GLXDRIdrawable *base, int buffer, const int *attrib_list) { struct glx_context *gc = __glXGetCurrentContext(); - struct dri3_context *pcp = (struct dri3_context *) gc; struct dri3_drawable *pdraw = (struct dri3_drawable *) base; struct dri3_screen *psc; @@ -687,7 +678,7 @@ dri3_bind_tex_image(__GLXDRIdrawable *base, XSync(gc->currentDpy, false); - (*psc->texBuffer->setTexBuffer2) (pcp->driContext, + (*psc->texBuffer->setTexBuffer2) (gc->driContext, pdraw->base.textureTarget, pdraw->base.textureFormat, pdraw->loader_drawable.dri_drawable); @@ -698,7 +689,6 @@ static void dri3_release_tex_image(__GLXDRIdrawable *base, int buffer) { struct glx_context *gc = __glXGetCurrentContext(); - struct dri3_context *pcp = (struct dri3_context *) gc; struct dri3_drawable *pdraw = (struct dri3_drawable *) base; struct dri3_screen *psc; @@ -707,7 +697,7 @@ dri3_release_tex_image(__GLXDRIdrawable *base, int buffer) if (psc->texBuffer->base.version >= 3 && psc->texBuffer->releaseTexBuffer != NULL) - (*psc->texBuffer->releaseTexBuffer) (pcp->driContext, + (*psc->texBuffer->releaseTexBuffer) (gc->driContext, pdraw->base.textureTarget, pdraw->loader_drawable.dri_drawable); } diff --git a/src/glx/dri3_priv.h b/src/glx/dri3_priv.h index 61cde69a0a9..5b43f732ad5 100644 --- a/src/glx/dri3_priv.h +++ b/src/glx/dri3_priv.h @@ -112,12 +112,6 @@ struct dri3_screen { struct loader_dri3_extensions loader_dri3_ext; }; -struct dri3_context -{ - struct glx_context base; - __DRIcontext *driContext; -}; - struct dri3_drawable { __GLXDRIdrawable base; struct loader_dri3_drawable loader_drawable; diff --git a/src/glx/dri_common_interop.c b/src/glx/dri_common_interop.c index 2d4fc3d3e62..0952a85cae7 100644 --- a/src/glx/dri_common_interop.c +++ b/src/glx/dri_common_interop.c @@ -37,12 +37,11 @@ dri2_interop_query_device_info(struct glx_context *ctx, struct mesa_glinterop_device_info *out) { struct dri2_screen *psc = (struct dri2_screen*)ctx->psc; - struct dri2_context *drictx = (struct dri2_context*)ctx; if (!psc->interop) return MESA_GLINTEROP_UNSUPPORTED; - return psc->interop->query_device_info(drictx->driContext, out); + return psc->interop->query_device_info(ctx->driContext, out); } _X_HIDDEN int @@ -51,12 +50,11 @@ dri2_interop_export_object(struct glx_context *ctx, struct mesa_glinterop_export_out *out) { struct dri2_screen *psc = (struct dri2_screen*)ctx->psc; - struct dri2_context *drictx = (struct dri2_context*)ctx; if (!psc->interop) return MESA_GLINTEROP_UNSUPPORTED; - return psc->interop->export_object(drictx->driContext, in, out); + return psc->interop->export_object(ctx->driContext, in, out); } #if defined(HAVE_DRI3) @@ -66,12 +64,11 @@ dri3_interop_query_device_info(struct glx_context *ctx, struct mesa_glinterop_device_info *out) { struct dri3_screen *psc = (struct dri3_screen*)ctx->psc; - struct dri3_context *drictx = (struct dri3_context*)ctx; if (!psc->interop) return MESA_GLINTEROP_UNSUPPORTED; - return psc->interop->query_device_info(drictx->driContext, out); + return psc->interop->query_device_info(ctx->driContext, out); } _X_HIDDEN int @@ -80,12 +77,11 @@ dri3_interop_export_object(struct glx_context *ctx, struct mesa_glinterop_export_out *out) { struct dri3_screen *psc = (struct dri3_screen*)ctx->psc; - struct dri3_context *drictx = (struct dri3_context*)ctx; if (!psc->interop) return MESA_GLINTEROP_UNSUPPORTED; - return psc->interop->export_object(drictx->driContext, in, out); + return psc->interop->export_object(ctx->driContext, in, out); } #endif /* HAVE_DRI3 */ diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 5849486c393..200156be2b8 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -415,24 +415,22 @@ static const __DRIextension *kopper_extensions_noshm[] = { static void drisw_destroy_context(struct glx_context *context) { - struct drisw_context *pcp = (struct drisw_context *) context; struct drisw_screen *psc = (struct drisw_screen *) context->psc; - driReleaseDrawables(&pcp->base); + driReleaseDrawables(context); free((char *) context->extensions); - (*psc->core->destroyContext) (pcp->driContext); + (*psc->core->destroyContext) (context->driContext); - free(pcp); + free(context); } static int drisw_bind_context(struct glx_context *context, struct glx_context *old, GLXDrawable draw, GLXDrawable read) { - struct drisw_context *pcp = (struct drisw_context *) context; - struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc; + struct drisw_screen *psc = (struct drisw_screen *) context->psc; struct drisw_drawable *pdraw, *pread; pdraw = (struct drisw_drawable *) driFetchDrawable(context, draw); @@ -440,7 +438,7 @@ drisw_bind_context(struct glx_context *context, struct glx_context *old, driReleaseDrawables(old); - if (!(*psc->core->bindContext) (pcp->driContext, + if (!(*psc->core->bindContext) (context->driContext, pdraw ? pdraw->driDrawable : NULL, pread ? pread->driDrawable : NULL)) return GLXBadContext; @@ -457,10 +455,9 @@ drisw_bind_context(struct glx_context *context, struct glx_context *old, static void drisw_unbind_context(struct glx_context *context, struct glx_context *new) { - struct drisw_context *pcp = (struct drisw_context *) context; - struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc; + struct drisw_screen *psc = (struct drisw_screen *) context->psc; - (*psc->core->unbindContext) (pcp->driContext); + (*psc->core->unbindContext) (context->driContext); } static void @@ -480,7 +477,6 @@ drisw_bind_tex_image(__GLXDRIdrawable *base, int buffer, const int *attrib_list) { struct glx_context *gc = __glXGetCurrentContext(); - struct drisw_context *pcp = (struct drisw_context *) gc; struct drisw_drawable *pdraw = (struct drisw_drawable *) base; struct drisw_screen *psc; @@ -492,13 +488,13 @@ drisw_bind_tex_image(__GLXDRIdrawable *base, if (psc->texBuffer->base.version >= 2 && psc->texBuffer->setTexBuffer2 != NULL) { - (*psc->texBuffer->setTexBuffer2) (pcp->driContext, + (*psc->texBuffer->setTexBuffer2) (gc->driContext, pdraw->base.textureTarget, pdraw->base.textureFormat, pdraw->driDrawable); } else { - (*psc->texBuffer->setTexBuffer) (pcp->driContext, + (*psc->texBuffer->setTexBuffer) (gc->driContext, pdraw->base.textureTarget, pdraw->driDrawable); } @@ -509,7 +505,6 @@ static void drisw_release_tex_image(__GLXDRIdrawable *base, int buffer) { struct glx_context *gc = __glXGetCurrentContext(); - struct drisw_context *pcp = (struct drisw_context *) gc; struct drisw_drawable *pdraw = (struct drisw_drawable *) base; struct drisw_screen *psc; @@ -521,7 +516,7 @@ drisw_release_tex_image(__GLXDRIdrawable *base, int buffer) if (psc->texBuffer->base.version >= 3 && psc->texBuffer->releaseTexBuffer != NULL) { - (*psc->texBuffer->releaseTexBuffer) (pcp->driContext, + (*psc->texBuffer->releaseTexBuffer) (gc->driContext, pdraw->base.textureTarget, pdraw->driDrawable); } @@ -558,7 +553,7 @@ drisw_create_context_attribs(struct glx_screen *base, const uint32_t *attribs, unsigned *error) { - struct drisw_context *pcp, *pcp_shared; + struct glx_context *pcp, *pcp_shared; __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base; struct drisw_screen *psc = (struct drisw_screen *) base; __DRIcontext *shared = NULL; @@ -598,7 +593,7 @@ drisw_create_context_attribs(struct glx_screen *base, return NULL; } - pcp_shared = (struct drisw_context *) shareList; + pcp_shared = (struct glx_context *) shareList; shared = pcp_shared->driContext; } @@ -606,7 +601,7 @@ drisw_create_context_attribs(struct glx_screen *base, if (pcp == NULL) return NULL; - if (!glx_context_init(&pcp->base, &psc->base, config_base)) { + if (!glx_context_init(pcp, &psc->base, config_base)) { free(pcp); return NULL; } @@ -627,7 +622,7 @@ drisw_create_context_attribs(struct glx_screen *base, if (dca.no_error) { ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_NO_ERROR; ctx_attribs[num_ctx_attribs++] = GL_TRUE; - pcp->base.noError = GL_TRUE; + pcp->noError = GL_TRUE; } if (dca.flags != 0) { @@ -635,7 +630,7 @@ drisw_create_context_attribs(struct glx_screen *base, ctx_attribs[num_ctx_attribs++] = dca.flags; } - pcp->base.renderType = dca.render_type; + pcp->renderType = dca.render_type; pcp->driContext = (*psc->swrast->createContextAttribs) (psc->driScreen, @@ -651,9 +646,9 @@ drisw_create_context_attribs(struct glx_screen *base, return NULL; } - pcp->base.vtable = base->context_vtable; + pcp->vtable = base->context_vtable; - return &pcp->base; + return pcp; } static void diff --git a/src/glx/drisw_priv.h b/src/glx/drisw_priv.h index 008953c8dd6..a75f2c5f575 100644 --- a/src/glx/drisw_priv.h +++ b/src/glx/drisw_priv.h @@ -35,13 +35,6 @@ struct drisw_display bool zink; }; -struct drisw_context -{ - struct glx_context base; - __DRIcontext *driContext; - -}; - struct drisw_screen { struct glx_screen base; diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index b793bd2e275..7de7391ad01 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -343,9 +343,8 @@ struct glx_context */ Bool isDirect; -#if defined(GLX_DIRECT_RENDERING) && defined(GLX_USE_APPLEGL) + /* Backend private state for the context */ void *driContext; -#endif /** * \c dpy of current display for this context. Will be \c NULL if not