1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
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 TUNGSTEN GRAPHICS 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 #include "intel_screen.h"
29 #include "intel_context.h"
30 #include "intel_batchbuffer.h"
31 #include "intel_reg.h"
33 #include "pipe/p_context.h"
34 #include "state_tracker/st_public.h"
35 #include "state_tracker/st_context.h"
36 #include "state_tracker/st_cb_fbo.h"
37 #include "intel_egl.h"
41 intel_display_surface(struct egl_drm_drawable
*draw
,
42 struct pipe_surface
*surf
);
44 void intel_swap_buffers(struct egl_drm_drawable
*draw
)
46 struct intel_framebuffer
*intel_fb
= (struct intel_framebuffer
*)draw
->priv
;
47 struct pipe_surface
*back_surf
;
50 assert(intel_fb
->stfb
);
52 back_surf
= st_get_framebuffer_surface(intel_fb
->stfb
, ST_SURFACE_BACK_LEFT
);
54 st_notify_swapbuffers(intel_fb
->stfb
);
56 intel_display_surface(draw
, back_surf
);
57 st_notify_swapbuffers_complete(intel_fb
->stfb
);
62 intel_display_surface(struct egl_drm_drawable
*draw
,
63 struct pipe_surface
*surf
)
65 struct intel_context
*intel
= NULL
;
66 struct intel_framebuffer
*intel_fb
= (struct intel_framebuffer
*)draw
->priv
;
67 struct _DriFenceObject
*fence
;
69 //const int srcWidth = surf->width;
70 //const int srcHeight = surf->height;
72 intel
= intel_fb
->screen
->dummy
;
74 printf("No dummy context\n");
78 const int dstWidth
= intel_fb
->front
->width
;
79 const int dstHeight
= intel_fb
->front
->height
;
80 const int dstPitch
= intel_fb
->front
->pitch
/ 4;//draw->front.cpp;
82 const int cpp
= 4;//intel_fb->front->cpp;
83 const int srcPitch
= surf
->stride
/ cpp
;
88 BR13
= (dstPitch
* cpp
) | (0xCC << 16) | (1 << 24) | (1 << 25);
89 CMD
= (XY_SRC_COPY_BLT_CMD
| XY_SRC_COPY_BLT_WRITE_ALPHA
|
90 XY_SRC_COPY_BLT_WRITE_RGB
);
95 OUT_BATCH((0 << 16) | 0);
96 OUT_BATCH((dstHeight
<< 16) | dstWidth
);
98 OUT_RELOC(intel_fb
->front_buffer
,
99 DRM_BO_FLAG_MEM_TT
| DRM_BO_FLAG_WRITE
,
100 DRM_BO_MASK_MEM
| DRM_BO_FLAG_WRITE
, 0);
102 OUT_BATCH((0 << 16) | 0);
103 OUT_BATCH((srcPitch
* cpp
) & 0xffff);
104 OUT_RELOC(dri_bo(surf
->buffer
),
105 DRM_BO_FLAG_MEM_TT
| DRM_BO_FLAG_READ
,
106 DRM_BO_MASK_MEM
| DRM_BO_FLAG_READ
, 0);
108 fence
= intel_be_batchbuffer_flush(intel
->base
.batch
);
109 driFenceUnReference(&fence
);
110 intel_be_batchbuffer_finish(intel
->base
.batch
);