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
;
61 struct winsys_handle whandle
;
63 memset(&templat
, 0, sizeof(templat
));
64 templat
.tex_usage
|= PIPE_TEXTURE_USAGE_RENDER_TARGET
;
65 templat
.target
= PIPE_TEXTURE_2D
;
66 templat
.last_level
= 0;
68 templat
.format
= format
;
69 templat
.width0
= width
;
70 templat
.height0
= height
;
72 memset(&whandle
, 0, sizeof(whandle
));
73 whandle
.handle
= handle
;
74 whandle
.stride
= pitch
;
76 texture
= screen
->texture_from_handle(screen
, &templat
, &whandle
);
79 debug_printf("%s: Failed to blanket the buffer with a texture\n", __func__
);
83 surface
= screen
->get_tex_surface(screen
, texture
, 0, 0, 0,
84 PIPE_BUFFER_USAGE_GPU_READ
|
85 PIPE_BUFFER_USAGE_GPU_WRITE
);
87 /* we don't need the texture from this point on */
88 pipe_texture_reference(&texture
, NULL
);
93 * Pixmaps have will have the same name of fake front and front.
96 dri2_check_if_pixmap(__DRIbuffer
*buffers
, int count
)
98 boolean found
= FALSE
;
99 boolean is_pixmap
= FALSE
;
103 for (i
= 0; i
< count
; i
++) {
104 switch (buffers
[i
].attachment
) {
105 case __DRI_BUFFER_FRONT_LEFT
:
106 case __DRI_BUFFER_FAKE_FRONT_LEFT
:
108 is_pixmap
= buffers
[i
].name
== name
;
110 name
= buffers
[i
].name
;
122 * This will be called a drawable is known to have been resized.
125 dri_get_buffers(__DRIdrawable
* dPriv
)
128 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
129 struct pipe_surface
*surface
= NULL
;
130 struct dri_screen
*st_screen
= dri_screen(drawable
->sPriv
);
131 struct pipe_screen
*screen
= st_screen
->pipe_screen
;
132 __DRIbuffer
*buffers
= NULL
;
133 __DRIscreen
*dri_screen
= drawable
->sPriv
;
134 __DRIdrawable
*dri_drawable
= drawable
->dPriv
;
135 struct drm_api
*api
= st_screen
->api
;
136 boolean have_depth
= FALSE
;
139 if ((dri_screen
->dri2
.loader
140 && (dri_screen
->dri2
.loader
->base
.version
> 2)
141 && (dri_screen
->dri2
.loader
->getBuffersWithFormat
!= NULL
))) {
142 buffers
= (*dri_screen
->dri2
.loader
->getBuffersWithFormat
)
143 (dri_drawable
, &dri_drawable
->w
, &dri_drawable
->h
,
144 drawable
->attachments
, drawable
->num_attachments
,
145 &count
, dri_drawable
->loaderPrivate
);
147 assert(dri_screen
->dri2
.loader
);
148 buffers
= (*dri_screen
->dri2
.loader
->getBuffers
) (dri_drawable
,
151 drawable
->attachments
,
153 num_attachments
, &count
,
158 if (buffers
== NULL
) {
162 /* set one cliprect to cover the whole dri_drawable */
165 dri_drawable
->backX
= 0;
166 dri_drawable
->backY
= 0;
167 dri_drawable
->numClipRects
= 1;
168 dri_drawable
->pClipRects
[0].x1
= 0;
169 dri_drawable
->pClipRects
[0].y1
= 0;
170 dri_drawable
->pClipRects
[0].x2
= dri_drawable
->w
;
171 dri_drawable
->pClipRects
[0].y2
= dri_drawable
->h
;
172 dri_drawable
->numBackClipRects
= 1;
173 dri_drawable
->pBackClipRects
[0].x1
= 0;
174 dri_drawable
->pBackClipRects
[0].y1
= 0;
175 dri_drawable
->pBackClipRects
[0].x2
= dri_drawable
->w
;
176 dri_drawable
->pBackClipRects
[0].y2
= dri_drawable
->h
;
178 if (drawable
->old_num
== count
&&
179 drawable
->old_w
== dri_drawable
->w
&&
180 drawable
->old_h
== dri_drawable
->h
&&
181 memcmp(drawable
->old
, buffers
, sizeof(__DRIbuffer
) * count
) == 0) {
184 drawable
->old_num
= count
;
185 drawable
->old_w
= dri_drawable
->w
;
186 drawable
->old_h
= dri_drawable
->h
;
187 memcpy(drawable
->old
, buffers
, sizeof(__DRIbuffer
) * count
);
190 drawable
->is_pixmap
= dri2_check_if_pixmap(buffers
, count
);
192 for (i
= 0; i
< count
; i
++) {
193 enum pipe_format format
= 0;
196 switch (buffers
[i
].attachment
) {
197 case __DRI_BUFFER_FRONT_LEFT
:
198 if (!st_screen
->auto_fake_front
)
201 case __DRI_BUFFER_FAKE_FRONT_LEFT
:
202 index
= ST_SURFACE_FRONT_LEFT
;
203 format
= drawable
->color_format
;
205 case __DRI_BUFFER_BACK_LEFT
:
206 index
= ST_SURFACE_BACK_LEFT
;
207 format
= drawable
->color_format
;
209 case __DRI_BUFFER_DEPTH
:
210 case __DRI_BUFFER_DEPTH_STENCIL
:
211 case __DRI_BUFFER_STENCIL
:
212 index
= ST_SURFACE_DEPTH
;
213 format
= drawable
->depth_stencil_format
;
215 case __DRI_BUFFER_ACCUM
:
220 if (index
== ST_SURFACE_DEPTH
) {
227 surface
= dri_surface_from_handle(api
,
232 dri_drawable
->h
, buffers
[i
].pitch
);
234 switch (buffers
[i
].attachment
) {
235 case __DRI_BUFFER_FRONT_LEFT
:
236 case __DRI_BUFFER_FAKE_FRONT_LEFT
:
237 case __DRI_BUFFER_BACK_LEFT
:
238 drawable
->color_format
= surface
->format
;
240 case __DRI_BUFFER_DEPTH
:
241 case __DRI_BUFFER_DEPTH_STENCIL
:
242 case __DRI_BUFFER_STENCIL
:
243 drawable
->depth_stencil_format
= surface
->format
;
245 case __DRI_BUFFER_ACCUM
:
250 st_set_framebuffer_surface(drawable
->stfb
, index
, surface
);
251 pipe_surface_reference(&surface
, NULL
);
253 /* this needed, or else the state tracker fails to pick the new buffers */
254 st_resize_framebuffer(drawable
->stfb
, dri_drawable
->w
, dri_drawable
->h
);
258 * These are used for GLX_EXT_texture_from_pixmap
260 void dri2_set_tex_buffer2(__DRIcontext
*pDRICtx
, GLint target
,
261 GLint format
, __DRIdrawable
*dPriv
)
263 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
264 struct pipe_surface
*ps
;
266 if (!drawable
->stfb
->Base
.Attachment
[BUFFER_FRONT_LEFT
].Renderbuffer
) {
267 struct gl_renderbuffer
*rb
=
268 st_new_renderbuffer_fb(drawable
->color_format
, 0 /*XXX*/, FALSE
);
269 _mesa_add_renderbuffer(&drawable
->stfb
->Base
, BUFFER_FRONT_LEFT
, rb
);
272 dri_get_buffers(drawable
->dPriv
);
273 st_get_framebuffer_surface(drawable
->stfb
, ST_SURFACE_FRONT_LEFT
, &ps
);
278 st_bind_texture_surface(ps
, target
== GL_TEXTURE_2D
? ST_TEXTURE_2D
:
279 ST_TEXTURE_RECT
, 0, drawable
->color_format
);
282 void dri2_set_tex_buffer(__DRIcontext
*pDRICtx
, GLint target
,
283 __DRIdrawable
*dPriv
)
285 dri2_set_tex_buffer2(pDRICtx
, target
, __DRI_TEXTURE_FORMAT_RGBA
, dPriv
);
289 dri_update_buffer(struct pipe_screen
*screen
, void *context_private
)
291 struct dri_context
*ctx
= (struct dri_context
*)context_private
;
293 if (ctx
->d_stamp
== *ctx
->dPriv
->pStamp
&&
294 ctx
->r_stamp
== *ctx
->rPriv
->pStamp
)
297 ctx
->d_stamp
= *ctx
->dPriv
->pStamp
;
298 ctx
->r_stamp
= *ctx
->rPriv
->pStamp
;
300 /* Ask the X server for new renderbuffers. */
301 dri_get_buffers(ctx
->dPriv
);
302 if (ctx
->dPriv
!= ctx
->rPriv
)
303 dri_get_buffers(ctx
->rPriv
);
308 dri_flush_frontbuffer(struct pipe_screen
*screen
,
309 struct pipe_surface
*surf
, void *context_private
)
311 struct dri_context
*ctx
= (struct dri_context
*)context_private
;
312 struct dri_drawable
*drawable
= dri_drawable(ctx
->dPriv
);
313 __DRIdrawable
*dri_drawable
= ctx
->dPriv
;
314 __DRIscreen
*dri_screen
= ctx
->sPriv
;
316 /* XXX Does this function get called with DRI1? */
318 if (ctx
->dPriv
== NULL
) {
319 debug_printf("%s: no drawable bound to context\n", __func__
);
324 /* TODO if rendering to pixmaps is slow enable this code. */
325 if (drawable
->is_pixmap
)
331 (*dri_screen
->dri2
.loader
->flushFrontBuffer
)(dri_drawable
,
332 dri_drawable
->loaderPrivate
);
336 * This is called when we need to set up GL rendering to a new X window.
339 dri_create_buffer(__DRIscreen
* sPriv
,
340 __DRIdrawable
* dPriv
,
341 const __GLcontextModes
* visual
, boolean isPixmap
)
343 struct dri_screen
*screen
= sPriv
->private;
344 struct dri_drawable
*drawable
= NULL
;
348 goto fail
; /* not implemented */
350 drawable
= CALLOC_STRUCT(dri_drawable
);
351 if (drawable
== NULL
)
354 if (visual
->redBits
== 8) {
355 if (visual
->alphaBits
== 8)
356 drawable
->color_format
= PIPE_FORMAT_B8G8R8A8_UNORM
;
358 drawable
->color_format
= PIPE_FORMAT_B8G8R8X8_UNORM
;
360 drawable
->color_format
= PIPE_FORMAT_B5G6R5_UNORM
;
363 switch(visual
->depthBits
) {
366 drawable
->depth_stencil_format
= PIPE_FORMAT_NONE
;
369 drawable
->depth_stencil_format
= PIPE_FORMAT_Z16_UNORM
;
372 if (visual
->stencilBits
== 0) {
373 drawable
->depth_stencil_format
= (screen
->d_depth_bits_last
) ?
374 PIPE_FORMAT_Z24X8_UNORM
:
375 PIPE_FORMAT_X8Z24_UNORM
;
377 drawable
->depth_stencil_format
= (screen
->sd_depth_bits_last
) ?
378 PIPE_FORMAT_Z24S8_UNORM
:
379 PIPE_FORMAT_S8Z24_UNORM
;
383 drawable
->depth_stencil_format
= PIPE_FORMAT_Z32_UNORM
;
387 drawable
->stfb
= st_create_framebuffer(visual
,
388 drawable
->color_format
,
389 drawable
->depth_stencil_format
,
390 drawable
->depth_stencil_format
,
392 dPriv
->h
, (void *)drawable
);
393 if (drawable
->stfb
== NULL
)
396 drawable
->sPriv
= sPriv
;
397 drawable
->dPriv
= dPriv
;
398 dPriv
->driverPrivate
= (void *)drawable
;
400 /* setup dri2 buffers information */
401 /* TODO incase of double buffer visual, delay fake creation */
403 if (sPriv
->dri2
.loader
404 && (sPriv
->dri2
.loader
->base
.version
> 2)
405 && (sPriv
->dri2
.loader
->getBuffersWithFormat
!= NULL
)) {
406 drawable
->attachments
[i
++] = __DRI_BUFFER_FRONT_LEFT
;
407 drawable
->attachments
[i
++] = visual
->rgbBits
;
408 if (!screen
->auto_fake_front
) {
409 drawable
->attachments
[i
++] = __DRI_BUFFER_FAKE_FRONT_LEFT
;
410 drawable
->attachments
[i
++] = visual
->rgbBits
;
412 if (visual
->doubleBufferMode
) {
413 drawable
->attachments
[i
++] = __DRI_BUFFER_BACK_LEFT
;
414 drawable
->attachments
[i
++] = visual
->rgbBits
;
416 if (visual
->depthBits
&& visual
->stencilBits
) {
417 drawable
->attachments
[i
++] = __DRI_BUFFER_DEPTH_STENCIL
;
418 drawable
->attachments
[i
++] = visual
->depthBits
+ visual
->stencilBits
;
419 } else if (visual
->depthBits
) {
420 drawable
->attachments
[i
++] = __DRI_BUFFER_DEPTH
;
421 drawable
->attachments
[i
++] = visual
->depthBits
;
422 } else if (visual
->stencilBits
) {
423 drawable
->attachments
[i
++] = __DRI_BUFFER_STENCIL
;
424 drawable
->attachments
[i
++] = visual
->stencilBits
;
426 drawable
->num_attachments
= i
/ 2;
428 drawable
->attachments
[i
++] = __DRI_BUFFER_FRONT_LEFT
;
429 if (!screen
->auto_fake_front
)
430 drawable
->attachments
[i
++] = __DRI_BUFFER_FAKE_FRONT_LEFT
;
431 if (visual
->doubleBufferMode
)
432 drawable
->attachments
[i
++] = __DRI_BUFFER_BACK_LEFT
;
433 if (visual
->depthBits
&& visual
->stencilBits
)
434 drawable
->attachments
[i
++] = __DRI_BUFFER_DEPTH_STENCIL
;
435 else if (visual
->depthBits
)
436 drawable
->attachments
[i
++] = __DRI_BUFFER_DEPTH
;
437 else if (visual
->stencilBits
)
438 drawable
->attachments
[i
++] = __DRI_BUFFER_STENCIL
;
439 drawable
->num_attachments
= i
;
442 drawable
->desired_fences
= 2;
450 static struct pipe_fence_handle
*
451 dri_swap_fences_pop_front(struct dri_drawable
*draw
)
453 struct pipe_screen
*screen
= dri_screen(draw
->sPriv
)->pipe_screen
;
454 struct pipe_fence_handle
*fence
= NULL
;
456 if (draw
->cur_fences
>= draw
->desired_fences
) {
457 screen
->fence_reference(screen
, &fence
, draw
->swap_fences
[draw
->tail
]);
458 screen
->fence_reference(screen
, &draw
->swap_fences
[draw
->tail
++], NULL
);
460 draw
->tail
&= DRI_SWAP_FENCES_MASK
;
466 dri_swap_fences_push_back(struct dri_drawable
*draw
,
467 struct pipe_fence_handle
*fence
)
469 struct pipe_screen
*screen
= dri_screen(draw
->sPriv
)->pipe_screen
;
474 if (draw
->cur_fences
< DRI_SWAP_FENCES_MAX
) {
476 screen
->fence_reference(screen
, &draw
->swap_fences
[draw
->head
++],
478 draw
->head
&= DRI_SWAP_FENCES_MASK
;
483 dri_destroy_buffer(__DRIdrawable
* dPriv
)
485 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
486 struct pipe_fence_handle
*fence
;
487 struct pipe_screen
*screen
= dri_screen(drawable
->sPriv
)->pipe_screen
;
489 st_unreference_framebuffer(drawable
->stfb
);
490 drawable
->desired_fences
= 0;
491 while (drawable
->cur_fences
) {
492 fence
= dri_swap_fences_pop_front(drawable
);
493 screen
->fence_reference(screen
, &fence
, NULL
);
500 dri1_update_drawables_locked(struct dri_context
*ctx
,
501 __DRIdrawable
* driDrawPriv
,
502 __DRIdrawable
* driReadPriv
)
504 if (ctx
->stLostLock
) {
505 ctx
->stLostLock
= FALSE
;
506 if (driDrawPriv
== driReadPriv
)
507 DRI_VALIDATE_DRAWABLE_INFO(ctx
->sPriv
, driDrawPriv
);
509 DRI_VALIDATE_TWO_DRAWABLES_INFO(ctx
->sPriv
, driDrawPriv
,
515 * This ensures all contexts which bind to a drawable pick up the
516 * drawable change and signal new buffer state.
517 * Calling st_resize_framebuffer for each context may seem like overkill,
518 * but no new buffers will actually be allocated if the dimensions don't
523 dri1_propagate_drawable_change(struct dri_context
*ctx
)
525 __DRIdrawable
*dPriv
= ctx
->dPriv
;
526 __DRIdrawable
*rPriv
= ctx
->rPriv
;
527 boolean flushed
= FALSE
;
529 if (dPriv
&& ctx
->d_stamp
!= dPriv
->lastStamp
) {
531 st_flush(ctx
->st
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
533 ctx
->d_stamp
= dPriv
->lastStamp
;
534 st_resize_framebuffer(dri_drawable(dPriv
)->stfb
, dPriv
->w
, dPriv
->h
);
538 if (rPriv
&& dPriv
!= rPriv
&& ctx
->r_stamp
!= rPriv
->lastStamp
) {
541 st_flush(ctx
->st
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
542 ctx
->r_stamp
= rPriv
->lastStamp
;
543 st_resize_framebuffer(dri_drawable(rPriv
)->stfb
, rPriv
->w
, rPriv
->h
);
545 } else if (rPriv
&& dPriv
== rPriv
) {
547 ctx
->r_stamp
= ctx
->d_stamp
;
553 dri1_update_drawables(struct dri_context
*ctx
,
554 struct dri_drawable
*draw
, struct dri_drawable
*read
)
557 dri1_update_drawables_locked(ctx
, draw
->dPriv
, read
->dPriv
);
560 dri1_propagate_drawable_change(ctx
);
563 static INLINE boolean
564 dri1_intersect_src_bbox(struct drm_clip_rect
*dst
,
567 const struct drm_clip_rect
*src
,
568 const struct drm_clip_rect
*bbox
)
573 xy1
= ((int)src
->x1
> (int)bbox
->x1
+ dst_x
) ? src
->x1
:
574 (int)bbox
->x1
+ dst_x
;
575 xy2
= ((int)src
->x2
< (int)bbox
->x2
+ dst_x
) ? src
->x2
:
576 (int)bbox
->x2
+ dst_x
;
577 if (xy1
>= xy2
|| xy1
< 0)
583 xy1
= ((int)src
->y1
> (int)bbox
->y1
+ dst_y
) ? src
->y1
:
584 (int)bbox
->y1
+ dst_y
;
585 xy2
= ((int)src
->y2
< (int)bbox
->y2
+ dst_y
) ? src
->y2
:
586 (int)bbox
->y2
+ dst_y
;
587 if (xy1
>= xy2
|| xy1
< 0)
596 dri1_swap_copy(struct dri_context
*ctx
,
597 struct pipe_surface
*dst
,
598 struct pipe_surface
*src
,
599 __DRIdrawable
* dPriv
, const struct drm_clip_rect
*bbox
)
601 struct pipe_context
*pipe
= ctx
->pipe
;
602 struct drm_clip_rect clip
;
603 struct drm_clip_rect
*cur
;
606 cur
= dPriv
->pClipRects
;
608 for (i
= 0; i
< dPriv
->numClipRects
; ++i
) {
609 if (dri1_intersect_src_bbox(&clip
, dPriv
->x
, dPriv
->y
, cur
++, bbox
)) {
610 if (pipe
->surface_copy
) {
611 pipe
->surface_copy(pipe
, dst
, clip
.x1
, clip
.y1
,
613 (int)clip
.x1
- dPriv
->x
,
614 (int)clip
.y1
- dPriv
->y
,
615 clip
.x2
- clip
.x1
, clip
.y2
- clip
.y1
);
617 util_surface_copy(pipe
, FALSE
, dst
, clip
.x1
, clip
.y1
,
619 (int)clip
.x1
- dPriv
->x
,
620 (int)clip
.y1
- dPriv
->y
,
621 clip
.x2
- clip
.x1
, clip
.y2
- clip
.y1
);
628 dri1_copy_to_front(struct dri_context
*ctx
,
629 struct pipe_surface
*surf
,
630 __DRIdrawable
* dPriv
,
631 const struct drm_clip_rect
*sub_box
,
632 struct pipe_fence_handle
**fence
)
634 struct pipe_context
*pipe
= ctx
->pipe
;
635 boolean save_lost_lock
;
638 struct drm_clip_rect bbox
;
639 boolean visible
= TRUE
;
644 save_lost_lock
= ctx
->stLostLock
;
645 dri1_update_drawables_locked(ctx
, dPriv
, dPriv
);
646 st_get_framebuffer_dimensions(dri_drawable(dPriv
)->stfb
, &cur_w
, &cur_h
);
654 visible
= dri1_intersect_src_bbox(&bbox
, 0, 0, &bbox
, sub_box
);
656 if (visible
&& __dri1_api_hooks
->present_locked
) {
658 __dri1_api_hooks
->present_locked(pipe
,
662 dPriv
->x
, dPriv
->y
, &bbox
, fence
);
664 } else if (visible
&& __dri1_api_hooks
->front_srf_locked
) {
666 struct pipe_surface
*front
= __dri1_api_hooks
->front_srf_locked(pipe
);
669 dri1_swap_copy(ctx
, front
, surf
, dPriv
, &bbox
);
671 st_flush(ctx
->st
, PIPE_FLUSH_RENDER_CACHE
, fence
);
674 ctx
->stLostLock
= save_lost_lock
;
677 * FIXME: Revisit this: Update drawables on copy_sub_buffer ?
681 dri1_update_drawables_locked(ctx
, ctx
->dPriv
, ctx
->rPriv
);
684 dri1_propagate_drawable_change(ctx
);
688 dri1_flush_frontbuffer(struct pipe_screen
*screen
,
689 struct pipe_surface
*surf
, void *context_private
)
691 struct dri_context
*ctx
= (struct dri_context
*)context_private
;
692 struct pipe_fence_handle
*dummy_fence
;
694 dri1_copy_to_front(ctx
, surf
, ctx
->dPriv
, NULL
, &dummy_fence
);
695 screen
->fence_reference(screen
, &dummy_fence
, NULL
);
698 * FIXME: Do we need swap throttling here?
703 dri_swap_buffers(__DRIdrawable
* dPriv
)
705 struct dri_context
*ctx
;
706 struct pipe_surface
*back_surf
;
707 struct dri_drawable
*draw
= dri_drawable(dPriv
);
708 struct pipe_screen
*screen
= dri_screen(draw
->sPriv
)->pipe_screen
;
709 struct pipe_fence_handle
*fence
;
710 struct st_context
*st
= st_get_current();
712 assert(__dri1_api_hooks
!= NULL
);
715 return; /* For now */
717 ctx
= (struct dri_context
*)st
->pipe
->priv
;
719 st_get_framebuffer_surface(draw
->stfb
, ST_SURFACE_BACK_LEFT
, &back_surf
);
721 st_notify_swapbuffers(draw
->stfb
);
722 st_flush(ctx
->st
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
723 fence
= dri_swap_fences_pop_front(draw
);
725 (void)screen
->fence_finish(screen
, fence
, 0);
726 screen
->fence_reference(screen
, &fence
, NULL
);
728 dri1_copy_to_front(ctx
, back_surf
, dPriv
, NULL
, &fence
);
729 dri_swap_fences_push_back(draw
, fence
);
730 screen
->fence_reference(screen
, &fence
, NULL
);
735 dri_copy_sub_buffer(__DRIdrawable
* dPriv
, int x
, int y
, int w
, int h
)
737 struct pipe_screen
*screen
= dri_screen(dPriv
->driScreenPriv
)->pipe_screen
;
738 struct drm_clip_rect sub_bbox
;
739 struct dri_context
*ctx
;
740 struct pipe_surface
*back_surf
;
741 struct dri_drawable
*draw
= dri_drawable(dPriv
);
742 struct pipe_fence_handle
*dummy_fence
;
743 struct st_context
*st
= st_get_current();
745 assert(__dri1_api_hooks
!= NULL
);
750 ctx
= (struct dri_context
*)st
->pipe
->priv
;
757 st_get_framebuffer_surface(draw
->stfb
, ST_SURFACE_BACK_LEFT
, &back_surf
);
759 st_flush(ctx
->st
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
760 dri1_copy_to_front(ctx
, back_surf
, dPriv
, &sub_bbox
, &dummy_fence
);
761 screen
->fence_reference(screen
, &dummy_fence
, NULL
);
765 /* vim: set sw=3 ts=8 sts=3 expandtab: */