sp_state_surface.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 /* Authors:  Keith Whitwell <keith@tungstengraphics.com>
00029  */
00030 #include "pipe/p_inlines.h"
00031 
00032 #include "sp_context.h"
00033 #include "sp_state.h"
00034 #include "sp_surface.h"
00035 #include "sp_tile_cache.h"
00036 
00037 #include "draw/draw_context.h"
00038 
00039 
00046 void
00047 softpipe_set_framebuffer_state(struct pipe_context *pipe,
00048                                const struct pipe_framebuffer_state *fb)
00049 {
00050    struct softpipe_context *sp = softpipe_context(pipe);
00051    uint i;
00052 
00053    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
00054       /* check if changing cbuf */
00055       if (sp->framebuffer.cbufs[i] != fb->cbufs[i]) {
00056          /* flush old */
00057          sp_flush_tile_cache(sp, sp->cbuf_cache[i]);
00058 
00059          /* assign new */
00060          sp->framebuffer.cbufs[i] = fb->cbufs[i];
00061 
00062          /* update cache */
00063          sp_tile_cache_set_surface(sp->cbuf_cache[i], fb->cbufs[i]);
00064       }
00065    }
00066 
00067    sp->framebuffer.num_cbufs = fb->num_cbufs;
00068 
00069    /* zbuf changing? */
00070    if (sp->framebuffer.zsbuf != fb->zsbuf) {
00071       /* flush old */
00072       sp_flush_tile_cache(sp, sp->zsbuf_cache);
00073 
00074       /* assign new */
00075       sp->framebuffer.zsbuf = fb->zsbuf;
00076 
00077       /* update cache */
00078       sp_tile_cache_set_surface(sp->zsbuf_cache, fb->zsbuf);
00079    }
00080 
00081 #if 0
00082    /* XXX combined depth/stencil here */
00083 
00084    /* sbuf changing? */
00085    if (sp->framebuffer.sbuf != fb->sbuf) {
00086       /* flush old */
00087       sp_flush_tile_cache(sp, sp->sbuf_cache_sep);
00088 
00089       /* assign new */
00090       sp->framebuffer.sbuf = fb->sbuf;
00091 
00092       /* update cache */
00093       if (fb->sbuf != fb->zbuf) {
00094          /* separate stencil buf */
00095          sp->sbuf_cache = sp->sbuf_cache_sep;
00096          sp_tile_cache_set_surface(sp->sbuf_cache, fb->sbuf);
00097       }
00098       else {
00099          /* combined depth/stencil */
00100          sp->sbuf_cache = sp->zbuf_cache;
00101          sp_tile_cache_set_surface(sp->sbuf_cache, fb->sbuf);
00102       }
00103    }
00104 #endif
00105 
00106    /* Tell draw module how deep the Z/depth buffer is */
00107    {
00108       int depth_bits;
00109       double mrd;
00110       if (sp->framebuffer.zsbuf) {
00111          depth_bits = pf_get_component_bits(sp->framebuffer.zsbuf->format,
00112                                             PIPE_FORMAT_COMP_Z);
00113       }
00114       else {
00115          depth_bits = 0;
00116       }
00117       if (depth_bits > 16) {
00118          mrd = 0.0000001;
00119       }
00120       else {
00121          mrd = 0.00002;
00122       }
00123       draw_set_mrd(sp->draw, mrd);
00124    }
00125 
00126    sp->framebuffer.width = fb->width;
00127    sp->framebuffer.height = fb->height;
00128 
00129    sp->dirty |= SP_NEW_FRAMEBUFFER;
00130 }

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