summaryrefslogtreecommitdiffstats
path: root/meta-emenlow/recipes-graphics/libva/libva-0.31.0/038_g45_vaPutSurface_cliprects.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-emenlow/recipes-graphics/libva/libva-0.31.0/038_g45_vaPutSurface_cliprects.patch')
-rw-r--r--meta-emenlow/recipes-graphics/libva/libva-0.31.0/038_g45_vaPutSurface_cliprects.patch531
1 files changed, 531 insertions, 0 deletions
diff --git a/meta-emenlow/recipes-graphics/libva/libva-0.31.0/038_g45_vaPutSurface_cliprects.patch b/meta-emenlow/recipes-graphics/libva/libva-0.31.0/038_g45_vaPutSurface_cliprects.patch
new file mode 100644
index 00000000..ca2e1bd4
--- /dev/null
+++ b/meta-emenlow/recipes-graphics/libva/libva-0.31.0/038_g45_vaPutSurface_cliprects.patch
@@ -0,0 +1,531 @@
1From 90de12a47e26ccc0b4cc8189c76991609481870d Mon Sep 17 00:00:00 2001
2From: Gwenole Beauchesne <gbeauchesne@splitted-desktop.com>
3Date: Wed, 4 Nov 2009 17:34:53 +0000
4Subject: [PATCH] [G45] Handle cliprects in vaPutSurface().
5
6---
7 i965_drv_video/i965_drv_video.c | 39 ++++--
8 i965_drv_video/i965_render.c | 284 +++++++++++++++++++--------------------
9 i965_drv_video/i965_render.h | 30 ++---
10 3 files changed, 176 insertions(+), 177 deletions(-)
11
12diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c
13index e8f638c..20d6bab 100644
14--- a/i965_drv_video/i965_drv_video.c
15+++ b/i965_drv_video/i965_drv_video.c
16@@ -1507,13 +1507,23 @@ i965_PutSurface(VADriverContextP ctx,
17 union dri_buffer *buffer;
18 struct intel_region *dest_region;
19 struct object_surface *obj_surface;
20- int ret;
21+ int ret;
22 uint32_t name;
23+ VARectangle src_rect, dst_rect;
24 Bool new_region = False;
25+
26 /* Currently don't support DRI1 */
27 if (dri_state->driConnectedFlag != VA_DRI2)
28 return VA_STATUS_ERROR_UNKNOWN;
29
30+ /* XXX: we currently only support up to 64 cliprects */
31+ if (number_cliprects > MAX_CLIP_RECTS)
32+ return VA_STATUS_ERROR_OPERATION_FAILED;
33+
34+ obj_surface = SURFACE(surface);
35+ if (!obj_surface)
36+ return VA_STATUS_ERROR_INVALID_SURFACE;
37+
38 dri_drawable = dri_get_drawable(ctx, draw);
39 assert(dri_drawable);
40
41@@ -1552,17 +1562,24 @@ i965_PutSurface(VADriverContextP ctx,
42 assert(ret == 0);
43 }
44
45- i965_render_put_surface(ctx, surface,
46- srcx, srcy, srcw, srch,
47- destx, desty, destw, desth);
48- obj_surface = SURFACE(surface);
49- if(obj_surface->subpic != VA_INVALID_ID) {
50- i965_render_put_subpic(ctx, surface,
51- srcx, srcy, srcw, srch,
52- destx, desty, destw, desth);
53- }
54- dri_swap_buffer(ctx, dri_drawable);
55+ src_rect.x = srcx;
56+ src_rect.y = srcy;
57+ src_rect.width = srcw;
58+ src_rect.height = srch;
59+
60+ dst_rect.x = destx;
61+ dst_rect.y = desty;
62+ dst_rect.width = destw;
63+ dst_rect.height = desth;
64
65+ i965_render_put_surface(ctx, surface, &src_rect, &dst_rect,
66+ cliprects, number_cliprects);
67+
68+ if (obj_surface->subpic != VA_INVALID_ID)
69+ i965_render_put_subpic(ctx, surface, &src_rect, &dst_rect,
70+ cliprects, number_cliprects);
71+
72+ dri_swap_buffer(ctx, dri_drawable);
73 return VA_STATUS_SUCCESS;
74 }
75
76diff --git a/i965_drv_video/i965_render.c b/i965_drv_video/i965_render.c
77index 0476087..d7cd8fe 100644
78--- a/i965_drv_video/i965_render.c
79+++ b/i965_drv_video/i965_render.c
80@@ -787,13 +787,81 @@ i965_render_binding_table(VADriverContextP ctx)
81 dri_bo_unmap(render_state->wm.binding_table);
82 }
83
84-static void
85+static unsigned int
86+i965_render_do_upload_vertex(VADriverContextP ctx,
87+ unsigned int width,
88+ unsigned int height,
89+ const VARectangle *src_rect,
90+ const VARectangle *dst_rect,
91+ const VARectangle *cliprects,
92+ unsigned int num_cliprects)
93+{
94+ struct i965_driver_data *i965 = i965_driver_data(ctx);
95+ struct i965_render_state *render_state = &i965->render_state;
96+ struct intel_region *dest_region = render_state->draw_region;
97+ float *vb, tx1, tx2, ty1, ty2;
98+ int x1, x2, y1, y2;
99+ unsigned int i, n;
100+
101+ if (!cliprects || num_cliprects == 0) {
102+ cliprects = dst_rect;
103+ num_cliprects = 1;
104+ }
105+
106+ dri_bo_map(render_state->vb.vertex_buffer, 1);
107+ assert(render_state->vb.vertex_buffer->virtual);
108+ vb = render_state->vb.vertex_buffer->virtual;
109+
110+ for (n = 0, i = 0; i < num_cliprects; i++) {
111+ x1 = dest_region->x + cliprects[i].x;
112+ y1 = dest_region->y + cliprects[i].y;
113+ x2 = x1 + cliprects[i].width;
114+ y2 = y1 + cliprects[i].height;
115+ x1 = MAX(x1, dst_rect->x);
116+ y1 = MAX(y1, dst_rect->y);
117+ x2 = MIN(x2, dst_rect->x + dst_rect->width);
118+ y2 = MIN(y2, dst_rect->y + dst_rect->height);
119+
120+ if (x2 <= x1 || y2 <= y1)
121+ continue;
122+
123+ const float sx1 = (float)(x1 - dst_rect->x) / (float)dst_rect->width;
124+ const float sy1 = (float)(y1 - dst_rect->y) / (float)dst_rect->height;
125+ const float sx2 = (float)(x2 - dst_rect->x) / (float)dst_rect->width;
126+ const float sy2 = (float)(y2 - dst_rect->y) / (float)dst_rect->height;
127+ tx1 = ((float)src_rect->x + sx1 * (float)src_rect->width) / width;
128+ ty1 = ((float)src_rect->y + sy1 * (float)src_rect->height) / height;
129+ tx2 = ((float)src_rect->x + sx2 * (float)src_rect->width) / width;
130+ ty2 = ((float)src_rect->y + sy2 * (float)src_rect->height) / height;
131+
132+ vb[n++] = tx2;
133+ vb[n++] = ty2;
134+ vb[n++] = x2;
135+ vb[n++] = y2;
136+
137+ vb[n++] = tx1;
138+ vb[n++] = ty2;
139+ vb[n++] = x1;
140+ vb[n++] = y2;
141+
142+ vb[n++] = tx1;
143+ vb[n++] = ty1;
144+ vb[n++] = x1;
145+ vb[n++] = y1;
146+ }
147+
148+ dri_bo_unmap(render_state->vb.vertex_buffer);
149+ return n / 12;
150+}
151+
152+static unsigned int
153 i965_subpic_render_upload_vertex(VADriverContextP ctx,
154 VASurfaceID surface,
155- const VARectangle *output_rect)
156-{
157+ const VARectangle *output_rect,
158+ const VARectangle *cliprects,
159+ unsigned int num_cliprects)
160+{
161 struct i965_driver_data *i965 = i965_driver_data(ctx);
162- struct i965_render_state *render_state = &i965->render_state;
163 struct object_surface *obj_surface = SURFACE(surface);
164 struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic);
165
166@@ -803,8 +871,6 @@ i965_subpic_render_upload_vertex(VADriverContextP ctx,
167 const float ssy = (float)output_rect->height / (float)obj_surface->height;
168 const float sx = psx * ssx;
169 const float sy = psy * ssy;
170- float *vb, tx1, tx2, ty1, ty2, x1, x2, y1, y2;
171- int i = 0;
172
173 VARectangle dst_rect;
174 dst_rect.x = output_rect->x + sx * (float)obj_subpic->dst_rect.x;
175@@ -812,106 +878,38 @@ i965_subpic_render_upload_vertex(VADriverContextP ctx,
176 dst_rect.width = sx * (float)obj_subpic->dst_rect.width;
177 dst_rect.height = sy * (float)obj_subpic->dst_rect.height;
178
179- dri_bo_map(render_state->vb.vertex_buffer, 1);
180- assert(render_state->vb.vertex_buffer->virtual);
181- vb = render_state->vb.vertex_buffer->virtual;
182-
183- tx1 = (float)obj_subpic->src_rect.x / (float)obj_subpic->width;
184- ty1 = (float)obj_subpic->src_rect.y / (float)obj_subpic->height;
185- tx2 = (float)(obj_subpic->src_rect.x + obj_subpic->src_rect.width) / (float)obj_subpic->width;
186- ty2 = (float)(obj_subpic->src_rect.y + obj_subpic->src_rect.height) / (float)obj_subpic->height;
187-
188- x1 = (float)dst_rect.x;
189- y1 = (float)dst_rect.y;
190- x2 = (float)(dst_rect.x + dst_rect.width);
191- y2 = (float)(dst_rect.y + dst_rect.height);
192-
193- vb[i++] = tx2;
194- vb[i++] = ty2;
195- vb[i++] = x2;
196- vb[i++] = y2;
197-
198- vb[i++] = tx1;
199- vb[i++] = ty2;
200- vb[i++] = x1;
201- vb[i++] = y2;
202-
203- vb[i++] = tx1;
204- vb[i++] = ty1;
205- vb[i++] = x1;
206- vb[i++] = y1;
207- dri_bo_unmap(render_state->vb.vertex_buffer);
208+ return i965_render_do_upload_vertex(ctx,
209+ obj_subpic->width, obj_subpic->height,
210+ &obj_subpic->src_rect, &dst_rect,
211+ cliprects, num_cliprects);
212 }
213
214-static void
215+static unsigned int
216 i965_render_upload_vertex(VADriverContextP ctx,
217 VASurfaceID surface,
218- short srcx,
219- short srcy,
220- unsigned short srcw,
221- unsigned short srch,
222- short destx,
223- short desty,
224- unsigned short destw,
225- unsigned short desth)
226+ const VARectangle *src_rect,
227+ const VARectangle *dst_rect,
228+ const VARectangle *cliprects,
229+ unsigned int num_cliprects)
230 {
231 struct i965_driver_data *i965 = i965_driver_data(ctx);
232- struct i965_render_state *render_state = &i965->render_state;
233- struct intel_region *dest_region = render_state->draw_region;
234- struct object_surface *obj_surface;
235- float *vb;
236-
237- float u1, v1, u2, v2;
238- int i, width, height;
239- int box_x1 = dest_region->x + destx;
240- int box_y1 = dest_region->y + desty;
241- int box_x2 = box_x1 + destw;
242- int box_y2 = box_y1 + desth;
243-
244- obj_surface = SURFACE(surface);
245- assert(surface);
246- width = obj_surface->width;
247- height = obj_surface->height;
248-
249- u1 = (float)srcx / width;
250- v1 = (float)srcy / height;
251- u2 = (float)(srcx + srcw) / width;
252- v2 = (float)(srcy + srch) / height;
253-
254- dri_bo_map(render_state->vb.vertex_buffer, 1);
255- assert(render_state->vb.vertex_buffer->virtual);
256- vb = render_state->vb.vertex_buffer->virtual;
257-
258- i = 0;
259- vb[i++] = u2;
260- vb[i++] = v2;
261- vb[i++] = (float)box_x2;
262- vb[i++] = (float)box_y2;
263-
264- vb[i++] = u1;
265- vb[i++] = v2;
266- vb[i++] = (float)box_x1;
267- vb[i++] = (float)box_y2;
268-
269- vb[i++] = u1;
270- vb[i++] = v1;
271- vb[i++] = (float)box_x1;
272- vb[i++] = (float)box_y1;
273+ struct object_surface *obj_surface = SURFACE(surface);
274+ assert(obj_surface);
275
276- dri_bo_unmap(render_state->vb.vertex_buffer);
277+ return i965_render_do_upload_vertex(ctx,
278+ obj_surface->width, obj_surface->height,
279+ src_rect,
280+ dst_rect,
281+ cliprects, num_cliprects);
282 }
283
284-static void
285+static unsigned int
286 i965_surface_render_state_setup(VADriverContextP ctx,
287- VASurfaceID surface,
288- short srcx,
289- short srcy,
290- unsigned short srcw,
291- unsigned short srch,
292- short destx,
293- short desty,
294- unsigned short destw,
295- unsigned short desth)
296+ VASurfaceID surface,
297+ const VARectangle *src_rect,
298+ const VARectangle *dst_rect,
299+ const VARectangle *cliprects,
300+ unsigned int num_cliprects)
301 {
302 i965_render_vs_unit(ctx);
303 i965_render_sf_unit(ctx);
304@@ -922,21 +920,17 @@ i965_surface_render_state_setup(VADriverContextP ctx,
305 i965_render_cc_viewport(ctx);
306 i965_render_cc_unit(ctx);
307 i965_render_binding_table(ctx);
308- i965_render_upload_vertex(ctx, surface,
309- srcx, srcy, srcw, srch,
310- destx, desty, destw, desth);
311+ return i965_render_upload_vertex(ctx, surface, src_rect, dst_rect,
312+ cliprects, num_cliprects);
313 }
314-static void
315+
316+static unsigned int
317 i965_subpic_render_state_setup(VADriverContextP ctx,
318- VASurfaceID surface,
319- short srcx,
320- short srcy,
321- unsigned short srcw,
322- unsigned short srch,
323- short destx,
324- short desty,
325- unsigned short destw,
326- unsigned short desth)
327+ VASurfaceID surface,
328+ const VARectangle *src_rect,
329+ const VARectangle *dst_rect,
330+ const VARectangle *cliprects,
331+ unsigned int num_cliprects)
332 {
333 i965_render_vs_unit(ctx);
334 i965_render_sf_unit(ctx);
335@@ -947,16 +941,10 @@ i965_subpic_render_state_setup(VADriverContextP ctx,
336 i965_render_cc_viewport(ctx);
337 i965_subpic_render_cc_unit(ctx);
338 i965_render_binding_table(ctx);
339-
340- VARectangle output_rect;
341- output_rect.x = destx;
342- output_rect.y = desty;
343- output_rect.width = destw;
344- output_rect.height = desth;
345- i965_subpic_render_upload_vertex(ctx, surface, &output_rect);
346+ return i965_subpic_render_upload_vertex(ctx, surface, dst_rect,
347+ cliprects, num_cliprects);
348 }
349
350-
351 static void
352 i965_render_pipeline_select(VADriverContextP ctx)
353 {
354@@ -1192,7 +1180,7 @@ i965_render_upload_image_palette(
355 }
356
357 static void
358-i965_render_startup(VADriverContextP ctx)
359+i965_render_startup(VADriverContextP ctx, unsigned int vb_offset)
360 {
361 struct i965_driver_data *i965 = i965_driver_data(ctx);
362 struct i965_render_state *render_state = &i965->render_state;
363@@ -1203,7 +1191,7 @@ i965_render_startup(VADriverContextP ctx)
364 (0 << VB0_BUFFER_INDEX_SHIFT) |
365 VB0_VERTEXDATA |
366 ((4 * 4) << VB0_BUFFER_PITCH_SHIFT));
367- OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 0);
368+ OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, vb_offset);
369
370 if (IS_IGDNG(i965->intel.device_id))
371 OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 12 * 4);
372@@ -1268,8 +1256,10 @@ i965_clear_dest_region(VADriverContextP ctx)
373 }
374
375 static void
376-i965_surface_render_pipeline_setup(VADriverContextP ctx)
377+i965_surface_render_pipeline_setup(VADriverContextP ctx, unsigned int n_rects)
378 {
379+ unsigned int i;
380+
381 intel_batchbuffer_start_atomic(ctx, 0x1000);
382 intel_batchbuffer_emit_mi_flush(ctx);
383 i965_clear_dest_region(ctx);
384@@ -1283,13 +1273,16 @@ i965_surface_render_pipeline_setup(VADriverContextP ctx)
385 i965_render_cs_urb_layout(ctx);
386 i965_render_drawing_rectangle(ctx);
387 i965_render_vertex_elements(ctx);
388- i965_render_startup(ctx);
389+ for (i = 0; i < n_rects; i++)
390+ i965_render_startup(ctx, 48 * i);
391 intel_batchbuffer_end_atomic(ctx);
392 }
393
394 static void
395-i965_subpic_render_pipeline_setup(VADriverContextP ctx)
396+i965_subpic_render_pipeline_setup(VADriverContextP ctx, unsigned int n_rects)
397 {
398+ unsigned int i;
399+
400 intel_batchbuffer_start_atomic(ctx, 0x1000);
401 intel_batchbuffer_emit_mi_flush(ctx);
402 i965_render_pipeline_select(ctx);
403@@ -1302,7 +1295,8 @@ i965_subpic_render_pipeline_setup(VADriverContextP ctx)
404 i965_render_cs_urb_layout(ctx);
405 i965_render_drawing_rectangle(ctx);
406 i965_render_vertex_elements(ctx);
407- i965_render_startup(ctx);
408+ for (i = 0; i < n_rects; i++)
409+ i965_render_startup(ctx, 48 * i);
410 intel_batchbuffer_end_atomic(ctx);
411 }
412
413@@ -1396,45 +1390,39 @@ i965_render_initialize(VADriverContextP ctx)
414 void
415 i965_render_put_surface(VADriverContextP ctx,
416 VASurfaceID surface,
417- short srcx,
418- short srcy,
419- unsigned short srcw,
420- unsigned short srch,
421- short destx,
422- short desty,
423- unsigned short destw,
424- unsigned short desth)
425+ const VARectangle *src_rect,
426+ const VARectangle *dst_rect,
427+ const VARectangle *cliprects,
428+ unsigned int num_cliprects)
429 {
430+ unsigned int n_rects;
431+
432 i965_render_initialize(ctx);
433- i965_surface_render_state_setup(ctx, surface,
434- srcx, srcy, srcw, srch,
435- destx, desty, destw, desth);
436- i965_surface_render_pipeline_setup(ctx);
437+ n_rects = i965_surface_render_state_setup(ctx, surface,
438+ src_rect, dst_rect,
439+ cliprects, num_cliprects);
440+ i965_surface_render_pipeline_setup(ctx, n_rects);
441 intel_batchbuffer_flush(ctx);
442 }
443
444 void
445 i965_render_put_subpic(VADriverContextP ctx,
446- VASurfaceID surface,
447- short srcx,
448- short srcy,
449- unsigned short srcw,
450- unsigned short srch,
451- short destx,
452- short desty,
453- unsigned short destw,
454- unsigned short desth)
455+ VASurfaceID surface,
456+ const VARectangle *src_rect,
457+ const VARectangle *dst_rect,
458+ const VARectangle *cliprects,
459+ unsigned int num_cliprects)
460 {
461 struct i965_driver_data *i965 = i965_driver_data(ctx);
462 struct object_surface *obj_surface = SURFACE(surface);
463 struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic);
464+ unsigned int n_rects;
465 assert(obj_subpic);
466
467 i965_render_initialize(ctx);
468- i965_subpic_render_state_setup(ctx, surface,
469- srcx, srcy, srcw, srch,
470- destx, desty, destw, desth);
471- i965_subpic_render_pipeline_setup(ctx);
472+ n_rects = i965_subpic_render_state_setup(ctx, surface, src_rect, dst_rect,
473+ cliprects, num_cliprects);
474+ i965_subpic_render_pipeline_setup(ctx, n_rects);
475 i965_render_upload_image_palette(ctx, obj_subpic->image, 0xff);
476 intel_batchbuffer_flush(ctx);
477 }
478diff --git a/i965_drv_video/i965_render.h b/i965_drv_video/i965_render.h
479index e3dce02..d2e23f1 100644
480--- a/i965_drv_video/i965_render.h
481+++ b/i965_drv_video/i965_render.h
482@@ -28,6 +28,7 @@
483 #ifndef _I965_RENDER_H_
484 #define _I965_RENDER_H_
485
486+#define MAX_CLIP_RECTS 80 /* vb_bo:4096 / vb:(3*4*4) */
487 #define MAX_RENDER_SURFACES 16
488 #define MAX_SAMPLERS 16
489
490@@ -65,27 +66,20 @@ struct i965_render_state
491
492 Bool i965_render_init(VADriverContextP ctx);
493 Bool i965_render_terminate(VADriverContextP ctx);
494+
495 void i965_render_put_surface(VADriverContextP ctx,
496 VASurfaceID surface,
497- short srcx,
498- short srcy,
499- unsigned short srcw,
500- unsigned short srch,
501- short destx,
502- short desty,
503- unsigned short destw,
504- unsigned short desth);
505-
506+ const VARectangle *src_rect,
507+ const VARectangle *dst_rect,
508+ const VARectangle *cliprects,
509+ unsigned int num_cliprects);
510
511 void
512 i965_render_put_subpic(VADriverContextP ctx,
513- VASurfaceID surface,
514- short srcx,
515- short srcy,
516- unsigned short srcw,
517- unsigned short srch,
518- short destx,
519- short desty,
520- unsigned short destw,
521- unsigned short desth);
522+ VASurfaceID surface,
523+ const VARectangle *src_rect,
524+ const VARectangle *dst_rect,
525+ const VARectangle *cliprects,
526+ unsigned int num_cliprects);
527+
528 #endif /* _I965_RENDER_H_ */
529--
5301.5.4.3
531