core | glapi | vbo | math | shader | swrast | swrast_setup | tnl | tnl_dd

state.c File Reference


Detailed Description

State management.

This file manages recalculation of derived values in GLcontext.

#include "glheader.h"
#include "mtypes.h"
#include "context.h"
#include "debug.h"
#include "macros.h"
#include "ffvertex_prog.h"
#include "framebuffer.h"
#include "light.h"
#include "matrix.h"
#include "pixel.h"
#include "shader/program.h"
#include "shader/prog_parameter.h"
#include "state.h"
#include "stencil.h"
#include "texenvprogram.h"
#include "texobj.h"
#include "texstate.h"
#include "viewport.h"

Functions

static void update_separate_specular (GLcontext *ctx)
static void compute_max_element (struct gl_client_array *array)
 Compute the index of the last array element that can be safely accessed in a vertex array.
static GLuint update_min (GLuint min, struct gl_client_array *array)
 Helper for update_arrays().
static void update_arrays (GLcontext *ctx)
 Update ctx->Array._MaxElement (the max legal index into all enabled arrays).
static void update_program_enables (GLcontext *ctx)
 Update the following fields: ctx->VertexProgram._Enabled ctx->FragmentProgram._Enabled ctx->ATIFragmentShader._Enabled This needs to be done before texture state validation.
static GLbitfield update_program (GLcontext *ctx)
 Update vertex/fragment program state.
static GLbitfield update_program_constants (GLcontext *ctx)
 Examine shader constants and return either _NEW_PROGRAM_CONSTANTS or 0.
static void update_viewport_matrix (GLcontext *ctx)
static void update_multisample (GLcontext *ctx)
 Update derived multisample state.
static void update_color (GLcontext *ctx)
 Update derived color/blend/logicop state.
static void update_polygon (GLcontext *ctx)
void _mesa_update_state_locked (GLcontext *ctx)
 Update the ctx->_TriangleCaps bitfield.
void _mesa_update_state (GLcontext *ctx)
void _mesa_set_varying_vp_inputs (GLcontext *ctx, GLbitfield varying_inputs)
 Want to figure out which fragment program inputs are actually constant/current values from ctx->Current.
void _mesa_set_vp_override (GLcontext *ctx, GLboolean flag)
 Used by drivers to tell core Mesa that the driver is going to install/ use its own vertex program.


Function Documentation

void _mesa_set_varying_vp_inputs ( GLcontext ctx,
GLbitfield  varying_inputs 
)

Want to figure out which fragment program inputs are actually constant/current values from ctx->Current.

These should be referenced as a tracked state variable rather than a fragment program input, to save the overhead of putting a constant value in every submitted vertex, transferring it to hardware, interpolating it across the triangle, etc...

When there is a VP bound, just use vp->outputs. But when we're generating vp from fixed function state, basically want to calculate:

vp_out_2_fp_in( vp_in_2_vp_out( varying_inputs ) | potential_vp_outputs )

Where potential_vp_outputs is calculated by looking at enabled texgen, etc.

The generated fragment program should then only declare inputs that may vary or otherwise differ from the ctx->Current values. Otherwise, the fp should track them as state values instead.

void _mesa_set_vp_override ( GLcontext ctx,
GLboolean  flag 
)

Used by drivers to tell core Mesa that the driver is going to install/ use its own vertex program.

In particular, this will prevent generated fragment programs from using state vars instead of ordinary varyings/inputs.

void _mesa_update_state ( GLcontext ctx  ) 

void _mesa_update_state_locked ( GLcontext ctx  ) 

Update the ctx->_TriangleCaps bitfield.

XXX that bitfield should really go away someday! This function must be called after other update_*() functions since there are dependencies on some other derived values. Compute derived GL state. If __GLcontextRec::NewState is non-zero then this function must be called before rendering anything.

Calls dd_function_table::UpdateState to perform any internal state management necessary.

See also:
_mesa_update_modelview_project(), _mesa_update_texture(), _mesa_update_buffer_bounds(), _mesa_update_lighting() and _mesa_update_tnl_spaces().

static void compute_max_element ( struct gl_client_array array  )  [static]

Compute the index of the last array element that can be safely accessed in a vertex array.

We can really only do this when the array lives in a VBO. The array->_MaxElement field will be updated. Later in glDrawArrays/Elements/etc we can do some bounds checking.

static void update_arrays ( GLcontext ctx  )  [static]

Update ctx->Array._MaxElement (the max legal index into all enabled arrays).

Need to do this upon new array state or new buffer object state.

static void update_color ( GLcontext ctx  )  [static]

Update derived color/blend/logicop state.

static GLuint update_min ( GLuint  min,
struct gl_client_array array 
) [static]

Helper for update_arrays().

Returns:
min(current min, array->_MaxElement).

static void update_multisample ( GLcontext ctx  )  [static]

Update derived multisample state.

static void update_polygon ( GLcontext ctx  )  [static]

static GLbitfield update_program ( GLcontext ctx  )  [static]

Update vertex/fragment program state.

In particular, update these fields: ctx->VertexProgram._Current ctx->VertexProgram._TnlProgram, These point to the highest priority enabled vertex/fragment program or are NULL if fixed-function processing is to be done.

This function needs to be called after texture state validation in case we're generating a fragment program from fixed-function texture state.

Returns:
bitfield which will indicate _NEW_PROGRAM state if a new vertex or fragment program is being used.

static GLbitfield update_program_constants ( GLcontext ctx  )  [static]

Examine shader constants and return either _NEW_PROGRAM_CONSTANTS or 0.

static void update_program_enables ( GLcontext ctx  )  [static]

Update the following fields: ctx->VertexProgram._Enabled ctx->FragmentProgram._Enabled ctx->ATIFragmentShader._Enabled This needs to be done before texture state validation.

static void update_separate_specular ( GLcontext ctx  )  [static]

static void update_viewport_matrix ( GLcontext ctx  )  [static]


Generated on Sun Sep 27 06:47:46 2009 for Mesa Main by  doxygen 1.5.4