• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/intel/libva


Commit MetaInfo

Revisão06d54f63325ec7ed10456c6665d7c6cac1616169 (tree)
Hora2010-06-02 14:51:12
AutorXiang, Haihao <haihao.xiang@inte...>
CommiterXiang, Haihao

Mensagem de Log

libva: update DRI2 to support swapbuffer

Mudança Sumário

Diff

--- a/va/x11/dri2_util.c
+++ b/va/x11/dri2_util.c
@@ -35,6 +35,8 @@ struct dri2_drawable
3535 int front_index;
3636 };
3737
38+static int gsDRI2SwapAvailable;
39+
3840 static struct dri_drawable *
3941 dri2CreateDrawable(VADriverContextP ctx, XID x_drawable)
4042 {
@@ -68,15 +70,21 @@ dri2SwapBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
6870 XserverRegion region;
6971
7072 if (dri2_drawable->has_backbuffer) {
71- xrect.x = 0;
72- xrect.y = 0;
73- xrect.width = dri2_drawable->width;
74- xrect.height = dri2_drawable->height;
75-
76- region = XFixesCreateRegion(ctx->x11_dpy, &xrect, 1);
77- VA_DRI2CopyRegion(ctx->x11_dpy, dri_drawable->x_drawable, region,
78- DRI2BufferFrontLeft, DRI2BufferBackLeft);
79- XFixesDestroyRegion(ctx->x11_dpy, region);
73+ if (gsDRI2SwapAvailable) {
74+ CARD64 ret;
75+ VA_DRI2SwapBuffers(ctx->x11_dpy, dri_drawable->x_drawable, 0, 0,
76+ 0, &ret);
77+ } else {
78+ xrect.x = 0;
79+ xrect.y = 0;
80+ xrect.width = dri2_drawable->width;
81+ xrect.height = dri2_drawable->height;
82+
83+ region = XFixesCreateRegion(ctx->x11_dpy, &xrect, 1);
84+ VA_DRI2CopyRegion(ctx->x11_dpy, dri_drawable->x_drawable, region,
85+ DRI2BufferFrontLeft, DRI2BufferBackLeft);
86+ XFixesDestroyRegion(ctx->x11_dpy, region);
87+ }
8088 }
8189 }
8290
@@ -91,7 +99,6 @@ dri2GetRenderingBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
9199
92100 i = 0;
93101 attachments[i++] = __DRI_BUFFER_BACK_LEFT;
94- attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
95102 buffers = VA_DRI2GetBuffers(ctx->x11_dpy, dri_drawable->x_drawable,
96103 &dri2_drawable->width, &dri2_drawable->height,
97104 attachments, i, &count);
@@ -179,6 +186,7 @@ isDRI2Connected(VADriverContextP ctx, char **driver_name)
179186 dri_state->swapBuffer = dri2SwapBuffer;
180187 dri_state->getRenderingBuffer = dri2GetRenderingBuffer;
181188 dri_state->close = dri2Close;
189+ gsDRI2SwapAvailable = (minor >= 2);
182190
183191 return True;
184192
--- a/va/x11/va_dri2.c
+++ b/va/x11/va_dri2.c
@@ -305,3 +305,45 @@ void VA_DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
305305 UnlockDisplay(dpy);
306306 SyncHandle();
307307 }
308+
309+static void
310+load_swap_req(xDRI2SwapBuffersReq *req, CARD64 target, CARD64 divisor,
311+ CARD64 remainder)
312+{
313+ req->target_msc_hi = target >> 32;
314+ req->target_msc_lo = target & 0xffffffff;
315+ req->divisor_hi = divisor >> 32;
316+ req->divisor_lo = divisor & 0xffffffff;
317+ req->remainder_hi = remainder >> 32;
318+ req->remainder_lo = remainder & 0xffffffff;
319+}
320+
321+static CARD64
322+vals_to_card64(CARD32 lo, CARD32 hi)
323+{
324+ return (CARD64)hi << 32 | lo;
325+}
326+
327+void VA_DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc,
328+ CARD64 divisor, CARD64 remainder, CARD64 *count)
329+{
330+ XExtDisplayInfo *info = DRI2FindDisplay(dpy);
331+ xDRI2SwapBuffersReq *req;
332+ xDRI2SwapBuffersReply rep;
333+
334+ XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName);
335+
336+ LockDisplay(dpy);
337+ GetReq(DRI2SwapBuffers, req);
338+ req->reqType = info->codes->major_opcode;
339+ req->dri2ReqType = X_DRI2SwapBuffers;
340+ req->drawable = drawable;
341+ load_swap_req(req, target_msc, divisor, remainder);
342+
343+ _XReply(dpy, (xReply *)&rep, 0, xFalse);
344+
345+ *count = vals_to_card64(rep.swap_lo, rep.swap_hi);
346+
347+ UnlockDisplay(dpy);
348+ SyncHandle();
349+}
--- a/va/x11/va_dri2.h
+++ b/va/x11/va_dri2.h
@@ -33,6 +33,7 @@
3333 #ifndef _VA_DRI2_H_
3434 #define _VA_DRI2_H_
3535
36+#include <X11/Xproto.h>
3637 #include <X11/extensions/Xfixes.h>
3738 #include <X11/Xfuncproto.h>
3839 #include <xf86drm.h>
@@ -63,9 +64,10 @@ VA_DRI2GetBuffers(Display *dpy, XID drawable,
6364 int *width, int *height,
6465 unsigned int *attachments, int count,
6566 int *outCount);
66-#if 0
6767 extern void
6868 VA_DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
69- CARD32 dest, CARD32 src);
70-#endif
69+ CARD32 dest, CARD32 src);
70+extern void
71+VA_DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
72+ CARD64 remainder, CARD64 *count);
7173 #endif
--- a/va/x11/va_dri2str.h
+++ b/va/x11/va_dri2str.h
@@ -35,11 +35,11 @@
3535
3636 #define DRI2_NAME "DRI2"
3737 #define DRI2_MAJOR 1
38-#define DRI2_MINOR 0
38+#define DRI2_MINOR 2
3939
4040 #define DRI2NumberErrors 0
41-#define DRI2NumberEvents 0
42-#define DRI2NumberRequests 7
41+#define DRI2NumberEvents 2
42+#define DRI2NumberRequests 13
4343
4444 #define X_DRI2QueryVersion 0
4545 #define X_DRI2Connect 1
@@ -48,6 +48,12 @@
4848 #define X_DRI2DestroyDrawable 4
4949 #define X_DRI2GetBuffers 5
5050 #define X_DRI2CopyRegion 6
51+#define X_DRI2GetBuffersWithFormat 7
52+#define X_DRI2SwapBuffers 8
53+#define X_DRI2GetMSC 9
54+#define X_DRI2WaitMSC 10
55+#define X_DRI2WaitSBC 11
56+#define X_DRI2SwapInterval 12
5157
5258 typedef struct {
5359 CARD32 attachment B32;
@@ -190,4 +196,32 @@ typedef struct {
190196 } xDRI2CopyRegionReply;
191197 #define sz_xDRI2CopyRegionReply 32
192198
199+typedef struct {
200+ CARD8 reqType;
201+ CARD8 dri2ReqType;
202+ CARD16 length B16;
203+ CARD32 drawable B32;
204+ CARD32 target_msc_hi B32;
205+ CARD32 target_msc_lo B32;
206+ CARD32 divisor_hi B32;
207+ CARD32 divisor_lo B32;
208+ CARD32 remainder_hi B32;
209+ CARD32 remainder_lo B32;
210+} xDRI2SwapBuffersReq;
211+#define sz_xDRI2SwapBuffersReq 32
212+
213+typedef struct {
214+ BYTE type; /* X_Reply */
215+ BYTE pad1;
216+ CARD16 sequenceNumber B16;
217+ CARD32 length B32;
218+ CARD32 swap_hi B32;
219+ CARD32 swap_lo B32;
220+ CARD32 pad2 B32;
221+ CARD32 pad3 B32;
222+ CARD32 pad4 B32;
223+ CARD32 pad5 B32;
224+} xDRI2SwapBuffersReply;
225+#define sz_xDRI2SwapBuffersReply 32
226+
193227 #endif