intel_swapbuffers.c

Go to the documentation of this file.
00001 /**************************************************************************
00002  *
00003  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  *
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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         //const int srcWidth = surf->width;
00070         //const int srcHeight = surf->height;
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;//draw->front.cpp;
00081 
00082         const int cpp = 4;//intel_fb->front->cpp;
00083         const int srcPitch = surf->stride / cpp;
00084 
00085         int BR13, CMD;
00086         //int i;
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 }

Generated on Tue Sep 29 06:25:17 2009 for Gallium3D by  doxygen 1.5.4