fo_state_emit.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 
00031 #include "fo_context.h"
00032 
00033 /* This looks like a lot of work at the moment - we're keeping a
00034  * duplicate copy of the state up-to-date.  
00035  *
00036  * This can change in two ways:
00037  * - With constant state objects we would only need to save a pointer,
00038  *     not the whole object.
00039  * - By adding a callback in the state tracker to re-emit state.  The
00040  *     state tracker knows the current state already and can re-emit it 
00041  *     without additional complexity.
00042  *
00043  * This works as a proof-of-concept, but a final version will have
00044  * lower overheads.
00045  */
00046 
00047 
00048 /* Bring the software pipe uptodate with current state.
00049  * 
00050  * With constant state objects we would probably just send all state
00051  * to both rasterizers all the time???
00052  */
00053 void
00054 failover_state_emit( struct failover_context *failover )
00055 {
00056    if (failover->dirty & FO_NEW_BLEND)
00057       failover->sw->bind_blend_state( failover->sw,
00058                                       failover->blend->sw_state );
00059 
00060    if (failover->dirty & FO_NEW_BLEND_COLOR)
00061       failover->sw->set_blend_color( failover->sw, &failover->blend_color );
00062 
00063    if (failover->dirty & FO_NEW_CLIP)
00064       failover->sw->set_clip_state( failover->sw, &failover->clip );
00065 
00066    if (failover->dirty & FO_NEW_DEPTH_STENCIL)
00067       failover->sw->bind_depth_stencil_alpha_state( failover->sw,
00068                                                     failover->depth_stencil->sw_state );
00069 
00070    if (failover->dirty & FO_NEW_FRAMEBUFFER)
00071       failover->sw->set_framebuffer_state( failover->sw, &failover->framebuffer );
00072 
00073    if (failover->dirty & FO_NEW_FRAGMENT_SHADER)
00074       failover->sw->bind_fs_state( failover->sw,
00075                                    failover->fragment_shader->sw_state );
00076 
00077    if (failover->dirty & FO_NEW_VERTEX_SHADER)
00078       failover->sw->bind_vs_state( failover->sw,
00079                                    failover->vertex_shader->sw_state );
00080 
00081    if (failover->dirty & FO_NEW_STIPPLE)
00082       failover->sw->set_polygon_stipple( failover->sw, &failover->poly_stipple );
00083 
00084    if (failover->dirty & FO_NEW_RASTERIZER)
00085       failover->sw->bind_rasterizer_state( failover->sw,
00086                                            failover->rasterizer->sw_state );
00087 
00088    if (failover->dirty & FO_NEW_SCISSOR)
00089       failover->sw->set_scissor_state( failover->sw, &failover->scissor );
00090 
00091    if (failover->dirty & FO_NEW_VIEWPORT)
00092       failover->sw->set_viewport_state( failover->sw, &failover->viewport );
00093 
00094    if (failover->dirty & FO_NEW_SAMPLER) {
00095       failover->sw->bind_sampler_states( failover->sw, failover->num_samplers,
00096                                          failover->sw_sampler_state );
00097    }
00098 
00099    if (failover->dirty & FO_NEW_TEXTURE) {
00100       failover->sw->set_sampler_textures( failover->sw, failover->num_textures, 
00101                                           failover->texture );
00102    }
00103 
00104    if (failover->dirty & FO_NEW_VERTEX_BUFFER) {
00105       failover->sw->set_vertex_buffers( failover->sw,
00106                                         failover->num_vertex_buffers,
00107                                         failover->vertex_buffers );
00108    }
00109 
00110    if (failover->dirty & FO_NEW_VERTEX_ELEMENT) {
00111       failover->sw->set_vertex_elements( failover->sw,
00112                                          failover->num_vertex_elements,
00113                                          failover->vertex_elements );
00114    }
00115 
00116    failover->dirty = 0;
00117 }

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