00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 #include "intel_device.h"
00029 #include "intel_context.h"
00030 #include "intel_batchbuffer.h"
00031 #include "intel_reg.h"
00032 
00033 #include "pipe/p_context.h"
00034 #include "state_tracker/st_public.h"
00035 #include "state_tracker/st_context.h"
00036 #include "state_tracker/st_cb_fbo.h"
00037 #include "intel_egl.h"
00038 
00039 
00040 static void
00041 intel_display_surface(struct egl_drm_drawable *draw,
00042                       struct pipe_surface *surf);
00043 
00044 void intel_swap_buffers(struct egl_drm_drawable *draw)
00045 {
00046         struct intel_framebuffer *intel_fb = (struct intel_framebuffer *)draw->priv;
00047         struct pipe_surface *back_surf;
00048 
00049         assert(intel_fb);
00050         assert(intel_fb->stfb);
00051 
00052         back_surf = st_get_framebuffer_surface(intel_fb->stfb, ST_SURFACE_BACK_LEFT);
00053         if (back_surf) {
00054                 st_notify_swapbuffers(intel_fb->stfb);
00055                 if (intel_fb->front)
00056                         intel_display_surface(draw, back_surf);
00057                 st_notify_swapbuffers_complete(intel_fb->stfb);
00058         }
00059 }
00060 
00061 static void
00062 intel_display_surface(struct egl_drm_drawable *draw,
00063                       struct pipe_surface *surf)
00064 {
00065         struct intel_context *intel = NULL;
00066         struct intel_framebuffer *intel_fb = (struct intel_framebuffer *)draw->priv;
00067         struct _DriFenceObject *fence;
00068 
00069         
00070         
00071 
00072         intel = intel_fb->device->dummy;
00073         if (!intel) {
00074                 printf("No dummy context\n");
00075                 return;
00076         }
00077 
00078         const int dstWidth = intel_fb->front->width;
00079         const int dstHeight = intel_fb->front->height;
00080         const int dstPitch = intel_fb->front->pitch / 4;
00081 
00082         const int cpp = 4;
00083         const int srcPitch = surf->stride / cpp;
00084 
00085         int BR13, CMD;
00086         
00087 
00088         BR13 = (dstPitch * cpp) | (0xCC << 16) | (1 << 24) | (1 << 25);
00089         CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
00090                         XY_SRC_COPY_BLT_WRITE_RGB);
00091 
00092         BEGIN_BATCH(8, 2);
00093         OUT_BATCH(CMD);
00094         OUT_BATCH(BR13);
00095         OUT_BATCH((0 << 16) | 0);
00096         OUT_BATCH((dstHeight << 16) | dstWidth);
00097 
00098         OUT_RELOC(intel_fb->front_buffer,
00099                 DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE,
00100                 DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0);
00101 
00102         OUT_BATCH((0 << 16) | 0);
00103         OUT_BATCH((srcPitch * cpp) & 0xffff);
00104         OUT_RELOC(dri_bo(surf->buffer),
00105                         DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
00106                         DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0);
00107 
00108         fence = intel_be_batchbuffer_flush(intel->base.batch);
00109         driFenceUnReference(&fence);
00110         intel_be_batchbuffer_finish(intel->base.batch);
00111 }