i915_state_immediate.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:
00029   *   Keith Whitwell <keith@tungstengraphics.com>
00030   */
00031  
00032 #include "i915_state_inlines.h"
00033 #include "i915_context.h"
00034 #include "i915_state.h"
00035 #include "i915_reg.h"
00036 #include "util/u_memory.h"
00037 
00038 
00039 /* All state expressable with the LOAD_STATE_IMMEDIATE_1 packet.
00040  * Would like to opportunistically recombine all these fragments into
00041  * a single packet containing only what has changed, but for now emit
00042  * as multiple packets.
00043  */
00044 
00045 
00046 
00047 
00048 /***********************************************************************
00049  * S0,S1: Vertex buffer state.  
00050  */
00051 static void upload_S0S1(struct i915_context *i915)
00052 {
00053    unsigned LIS0, LIS1;
00054 
00055    /* INTEL_NEW_VBO */
00056    /* TODO: re-use vertex buffers here? */
00057    LIS0 = i915->vbo_offset;
00058 
00059    /* INTEL_NEW_VERTEX_SIZE -- do this where the vertex size is calculated! 
00060     */
00061    {
00062       unsigned vertex_size = i915->current.vertex_info.size;
00063 
00064       LIS1 = ((vertex_size << 24) |
00065               (vertex_size << 16));
00066    }
00067 
00068    /* INTEL_NEW_VBO */
00069    /* TODO: use a vertex generation number to track vbo changes */
00070    if (1 ||
00071        i915->current.immediate[I915_IMMEDIATE_S0] != LIS0 ||
00072        i915->current.immediate[I915_IMMEDIATE_S1] != LIS1) 
00073    {
00074       i915->current.immediate[I915_IMMEDIATE_S0] = LIS0;
00075       i915->current.immediate[I915_IMMEDIATE_S1] = LIS1;
00076       i915->hardware_dirty |= I915_HW_IMMEDIATE;
00077    }
00078 }
00079 
00080 const struct i915_tracked_state i915_upload_S0S1 = {
00081    I915_NEW_VBO | I915_NEW_VERTEX_FORMAT,
00082    upload_S0S1
00083 };
00084 
00085 
00086 
00087 
00088 /***********************************************************************
00089  * S4: Vertex format, rasterization state
00090  */
00091 static void upload_S2S4(struct i915_context *i915)
00092 {
00093    unsigned LIS2, LIS4;
00094 
00095    /* I915_NEW_VERTEX_FORMAT */
00096    {
00097       LIS2 = i915->current.vertex_info.hwfmt[1];
00098       LIS4 = i915->current.vertex_info.hwfmt[0];
00099       /*
00100       debug_printf("LIS2: 0x%x  LIS4: 0x%x\n", LIS2, LIS4);
00101       */
00102       assert(LIS4); /* should never be zero? */
00103    }
00104 
00105    LIS4 |= i915->rasterizer->LIS4;
00106 
00107    if (LIS2 != i915->current.immediate[I915_IMMEDIATE_S2] ||
00108        LIS4 != i915->current.immediate[I915_IMMEDIATE_S4]) {
00109 
00110       i915->current.immediate[I915_IMMEDIATE_S2] = LIS2;
00111       i915->current.immediate[I915_IMMEDIATE_S4] = LIS4;
00112       i915->hardware_dirty |= I915_HW_IMMEDIATE;
00113    }
00114 }
00115 
00116 
00117 const struct i915_tracked_state i915_upload_S2S4 = {
00118    I915_NEW_RASTERIZER | I915_NEW_VERTEX_FORMAT,
00119    upload_S2S4
00120 };
00121 
00122 
00123 
00124 /***********************************************************************
00125  * 
00126  */
00127 static void upload_S5( struct i915_context *i915 )
00128 {
00129    unsigned LIS5 = 0;
00130 
00131    LIS5 |= i915->depth_stencil->stencil_LIS5;
00132 
00133    LIS5 |= i915->blend->LIS5;
00134 
00135 #if 0
00136    /* I915_NEW_RASTERIZER */
00137    if (i915->state.Polygon->OffsetFill) {
00138       LIS5 |= S5_GLOBAL_DEPTH_OFFSET_ENABLE;
00139    }
00140 #endif
00141 
00142 
00143    if (LIS5 != i915->current.immediate[I915_IMMEDIATE_S5]) {
00144       i915->current.immediate[I915_IMMEDIATE_S5] = LIS5;
00145       i915->hardware_dirty |= I915_HW_IMMEDIATE;
00146    }
00147 }
00148 
00149 const struct i915_tracked_state i915_upload_S5 = {
00150    (I915_NEW_DEPTH_STENCIL | I915_NEW_BLEND | I915_NEW_RASTERIZER),
00151    upload_S5
00152 };
00153 
00154 
00155 /***********************************************************************
00156  */
00157 static void upload_S6( struct i915_context *i915 )
00158 {
00159    unsigned LIS6 = (2 << S6_TRISTRIP_PV_SHIFT);
00160 
00161    /* I915_NEW_FRAMEBUFFER
00162     */
00163    if (i915->framebuffer.cbufs[0])
00164       LIS6 |= S6_COLOR_WRITE_ENABLE;
00165 
00166    /* I915_NEW_BLEND
00167     */
00168    LIS6 |= i915->blend->LIS6;
00169 
00170    /* I915_NEW_DEPTH
00171     */
00172    LIS6 |= i915->depth_stencil->depth_LIS6;
00173 
00174    if (LIS6 != i915->current.immediate[I915_IMMEDIATE_S6]) {
00175       i915->current.immediate[I915_IMMEDIATE_S6] = LIS6;
00176       i915->hardware_dirty |= I915_HW_IMMEDIATE;
00177    }
00178 }
00179 
00180 const struct i915_tracked_state i915_upload_S6 = {
00181    I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL | I915_NEW_FRAMEBUFFER,
00182    upload_S6
00183 };
00184 
00185 
00186 /***********************************************************************
00187  */
00188 static void upload_S7( struct i915_context *i915 )
00189 {
00190    unsigned LIS7;
00191 
00192    /* I915_NEW_RASTERIZER
00193     */
00194    LIS7 = i915->rasterizer->LIS7;
00195 
00196    if (LIS7 != i915->current.immediate[I915_IMMEDIATE_S7]) {
00197       i915->current.immediate[I915_IMMEDIATE_S7] = LIS7;
00198       i915->hardware_dirty |= I915_HW_IMMEDIATE;
00199    }
00200 }
00201 
00202 const struct i915_tracked_state i915_upload_S7 = {
00203    I915_NEW_RASTERIZER,
00204    upload_S7
00205 };
00206 
00207 
00208 static const struct i915_tracked_state *atoms[] = {
00209    &i915_upload_S0S1,
00210    &i915_upload_S2S4,
00211    &i915_upload_S5,
00212    &i915_upload_S6,
00213    &i915_upload_S7
00214 };
00215 
00216 /* 
00217  */
00218 void i915_update_immediate( struct i915_context *i915 )
00219 {
00220    int i;
00221 
00222    for (i = 0; i < Elements(atoms); i++)
00223       if (i915->dirty & atoms[i]->dirty)
00224          atoms[i]->update( i915 );
00225 }

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