1 /**************************************************************************
3 * Copyright 2009, VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 * Author: Keith Whitwell <keithw@vmware.com>
29 * Author: Jakob Bornecrantz <wallbraker@gmail.com>
32 #include "dri_screen.h"
33 #include "dri_context.h"
34 #include "dri_drawable.h"
36 #include "pipe/p_context.h"
37 #include "pipe/p_screen.h"
38 #include "main/mtypes.h"
39 #include "main/renderbuffer.h"
40 #include "state_tracker/drm_api.h"
41 #include "state_tracker/dri1_api.h"
42 #include "state_tracker/st_public.h"
43 #include "state_tracker/st_context.h"
44 #include "state_tracker/st_cb_fbo.h"
46 #include "util/u_format.h"
47 #include "util/u_memory.h"
48 #include "util/u_rect.h"
49 #include "util/u_inlines.h"
51 static struct pipe_surface
*
52 dri_surface_from_handle(struct drm_api
*api
,
53 struct pipe_screen
*screen
,
55 enum pipe_format format
,
56 unsigned width
, unsigned height
, unsigned pitch
)
58 struct pipe_surface
*surface
= NULL
;
59 struct pipe_texture
*texture
= NULL
;
60 struct pipe_texture templat
;
62 memset(&templat
, 0, sizeof(templat
));
63 templat
.tex_usage
|= PIPE_TEXTURE_USAGE_RENDER_TARGET
;
64 templat
.target
= PIPE_TEXTURE_2D
;
65 templat
.last_level
= 0;
67 templat
.format
= format
;
68 templat
.width0
= width
;
69 templat
.height0
= height
;
71 texture
= api
->texture_from_shared_handle(api
, screen
, &templat
,
72 "dri2 buffer", pitch
, handle
);
75 debug_printf("%s: Failed to blanket the buffer with a texture\n", __func__
);
79 surface
= screen
->get_tex_surface(screen
, texture
, 0, 0, 0,
80 PIPE_BUFFER_USAGE_GPU_READ
|
81 PIPE_BUFFER_USAGE_GPU_WRITE
);
83 /* we don't need the texture from this point on */
84 pipe_texture_reference(&texture
, NULL
);
89 * Pixmaps have will have the same name of fake front and front.
92 dri2_check_if_pixmap(__DRIbuffer
*buffers
, int count
)
94 boolean found
= FALSE
;
95 boolean is_pixmap
= FALSE
;
99 for (i
= 0; i
< count
; i
++) {
100 switch (buffers
[i
].attachment
) {
101 case __DRI_BUFFER_FRONT_LEFT
:
102 case __DRI_BUFFER_FAKE_FRONT_LEFT
:
104 is_pixmap
= buffers
[i
].name
== name
;
106 name
= buffers
[i
].name
;
118 * This will be called a drawable is known to have been resized.
121 dri_get_buffers(__DRIdrawable
* dPriv
)
124 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
125 struct pipe_surface
*surface
= NULL
;
126 struct dri_screen
*st_screen
= dri_screen(drawable
->sPriv
);
127 struct pipe_screen
*screen
= st_screen
->pipe_screen
;
128 __DRIbuffer
*buffers
= NULL
;
129 __DRIscreen
*dri_screen
= drawable
->sPriv
;
130 __DRIdrawable
*dri_drawable
= drawable
->dPriv
;
131 struct drm_api
*api
= st_screen
->api
;
132 boolean have_depth
= FALSE
;
135 if ((dri_screen
->dri2
.loader
136 && (dri_screen
->dri2
.loader
->base
.version
> 2)
137 && (dri_screen
->dri2
.loader
->getBuffersWithFormat
!= NULL
)))
138 buffers
= (*dri_screen
->dri2
.loader
->getBuffersWithFormat
)
139 (dri_drawable
, &dri_drawable
->w
, &dri_drawable
->h
,
140 drawable
->attachments
, drawable
->num_attachments
,
141 &count
, dri_drawable
->loaderPrivate
);
143 buffers
= (*dri_screen
->dri2
.loader
->getBuffers
) (dri_drawable
,
146 drawable
->attachments
,
148 num_attachments
, &count
,
152 if (buffers
== NULL
) {
156 /* set one cliprect to cover the whole dri_drawable */
159 dri_drawable
->backX
= 0;
160 dri_drawable
->backY
= 0;
161 dri_drawable
->numClipRects
= 1;
162 dri_drawable
->pClipRects
[0].x1
= 0;
163 dri_drawable
->pClipRects
[0].y1
= 0;
164 dri_drawable
->pClipRects
[0].x2
= dri_drawable
->w
;
165 dri_drawable
->pClipRects
[0].y2
= dri_drawable
->h
;
166 dri_drawable
->numBackClipRects
= 1;
167 dri_drawable
->pBackClipRects
[0].x1
= 0;
168 dri_drawable
->pBackClipRects
[0].y1
= 0;
169 dri_drawable
->pBackClipRects
[0].x2
= dri_drawable
->w
;
170 dri_drawable
->pBackClipRects
[0].y2
= dri_drawable
->h
;
172 if (drawable
->old_num
== count
&&
173 drawable
->old_w
== dri_drawable
->w
&&
174 drawable
->old_h
== dri_drawable
->h
&&
175 memcmp(drawable
->old
, buffers
, sizeof(__DRIbuffer
) * count
) == 0) {
178 drawable
->old_num
= count
;
179 drawable
->old_w
= dri_drawable
->w
;
180 drawable
->old_h
= dri_drawable
->h
;
181 memcpy(drawable
->old
, buffers
, sizeof(__DRIbuffer
) * count
);
184 drawable
->is_pixmap
= dri2_check_if_pixmap(buffers
, count
);
186 for (i
= 0; i
< count
; i
++) {
187 enum pipe_format format
= 0;
190 switch (buffers
[i
].attachment
) {
191 case __DRI_BUFFER_FRONT_LEFT
:
192 if (!st_screen
->auto_fake_front
)
195 case __DRI_BUFFER_FAKE_FRONT_LEFT
:
196 index
= ST_SURFACE_FRONT_LEFT
;
197 format
= drawable
->color_format
;
199 case __DRI_BUFFER_BACK_LEFT
:
200 index
= ST_SURFACE_BACK_LEFT
;
201 format
= drawable
->color_format
;
203 case __DRI_BUFFER_DEPTH
:
204 case __DRI_BUFFER_DEPTH_STENCIL
:
205 case __DRI_BUFFER_STENCIL
:
206 index
= ST_SURFACE_DEPTH
;
207 format
= drawable
->depth_stencil_format
;
209 case __DRI_BUFFER_ACCUM
:
214 if (index
== ST_SURFACE_DEPTH
) {
221 surface
= dri_surface_from_handle(api
,
226 dri_drawable
->h
, buffers
[i
].pitch
);
228 switch (buffers
[i
].attachment
) {
229 case __DRI_BUFFER_FRONT_LEFT
:
230 case __DRI_BUFFER_FAKE_FRONT_LEFT
:
231 case __DRI_BUFFER_BACK_LEFT
:
232 drawable
->color_format
= surface
->format
;
234 case __DRI_BUFFER_DEPTH
:
235 case __DRI_BUFFER_DEPTH_STENCIL
:
236 case __DRI_BUFFER_STENCIL
:
237 drawable
->depth_stencil_format
= surface
->format
;
239 case __DRI_BUFFER_ACCUM
:
244 st_set_framebuffer_surface(drawable
->stfb
, index
, surface
);
245 pipe_surface_reference(&surface
, NULL
);
247 /* this needed, or else the state tracker fails to pick the new buffers */
248 st_resize_framebuffer(drawable
->stfb
, dri_drawable
->w
, dri_drawable
->h
);
252 * These are used for GLX_EXT_texture_from_pixmap
254 void dri2_set_tex_buffer2(__DRIcontext
*pDRICtx
, GLint target
,
255 GLint format
, __DRIdrawable
*dPriv
)
257 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
258 struct pipe_surface
*ps
;
260 if (!drawable
->stfb
->Base
.Attachment
[BUFFER_FRONT_LEFT
].Renderbuffer
) {
261 struct gl_renderbuffer
*rb
=
262 st_new_renderbuffer_fb(drawable
->color_format
, 0 /*XXX*/, FALSE
);
263 _mesa_add_renderbuffer(&drawable
->stfb
->Base
, BUFFER_FRONT_LEFT
, rb
);
266 dri_get_buffers(drawable
->dPriv
);
267 st_get_framebuffer_surface(drawable
->stfb
, ST_SURFACE_FRONT_LEFT
, &ps
);
272 st_bind_texture_surface(ps
, target
== GL_TEXTURE_2D
? ST_TEXTURE_2D
:
273 ST_TEXTURE_RECT
, 0, drawable
->color_format
);
276 void dri2_set_tex_buffer(__DRIcontext
*pDRICtx
, GLint target
,
277 __DRIdrawable
*dPriv
)
279 dri2_set_tex_buffer2(pDRICtx
, target
, __DRI_TEXTURE_FORMAT_RGBA
, dPriv
);
283 dri_update_buffer(struct pipe_screen
*screen
, void *context_private
)
285 struct dri_context
*ctx
= (struct dri_context
*)context_private
;
287 dri_get_buffers(ctx
->dPriv
);
291 dri_flush_frontbuffer(struct pipe_screen
*screen
,
292 struct pipe_surface
*surf
, void *context_private
)
294 struct dri_context
*ctx
= (struct dri_context
*)context_private
;
295 struct dri_drawable
*drawable
= dri_drawable(ctx
->dPriv
);
296 __DRIdrawable
*dri_drawable
= ctx
->dPriv
;
297 __DRIscreen
*dri_screen
= ctx
->sPriv
;
299 /* XXX Does this function get called with DRI1? */
301 if (ctx
->dPriv
== NULL
) {
302 debug_printf("%s: no drawable bound to context\n", __func__
);
307 /* TODO if rendering to pixmaps is slow enable this code. */
308 if (drawable
->is_pixmap
)
314 (*dri_screen
->dri2
.loader
->flushFrontBuffer
)(dri_drawable
,
315 dri_drawable
->loaderPrivate
);
319 * This is called when we need to set up GL rendering to a new X window.
322 dri_create_buffer(__DRIscreen
* sPriv
,
323 __DRIdrawable
* dPriv
,
324 const __GLcontextModes
* visual
, boolean isPixmap
)
326 struct dri_screen
*screen
= sPriv
->private;
327 struct dri_drawable
*drawable
= NULL
;
331 goto fail
; /* not implemented */
333 drawable
= CALLOC_STRUCT(dri_drawable
);
334 if (drawable
== NULL
)
337 if (visual
->redBits
== 8) {
338 if (visual
->alphaBits
== 8)
339 drawable
->color_format
= PIPE_FORMAT_A8R8G8B8_UNORM
;
341 drawable
->color_format
= PIPE_FORMAT_X8R8G8B8_UNORM
;
343 drawable
->color_format
= PIPE_FORMAT_R5G6B5_UNORM
;
346 switch(visual
->depthBits
) {
349 drawable
->depth_stencil_format
= PIPE_FORMAT_NONE
;
352 drawable
->depth_stencil_format
= PIPE_FORMAT_Z16_UNORM
;
355 if (visual
->stencilBits
== 0) {
356 drawable
->depth_stencil_format
= (screen
->d_depth_bits_last
) ?
357 PIPE_FORMAT_X8Z24_UNORM
:
358 PIPE_FORMAT_Z24X8_UNORM
;
360 drawable
->depth_stencil_format
= (screen
->sd_depth_bits_last
) ?
361 PIPE_FORMAT_S8Z24_UNORM
:
362 PIPE_FORMAT_Z24S8_UNORM
;
366 drawable
->depth_stencil_format
= PIPE_FORMAT_Z32_UNORM
;
370 drawable
->stfb
= st_create_framebuffer(visual
,
371 drawable
->color_format
,
372 drawable
->depth_stencil_format
,
373 drawable
->depth_stencil_format
,
375 dPriv
->h
, (void *)drawable
);
376 if (drawable
->stfb
== NULL
)
379 drawable
->sPriv
= sPriv
;
380 drawable
->dPriv
= dPriv
;
381 dPriv
->driverPrivate
= (void *)drawable
;
383 /* setup dri2 buffers information */
384 /* TODO incase of double buffer visual, delay fake creation */
386 if (sPriv
->dri2
.loader
387 && (sPriv
->dri2
.loader
->base
.version
> 2)
388 && (sPriv
->dri2
.loader
->getBuffersWithFormat
!= NULL
)) {
389 drawable
->attachments
[i
++] = __DRI_BUFFER_FRONT_LEFT
;
390 drawable
->attachments
[i
++] = visual
->rgbBits
;
391 if (!screen
->auto_fake_front
) {
392 drawable
->attachments
[i
++] = __DRI_BUFFER_FAKE_FRONT_LEFT
;
393 drawable
->attachments
[i
++] = visual
->rgbBits
;
395 if (visual
->doubleBufferMode
) {
396 drawable
->attachments
[i
++] = __DRI_BUFFER_BACK_LEFT
;
397 drawable
->attachments
[i
++] = visual
->rgbBits
;
399 if (visual
->depthBits
&& visual
->stencilBits
) {
400 drawable
->attachments
[i
++] = __DRI_BUFFER_DEPTH_STENCIL
;
401 drawable
->attachments
[i
++] = visual
->depthBits
+ visual
->stencilBits
;
402 } else if (visual
->depthBits
) {
403 drawable
->attachments
[i
++] = __DRI_BUFFER_DEPTH
;
404 drawable
->attachments
[i
++] = visual
->depthBits
;
405 } else if (visual
->stencilBits
) {
406 drawable
->attachments
[i
++] = __DRI_BUFFER_STENCIL
;
407 drawable
->attachments
[i
++] = visual
->stencilBits
;
409 drawable
->num_attachments
= i
/ 2;
411 drawable
->attachments
[i
++] = __DRI_BUFFER_FRONT_LEFT
;
412 if (!screen
->auto_fake_front
)
413 drawable
->attachments
[i
++] = __DRI_BUFFER_FAKE_FRONT_LEFT
;
414 if (visual
->doubleBufferMode
)
415 drawable
->attachments
[i
++] = __DRI_BUFFER_BACK_LEFT
;
416 if (visual
->depthBits
&& visual
->stencilBits
)
417 drawable
->attachments
[i
++] = __DRI_BUFFER_DEPTH_STENCIL
;
418 else if (visual
->depthBits
)
419 drawable
->attachments
[i
++] = __DRI_BUFFER_DEPTH
;
420 else if (visual
->stencilBits
)
421 drawable
->attachments
[i
++] = __DRI_BUFFER_STENCIL
;
422 drawable
->num_attachments
= i
;
425 drawable
->desired_fences
= 2;
433 static struct pipe_fence_handle
*
434 dri_swap_fences_pop_front(struct dri_drawable
*draw
)
436 struct pipe_screen
*screen
= dri_screen(draw
->sPriv
)->pipe_screen
;
437 struct pipe_fence_handle
*fence
= NULL
;
439 if (draw
->cur_fences
>= draw
->desired_fences
) {
440 screen
->fence_reference(screen
, &fence
, draw
->swap_fences
[draw
->tail
]);
441 screen
->fence_reference(screen
, &draw
->swap_fences
[draw
->tail
++], NULL
);
443 draw
->tail
&= DRI_SWAP_FENCES_MASK
;
449 dri_swap_fences_push_back(struct dri_drawable
*draw
,
450 struct pipe_fence_handle
*fence
)
452 struct pipe_screen
*screen
= dri_screen(draw
->sPriv
)->pipe_screen
;
457 if (draw
->cur_fences
< DRI_SWAP_FENCES_MAX
) {
459 screen
->fence_reference(screen
, &draw
->swap_fences
[draw
->head
++],
461 draw
->head
&= DRI_SWAP_FENCES_MASK
;
466 dri_destroy_buffer(__DRIdrawable
* dPriv
)
468 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
469 struct pipe_fence_handle
*fence
;
470 struct pipe_screen
*screen
= dri_screen(drawable
->sPriv
)->pipe_screen
;
472 st_unreference_framebuffer(drawable
->stfb
);
473 drawable
->desired_fences
= 0;
474 while (drawable
->cur_fences
) {
475 fence
= dri_swap_fences_pop_front(drawable
);
476 screen
->fence_reference(screen
, &fence
, NULL
);
483 dri1_update_drawables_locked(struct dri_context
*ctx
,
484 __DRIdrawable
* driDrawPriv
,
485 __DRIdrawable
* driReadPriv
)
487 if (ctx
->stLostLock
) {
488 ctx
->stLostLock
= FALSE
;
489 if (driDrawPriv
== driReadPriv
)
490 DRI_VALIDATE_DRAWABLE_INFO(ctx
->sPriv
, driDrawPriv
);
492 DRI_VALIDATE_TWO_DRAWABLES_INFO(ctx
->sPriv
, driDrawPriv
,
498 * This ensures all contexts which bind to a drawable pick up the
499 * drawable change and signal new buffer state.
500 * Calling st_resize_framebuffer for each context may seem like overkill,
501 * but no new buffers will actually be allocated if the dimensions don't
506 dri1_propagate_drawable_change(struct dri_context
*ctx
)
508 __DRIdrawable
*dPriv
= ctx
->dPriv
;
509 __DRIdrawable
*rPriv
= ctx
->rPriv
;
510 boolean flushed
= FALSE
;
512 if (dPriv
&& ctx
->d_stamp
!= dPriv
->lastStamp
) {
514 st_flush(ctx
->st
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
516 ctx
->d_stamp
= dPriv
->lastStamp
;
517 st_resize_framebuffer(dri_drawable(dPriv
)->stfb
, dPriv
->w
, dPriv
->h
);
521 if (rPriv
&& dPriv
!= rPriv
&& ctx
->r_stamp
!= rPriv
->lastStamp
) {
524 st_flush(ctx
->st
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
525 ctx
->r_stamp
= rPriv
->lastStamp
;
526 st_resize_framebuffer(dri_drawable(rPriv
)->stfb
, rPriv
->w
, rPriv
->h
);
528 } else if (rPriv
&& dPriv
== rPriv
) {
530 ctx
->r_stamp
= ctx
->d_stamp
;
536 dri1_update_drawables(struct dri_context
*ctx
,
537 struct dri_drawable
*draw
, struct dri_drawable
*read
)
540 dri1_update_drawables_locked(ctx
, draw
->dPriv
, read
->dPriv
);
543 dri1_propagate_drawable_change(ctx
);
546 static INLINE boolean
547 dri1_intersect_src_bbox(struct drm_clip_rect
*dst
,
550 const struct drm_clip_rect
*src
,
551 const struct drm_clip_rect
*bbox
)
556 xy1
= ((int)src
->x1
> (int)bbox
->x1
+ dst_x
) ? src
->x1
:
557 (int)bbox
->x1
+ dst_x
;
558 xy2
= ((int)src
->x2
< (int)bbox
->x2
+ dst_x
) ? src
->x2
:
559 (int)bbox
->x2
+ dst_x
;
560 if (xy1
>= xy2
|| xy1
< 0)
566 xy1
= ((int)src
->y1
> (int)bbox
->y1
+ dst_y
) ? src
->y1
:
567 (int)bbox
->y1
+ dst_y
;
568 xy2
= ((int)src
->y2
< (int)bbox
->y2
+ dst_y
) ? src
->y2
:
569 (int)bbox
->y2
+ dst_y
;
570 if (xy1
>= xy2
|| xy1
< 0)
579 dri1_swap_copy(struct dri_context
*ctx
,
580 struct pipe_surface
*dst
,
581 struct pipe_surface
*src
,
582 __DRIdrawable
* dPriv
, const struct drm_clip_rect
*bbox
)
584 struct pipe_context
*pipe
= ctx
->pipe
;
585 struct drm_clip_rect clip
;
586 struct drm_clip_rect
*cur
;
589 cur
= dPriv
->pClipRects
;
591 for (i
= 0; i
< dPriv
->numClipRects
; ++i
) {
592 if (dri1_intersect_src_bbox(&clip
, dPriv
->x
, dPriv
->y
, cur
++, bbox
)) {
593 if (pipe
->surface_copy
) {
594 pipe
->surface_copy(pipe
, dst
, clip
.x1
, clip
.y1
,
596 (int)clip
.x1
- dPriv
->x
,
597 (int)clip
.y1
- dPriv
->y
,
598 clip
.x2
- clip
.x1
, clip
.y2
- clip
.y1
);
600 util_surface_copy(pipe
, FALSE
, dst
, clip
.x1
, clip
.y1
,
602 (int)clip
.x1
- dPriv
->x
,
603 (int)clip
.y1
- dPriv
->y
,
604 clip
.x2
- clip
.x1
, clip
.y2
- clip
.y1
);
611 dri1_copy_to_front(struct dri_context
*ctx
,
612 struct pipe_surface
*surf
,
613 __DRIdrawable
* dPriv
,
614 const struct drm_clip_rect
*sub_box
,
615 struct pipe_fence_handle
**fence
)
617 struct pipe_context
*pipe
= ctx
->pipe
;
618 boolean save_lost_lock
;
621 struct drm_clip_rect bbox
;
622 boolean visible
= TRUE
;
627 save_lost_lock
= ctx
->stLostLock
;
628 dri1_update_drawables_locked(ctx
, dPriv
, dPriv
);
629 st_get_framebuffer_dimensions(dri_drawable(dPriv
)->stfb
, &cur_w
, &cur_h
);
637 visible
= dri1_intersect_src_bbox(&bbox
, 0, 0, &bbox
, sub_box
);
639 if (visible
&& __dri1_api_hooks
->present_locked
) {
641 __dri1_api_hooks
->present_locked(pipe
,
645 dPriv
->x
, dPriv
->y
, &bbox
, fence
);
647 } else if (visible
&& __dri1_api_hooks
->front_srf_locked
) {
649 struct pipe_surface
*front
= __dri1_api_hooks
->front_srf_locked(pipe
);
652 dri1_swap_copy(ctx
, front
, surf
, dPriv
, &bbox
);
654 st_flush(ctx
->st
, PIPE_FLUSH_RENDER_CACHE
, fence
);
657 ctx
->stLostLock
= save_lost_lock
;
660 * FIXME: Revisit this: Update drawables on copy_sub_buffer ?
664 dri1_update_drawables_locked(ctx
, ctx
->dPriv
, ctx
->rPriv
);
667 dri1_propagate_drawable_change(ctx
);
671 dri1_flush_frontbuffer(struct pipe_screen
*screen
,
672 struct pipe_surface
*surf
, void *context_private
)
674 struct dri_context
*ctx
= (struct dri_context
*)context_private
;
675 struct pipe_fence_handle
*dummy_fence
;
677 dri1_copy_to_front(ctx
, surf
, ctx
->dPriv
, NULL
, &dummy_fence
);
678 screen
->fence_reference(screen
, &dummy_fence
, NULL
);
681 * FIXME: Do we need swap throttling here?
686 dri_swap_buffers(__DRIdrawable
* dPriv
)
688 struct dri_context
*ctx
;
689 struct pipe_surface
*back_surf
;
690 struct dri_drawable
*draw
= dri_drawable(dPriv
);
691 struct pipe_screen
*screen
= dri_screen(draw
->sPriv
)->pipe_screen
;
692 struct pipe_fence_handle
*fence
;
693 struct st_context
*st
= st_get_current();
695 assert(__dri1_api_hooks
!= NULL
);
698 return; /* For now */
700 ctx
= (struct dri_context
*)st
->pipe
->priv
;
702 st_get_framebuffer_surface(draw
->stfb
, ST_SURFACE_BACK_LEFT
, &back_surf
);
704 st_notify_swapbuffers(draw
->stfb
);
705 st_flush(ctx
->st
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
706 fence
= dri_swap_fences_pop_front(draw
);
708 (void)screen
->fence_finish(screen
, fence
, 0);
709 screen
->fence_reference(screen
, &fence
, NULL
);
711 dri1_copy_to_front(ctx
, back_surf
, dPriv
, NULL
, &fence
);
712 dri_swap_fences_push_back(draw
, fence
);
713 screen
->fence_reference(screen
, &fence
, NULL
);
718 dri_copy_sub_buffer(__DRIdrawable
* dPriv
, int x
, int y
, int w
, int h
)
720 struct pipe_screen
*screen
= dri_screen(dPriv
->driScreenPriv
)->pipe_screen
;
721 struct drm_clip_rect sub_bbox
;
722 struct dri_context
*ctx
;
723 struct pipe_surface
*back_surf
;
724 struct dri_drawable
*draw
= dri_drawable(dPriv
);
725 struct pipe_fence_handle
*dummy_fence
;
726 struct st_context
*st
= st_get_current();
728 assert(__dri1_api_hooks
!= NULL
);
733 ctx
= (struct dri_context
*)st
->pipe
->priv
;
740 st_get_framebuffer_surface(draw
->stfb
, ST_SURFACE_BACK_LEFT
, &back_surf
);
742 st_flush(ctx
->st
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
743 dri1_copy_to_front(ctx
, back_surf
, dPriv
, &sub_bbox
, &dummy_fence
);
744 screen
->fence_reference(screen
, &dummy_fence
, NULL
);
748 /* vim: set sw=3 ts=8 sts=3 expandtab: */