hardware/intel/libva
リビジョン | 06d54f63325ec7ed10456c6665d7c6cac1616169 (tree) |
---|---|
日時 | 2010-06-02 14:51:12 |
作者 | Xiang, Haihao <haihao.xiang@inte...> |
コミッター | Xiang, Haihao |
libva: update DRI2 to support swapbuffer
@@ -35,6 +35,8 @@ struct dri2_drawable | ||
35 | 35 | int front_index; |
36 | 36 | }; |
37 | 37 | |
38 | +static int gsDRI2SwapAvailable; | |
39 | + | |
38 | 40 | static struct dri_drawable * |
39 | 41 | dri2CreateDrawable(VADriverContextP ctx, XID x_drawable) |
40 | 42 | { |
@@ -68,15 +70,21 @@ dri2SwapBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable) | ||
68 | 70 | XserverRegion region; |
69 | 71 | |
70 | 72 | 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 | + } | |
80 | 88 | } |
81 | 89 | } |
82 | 90 |
@@ -91,7 +99,6 @@ dri2GetRenderingBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable) | ||
91 | 99 | |
92 | 100 | i = 0; |
93 | 101 | attachments[i++] = __DRI_BUFFER_BACK_LEFT; |
94 | - attachments[i++] = __DRI_BUFFER_FRONT_LEFT; | |
95 | 102 | buffers = VA_DRI2GetBuffers(ctx->x11_dpy, dri_drawable->x_drawable, |
96 | 103 | &dri2_drawable->width, &dri2_drawable->height, |
97 | 104 | attachments, i, &count); |
@@ -179,6 +186,7 @@ isDRI2Connected(VADriverContextP ctx, char **driver_name) | ||
179 | 186 | dri_state->swapBuffer = dri2SwapBuffer; |
180 | 187 | dri_state->getRenderingBuffer = dri2GetRenderingBuffer; |
181 | 188 | dri_state->close = dri2Close; |
189 | + gsDRI2SwapAvailable = (minor >= 2); | |
182 | 190 | |
183 | 191 | return True; |
184 | 192 |
@@ -305,3 +305,45 @@ void VA_DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region, | ||
305 | 305 | UnlockDisplay(dpy); |
306 | 306 | SyncHandle(); |
307 | 307 | } |
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 | +} |
@@ -33,6 +33,7 @@ | ||
33 | 33 | #ifndef _VA_DRI2_H_ |
34 | 34 | #define _VA_DRI2_H_ |
35 | 35 | |
36 | +#include <X11/Xproto.h> | |
36 | 37 | #include <X11/extensions/Xfixes.h> |
37 | 38 | #include <X11/Xfuncproto.h> |
38 | 39 | #include <xf86drm.h> |
@@ -63,9 +64,10 @@ VA_DRI2GetBuffers(Display *dpy, XID drawable, | ||
63 | 64 | int *width, int *height, |
64 | 65 | unsigned int *attachments, int count, |
65 | 66 | int *outCount); |
66 | -#if 0 | |
67 | 67 | extern void |
68 | 68 | 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); | |
71 | 73 | #endif |
@@ -35,11 +35,11 @@ | ||
35 | 35 | |
36 | 36 | #define DRI2_NAME "DRI2" |
37 | 37 | #define DRI2_MAJOR 1 |
38 | -#define DRI2_MINOR 0 | |
38 | +#define DRI2_MINOR 2 | |
39 | 39 | |
40 | 40 | #define DRI2NumberErrors 0 |
41 | -#define DRI2NumberEvents 0 | |
42 | -#define DRI2NumberRequests 7 | |
41 | +#define DRI2NumberEvents 2 | |
42 | +#define DRI2NumberRequests 13 | |
43 | 43 | |
44 | 44 | #define X_DRI2QueryVersion 0 |
45 | 45 | #define X_DRI2Connect 1 |
@@ -48,6 +48,12 @@ | ||
48 | 48 | #define X_DRI2DestroyDrawable 4 |
49 | 49 | #define X_DRI2GetBuffers 5 |
50 | 50 | #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 | |
51 | 57 | |
52 | 58 | typedef struct { |
53 | 59 | CARD32 attachment B32; |
@@ -190,4 +196,32 @@ typedef struct { | ||
190 | 196 | } xDRI2CopyRegionReply; |
191 | 197 | #define sz_xDRI2CopyRegionReply 32 |
192 | 198 | |
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 | + | |
193 | 227 | #endif |