sp_flush.c

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2007 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 /* Author:
00029  *    Keith Whitwell <keith@tungstengraphics.com>
00030  */
00031 
00032 
00033 #include "pipe/p_defines.h"
00034 #include "draw/draw_context.h"
00035 #include "sp_flush.h"
00036 #include "sp_context.h"
00037 #include "sp_surface.h"
00038 #include "sp_state.h"
00039 #include "sp_tile_cache.h"
00040 #include "sp_winsys.h"
00041 
00042 
00043 void
00044 softpipe_flush( struct pipe_context *pipe,
00045                 unsigned flags,
00046                 struct pipe_fence_handle **fence )
00047 {
00048    struct softpipe_context *softpipe = softpipe_context(pipe);
00049    uint i;
00050 
00051    draw_flush(softpipe->draw);
00052 
00053    if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
00054       for (i = 0; i < softpipe->num_textures; i++) {
00055          sp_flush_tile_cache(softpipe, softpipe->tex_cache[i]);
00056       }
00057    }
00058 
00059    if (flags & PIPE_FLUSH_RENDER_CACHE) {
00060       for (i = 0; i < softpipe->framebuffer.num_cbufs; i++)
00061          if (softpipe->cbuf_cache[i])
00062             sp_flush_tile_cache(softpipe, softpipe->cbuf_cache[i]);
00063 
00064       if (softpipe->zsbuf_cache)
00065          sp_flush_tile_cache(softpipe, softpipe->zsbuf_cache);
00066 
00067       /* Need this call for hardware buffers before swapbuffers.
00068        *
00069        * there should probably be another/different flush-type function
00070        * that's called before swapbuffers because we don't always want
00071        * to unmap surfaces when flushing.
00072        */
00073       softpipe_unmap_surfaces(softpipe);
00074    }
00075 
00076    /* Enable to dump BMPs of the color/depth buffers each frame */
00077 #if 0
00078    if(flags & PIPE_FLUSH_FRAME) {
00079       static unsigned frame_no = 1;
00080       static char filename[256];
00081       util_snprintf(filename, sizeof(filename), "cbuf_%u.bmp", frame_no);
00082       debug_dump_surface_bmp(filename, softpipe->framebuffer.cbufs[0]);
00083       util_snprintf(filename, sizeof(filename), "zsbuf_%u.bmp", frame_no);
00084       debug_dump_surface_bmp(filename, softpipe->framebuffer.zsbuf);
00085       ++frame_no;
00086    }
00087 #endif
00088    
00089    if (fence)
00090       *fence = NULL;
00091 }
00092 

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