summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-02-24 18:24:07 -0800
committerIan Romanick <ian.d.romanick@intel.com>2010-03-03 12:37:04 -0800
commita9c1b3caf67f035df83c6a4e38709cfa395f4cc6 (patch)
tree548d499762ff263d8f5a8a0d94b0d9f6cac0e506 /src/mesa
parent5cf2c5851bcd29c2d53bb04ab692b4b156f5a74d (diff)
tnl: Remove color-index TNL support
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/swrast_setup/ss_context.c5
-rw-r--r--src/mesa/tnl/t_context.c33
-rw-r--r--src/mesa/tnl/t_rasterpos.c52
-rw-r--r--src/mesa/tnl/t_vb_light.c37
-rw-r--r--src/mesa/tnl/t_vb_lighttmp.h173
5 files changed, 39 insertions, 261 deletions
diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c
index bc1ec58992..ebd1574c43 100644
--- a/src/mesa/swrast_setup/ss_context.c
+++ b/src/mesa/swrast_setup/ss_context.c
@@ -141,11 +141,6 @@ setup_vertex_format(GLcontext *ctx)
EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F, attrib[FRAG_ATTRIB_COL1]);
}
- if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR_INDEX )) {
- EMIT_ATTR( _TNL_ATTRIB_COLOR_INDEX, EMIT_1F,
- attrib[FRAG_ATTRIB_CI][0] );
- }
-
if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) {
const GLint emit = ctx->FragmentProgram._Current ? EMIT_4F : EMIT_1F;
EMIT_ATTR( _TNL_ATTRIB_FOG, emit, attrib[FRAG_ATTRIB_FOGC]);
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
index 5a14e595a0..f27c8ad9d6 100644
--- a/src/mesa/tnl/t_context.c
+++ b/src/mesa/tnl/t_context.c
@@ -107,6 +107,7 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
TNLcontext *tnl = TNL_CONTEXT(ctx);
const struct gl_vertex_program *vp = ctx->VertexProgram._Current;
const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
+ GLuint i;
if (new_state & (_NEW_HINT | _NEW_PROGRAM)) {
ASSERT(tnl->AllowVertexFog || tnl->AllowPixelFog);
@@ -119,29 +120,21 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
/* Calculate tnl->render_inputs. This bitmask indicates which vertex
* attributes need to be emitted to the rasterizer.
*/
- if (ctx->Visual.rgbMode) {
- GLuint i;
-
- RENDERINPUTS_ZERO( tnl->render_inputs_bitset );
- RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POS );
+ RENDERINPUTS_ZERO( tnl->render_inputs_bitset );
+ RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POS );
- if (!fp || (fp->Base.InputsRead & FRAG_BIT_COL0)) {
- RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR0 );
- }
+ if (!fp || (fp->Base.InputsRead & FRAG_BIT_COL0)) {
+ RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR0 );
+ }
- if (NEED_SECONDARY_COLOR(ctx))
- RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR1 );
+ if (NEED_SECONDARY_COLOR(ctx))
+ RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR1 );
- for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
- if (ctx->Texture._EnabledCoordUnits & (1 << i) ||
- (fp && fp->Base.InputsRead & FRAG_BIT_TEX(i))) {
- RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_TEX(i) );
- }
- }
- }
- else {
- RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POS );
- RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR_INDEX );
+ for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
+ if (ctx->Texture._EnabledCoordUnits & (1 << i) ||
+ (fp && fp->Base.InputsRead & FRAG_BIT_TEX(i))) {
+ RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_TEX(i) );
+ }
}
if (ctx->Fog.Enabled) {
diff --git a/src/mesa/tnl/t_rasterpos.c b/src/mesa/tnl/t_rasterpos.c
index 13b84a7d77..3596d162b2 100644
--- a/src/mesa/tnl/t_rasterpos.c
+++ b/src/mesa/tnl/t_rasterpos.c
@@ -119,8 +119,7 @@ shade_rastpos(GLcontext *ctx,
const GLfloat vertex[4],
const GLfloat normal[3],
GLfloat Rcolor[4],
- GLfloat Rspec[4],
- GLfloat *Rindex)
+ GLfloat Rspec[4])
{
/*const*/ GLfloat (*base)[3] = ctx->Light._BaseColor;
const struct gl_light *light;
@@ -244,28 +243,14 @@ shade_rastpos(GLcontext *ctx,
ACC_SCALE_SCALAR_3V( specularColor, attenuation, specularContrib );
}
- if (ctx->Visual.rgbMode) {
- Rcolor[0] = CLAMP(diffuseColor[0], 0.0F, 1.0F);
- Rcolor[1] = CLAMP(diffuseColor[1], 0.0F, 1.0F);
- Rcolor[2] = CLAMP(diffuseColor[2], 0.0F, 1.0F);
- Rcolor[3] = CLAMP(diffuseColor[3], 0.0F, 1.0F);
- Rspec[0] = CLAMP(specularColor[0], 0.0F, 1.0F);
- Rspec[1] = CLAMP(specularColor[1], 0.0F, 1.0F);
- Rspec[2] = CLAMP(specularColor[2], 0.0F, 1.0F);
- Rspec[3] = CLAMP(specularColor[3], 0.0F, 1.0F);
- }
- else {
- GLfloat *ind = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_INDEXES];
- GLfloat d_a = ind[MAT_INDEX_DIFFUSE] - ind[MAT_INDEX_AMBIENT];
- GLfloat s_a = ind[MAT_INDEX_SPECULAR] - ind[MAT_INDEX_AMBIENT];
- GLfloat i = (ind[MAT_INDEX_AMBIENT]
- + diffuseCI * (1.0F-specularCI) * d_a
- + specularCI * s_a);
- if (i > ind[MAT_INDEX_SPECULAR]) {
- i = ind[MAT_INDEX_SPECULAR];
- }
- *Rindex = i;
- }
+ Rcolor[0] = CLAMP(diffuseColor[0], 0.0F, 1.0F);
+ Rcolor[1] = CLAMP(diffuseColor[1], 0.0F, 1.0F);
+ Rcolor[2] = CLAMP(diffuseColor[2], 0.0F, 1.0F);
+ Rcolor[3] = CLAMP(diffuseColor[3], 0.0F, 1.0F);
+ Rspec[0] = CLAMP(specularColor[0], 0.0F, 1.0F);
+ Rspec[1] = CLAMP(specularColor[1], 0.0F, 1.0F);
+ Rspec[2] = CLAMP(specularColor[2], 0.0F, 1.0F);
+ Rspec[3] = CLAMP(specularColor[3], 0.0F, 1.0F);
}
@@ -469,21 +454,14 @@ _tnl_RasterPos(GLcontext *ctx, const GLfloat vObj[4])
/* lighting */
shade_rastpos( ctx, vObj, norm,
ctx->Current.RasterColor,
- ctx->Current.RasterSecondaryColor,
- &ctx->Current.RasterIndex );
+ ctx->Current.RasterSecondaryColor );
}
else {
- /* use current color or index */
- if (ctx->Visual.rgbMode) {
- COPY_4FV(ctx->Current.RasterColor,
- ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
- COPY_4FV(ctx->Current.RasterSecondaryColor,
- ctx->Current.Attrib[VERT_ATTRIB_COLOR1]);
- }
- else {
- ctx->Current.RasterIndex
- = ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0];
- }
+ /* use current color */
+ COPY_4FV(ctx->Current.RasterColor,
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
+ COPY_4FV(ctx->Current.RasterSecondaryColor,
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR1]);
}
/* texture coords */
diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c
index 8a0fe63fd8..e7309aaac6 100644
--- a/src/mesa/tnl/t_vb_light.c
+++ b/src/mesa/tnl/t_vb_light.c
@@ -64,7 +64,6 @@ struct light_stage_data {
GLvector4f Input;
GLvector4f LitColor[2];
GLvector4f LitSecondary[2];
- GLvector4f LitIndex[2];
light_func *light_func_tab;
struct material_cursor mat[MAT_ATTRIB_MAX];
@@ -161,7 +160,6 @@ static light_func _tnl_light_tab[MAX_LIGHT_FUNC];
static light_func _tnl_light_fast_tab[MAX_LIGHT_FUNC];
static light_func _tnl_light_fast_single_tab[MAX_LIGHT_FUNC];
static light_func _tnl_light_spec_tab[MAX_LIGHT_FUNC];
-static light_func _tnl_light_ci_tab[MAX_LIGHT_FUNC];
#define TAG(x) x
#define IDX (0)
@@ -260,22 +258,18 @@ static void validate_lighting( GLcontext *ctx,
if (!ctx->Light.Enabled || ctx->VertexProgram._Current)
return;
- if (ctx->Visual.rgbMode) {
- if (ctx->Light._NeedVertices) {
- if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
- tab = _tnl_light_spec_tab;
- else
- tab = _tnl_light_tab;
- }
- else {
- if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev)
- tab = _tnl_light_fast_single_tab;
- else
- tab = _tnl_light_fast_tab;
- }
+ if (ctx->Light._NeedVertices) {
+ if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
+ tab = _tnl_light_spec_tab;
+ else
+ tab = _tnl_light_tab;
+ }
+ else {
+ if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev)
+ tab = _tnl_light_fast_single_tab;
+ else
+ tab = _tnl_light_fast_tab;
}
- else
- tab = _tnl_light_ci_tab;
LIGHT_STAGE_DATA(stage)->light_func_tab = tab;
@@ -311,19 +305,12 @@ static GLboolean init_lighting( GLcontext *ctx,
_mesa_vector4f_alloc( &store->LitColor[1], 0, size, 32 );
_mesa_vector4f_alloc( &store->LitSecondary[0], 0, size, 32 );
_mesa_vector4f_alloc( &store->LitSecondary[1], 0, size, 32 );
- _mesa_vector4f_alloc( &store->LitIndex[0], 0, size, 32 );
- _mesa_vector4f_alloc( &store->LitIndex[1], 0, size, 32 );
store->LitColor[0].size = 4;
store->LitColor[1].size = 4;
store->LitSecondary[0].size = 3;
store->LitSecondary[1].size = 3;
- store->LitIndex[0].size = 1;
- store->LitIndex[0].stride = sizeof(GLfloat);
- store->LitIndex[1].size = 1;
- store->LitIndex[1].stride = sizeof(GLfloat);
-
return GL_TRUE;
}
@@ -340,8 +327,6 @@ static void dtr( struct tnl_pipeline_stage *stage )
_mesa_vector4f_free( &store->LitColor[1] );
_mesa_vector4f_free( &store->LitSecondary[0] );
_mesa_vector4f_free( &store->LitSecondary[1] );
- _mesa_vector4f_free( &store->LitIndex[0] );
- _mesa_vector4f_free( &store->LitIndex[1] );
FREE( store );
stage->privatePtr = NULL;
}
diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h
index 4ebef2356f..0a98c6b02a 100644
--- a/src/mesa/tnl/t_vb_lighttmp.h
+++ b/src/mesa/tnl/t_vb_lighttmp.h
@@ -637,185 +637,12 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
-
-/*
- * Use current lighting/material settings to compute the color indexes
- * for an array of vertices.
- * Input: n - number of vertices to light
- * side - 0=use front material, 1=use back material
- * vertex - array of [n] vertex position in eye coordinates
- * normal - array of [n] surface normal vector
- * Output: indexResult - resulting array of [n] color indexes
- */
-static void TAG(light_ci)( GLcontext *ctx,
- struct vertex_buffer *VB,
- struct tnl_pipeline_stage *stage,
- GLvector4f *input )
-{
- struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
- GLuint j;
- const GLuint vstride = input->stride;
- const GLfloat *vertex = (GLfloat *) input->data;
- const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
- const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
- GLfloat *indexResult[2];
- const GLuint nr = VB->Count;
-
-#ifdef TRACE
- fprintf(stderr, "%s\n", __FUNCTION__ );
-#endif
-
- VB->AttribPtr[_TNL_ATTRIB_COLOR_INDEX] = &store->LitIndex[0];
-#if IDX & LIGHT_TWOSIDE
- VB->BackfaceIndexPtr = &store->LitIndex[1];
-#endif
-
- indexResult[0] = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_COLOR_INDEX]->data;
-#if IDX & LIGHT_TWOSIDE
- indexResult[1] = (GLfloat *)VB->BackfaceIndexPtr->data;
-#endif
-
- /* loop over vertices */
- for (j=0; j<nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal, nstride)) {
- GLfloat diffuse[2], specular[2];
- GLuint side = 0;
- struct gl_light *light;
-
-#if IDX & LIGHT_MATERIAL
- update_materials( ctx, store );
-#endif
-
- diffuse[0] = specular[0] = 0.0F;
-
-#if IDX & LIGHT_TWOSIDE
- diffuse[1] = specular[1] = 0.0F;
-#endif
-
- /* Accumulate diffuse and specular from each light source */
- foreach (light, &ctx->Light.EnabledList) {
-
- GLfloat attenuation = 1.0F;
- GLfloat VP[3]; /* unit vector from vertex to light */
- GLfloat n_dot_VP; /* dot product of l and n */
- GLfloat *h, n_dot_h, correction = 1.0;
-
- /* compute l and attenuation */
- if (!(light->_Flags & LIGHT_POSITIONAL)) {
- /* directional light */
- COPY_3V(VP, light->_VP_inf_norm);
- }
- else {
- GLfloat d; /* distance from vertex to light */
-
- SUB_3V(VP, light->_Position, vertex);
-
- d = (GLfloat) LEN_3FV( VP );
- if ( d > 1e-6) {
- GLfloat invd = 1.0F / d;
- SELF_SCALE_SCALAR_3V(VP, invd);
- }
-
- attenuation = 1.0F / (light->ConstantAttenuation + d *
- (light->LinearAttenuation + d *
- light->QuadraticAttenuation));
-
- /* spotlight attenuation */
- if (light->_Flags & LIGHT_SPOT) {
- GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection);
- if (PV_dot_dir < light->_CosCutoff) {
- continue; /* this light makes no contribution */
- }
- else {
- GLdouble x = PV_dot_dir * (EXP_TABLE_SIZE-1);
- GLint k = (GLint) x;
- GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
- + (x-k)*light->_SpotExpTable[k][1]);
- attenuation *= spot;
- }
- }
- }
-
- if (attenuation < 1e-3)
- continue; /* this light makes no contribution */
-
- n_dot_VP = DOT3( normal, VP );
-
- /* which side are we lighting? */
- if (n_dot_VP < 0.0F) {
-#if IDX & LIGHT_TWOSIDE
- side = 1;
- correction = -1;
- n_dot_VP = -n_dot_VP;
-#else
- continue;
-#endif
- }
-
- /* accumulate diffuse term */
- diffuse[side] += n_dot_VP * light->_dli * attenuation;
-
- /* specular term */
- if (ctx->Light.Model.LocalViewer) {
- GLfloat v[3];
- COPY_3V(v, vertex);
- NORMALIZE_3FV(v);
- SUB_3V(VP, VP, v); /* h = VP + VPe */
- h = VP;
- NORMALIZE_3FV(h);
- }
- else if (light->_Flags & LIGHT_POSITIONAL) {
- h = VP;
- /* Strangely, disabling this addition fixes a conformance
- * problem. If this code is enabled, l_sed.c fails.
- */
- /*ACC_3V(h, ctx->_EyeZDir);*/
- NORMALIZE_3FV(h);
- }
- else {
- h = light->_h_inf_norm;
- }
-
- n_dot_h = correction * DOT3(normal, h);
- if (n_dot_h > 0.0F) {
- GLfloat spec_coef;
- struct gl_shine_tab *tab = ctx->_ShineTable[side];
- GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef);
- specular[side] += spec_coef * light->_sli * attenuation;
- }
- } /*loop over lights*/
-
- /* Now compute final color index */
- for (side = 0 ; side < NR_SIDES ; side++) {
- const GLfloat *ind = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_INDEXES + side];
- GLfloat index;
-
- if (specular[side] > 1.0F) {
- index = ind[MAT_INDEX_SPECULAR];
- }
- else {
- GLfloat d_a = ind[MAT_INDEX_DIFFUSE] - ind[MAT_INDEX_AMBIENT];
- GLfloat s_a = ind[MAT_INDEX_SPECULAR] - ind[MAT_INDEX_AMBIENT];
- index = (ind[MAT_INDEX_AMBIENT]
- + diffuse[side] * (1.0F-specular[side]) * d_a
- + specular[side] * s_a);
- if (index > ind[MAT_INDEX_SPECULAR]) {
- index = ind[MAT_INDEX_SPECULAR];
- }
- }
- indexResult[side][j] = index;
- }
- } /*for vertex*/
-}
-
-
-
static void TAG(init_light_tab)( void )
{
_tnl_light_tab[IDX] = TAG(light_rgba);
_tnl_light_fast_tab[IDX] = TAG(light_fast_rgba);
_tnl_light_fast_single_tab[IDX] = TAG(light_fast_rgba_single);
_tnl_light_spec_tab[IDX] = TAG(light_rgba_spec);
- _tnl_light_ci_tab[IDX] = TAG(light_ci);
}