summaryrefslogtreecommitdiffstats
path: root/src/mesa/tnl/t_vp_build.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-10-29 12:18:58 -0600
committerBrian <[email protected]>2007-10-29 15:15:34 -0600
commit9946012949ad294b2255f914fee4c80cff5e0040 (patch)
tree675dca8f7e36cccda43b57ef6ac04b05d43d3a87 /src/mesa/tnl/t_vp_build.c
parent783cedcdc14feda9c8ad0ca754752254bfa589eb (diff)
refactoring to begin removing dependency on tnl context
Diffstat (limited to 'src/mesa/tnl/t_vp_build.c')
-rw-r--r--src/mesa/tnl/t_vp_build.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c
index 056eb0db8ef..2b7d8eebe03 100644
--- a/src/mesa/tnl/t_vp_build.c
+++ b/src/mesa/tnl/t_vp_build.c
@@ -114,10 +114,40 @@ static GLuint translate_texgen( GLboolean enabled, GLenum mode )
}
}
-static struct state_key *make_state_key( GLcontext *ctx )
+
+/**
+ * Returns bitmask of flags indicating which materials are set per-vertex
+ * in the current VB.
+ * XXX get these from the VBO...
+ */
+static GLbitfield
+tnl_get_per_vertex_materials(GLcontext *ctx)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+ GLbitfield mask = 0x0;
+
+ for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++)
+ if (VB->AttribPtr[i] && VB->AttribPtr[i]->stride)
+ mask |= 1 << (i - _TNL_FIRST_MAT);
+
+ return mask;
+}
+
+/**
+ * Should fog be computed per-vertex?
+ */
+static GLbitfield
+tnl_get_per_vertex_fog(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ return tnl->_DoVertexFog;
+}
+
+
+static struct state_key *make_state_key( GLcontext *ctx )
+{
const struct gl_fragment_program *fp;
struct state_key *key = CALLOC_STRUCT(state_key);
GLuint i;
@@ -152,9 +182,7 @@ static struct state_key *make_state_key( GLcontext *ctx )
key->light_color_material_mask = ctx->Light.ColorMaterialBitmask;
}
- for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++)
- if (VB->AttribPtr[i] && VB->AttribPtr[i]->stride)
- key->light_material_mask |= 1<<(i-_TNL_ATTRIB_MAT_FRONT_AMBIENT);
+ key->light_material_mask = tnl_get_per_vertex_materials(ctx);
for (i = 0; i < MAX_LIGHTS; i++) {
struct gl_light *light = &ctx->Light.Light[i];
@@ -187,8 +215,7 @@ static struct state_key *make_state_key( GLcontext *ctx )
if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT)
key->fog_source_is_depth = 1;
- if (tnl->_DoVertexFog)
- key->tnl_do_vertex_fog = 1;
+ key->tnl_do_vertex_fog = tnl_get_per_vertex_fog(ctx);
if (ctx->Point._Attenuated)
key->point_attenuated = 1;