glx: add drawable type argument when create drawable

For distinguish different behavior of pixmap and pbuffer
in latter commits.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13750>
This commit is contained in:
Qiang Yu 2021-11-09 17:19:44 +08:00 committed by Marge Bot
parent 6625c960c5
commit 887f5a6320
8 changed files with 26 additions and 16 deletions

View File

@ -309,7 +309,8 @@ dri2DestroyDrawable(__GLXDRIdrawable *base)
static __GLXDRIdrawable *
dri2CreateDrawable(struct glx_screen *base, XID xDrawable,
GLXDrawable drawable, struct glx_config *config_base)
GLXDrawable drawable, int type,
struct glx_config *config_base)
{
struct dri2_drawable *pdraw;
struct dri2_screen *psc = (struct dri2_screen *) base;

View File

@ -344,7 +344,8 @@ dri3_destroy_drawable(__GLXDRIdrawable *base)
static __GLXDRIdrawable *
dri3_create_drawable(struct glx_screen *base, XID xDrawable,
GLXDrawable drawable, struct glx_config *config_base)
GLXDrawable drawable, int type,
struct glx_config *config_base)
{
struct dri3_drawable *pdraw;
struct dri3_screen *psc = (struct dri3_screen *) base;

View File

@ -405,7 +405,7 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
}
pdraw = psc->driScreen->createDrawable(psc, glxDrawable, glxDrawable,
config);
type, config);
if (pdraw == NULL) {
ErrorMessageF("failed to create drawable\n");

View File

@ -605,7 +605,8 @@ driswDestroyDrawable(__GLXDRIdrawable * pdraw)
static __GLXDRIdrawable *
driswCreateDrawable(struct glx_screen *base, XID xDrawable,
GLXDrawable drawable, struct glx_config *modes)
GLXDrawable drawable, int type,
struct glx_config *modes)
{
struct drisw_drawable *pdp;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;

View File

@ -258,7 +258,8 @@ driwindowsDestroyDrawable(__GLXDRIdrawable * pdraw)
static __GLXDRIdrawable *
driwindowsCreateDrawable(struct glx_screen *base, XID xDrawable,
GLXDrawable drawable, struct glx_config *modes)
GLXDrawable drawable, int type,
struct glx_config *modes)
{
struct driwindows_drawable *pdp;
struct driwindows_screen *psc = (struct driwindows_screen *) base;

View File

@ -168,7 +168,7 @@ determineTextureFormat(const int *attribs, int numAttribs)
static GLboolean
CreateDRIDrawable(Display *dpy, struct glx_config *config,
XID drawable, XID glxdrawable,
XID drawable, XID glxdrawable, int type,
const int *attrib_list, size_t num_attribs)
{
#ifdef GLX_DIRECT_RENDERING
@ -185,8 +185,8 @@ CreateDRIDrawable(Display *dpy, struct glx_config *config,
if (psc->driScreen == NULL)
return GL_TRUE;
pdraw = psc->driScreen->createDrawable(psc, drawable,
glxdrawable, config);
pdraw = psc->driScreen->createDrawable(psc, drawable, glxdrawable,
type, config);
if (pdraw == NULL) {
fprintf(stderr, "failed to create drawable\n");
return GL_FALSE;
@ -435,7 +435,7 @@ protocolDestroyDrawable(Display *dpy, GLXDrawable drawable, CARD32 glxCode)
*/
static GLXDrawable
CreateDrawable(Display *dpy, struct glx_config *config,
Drawable drawable, const int *attrib_list, CARD8 glxCode)
Drawable drawable, int type, const int *attrib_list)
{
xGLXCreateWindowReq *req;
struct glx_drawable *glxDraw;
@ -466,13 +466,17 @@ CreateDrawable(Display *dpy, struct glx_config *config,
data = (CARD32 *) (req + 1);
req->reqType = opcode;
req->glxCode = glxCode;
req->screen = config->screen;
req->fbconfig = config->fbconfigID;
req->window = drawable;
req->glxwindow = xid = XAllocID(dpy);
req->numAttribs = i;
if (type == GLX_WINDOW_BIT)
req->glxCode = X_GLXCreateWindow;
else
req->glxCode = X_GLXCreatePixmap;
if (attrib_list)
memcpy(data, attrib_list, 8 * i);
@ -484,8 +488,9 @@ CreateDrawable(Display *dpy, struct glx_config *config,
return None;
}
if (!CreateDRIDrawable(dpy, config, drawable, xid, attrib_list, i)) {
if (glxCode == X_GLXCreatePixmap)
if (!CreateDRIDrawable(dpy, config, drawable, xid, type, attrib_list, i)) {
CARD8 glxCode;
if (type == GLX_PIXMAP_BIT)
glxCode = X_GLXDestroyPixmap;
else
glxCode = X_GLXDestroyWindow;
@ -602,7 +607,7 @@ CreatePbuffer(Display * dpy, struct glx_config *config,
SyncHandle();
/* xserver created a pixmap with the same id as pbuffer */
if (!CreateDRIDrawable(dpy, config, id, id, attrib_list, i)) {
if (!CreateDRIDrawable(dpy, config, id, id, GLX_PBUFFER_BIT, attrib_list, i)) {
CARD32 o = glx_1_3 ? X_GLXDestroyPbuffer : X_GLXvop_DestroyGLXPbufferSGIX;
protocolDestroyDrawable(dpy, id, o);
id = None;
@ -916,7 +921,7 @@ glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap,
return pixmap;
#else
return CreateDrawable(dpy, (struct glx_config *) config,
(Drawable) pixmap, attrib_list, X_GLXCreatePixmap);
(Drawable) pixmap, GLX_PIXMAP_BIT, attrib_list);
#endif
}
@ -950,7 +955,7 @@ glXCreateWindow(Display * dpy, GLXFBConfig config, Window win,
return win;
#else
return CreateDrawable(dpy, (struct glx_config *) config,
(Drawable) win, attrib_list, X_GLXCreateWindow);
(Drawable) win, GLX_WINDOW_BIT, attrib_list);
#endif
}

View File

@ -117,6 +117,7 @@ struct __GLXDRIscreenRec {
__GLXDRIdrawable *(*createDrawable)(struct glx_screen *psc,
XID drawable,
GLXDrawable glxDrawable,
int type,
struct glx_config *config);
int64_t (*swapBuffers)(__GLXDRIdrawable *pdraw, int64_t target_msc,

View File

@ -762,7 +762,7 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
return xid;
config = glx_config_find_visual(psc->visuals, vis->visualid);
pdraw = psc->driScreen->createDrawable(psc, pixmap, xid, config);
pdraw = psc->driScreen->createDrawable(psc, pixmap, xid, GLX_PIXMAP_BIT, config);
if (pdraw == NULL) {
fprintf(stderr, "failed to create pixmap\n");
xid = None;