By default Xlib isn't thread safe so we better avoid it when gl thread
is enabled.
It will help applications that use XCB. But it will still crash if
applications are still relying on Xlib (without XInitThread).
Note: those dri2* functions are typically called by gallium/mesa state
tracker to handle new backbuffer allocation. When the old backbuffer was
previously invalidated due to vsync.
Signed-off-by: Gregory Hainaut
---
src/glx/dri2.c | 118 -
src/glx/dri2.h | 25
src/glx/dri2_glx.c | 64 +
3 files changed, 47 insertions(+), 160 deletions(-)
diff --git a/src/glx/dri2.c b/src/glx/dri2.c
index f00b96525a..eed899e237 100644
--- a/src/glx/dri2.c
+++ b/src/glx/dri2.c
@@ -391,138 +391,20 @@ DRI2DestroyDrawable(Display * dpy, XID drawable)
LockDisplay(dpy);
GetReq(DRI2DestroyDrawable, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2DestroyDrawable;
req->drawable = drawable;
UnlockDisplay(dpy);
SyncHandle();
}
-DRI2Buffer *
-DRI2GetBuffers(Display * dpy, XID drawable,
- int *width, int *height,
- unsigned int *attachments, int count, int *outCount)
-{
- XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2GetBuffersReply rep;
- xDRI2GetBuffersReq *req;
- DRI2Buffer *buffers;
- xDRI2Buffer repBuffer;
- CARD32 *p;
- int i;
-
- XextCheckExtension(dpy, info, dri2ExtensionName, False);
-
- LockDisplay(dpy);
- GetReqExtra(DRI2GetBuffers, count * 4, req);
- req->reqType = info->codes->major_opcode;
- req->dri2ReqType = X_DRI2GetBuffers;
- req->drawable = drawable;
- req->count = count;
- p = (CARD32 *) & req[1];
- for (i = 0; i < count; i++)
- p[i] = attachments[i];
-
- if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return NULL;
- }
-
- *width = rep.width;
- *height = rep.height;
- *outCount = rep.count;
-
- buffers = malloc(rep.count * sizeof buffers[0]);
- if (buffers == NULL) {
- _XEatData(dpy, rep.count * sizeof repBuffer);
- UnlockDisplay(dpy);
- SyncHandle();
- return NULL;
- }
-
- for (i = 0; i < rep.count; i++) {
- _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
- buffers[i].attachment = repBuffer.attachment;
- buffers[i].name = repBuffer.name;
- buffers[i].pitch = repBuffer.pitch;
- buffers[i].cpp = repBuffer.cpp;
- buffers[i].flags = repBuffer.flags;
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- return buffers;
-}
-
-
-DRI2Buffer *
-DRI2GetBuffersWithFormat(Display * dpy, XID drawable,
- int *width, int *height,
- unsigned int *attachments, int count, int *outCount)
-{
- XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2GetBuffersReply rep;
- xDRI2GetBuffersReq *req;
- DRI2Buffer *buffers;
- xDRI2Buffer repBuffer;
- CARD32 *p;
- int i;
-
- XextCheckExtension(dpy, info, dri2ExtensionName, False);
-
- LockDisplay(dpy);
- GetReqExtra(DRI2GetBuffers, count * (4 * 2), req);
- req->reqType = info->codes->major_opcode;
- req->dri2ReqType = X_DRI2GetBuffersWithFormat;
- req->drawable = drawable;
- req->count = count;
- p = (CARD32 *) & req[1];
- for (i = 0; i < (count * 2); i++)
- p[i] = attachments[i];
-
- if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return NULL;
- }
-
- *width = rep.width;
- *height = rep.height;
- *outCount = rep.count;
-
- buffers = malloc(rep.count * sizeof buffers[0]);
- if (buffers == NULL) {
- _XEatData(dpy, rep.count * sizeof repBuffer);
- UnlockDisplay(dpy);
- SyncHandle();
- return NULL;
- }
-
- for (i = 0; i < rep.count; i++) {
- _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
- buffers[i].attachment = repBuffer.attachment;
- buffers[i].name = repBuffer.name;
- buffers[i].pitch = repBuffer.pitch;
- buffers[i].cpp = repBuffer.cpp;
- buffers[i].flags = repBuffer.flags;
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- return buffers;
-}
-
-
void
DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region,
CARD32 dest, CARD32 src)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2CopyRegionReq *req;
xDRI2CopyRegionReply rep;
XextSimpleCheckExtension(dpy, info, dri2ExtensionName);
diff --git a/src/glx/dri2.h b/src/glx/dri2.h
index 4be5bf8eb8..c383e27123 100644
--- a/src/glx/dri2.h
+++ b/src/glx/dri2.h
@@ -30,29 +30,20 @@
* Kristian Høgsberg (k...@redhat.com)
*/
#ifndef _DRI2_H_
#define _DRI2_H_
#include
#include
#include
-typedef struct
-{
- unsigned int attachment;
- unsigned int name;
- unsigned int pitch;
- unsigned int cpp;
- unsigned int flags;
-} DRI2Buffer;
-
struct glx_screen;
extern Bool
DRI2QueryExtension(Di