glx: Move {Bind,Release}TexImage from context to screen vtable

All the other operations on drawables live there, be consistent.

Acked-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9992>
This commit is contained in:
Adam Jackson 2021-03-19 13:39:01 -04:00 committed by Marge Bot
parent e8d10a15f1
commit a2b474c333
8 changed files with 103 additions and 130 deletions

View File

@ -114,8 +114,6 @@ static const struct glx_context_vtable applegl_context_vtable = {
.unbind = applegl_unbind_context,
.wait_gl = applegl_wait_gl,
.wait_x = applegl_wait_x,
.bind_tex_image = NULL,
.release_tex_image = NULL,
};
struct glx_context *

View File

@ -980,21 +980,16 @@ dri2InvalidateBuffers(Display *dpy, XID drawable)
}
static void
dri2_bind_tex_image(Display * dpy,
GLXDrawable drawable,
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;
__GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
struct glx_display *dpyPriv = __glXInitialize(dpy);
struct glx_display *dpyPriv = __glXInitialize(gc->currentDpy);
struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
struct dri2_display *pdp;
struct dri2_screen *psc;
if (dpyPriv == NULL)
return;
pdp = (struct dri2_display *) dpyPriv->dri2Display;
if (pdraw != NULL) {
@ -1020,16 +1015,14 @@ dri2_bind_tex_image(Display * dpy,
}
static void
dri2_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
dri2_release_tex_image(__GLXDRIdrawable *base, int buffer)
{
struct glx_context *gc = __glXGetCurrentContext();
struct dri2_context *pcp = (struct dri2_context *) gc;
__GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
struct glx_display *dpyPriv = __glXInitialize(dpy);
struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
struct dri2_screen *psc;
if (dpyPriv != NULL && pdraw != NULL) {
if (pdraw != NULL) {
psc = (struct dri2_screen *) base->psc;
if (psc->texBuffer->base.version >= 3 &&
@ -1047,8 +1040,6 @@ static const struct glx_context_vtable dri2_context_vtable = {
.unbind = dri2_unbind_context,
.wait_gl = dri2_wait_gl,
.wait_x = dri2_wait_x,
.bind_tex_image = dri2_bind_tex_image,
.release_tex_image = dri2_release_tex_image,
.interop_query_device_info = dri2_interop_query_device_info,
.interop_export_object = dri2_interop_export_object
};
@ -1297,6 +1288,8 @@ dri2CreateScreen(int screen, struct glx_display * priv)
psp->setSwapInterval = NULL;
psp->getSwapInterval = NULL;
psp->getBufferAge = NULL;
psp->bindTexImage = dri2_bind_tex_image;
psp->releaseTexImage = dri2_release_tex_image;
if (pdp->driMinor >= 2) {
psp->getDrawableMSC = dri2DrawableGetMSC;

View File

@ -664,13 +664,11 @@ dri3_get_swap_interval(__GLXDRIdrawable *pdraw)
}
static void
dri3_bind_tex_image(Display * dpy,
GLXDrawable drawable,
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;
__GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
struct dri3_drawable *pdraw = (struct dri3_drawable *) base;
struct dri3_screen *psc;
@ -679,7 +677,7 @@ dri3_bind_tex_image(Display * dpy,
psc->f->invalidate(pdraw->loader_drawable.dri_drawable);
XSync(dpy, false);
XSync(gc->currentDpy, false);
(*psc->texBuffer->setTexBuffer2) (pcp->driContext,
pdraw->base.textureTarget,
@ -689,11 +687,10 @@ dri3_bind_tex_image(Display * dpy,
}
static void
dri3_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
dri3_release_tex_image(__GLXDRIdrawable *base, int buffer)
{
struct glx_context *gc = __glXGetCurrentContext();
struct dri3_context *pcp = (struct dri3_context *) gc;
__GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
struct dri3_drawable *pdraw = (struct dri3_drawable *) base;
struct dri3_screen *psc;
@ -714,8 +711,6 @@ static const struct glx_context_vtable dri3_context_vtable = {
.unbind = dri3_unbind_context,
.wait_gl = dri3_wait_gl,
.wait_x = dri3_wait_x,
.bind_tex_image = dri3_bind_tex_image,
.release_tex_image = dri3_release_tex_image,
.interop_query_device_info = dri3_interop_query_device_info,
.interop_export_object = dri3_interop_export_object
};
@ -971,6 +966,8 @@ dri3_create_screen(int screen, struct glx_display * priv)
psp->waitForSBC = dri3_wait_for_sbc;
psp->setSwapInterval = dri3_set_swap_interval;
psp->getSwapInterval = dri3_get_swap_interval;
psp->bindTexImage = dri3_bind_tex_image;
psp->releaseTexImage = dri3_release_tex_image;
__glXEnableDirectExtension(&psc->base, "GLX_OML_sync_control");
__glXEnableDirectExtension(&psc->base, "GLX_SGI_video_sync");

View File

@ -424,18 +424,14 @@ drisw_wait_x(struct glx_context *context)
}
static void
drisw_bind_tex_image(Display * dpy,
GLXDrawable drawable,
int buffer, const int *attrib_list)
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;
__GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
struct drisw_drawable *pdraw = (struct drisw_drawable *) base;
struct drisw_screen *psc;
__glXInitialize(dpy);
if (pdraw != NULL) {
psc = (struct drisw_screen *) base->psc;
@ -458,16 +454,14 @@ drisw_bind_tex_image(Display * dpy,
}
static void
drisw_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
drisw_release_tex_image(__GLXDRIdrawable *base, int buffer)
{
struct glx_context *gc = __glXGetCurrentContext();
struct drisw_context *pcp = (struct drisw_context *) gc;
__GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
struct glx_display *dpyPriv = __glXInitialize(dpy);
struct drisw_drawable *pdraw = (struct drisw_drawable *) base;
struct drisw_screen *psc;
if (dpyPriv != NULL && pdraw != NULL) {
if (pdraw != NULL) {
psc = (struct drisw_screen *) base->psc;
if (!psc->texBuffer)
@ -488,8 +482,6 @@ static const struct glx_context_vtable drisw_context_vtable = {
.unbind = drisw_unbind_context,
.wait_gl = drisw_wait_gl,
.wait_x = drisw_wait_x,
.bind_tex_image = drisw_bind_tex_image,
.release_tex_image = drisw_release_tex_image,
};
static struct glx_context *
@ -901,6 +893,8 @@ driswCreateScreen(int screen, struct glx_display *priv)
psp->destroyScreen = driswDestroyScreen;
psp->createDrawable = driswCreateDrawable;
psp->swapBuffers = driswSwapBuffers;
psp->bindTexImage = drisw_bind_tex_image;
psp->releaseTexImage = drisw_release_tex_image;
if (psc->copySubBuffer)
psp->copySubBuffer = driswCopySubBuffer;

View File

@ -127,6 +127,8 @@ struct __GLXDRIscreenRec {
int (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval);
int (*getSwapInterval)(__GLXDRIdrawable *pdraw);
int (*getBufferAge)(__GLXDRIdrawable *pdraw);
void (*bindTexImage)(__GLXDRIdrawable *pdraw, int buffer, const int *attribs);
void (*releaseTexImage)(__GLXDRIdrawable *pdraw, int buffer);
};
struct __GLXDRIdrawableRec
@ -227,10 +229,6 @@ struct glx_context_vtable {
void (*unbind)(struct glx_context *context, struct glx_context *new_ctx);
void (*wait_gl)(struct glx_context *ctx);
void (*wait_x)(struct glx_context *ctx);
void (*bind_tex_image)(Display * dpy,
GLXDrawable drawable,
int buffer, const int *attrib_list);
void (*release_tex_image)(Display * dpy, GLXDrawable drawable, int buffer);
int (*interop_query_device_info)(struct glx_context *ctx,
struct mesa_glinterop_device_info *out);
int (*interop_export_object)(struct glx_context *ctx,

View File

@ -2436,23 +2436,103 @@ _X_HIDDEN void
glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer,
const int *attrib_list)
{
xGLXVendorPrivateReq *req;
struct glx_context *gc = __glXGetCurrentContext();
CARD32 *drawable_ptr;
INT32 *buffer_ptr;
CARD32 *num_attrib_ptr;
CARD32 *attrib_ptr;
CARD8 opcode;
unsigned int i = 0;
if (gc->vtable->bind_tex_image == NULL)
#ifdef GLX_DIRECT_RENDERING
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
if (pdraw != NULL) {
struct glx_screen *psc = pdraw->psc;
if (psc->driScreen->bindTexImage != NULL)
(*psc->driScreen->bindTexImage) (pdraw, buffer, attrib_list);
return;
}
#endif
if (attrib_list) {
while (attrib_list[i * 2] != None)
i++;
}
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return;
gc->vtable->bind_tex_image(dpy, drawable, buffer, attrib_list);
LockDisplay(dpy);
GetReqExtra(GLXVendorPrivate, 12 + 8 * i, req);
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivate;
req->vendorCode = X_GLXvop_BindTexImageEXT;
req->contextTag = gc->currentContextTag;
drawable_ptr = (CARD32 *) (req + 1);
buffer_ptr = (INT32 *) (drawable_ptr + 1);
num_attrib_ptr = (CARD32 *) (buffer_ptr + 1);
attrib_ptr = (CARD32 *) (num_attrib_ptr + 1);
*drawable_ptr = drawable;
*buffer_ptr = buffer;
*num_attrib_ptr = (CARD32) i;
i = 0;
if (attrib_list) {
while (attrib_list[i * 2] != None) {
*attrib_ptr++ = (CARD32) attrib_list[i * 2 + 0];
*attrib_ptr++ = (CARD32) attrib_list[i * 2 + 1];
i++;
}
}
UnlockDisplay(dpy);
SyncHandle();
}
_X_HIDDEN void
glXReleaseTexImageEXT(Display * dpy, GLXDrawable drawable, int buffer)
{
xGLXVendorPrivateReq *req;
struct glx_context *gc = __glXGetCurrentContext();
CARD32 *drawable_ptr;
INT32 *buffer_ptr;
CARD8 opcode;
if (gc->vtable->release_tex_image == NULL)
#ifdef GLX_DIRECT_RENDERING
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
if (pdraw != NULL) {
struct glx_screen *psc = pdraw->psc;
if (psc->driScreen->releaseTexImage != NULL)
(*psc->driScreen->releaseTexImage) (pdraw, buffer);
return;
}
#endif
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return;
gc->vtable->release_tex_image(dpy, drawable, buffer);
LockDisplay(dpy);
GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32), req);
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivate;
req->vendorCode = X_GLXvop_ReleaseTexImageEXT;
req->contextTag = gc->currentContextTag;
drawable_ptr = (CARD32 *) (req + 1);
buffer_ptr = (INT32 *) (drawable_ptr + 1);
*drawable_ptr = drawable;
*buffer_ptr = buffer;
UnlockDisplay(dpy);
SyncHandle();
}
/*@}*/

View File

@ -229,97 +229,12 @@ indirect_wait_x(struct glx_context *gc)
SyncHandle();
}
static void
indirect_bind_tex_image(Display * dpy,
GLXDrawable drawable,
int buffer, const int *attrib_list)
{
xGLXVendorPrivateReq *req;
struct glx_context *gc = __glXGetCurrentContext();
CARD32 *drawable_ptr;
INT32 *buffer_ptr;
CARD32 *num_attrib_ptr;
CARD32 *attrib_ptr;
CARD8 opcode;
unsigned int i;
i = 0;
if (attrib_list) {
while (attrib_list[i * 2] != None)
i++;
}
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return;
LockDisplay(dpy);
GetReqExtra(GLXVendorPrivate, 12 + 8 * i, req);
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivate;
req->vendorCode = X_GLXvop_BindTexImageEXT;
req->contextTag = gc->currentContextTag;
drawable_ptr = (CARD32 *) (req + 1);
buffer_ptr = (INT32 *) (drawable_ptr + 1);
num_attrib_ptr = (CARD32 *) (buffer_ptr + 1);
attrib_ptr = (CARD32 *) (num_attrib_ptr + 1);
*drawable_ptr = drawable;
*buffer_ptr = buffer;
*num_attrib_ptr = (CARD32) i;
i = 0;
if (attrib_list) {
while (attrib_list[i * 2] != None) {
*attrib_ptr++ = (CARD32) attrib_list[i * 2 + 0];
*attrib_ptr++ = (CARD32) attrib_list[i * 2 + 1];
i++;
}
}
UnlockDisplay(dpy);
SyncHandle();
}
static void
indirect_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
{
xGLXVendorPrivateReq *req;
struct glx_context *gc = __glXGetCurrentContext();
CARD32 *drawable_ptr;
INT32 *buffer_ptr;
CARD8 opcode;
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return;
LockDisplay(dpy);
GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32), req);
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivate;
req->vendorCode = X_GLXvop_ReleaseTexImageEXT;
req->contextTag = gc->currentContextTag;
drawable_ptr = (CARD32 *) (req + 1);
buffer_ptr = (INT32 *) (drawable_ptr + 1);
*drawable_ptr = drawable;
*buffer_ptr = buffer;
UnlockDisplay(dpy);
SyncHandle();
}
static const struct glx_context_vtable indirect_context_vtable = {
.destroy = indirect_destroy_context,
.bind = indirect_bind_context,
.unbind = indirect_unbind_context,
.wait_gl = indirect_wait_gl,
.wait_x = indirect_wait_x,
.bind_tex_image = indirect_bind_tex_image,
.release_tex_image = indirect_release_tex_image,
};
_X_HIDDEN struct glx_context *

View File

@ -44,8 +44,6 @@ const struct glx_context_vtable fake_glx_context::vt = {
NULL,
NULL,
NULL,
NULL,
NULL,
};
int fake_glx_context::contexts_allocated = 0;