diff options
author | Alan Hourihane <alanh@vmware.com> | 2009-02-16 11:39:34 +0000 |
---|---|---|
committer | Alan Hourihane <alanh@vmware.com> | 2009-02-16 11:45:55 +0000 |
commit | 2a8b8077d8f6001eb57deba60e1009fc99c28668 (patch) | |
tree | e6c9c9360a5762b65719e7d7151e09ce755999e6 | |
parent | ddb8d8945d1f44d16adc366b6612eef20ae813f7 (diff) |
dri2: support glXWaitGL & glXWaitX by copying fake front to front and
vice-versa.
-rw-r--r-- | glx/glxcmds.c | 39 | ||||
-rw-r--r-- | glx/glxdrawable.h | 2 | ||||
-rw-r--r-- | glx/glxdri.c | 2 | ||||
-rw-r--r-- | glx/glxdri2.c | 35 |
4 files changed, 67 insertions, 11 deletions
diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 33954ee64..8b6dfbc84 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c | |||
@@ -760,29 +760,46 @@ int __glXDisp_QueryVersion(__GLXclientState *cl, GLbyte *pc) | |||
760 | int __glXDisp_WaitGL(__GLXclientState *cl, GLbyte *pc) | 760 | int __glXDisp_WaitGL(__GLXclientState *cl, GLbyte *pc) |
761 | { | 761 | { |
762 | xGLXWaitGLReq *req = (xGLXWaitGLReq *)pc; | 762 | xGLXWaitGLReq *req = (xGLXWaitGLReq *)pc; |
763 | GLXContextTag tag = req->contextTag; | ||
764 | __GLXcontext *glxc = NULL; | ||
763 | int error; | 765 | int error; |
766 | |||
767 | if (tag) { | ||
768 | glxc = __glXLookupContextByTag(cl, tag); | ||
769 | if (!glxc) | ||
770 | return __glXError(GLXBadContextTag); | ||
764 | 771 | ||
765 | if (!__glXForceCurrent(cl, req->contextTag, &error)) { | 772 | if (!__glXForceCurrent(cl, req->contextTag, &error)) |
766 | return error; | 773 | return error; |
774 | |||
775 | CALL_Finish( GET_DISPATCH(), () ); | ||
767 | } | 776 | } |
768 | CALL_Finish( GET_DISPATCH(), () ); | 777 | |
778 | if (glxc && glxc->drawPriv->waitGL) | ||
779 | (*glxc->drawPriv->waitGL)(glxc->drawPriv); | ||
780 | |||
769 | return Success; | 781 | return Success; |
770 | } | 782 | } |
771 | 783 | ||
772 | int __glXDisp_WaitX(__GLXclientState *cl, GLbyte *pc) | 784 | int __glXDisp_WaitX(__GLXclientState *cl, GLbyte *pc) |
773 | { | 785 | { |
774 | xGLXWaitXReq *req = (xGLXWaitXReq *)pc; | 786 | xGLXWaitXReq *req = (xGLXWaitXReq *)pc; |
787 | GLXContextTag tag = req->contextTag; | ||
788 | __GLXcontext *glxc = NULL; | ||
775 | int error; | 789 | int error; |
790 | |||
791 | if (tag) { | ||
792 | glxc = __glXLookupContextByTag(cl, tag); | ||
793 | if (!glxc) | ||
794 | return __glXError(GLXBadContextTag); | ||
776 | 795 | ||
777 | if (!__glXForceCurrent(cl, req->contextTag, &error)) { | 796 | if (!__glXForceCurrent(cl, req->contextTag, &error)) |
778 | return error; | 797 | return error; |
779 | } | 798 | } |
780 | /* | 799 | |
781 | ** In a multithreaded server that had separate X and GL threads, we would | 800 | if (glxc && glxc->drawPriv->waitGL) |
782 | ** have to wait for the X thread to finish before returning. As it stands, | 801 | (*glxc->drawPriv->waitGL)(glxc->drawPriv); |
783 | ** this sample implementation only supports singlethreaded servers, and | 802 | |
784 | ** nothing needs to be done here. | ||
785 | */ | ||
786 | return Success; | 803 | return Success; |
787 | } | 804 | } |
788 | 805 | ||
diff --git a/glx/glxdrawable.h b/glx/glxdrawable.h index 45000bfb7..259b11e17 100644 --- a/glx/glxdrawable.h +++ b/glx/glxdrawable.h | |||
@@ -49,6 +49,8 @@ struct __GLXdrawable { | |||
49 | GLboolean (*swapBuffers)(__GLXdrawable *); | 49 | GLboolean (*swapBuffers)(__GLXdrawable *); |
50 | void (*copySubBuffer)(__GLXdrawable *drawable, | 50 | void (*copySubBuffer)(__GLXdrawable *drawable, |
51 | int x, int y, int w, int h); | 51 | int x, int y, int w, int h); |
52 | void (*waitX)(__GLXdrawable *); | ||
53 | void (*waitGL)(__GLXdrawable *); | ||
52 | 54 | ||
53 | DrawablePtr pDraw; | 55 | DrawablePtr pDraw; |
54 | XID drawId; | 56 | XID drawId; |
diff --git a/glx/glxdri.c b/glx/glxdri.c index fb9578243..b3b3e279b 100644 --- a/glx/glxdri.c +++ b/glx/glxdri.c | |||
@@ -704,6 +704,8 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen, | |||
704 | private->base.destroy = __glXDRIdrawableDestroy; | 704 | private->base.destroy = __glXDRIdrawableDestroy; |
705 | private->base.swapBuffers = __glXDRIdrawableSwapBuffers; | 705 | private->base.swapBuffers = __glXDRIdrawableSwapBuffers; |
706 | private->base.copySubBuffer = __glXDRIdrawableCopySubBuffer; | 706 | private->base.copySubBuffer = __glXDRIdrawableCopySubBuffer; |
707 | private->base.waitX = NULL; | ||
708 | private->base.waitGL = NULL; | ||
707 | 709 | ||
708 | __glXenterServer(GL_FALSE); | 710 | __glXenterServer(GL_FALSE); |
709 | retval = DRICreateDrawable(screen->pScreen, serverClient, | 711 | retval = DRICreateDrawable(screen->pScreen, serverClient, |
diff --git a/glx/glxdri2.c b/glx/glxdri2.c index 87c39595a..66e08895c 100644 --- a/glx/glxdri2.c +++ b/glx/glxdri2.c | |||
@@ -139,6 +139,39 @@ __glXDRIdrawableSwapBuffers(__GLXdrawable *drawable) | |||
139 | return TRUE; | 139 | return TRUE; |
140 | } | 140 | } |
141 | 141 | ||
142 | static void | ||
143 | __glXDRIdrawableWaitX(__GLXdrawable *drawable) | ||
144 | { | ||
145 | __GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable; | ||
146 | BoxRec box; | ||
147 | RegionRec region; | ||
148 | |||
149 | box.x1 = 0; | ||
150 | box.y1 = 0; | ||
151 | box.x2 = private->width; | ||
152 | box.y2 = private->height; | ||
153 | REGION_INIT(drawable->pDraw->pScreen, ®ion, &box, 0); | ||
154 | |||
155 | DRI2CopyRegion(drawable->pDraw, ®ion, | ||
156 | DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft); | ||
157 | } | ||
158 | |||
159 | static void | ||
160 | __glXDRIdrawableWaitGL(__GLXdrawable *drawable) | ||
161 | { | ||
162 | __GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable; | ||
163 | BoxRec box; | ||
164 | RegionRec region; | ||
165 | |||
166 | box.x1 = 0; | ||
167 | box.y1 = 0; | ||
168 | box.x2 = private->width; | ||
169 | box.y2 = private->height; | ||
170 | REGION_INIT(drawable->pDraw->pScreen, ®ion, &box, 0); | ||
171 | |||
172 | DRI2CopyRegion(drawable->pDraw, ®ion, | ||
173 | DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); | ||
174 | } | ||
142 | 175 | ||
143 | static int | 176 | static int |
144 | __glXDRIdrawableSwapInterval(__GLXdrawable *drawable, int interval) | 177 | __glXDRIdrawableSwapInterval(__GLXdrawable *drawable, int interval) |
@@ -337,6 +370,8 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen, | |||
337 | private->base.destroy = __glXDRIdrawableDestroy; | 370 | private->base.destroy = __glXDRIdrawableDestroy; |
338 | private->base.swapBuffers = __glXDRIdrawableSwapBuffers; | 371 | private->base.swapBuffers = __glXDRIdrawableSwapBuffers; |
339 | private->base.copySubBuffer = __glXDRIdrawableCopySubBuffer; | 372 | private->base.copySubBuffer = __glXDRIdrawableCopySubBuffer; |
373 | private->base.waitGL = __glXDRIdrawableWaitGL; | ||
374 | private->base.waitX = __glXDRIdrawableWaitX; | ||
340 | 375 | ||
341 | if (DRI2CreateDrawable(pDraw)) { | 376 | if (DRI2CreateDrawable(pDraw)) { |
342 | xfree(private); | 377 | xfree(private); |