1 #include <main/glheader.h>
2 #include <glapi/glthread.h>
3 #include <GL/internal/glcore.h>
5 #include <pipe/p_context.h>
6 #include <state_tracker/st_public.h>
7 #include <state_tracker/st_context.h>
8 #include <state_tracker/st_cb_fbo.h>
10 #include "nouveau_context.h"
11 #include "nouveau_screen.h"
12 #include "nouveau_swapbuffers.h"
14 #include "nouveau_pushbuf.h"
17 nouveau_copy_buffer(__DRIdrawablePrivate
*dPriv
, struct pipe_surface
*surf
,
18 const drm_clip_rect_t
*rect
)
20 struct nouveau_context
*nv
= dPriv
->driContextPriv
->driverPrivate
;
21 struct nouveau_screen
*nv_screen
= nv
->dri_screen
->private;
22 struct pipe_context
*pipe
= nv
->st
->pipe
;
23 drm_clip_rect_t
*pbox
;
27 if (!dPriv
->numClipRects
) {
31 pbox
= dPriv
->pClipRects
;
32 nbox
= dPriv
->numClipRects
;
34 for (i
= 0; i
< nbox
; i
++, pbox
++) {
35 int sx
, sy
, dx
, dy
, w
, h
;
37 sx
= pbox
->x1
- dPriv
->x
;
38 sy
= pbox
->y1
- dPriv
->y
;
41 w
= pbox
->x2
- pbox
->x1
;
42 h
= pbox
->y2
- pbox
->y1
;
44 pipe
->surface_copy(pipe
, nv_screen
->fb
, dx
, dy
, surf
,
48 pipe
->flush(pipe
, 0, NULL
);
51 if (nv
->last_stamp
!= dPriv
->lastStamp
) {
52 struct nouveau_framebuffer
*nvfb
= dPriv
->driverPrivate
;
53 st_resize_framebuffer(nvfb
->stfb
, dPriv
->w
, dPriv
->h
);
54 nv
->last_stamp
= dPriv
->lastStamp
;
59 nouveau_copy_sub_buffer(__DRIdrawablePrivate
*dPriv
, int x
, int y
, int w
, int h
)
61 struct nouveau_framebuffer
*nvfb
= dPriv
->driverPrivate
;
62 struct pipe_surface
*surf
;
64 st_get_framebuffer_surface(nvfb
->stfb
, ST_SURFACE_BACK_LEFT
, &surf
);
72 st_notify_swapbuffers(nvfb
->stfb
);
73 nouveau_copy_buffer(dPriv
, surf
, &rect
);
78 nouveau_swap_buffers(__DRIdrawablePrivate
*dPriv
)
80 struct nouveau_framebuffer
*nvfb
= dPriv
->driverPrivate
;
81 struct pipe_surface
*surf
;
83 st_get_framebuffer_surface(nvfb
->stfb
, ST_SURFACE_BACK_LEFT
, &surf
);
85 st_notify_swapbuffers(nvfb
->stfb
);
86 nouveau_copy_buffer(dPriv
, surf
, NULL
);
91 nouveau_flush_frontbuffer(struct pipe_screen
*pscreen
, struct pipe_surface
*ps
,
92 void *context_private
)
94 struct nouveau_context
*nv
= context_private
;
95 __DRIdrawablePrivate
*dPriv
= nv
->dri_drawable
;
97 nouveau_copy_buffer(dPriv
, ps
, NULL
);
101 nouveau_contended_lock(struct nouveau_context
*nv
)
103 struct nouveau_context
*nv_sub
= (struct nouveau_context
*)nv
;
104 __DRIdrawablePrivate
*dPriv
= nv_sub
->dri_drawable
;
105 __DRIscreenPrivate
*sPriv
= nv_sub
->dri_screen
;
107 /* If the window moved, may need to set a new cliprect now.
109 * NOTE: This releases and regains the hw lock, so all state
110 * checking must be done *after* this call:
113 DRI_VALIDATE_DRAWABLE_INFO(sPriv
, dPriv
);