glx/dri*: Unify glx_context subclassing
The AppleGLX way reads a little nicer than the DRI wrapping way, I think. First time for everything. Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18473>
This commit is contained in:
@@ -99,24 +99,22 @@ merge_counter(uint32_t hi, uint32_t lo)
|
|||||||
static void
|
static void
|
||||||
dri2_destroy_context(struct glx_context *context)
|
dri2_destroy_context(struct glx_context *context)
|
||||||
{
|
{
|
||||||
struct dri2_context *pcp = (struct dri2_context *) context;
|
|
||||||
struct dri2_screen *psc = (struct dri2_screen *) context->psc;
|
struct dri2_screen *psc = (struct dri2_screen *) context->psc;
|
||||||
|
|
||||||
driReleaseDrawables(&pcp->base);
|
driReleaseDrawables(context);
|
||||||
|
|
||||||
free((char *) context->extensions);
|
free((char *) context->extensions);
|
||||||
|
|
||||||
(*psc->core->destroyContext) (pcp->driContext);
|
(*psc->core->destroyContext) (context->driContext);
|
||||||
|
|
||||||
free(pcp);
|
free(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
dri2_bind_context(struct glx_context *context, struct glx_context *old,
|
dri2_bind_context(struct glx_context *context, struct glx_context *old,
|
||||||
GLXDrawable draw, GLXDrawable read)
|
GLXDrawable draw, GLXDrawable read)
|
||||||
{
|
{
|
||||||
struct dri2_context *pcp = (struct dri2_context *) context;
|
struct dri2_screen *psc = (struct dri2_screen *) context->psc;
|
||||||
struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc;
|
|
||||||
struct dri2_drawable *pdraw, *pread;
|
struct dri2_drawable *pdraw, *pread;
|
||||||
__DRIdrawable *dri_draw = NULL, *dri_read = NULL;
|
__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)
|
else if (read != None)
|
||||||
return GLXBadDrawable;
|
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 GLXBadContext;
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
@@ -144,10 +142,9 @@ dri2_bind_context(struct glx_context *context, struct glx_context *old,
|
|||||||
static void
|
static void
|
||||||
dri2_unbind_context(struct glx_context *context, struct glx_context *new)
|
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 *) context->psc;
|
||||||
struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc;
|
|
||||||
|
|
||||||
(*psc->core->unbindContext) (pcp->driContext);
|
(*psc->core->unbindContext) (context->driContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct glx_context *
|
static struct glx_context *
|
||||||
@@ -158,8 +155,7 @@ dri2_create_context_attribs(struct glx_screen *base,
|
|||||||
const uint32_t *attribs,
|
const uint32_t *attribs,
|
||||||
unsigned *error)
|
unsigned *error)
|
||||||
{
|
{
|
||||||
struct dri2_context *pcp = NULL;
|
struct glx_context *pcp = NULL;
|
||||||
struct dri2_context *pcp_shared = NULL;
|
|
||||||
struct dri2_screen *psc = (struct dri2_screen *) base;
|
struct dri2_screen *psc = (struct dri2_screen *) base;
|
||||||
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
|
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
|
||||||
__DRIcontext *shared = NULL;
|
__DRIcontext *shared = NULL;
|
||||||
@@ -192,8 +188,7 @@ dri2_create_context_attribs(struct glx_screen *base,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pcp_shared = (struct dri2_context *) shareList;
|
shared = shareList->driContext;
|
||||||
shared = pcp_shared->driContext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pcp = calloc(1, sizeof *pcp);
|
pcp = calloc(1, sizeof *pcp);
|
||||||
@@ -202,7 +197,7 @@ dri2_create_context_attribs(struct glx_screen *base,
|
|||||||
goto error_exit;
|
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;
|
goto error_exit;
|
||||||
|
|
||||||
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MAJOR_VERSION;
|
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) {
|
if (dca.no_error) {
|
||||||
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_NO_ERROR;
|
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_NO_ERROR;
|
||||||
ctx_attribs[num_ctx_attribs++] = dca.no_error;
|
ctx_attribs[num_ctx_attribs++] = dca.no_error;
|
||||||
pcp->base.noError = GL_TRUE;
|
pcp->noError = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dca.flags != 0) {
|
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
|
/* The renderType is retrieved from attribs, or set to default
|
||||||
* of GLX_RGBA_TYPE.
|
* of GLX_RGBA_TYPE.
|
||||||
*/
|
*/
|
||||||
pcp->base.renderType = dca.render_type;
|
pcp->renderType = dca.render_type;
|
||||||
|
|
||||||
pcp->driContext =
|
pcp->driContext =
|
||||||
(*psc->dri2->createContextAttribs) (psc->driScreen,
|
(*psc->dri2->createContextAttribs) (psc->driScreen,
|
||||||
@@ -253,9 +248,9 @@ dri2_create_context_attribs(struct glx_screen *base,
|
|||||||
if (pcp->driContext == NULL)
|
if (pcp->driContext == NULL)
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
|
|
||||||
pcp->base.vtable = base->context_vtable;
|
pcp->vtable = base->context_vtable;
|
||||||
|
|
||||||
return &pcp->base;
|
return pcp;
|
||||||
|
|
||||||
error_exit:
|
error_exit:
|
||||||
free(pcp);
|
free(pcp);
|
||||||
@@ -428,9 +423,8 @@ static __DRIcontext *
|
|||||||
dri2GetCurrentContext()
|
dri2GetCurrentContext()
|
||||||
{
|
{
|
||||||
struct glx_context *gc = __glXGetCurrentContext();
|
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
|
static void
|
||||||
driSetBackgroundContext(void *loaderPrivate)
|
driSetBackgroundContext(void *loaderPrivate)
|
||||||
{
|
{
|
||||||
struct dri2_context *pcp = (struct dri2_context *) loaderPrivate;
|
__glXSetCurrentContext(loaderPrivate);
|
||||||
__glXSetCurrentContext(&pcp->base);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLboolean
|
static GLboolean
|
||||||
driIsThreadSafe(void *loaderPrivate)
|
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
|
/* Check Xlib is running in thread safe mode
|
||||||
*
|
*
|
||||||
* 'lock_fns' is the XLockDisplay function pointer of the X11 display 'dpy'.
|
* 'lock_fns' is the XLockDisplay function pointer of the X11 display 'dpy'.
|
||||||
* It wll be NULL if XInitThreads wasn't called.
|
* 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 = {
|
static const __DRIdri2LoaderExtension dri2LoaderExtension = {
|
||||||
@@ -889,7 +882,6 @@ dri2_bind_tex_image(__GLXDRIdrawable *base,
|
|||||||
int buffer, const int *attrib_list)
|
int buffer, const int *attrib_list)
|
||||||
{
|
{
|
||||||
struct glx_context *gc = __glXGetCurrentContext();
|
struct glx_context *gc = __glXGetCurrentContext();
|
||||||
struct dri2_context *pcp = (struct dri2_context *) gc;
|
|
||||||
struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
|
struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
|
||||||
struct dri2_screen *psc;
|
struct dri2_screen *psc;
|
||||||
|
|
||||||
@@ -898,13 +890,13 @@ dri2_bind_tex_image(__GLXDRIdrawable *base,
|
|||||||
|
|
||||||
if (psc->texBuffer->base.version >= 2 &&
|
if (psc->texBuffer->base.version >= 2 &&
|
||||||
psc->texBuffer->setTexBuffer2 != NULL) {
|
psc->texBuffer->setTexBuffer2 != NULL) {
|
||||||
(*psc->texBuffer->setTexBuffer2) (pcp->driContext,
|
(*psc->texBuffer->setTexBuffer2) (gc->driContext,
|
||||||
pdraw->base.textureTarget,
|
pdraw->base.textureTarget,
|
||||||
pdraw->base.textureFormat,
|
pdraw->base.textureFormat,
|
||||||
pdraw->driDrawable);
|
pdraw->driDrawable);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(*psc->texBuffer->setTexBuffer) (pcp->driContext,
|
(*psc->texBuffer->setTexBuffer) (gc->driContext,
|
||||||
pdraw->base.textureTarget,
|
pdraw->base.textureTarget,
|
||||||
pdraw->driDrawable);
|
pdraw->driDrawable);
|
||||||
}
|
}
|
||||||
@@ -915,7 +907,6 @@ static void
|
|||||||
dri2_release_tex_image(__GLXDRIdrawable *base, int buffer)
|
dri2_release_tex_image(__GLXDRIdrawable *base, int buffer)
|
||||||
{
|
{
|
||||||
struct glx_context *gc = __glXGetCurrentContext();
|
struct glx_context *gc = __glXGetCurrentContext();
|
||||||
struct dri2_context *pcp = (struct dri2_context *) gc;
|
|
||||||
struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
|
struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
|
||||||
struct dri2_screen *psc;
|
struct dri2_screen *psc;
|
||||||
|
|
||||||
@@ -924,7 +915,7 @@ dri2_release_tex_image(__GLXDRIdrawable *base, int buffer)
|
|||||||
|
|
||||||
if (psc->texBuffer->base.version >= 3 &&
|
if (psc->texBuffer->base.version >= 3 &&
|
||||||
psc->texBuffer->releaseTexBuffer != NULL) {
|
psc->texBuffer->releaseTexBuffer != NULL) {
|
||||||
(*psc->texBuffer->releaseTexBuffer) (pcp->driContext,
|
(*psc->texBuffer->releaseTexBuffer) (gc->driContext,
|
||||||
pdraw->base.textureTarget,
|
pdraw->base.textureTarget,
|
||||||
pdraw->driDrawable);
|
pdraw->driDrawable);
|
||||||
}
|
}
|
||||||
|
@@ -60,12 +60,6 @@ struct dri2_screen {
|
|||||||
int show_fps_interval;
|
int show_fps_interval;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dri2_context
|
|
||||||
{
|
|
||||||
struct glx_context base;
|
|
||||||
__DRIcontext *driContext;
|
|
||||||
};
|
|
||||||
|
|
||||||
_X_HIDDEN int
|
_X_HIDDEN int
|
||||||
dri2_query_renderer_integer(struct glx_screen *base, int attribute,
|
dri2_query_renderer_integer(struct glx_screen *base, int attribute,
|
||||||
unsigned int *value);
|
unsigned int *value);
|
||||||
|
@@ -102,27 +102,25 @@ glx_dri3_in_current_context(struct loader_dri3_drawable *draw)
|
|||||||
if (!priv)
|
if (!priv)
|
||||||
return false;
|
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;
|
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 *
|
static __DRIcontext *
|
||||||
glx_dri3_get_dri_context(struct loader_dri3_drawable *draw)
|
glx_dri3_get_dri_context(struct loader_dri3_drawable *draw)
|
||||||
{
|
{
|
||||||
struct glx_context *gc = __glXGetCurrentContext();
|
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 *
|
static __DRIscreen *
|
||||||
glx_dri3_get_dri_screen(void)
|
glx_dri3_get_dri_screen(void)
|
||||||
{
|
{
|
||||||
struct glx_context *gc = __glXGetCurrentContext();
|
struct glx_context *gc = __glXGetCurrentContext();
|
||||||
struct dri3_context *pcp = (struct dri3_context *) gc;
|
struct dri3_screen *psc = (struct dri3_screen *) gc->psc;
|
||||||
struct dri3_screen *psc = (struct dri3_screen *) pcp->base.psc;
|
|
||||||
|
|
||||||
return (gc != &dummyContext && psc) ? psc->driScreen : NULL;
|
return (gc != &dummyContext && psc) ? psc->driScreen : NULL;
|
||||||
}
|
}
|
||||||
@@ -172,24 +170,22 @@ static const struct glx_context_vtable dri3_context_vtable;
|
|||||||
static void
|
static void
|
||||||
dri3_destroy_context(struct glx_context *context)
|
dri3_destroy_context(struct glx_context *context)
|
||||||
{
|
{
|
||||||
struct dri3_context *pcp = (struct dri3_context *) context;
|
|
||||||
struct dri3_screen *psc = (struct dri3_screen *) context->psc;
|
struct dri3_screen *psc = (struct dri3_screen *) context->psc;
|
||||||
|
|
||||||
driReleaseDrawables(&pcp->base);
|
driReleaseDrawables(context);
|
||||||
|
|
||||||
free((char *) context->extensions);
|
free((char *) context->extensions);
|
||||||
|
|
||||||
(*psc->core->destroyContext) (pcp->driContext);
|
(*psc->core->destroyContext) (context->driContext);
|
||||||
|
|
||||||
free(pcp);
|
free(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
dri3_bind_context(struct glx_context *context, struct glx_context *old,
|
dri3_bind_context(struct glx_context *context, struct glx_context *old,
|
||||||
GLXDrawable draw, GLXDrawable read)
|
GLXDrawable draw, GLXDrawable read)
|
||||||
{
|
{
|
||||||
struct dri3_context *pcp = (struct dri3_context *) context;
|
struct dri3_screen *psc = (struct dri3_screen *) context->psc;
|
||||||
struct dri3_screen *psc = (struct dri3_screen *) pcp->base.psc;
|
|
||||||
struct dri3_drawable *pdraw, *pread;
|
struct dri3_drawable *pdraw, *pread;
|
||||||
__DRIdrawable *dri_draw = NULL, *dri_read = NULL;
|
__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)
|
else if (read != None)
|
||||||
return GLXBadDrawable;
|
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 GLXBadContext;
|
||||||
|
|
||||||
if (dri_draw)
|
if (dri_draw)
|
||||||
@@ -222,10 +218,9 @@ dri3_bind_context(struct glx_context *context, struct glx_context *old,
|
|||||||
static void
|
static void
|
||||||
dri3_unbind_context(struct glx_context *context, struct glx_context *new)
|
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 *) context->psc;
|
||||||
struct dri3_screen *psc = (struct dri3_screen *) pcp->base.psc;
|
|
||||||
|
|
||||||
(*psc->core->unbindContext) (pcp->driContext);
|
(*psc->core->unbindContext) (context->driContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct glx_context *
|
static struct glx_context *
|
||||||
@@ -236,8 +231,7 @@ dri3_create_context_attribs(struct glx_screen *base,
|
|||||||
const uint32_t *attribs,
|
const uint32_t *attribs,
|
||||||
unsigned *error)
|
unsigned *error)
|
||||||
{
|
{
|
||||||
struct dri3_context *pcp = NULL;
|
struct glx_context *pcp = NULL;
|
||||||
struct dri3_context *pcp_shared = NULL;
|
|
||||||
struct dri3_screen *psc = (struct dri3_screen *) base;
|
struct dri3_screen *psc = (struct dri3_screen *) base;
|
||||||
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
|
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
|
||||||
__DRIcontext *shared = NULL;
|
__DRIcontext *shared = NULL;
|
||||||
@@ -270,8 +264,7 @@ dri3_create_context_attribs(struct glx_screen *base,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pcp_shared = (struct dri3_context *) shareList;
|
shared = shareList->driContext;
|
||||||
shared = pcp_shared->driContext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pcp = calloc(1, sizeof *pcp);
|
pcp = calloc(1, sizeof *pcp);
|
||||||
@@ -280,7 +273,7 @@ dri3_create_context_attribs(struct glx_screen *base,
|
|||||||
goto error_exit;
|
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;
|
goto error_exit;
|
||||||
|
|
||||||
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MAJOR_VERSION;
|
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) {
|
if (dca.no_error) {
|
||||||
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_NO_ERROR;
|
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_NO_ERROR;
|
||||||
ctx_attribs[num_ctx_attribs++] = dca.no_error;
|
ctx_attribs[num_ctx_attribs++] = dca.no_error;
|
||||||
pcp->base.noError = GL_TRUE;
|
pcp->noError = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dca.flags != 0) {
|
if (dca.flags != 0) {
|
||||||
@@ -313,7 +306,7 @@ dri3_create_context_attribs(struct glx_screen *base,
|
|||||||
ctx_attribs[num_ctx_attribs++] = dca.flags;
|
ctx_attribs[num_ctx_attribs++] = dca.flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
pcp->base.renderType = dca.render_type;
|
pcp->renderType = dca.render_type;
|
||||||
|
|
||||||
pcp->driContext =
|
pcp->driContext =
|
||||||
(*psc->image_driver->createContextAttribs) (psc->driScreen,
|
(*psc->image_driver->createContextAttribs) (psc->driScreen,
|
||||||
@@ -329,9 +322,9 @@ dri3_create_context_attribs(struct glx_screen *base,
|
|||||||
if (pcp->driContext == NULL)
|
if (pcp->driContext == NULL)
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
|
|
||||||
pcp->base.vtable = base->context_vtable;
|
pcp->vtable = base->context_vtable;
|
||||||
|
|
||||||
return &pcp->base;
|
return pcp;
|
||||||
|
|
||||||
error_exit:
|
error_exit:
|
||||||
free(pcp);
|
free(pcp);
|
||||||
@@ -547,8 +540,7 @@ dri3_flush_swap_buffers(__DRIdrawable *driDrawable, void *loaderPrivate)
|
|||||||
static void
|
static void
|
||||||
dri_set_background_context(void *loaderPrivate)
|
dri_set_background_context(void *loaderPrivate)
|
||||||
{
|
{
|
||||||
struct dri3_context *pcp = (struct dri3_context *)loaderPrivate;
|
__glXSetCurrentContext(loaderPrivate);
|
||||||
__glXSetCurrentContext(&pcp->base);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLboolean
|
static GLboolean
|
||||||
@@ -676,7 +668,6 @@ dri3_bind_tex_image(__GLXDRIdrawable *base,
|
|||||||
int buffer, const int *attrib_list)
|
int buffer, const int *attrib_list)
|
||||||
{
|
{
|
||||||
struct glx_context *gc = __glXGetCurrentContext();
|
struct glx_context *gc = __glXGetCurrentContext();
|
||||||
struct dri3_context *pcp = (struct dri3_context *) gc;
|
|
||||||
struct dri3_drawable *pdraw = (struct dri3_drawable *) base;
|
struct dri3_drawable *pdraw = (struct dri3_drawable *) base;
|
||||||
struct dri3_screen *psc;
|
struct dri3_screen *psc;
|
||||||
|
|
||||||
@@ -687,7 +678,7 @@ dri3_bind_tex_image(__GLXDRIdrawable *base,
|
|||||||
|
|
||||||
XSync(gc->currentDpy, false);
|
XSync(gc->currentDpy, false);
|
||||||
|
|
||||||
(*psc->texBuffer->setTexBuffer2) (pcp->driContext,
|
(*psc->texBuffer->setTexBuffer2) (gc->driContext,
|
||||||
pdraw->base.textureTarget,
|
pdraw->base.textureTarget,
|
||||||
pdraw->base.textureFormat,
|
pdraw->base.textureFormat,
|
||||||
pdraw->loader_drawable.dri_drawable);
|
pdraw->loader_drawable.dri_drawable);
|
||||||
@@ -698,7 +689,6 @@ static void
|
|||||||
dri3_release_tex_image(__GLXDRIdrawable *base, int buffer)
|
dri3_release_tex_image(__GLXDRIdrawable *base, int buffer)
|
||||||
{
|
{
|
||||||
struct glx_context *gc = __glXGetCurrentContext();
|
struct glx_context *gc = __glXGetCurrentContext();
|
||||||
struct dri3_context *pcp = (struct dri3_context *) gc;
|
|
||||||
struct dri3_drawable *pdraw = (struct dri3_drawable *) base;
|
struct dri3_drawable *pdraw = (struct dri3_drawable *) base;
|
||||||
struct dri3_screen *psc;
|
struct dri3_screen *psc;
|
||||||
|
|
||||||
@@ -707,7 +697,7 @@ dri3_release_tex_image(__GLXDRIdrawable *base, int buffer)
|
|||||||
|
|
||||||
if (psc->texBuffer->base.version >= 3 &&
|
if (psc->texBuffer->base.version >= 3 &&
|
||||||
psc->texBuffer->releaseTexBuffer != NULL)
|
psc->texBuffer->releaseTexBuffer != NULL)
|
||||||
(*psc->texBuffer->releaseTexBuffer) (pcp->driContext,
|
(*psc->texBuffer->releaseTexBuffer) (gc->driContext,
|
||||||
pdraw->base.textureTarget,
|
pdraw->base.textureTarget,
|
||||||
pdraw->loader_drawable.dri_drawable);
|
pdraw->loader_drawable.dri_drawable);
|
||||||
}
|
}
|
||||||
|
@@ -112,12 +112,6 @@ struct dri3_screen {
|
|||||||
struct loader_dri3_extensions loader_dri3_ext;
|
struct loader_dri3_extensions loader_dri3_ext;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dri3_context
|
|
||||||
{
|
|
||||||
struct glx_context base;
|
|
||||||
__DRIcontext *driContext;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct dri3_drawable {
|
struct dri3_drawable {
|
||||||
__GLXDRIdrawable base;
|
__GLXDRIdrawable base;
|
||||||
struct loader_dri3_drawable loader_drawable;
|
struct loader_dri3_drawable loader_drawable;
|
||||||
|
@@ -37,12 +37,11 @@ dri2_interop_query_device_info(struct glx_context *ctx,
|
|||||||
struct mesa_glinterop_device_info *out)
|
struct mesa_glinterop_device_info *out)
|
||||||
{
|
{
|
||||||
struct dri2_screen *psc = (struct dri2_screen*)ctx->psc;
|
struct dri2_screen *psc = (struct dri2_screen*)ctx->psc;
|
||||||
struct dri2_context *drictx = (struct dri2_context*)ctx;
|
|
||||||
|
|
||||||
if (!psc->interop)
|
if (!psc->interop)
|
||||||
return MESA_GLINTEROP_UNSUPPORTED;
|
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
|
_X_HIDDEN int
|
||||||
@@ -51,12 +50,11 @@ dri2_interop_export_object(struct glx_context *ctx,
|
|||||||
struct mesa_glinterop_export_out *out)
|
struct mesa_glinterop_export_out *out)
|
||||||
{
|
{
|
||||||
struct dri2_screen *psc = (struct dri2_screen*)ctx->psc;
|
struct dri2_screen *psc = (struct dri2_screen*)ctx->psc;
|
||||||
struct dri2_context *drictx = (struct dri2_context*)ctx;
|
|
||||||
|
|
||||||
if (!psc->interop)
|
if (!psc->interop)
|
||||||
return MESA_GLINTEROP_UNSUPPORTED;
|
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)
|
#if defined(HAVE_DRI3)
|
||||||
@@ -66,12 +64,11 @@ dri3_interop_query_device_info(struct glx_context *ctx,
|
|||||||
struct mesa_glinterop_device_info *out)
|
struct mesa_glinterop_device_info *out)
|
||||||
{
|
{
|
||||||
struct dri3_screen *psc = (struct dri3_screen*)ctx->psc;
|
struct dri3_screen *psc = (struct dri3_screen*)ctx->psc;
|
||||||
struct dri3_context *drictx = (struct dri3_context*)ctx;
|
|
||||||
|
|
||||||
if (!psc->interop)
|
if (!psc->interop)
|
||||||
return MESA_GLINTEROP_UNSUPPORTED;
|
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
|
_X_HIDDEN int
|
||||||
@@ -80,12 +77,11 @@ dri3_interop_export_object(struct glx_context *ctx,
|
|||||||
struct mesa_glinterop_export_out *out)
|
struct mesa_glinterop_export_out *out)
|
||||||
{
|
{
|
||||||
struct dri3_screen *psc = (struct dri3_screen*)ctx->psc;
|
struct dri3_screen *psc = (struct dri3_screen*)ctx->psc;
|
||||||
struct dri3_context *drictx = (struct dri3_context*)ctx;
|
|
||||||
|
|
||||||
if (!psc->interop)
|
if (!psc->interop)
|
||||||
return MESA_GLINTEROP_UNSUPPORTED;
|
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 */
|
#endif /* HAVE_DRI3 */
|
||||||
|
@@ -415,24 +415,22 @@ static const __DRIextension *kopper_extensions_noshm[] = {
|
|||||||
static void
|
static void
|
||||||
drisw_destroy_context(struct glx_context *context)
|
drisw_destroy_context(struct glx_context *context)
|
||||||
{
|
{
|
||||||
struct drisw_context *pcp = (struct drisw_context *) context;
|
|
||||||
struct drisw_screen *psc = (struct drisw_screen *) context->psc;
|
struct drisw_screen *psc = (struct drisw_screen *) context->psc;
|
||||||
|
|
||||||
driReleaseDrawables(&pcp->base);
|
driReleaseDrawables(context);
|
||||||
|
|
||||||
free((char *) context->extensions);
|
free((char *) context->extensions);
|
||||||
|
|
||||||
(*psc->core->destroyContext) (pcp->driContext);
|
(*psc->core->destroyContext) (context->driContext);
|
||||||
|
|
||||||
free(pcp);
|
free(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
drisw_bind_context(struct glx_context *context, struct glx_context *old,
|
drisw_bind_context(struct glx_context *context, struct glx_context *old,
|
||||||
GLXDrawable draw, GLXDrawable read)
|
GLXDrawable draw, GLXDrawable read)
|
||||||
{
|
{
|
||||||
struct drisw_context *pcp = (struct drisw_context *) context;
|
struct drisw_screen *psc = (struct drisw_screen *) context->psc;
|
||||||
struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc;
|
|
||||||
struct drisw_drawable *pdraw, *pread;
|
struct drisw_drawable *pdraw, *pread;
|
||||||
|
|
||||||
pdraw = (struct drisw_drawable *) driFetchDrawable(context, draw);
|
pdraw = (struct drisw_drawable *) driFetchDrawable(context, draw);
|
||||||
@@ -440,7 +438,7 @@ drisw_bind_context(struct glx_context *context, struct glx_context *old,
|
|||||||
|
|
||||||
driReleaseDrawables(old);
|
driReleaseDrawables(old);
|
||||||
|
|
||||||
if (!(*psc->core->bindContext) (pcp->driContext,
|
if (!(*psc->core->bindContext) (context->driContext,
|
||||||
pdraw ? pdraw->driDrawable : NULL,
|
pdraw ? pdraw->driDrawable : NULL,
|
||||||
pread ? pread->driDrawable : NULL))
|
pread ? pread->driDrawable : NULL))
|
||||||
return GLXBadContext;
|
return GLXBadContext;
|
||||||
@@ -457,10 +455,9 @@ drisw_bind_context(struct glx_context *context, struct glx_context *old,
|
|||||||
static void
|
static void
|
||||||
drisw_unbind_context(struct glx_context *context, struct glx_context *new)
|
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 *) context->psc;
|
||||||
struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc;
|
|
||||||
|
|
||||||
(*psc->core->unbindContext) (pcp->driContext);
|
(*psc->core->unbindContext) (context->driContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -480,7 +477,6 @@ drisw_bind_tex_image(__GLXDRIdrawable *base,
|
|||||||
int buffer, const int *attrib_list)
|
int buffer, const int *attrib_list)
|
||||||
{
|
{
|
||||||
struct glx_context *gc = __glXGetCurrentContext();
|
struct glx_context *gc = __glXGetCurrentContext();
|
||||||
struct drisw_context *pcp = (struct drisw_context *) gc;
|
|
||||||
struct drisw_drawable *pdraw = (struct drisw_drawable *) base;
|
struct drisw_drawable *pdraw = (struct drisw_drawable *) base;
|
||||||
struct drisw_screen *psc;
|
struct drisw_screen *psc;
|
||||||
|
|
||||||
@@ -492,13 +488,13 @@ drisw_bind_tex_image(__GLXDRIdrawable *base,
|
|||||||
|
|
||||||
if (psc->texBuffer->base.version >= 2 &&
|
if (psc->texBuffer->base.version >= 2 &&
|
||||||
psc->texBuffer->setTexBuffer2 != NULL) {
|
psc->texBuffer->setTexBuffer2 != NULL) {
|
||||||
(*psc->texBuffer->setTexBuffer2) (pcp->driContext,
|
(*psc->texBuffer->setTexBuffer2) (gc->driContext,
|
||||||
pdraw->base.textureTarget,
|
pdraw->base.textureTarget,
|
||||||
pdraw->base.textureFormat,
|
pdraw->base.textureFormat,
|
||||||
pdraw->driDrawable);
|
pdraw->driDrawable);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(*psc->texBuffer->setTexBuffer) (pcp->driContext,
|
(*psc->texBuffer->setTexBuffer) (gc->driContext,
|
||||||
pdraw->base.textureTarget,
|
pdraw->base.textureTarget,
|
||||||
pdraw->driDrawable);
|
pdraw->driDrawable);
|
||||||
}
|
}
|
||||||
@@ -509,7 +505,6 @@ static void
|
|||||||
drisw_release_tex_image(__GLXDRIdrawable *base, int buffer)
|
drisw_release_tex_image(__GLXDRIdrawable *base, int buffer)
|
||||||
{
|
{
|
||||||
struct glx_context *gc = __glXGetCurrentContext();
|
struct glx_context *gc = __glXGetCurrentContext();
|
||||||
struct drisw_context *pcp = (struct drisw_context *) gc;
|
|
||||||
struct drisw_drawable *pdraw = (struct drisw_drawable *) base;
|
struct drisw_drawable *pdraw = (struct drisw_drawable *) base;
|
||||||
struct drisw_screen *psc;
|
struct drisw_screen *psc;
|
||||||
|
|
||||||
@@ -521,7 +516,7 @@ drisw_release_tex_image(__GLXDRIdrawable *base, int buffer)
|
|||||||
|
|
||||||
if (psc->texBuffer->base.version >= 3 &&
|
if (psc->texBuffer->base.version >= 3 &&
|
||||||
psc->texBuffer->releaseTexBuffer != NULL) {
|
psc->texBuffer->releaseTexBuffer != NULL) {
|
||||||
(*psc->texBuffer->releaseTexBuffer) (pcp->driContext,
|
(*psc->texBuffer->releaseTexBuffer) (gc->driContext,
|
||||||
pdraw->base.textureTarget,
|
pdraw->base.textureTarget,
|
||||||
pdraw->driDrawable);
|
pdraw->driDrawable);
|
||||||
}
|
}
|
||||||
@@ -558,7 +553,7 @@ drisw_create_context_attribs(struct glx_screen *base,
|
|||||||
const uint32_t *attribs,
|
const uint32_t *attribs,
|
||||||
unsigned *error)
|
unsigned *error)
|
||||||
{
|
{
|
||||||
struct drisw_context *pcp, *pcp_shared;
|
struct glx_context *pcp, *pcp_shared;
|
||||||
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
|
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
|
||||||
struct drisw_screen *psc = (struct drisw_screen *) base;
|
struct drisw_screen *psc = (struct drisw_screen *) base;
|
||||||
__DRIcontext *shared = NULL;
|
__DRIcontext *shared = NULL;
|
||||||
@@ -598,7 +593,7 @@ drisw_create_context_attribs(struct glx_screen *base,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pcp_shared = (struct drisw_context *) shareList;
|
pcp_shared = (struct glx_context *) shareList;
|
||||||
shared = pcp_shared->driContext;
|
shared = pcp_shared->driContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -606,7 +601,7 @@ drisw_create_context_attribs(struct glx_screen *base,
|
|||||||
if (pcp == NULL)
|
if (pcp == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!glx_context_init(&pcp->base, &psc->base, config_base)) {
|
if (!glx_context_init(pcp, &psc->base, config_base)) {
|
||||||
free(pcp);
|
free(pcp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -627,7 +622,7 @@ drisw_create_context_attribs(struct glx_screen *base,
|
|||||||
if (dca.no_error) {
|
if (dca.no_error) {
|
||||||
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_NO_ERROR;
|
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_NO_ERROR;
|
||||||
ctx_attribs[num_ctx_attribs++] = GL_TRUE;
|
ctx_attribs[num_ctx_attribs++] = GL_TRUE;
|
||||||
pcp->base.noError = GL_TRUE;
|
pcp->noError = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dca.flags != 0) {
|
if (dca.flags != 0) {
|
||||||
@@ -635,7 +630,7 @@ drisw_create_context_attribs(struct glx_screen *base,
|
|||||||
ctx_attribs[num_ctx_attribs++] = dca.flags;
|
ctx_attribs[num_ctx_attribs++] = dca.flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
pcp->base.renderType = dca.render_type;
|
pcp->renderType = dca.render_type;
|
||||||
|
|
||||||
pcp->driContext =
|
pcp->driContext =
|
||||||
(*psc->swrast->createContextAttribs) (psc->driScreen,
|
(*psc->swrast->createContextAttribs) (psc->driScreen,
|
||||||
@@ -651,9 +646,9 @@ drisw_create_context_attribs(struct glx_screen *base,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pcp->base.vtable = base->context_vtable;
|
pcp->vtable = base->context_vtable;
|
||||||
|
|
||||||
return &pcp->base;
|
return pcp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -35,13 +35,6 @@ struct drisw_display
|
|||||||
bool zink;
|
bool zink;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct drisw_context
|
|
||||||
{
|
|
||||||
struct glx_context base;
|
|
||||||
__DRIcontext *driContext;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
struct drisw_screen
|
struct drisw_screen
|
||||||
{
|
{
|
||||||
struct glx_screen base;
|
struct glx_screen base;
|
||||||
|
@@ -343,9 +343,8 @@ struct glx_context
|
|||||||
*/
|
*/
|
||||||
Bool isDirect;
|
Bool isDirect;
|
||||||
|
|
||||||
#if defined(GLX_DIRECT_RENDERING) && defined(GLX_USE_APPLEGL)
|
/* Backend private state for the context */
|
||||||
void *driContext;
|
void *driContext;
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \c dpy of current display for this context. Will be \c NULL if not
|
* \c dpy of current display for this context. Will be \c NULL if not
|
||||||
|
Reference in New Issue
Block a user