diff options
author | Roland Scheidegger <[email protected]> | 2004-02-10 23:52:18 +0000 |
---|---|---|
committer | Roland Scheidegger <[email protected]> | 2004-02-10 23:52:18 +0000 |
commit | f64f940281f0d716e0ddc641e7ef1728f143d67f (patch) | |
tree | 8fa101f37693ef678e2424a6b077bd9f0793e606 | |
parent | 53c50f1667bae76b543196335ed77e1fb80b6b4d (diff) |
change lighting to use MULT instead of PREMULT (i.e. move some lighting color calculations to the GPU)
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_state.c | 65 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_state_init.c | 8 |
2 files changed, 34 insertions, 39 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c index 53537363fcf..c4ce6b1007d 100644 --- a/src/mesa/drivers/dri/radeon/radeon_state.c +++ b/src/mesa/drivers/dri/radeon/radeon_state.c @@ -773,6 +773,7 @@ static void update_global_ambient( GLcontext *ctx ) float *fcmd = (float *)RADEON_DB_STATE( glt ); /* Need to do more if both emmissive & ambient are PREMULT: + * Hope this is not needed for MULT */ if ((rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] & ((3 << RADEON_EMISSIVE_SOURCE_SHIFT) | @@ -795,9 +796,6 @@ static void update_global_ambient( GLcontext *ctx ) /* Update on change to * - light[p].colors * - light[p].enabled - * - material, - * - colormaterial enabled - * - colormaterial bitmask */ static void update_light_colors( GLcontext *ctx, GLuint p ) { @@ -808,25 +806,11 @@ static void update_light_colors( GLcontext *ctx, GLuint p ) if (l->Enabled) { radeonContextPtr rmesa = RADEON_CONTEXT(ctx); float *fcmd = (float *)RADEON_DB_STATE( lit[p] ); - GLuint bitmask = ctx->Light.ColorMaterialBitmask; - GLfloat (*mat)[4] = ctx->Light.Material.Attrib; COPY_4V( &fcmd[LIT_AMBIENT_RED], l->Ambient ); COPY_4V( &fcmd[LIT_DIFFUSE_RED], l->Diffuse ); COPY_4V( &fcmd[LIT_SPECULAR_RED], l->Specular ); - if (!ctx->Light.ColorMaterialEnabled) - bitmask = 0; - - if ((bitmask & MAT_BIT_FRONT_AMBIENT) == 0) - SELF_SCALE_3V( &fcmd[LIT_AMBIENT_RED], mat[MAT_ATTRIB_FRONT_AMBIENT] ); - - if ((bitmask & MAT_BIT_FRONT_DIFFUSE) == 0) - SELF_SCALE_3V( &fcmd[LIT_DIFFUSE_RED], mat[MAT_ATTRIB_FRONT_DIFFUSE] ); - - if ((bitmask & MAT_BIT_FRONT_SPECULAR) == 0) - SELF_SCALE_3V( &fcmd[LIT_SPECULAR_RED], mat[MAT_ATTRIB_FRONT_SPECULAR] ); - RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.lit[p] ); } } @@ -860,51 +844,66 @@ static void check_twoside_fallback( GLcontext *ctx ) static void radeonColorMaterial( GLcontext *ctx, GLenum face, GLenum mode ) { - if (ctx->Light.ColorMaterialEnabled) { radeonContextPtr rmesa = RADEON_CONTEXT(ctx); GLuint light_model_ctl1 = rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL]; - GLuint mask = ctx->Light.ColorMaterialBitmask; - /* Default to PREMULT: - */ light_model_ctl1 &= ~((3 << RADEON_EMISSIVE_SOURCE_SHIFT) | (3 << RADEON_AMBIENT_SOURCE_SHIFT) | (3 << RADEON_DIFFUSE_SOURCE_SHIFT) | (3 << RADEON_SPECULAR_SOURCE_SHIFT)); + if (ctx->Light.ColorMaterialEnabled) { + GLuint mask = ctx->Light.ColorMaterialBitmask; + if (mask & MAT_BIT_FRONT_EMISSION) { light_model_ctl1 |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE << RADEON_EMISSIVE_SOURCE_SHIFT); } + else { + light_model_ctl1 |= (RADEON_LM_SOURCE_STATE_MULT << + RADEON_EMISSIVE_SOURCE_SHIFT); + } if (mask & MAT_BIT_FRONT_AMBIENT) { light_model_ctl1 |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE << RADEON_AMBIENT_SOURCE_SHIFT); } + else { + light_model_ctl1 |= (RADEON_LM_SOURCE_STATE_MULT << + RADEON_AMBIENT_SOURCE_SHIFT); + } if (mask & MAT_BIT_FRONT_DIFFUSE) { light_model_ctl1 |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE << RADEON_DIFFUSE_SOURCE_SHIFT); } + else { + light_model_ctl1 |= (RADEON_LM_SOURCE_STATE_MULT << + RADEON_DIFFUSE_SOURCE_SHIFT); + } if (mask & MAT_BIT_FRONT_SPECULAR) { light_model_ctl1 |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE << RADEON_SPECULAR_SOURCE_SHIFT); } + else { + light_model_ctl1 |= (RADEON_LM_SOURCE_STATE_MULT << + RADEON_SPECULAR_SOURCE_SHIFT); + } + } + else { + /* Default to MULT: + */ + light_model_ctl1 |= (RADEON_LM_SOURCE_STATE_MULT << RADEON_EMISSIVE_SOURCE_SHIFT) | + (RADEON_LM_SOURCE_STATE_MULT << RADEON_AMBIENT_SOURCE_SHIFT) | + (RADEON_LM_SOURCE_STATE_MULT << RADEON_DIFFUSE_SOURCE_SHIFT) | + (RADEON_LM_SOURCE_STATE_MULT << RADEON_SPECULAR_SOURCE_SHIFT); + } if (light_model_ctl1 != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL]) { - GLuint p; - RADEON_STATECHANGE( rmesa, tcl ); rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] = light_model_ctl1; - - for (p = 0 ; p < MAX_LIGHTS; p++) - update_light_colors( ctx, p ); - update_global_ambient( ctx ); - } } - - check_twoside_fallback( ctx ); } void radeonUpdateMaterial( GLcontext *ctx ) @@ -912,7 +911,6 @@ void radeonUpdateMaterial( GLcontext *ctx ) radeonContextPtr rmesa = RADEON_CONTEXT(ctx); GLfloat (*mat)[4] = ctx->Light.Material.Attrib; GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( mtl ); - GLuint p; GLuint mask = ~0; if (ctx->Light.ColorMaterialEnabled) @@ -952,11 +950,8 @@ void radeonUpdateMaterial( GLcontext *ctx ) RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.mtl ); - for (p = 0 ; p < MAX_LIGHTS; p++) - update_light_colors( ctx, p ); - check_twoside_fallback( ctx ); - update_global_ambient( ctx ); +/* update_global_ambient( ctx );*/ } /* _NEW_LIGHT diff --git a/src/mesa/drivers/dri/radeon/radeon_state_init.c b/src/mesa/drivers/dri/radeon/radeon_state_init.c index ceb313a7e71..c84f5fd833c 100644 --- a/src/mesa/drivers/dri/radeon/radeon_state_init.c +++ b/src/mesa/drivers/dri/radeon/radeon_state_init.c @@ -499,10 +499,10 @@ void radeonInitState( radeonContextPtr rmesa ) (RADEON_SPECULAR_LIGHTS | RADEON_DIFFUSE_SPECULAR_COMBINE | RADEON_LOCAL_LIGHT_VEC_GL | - (RADEON_LM_SOURCE_STATE_PREMULT << RADEON_EMISSIVE_SOURCE_SHIFT) | - (RADEON_LM_SOURCE_STATE_PREMULT << RADEON_AMBIENT_SOURCE_SHIFT) | - (RADEON_LM_SOURCE_STATE_PREMULT << RADEON_DIFFUSE_SOURCE_SHIFT) | - (RADEON_LM_SOURCE_STATE_PREMULT << RADEON_SPECULAR_SOURCE_SHIFT)); + (RADEON_LM_SOURCE_STATE_MULT << RADEON_EMISSIVE_SOURCE_SHIFT) | + (RADEON_LM_SOURCE_STATE_MULT << RADEON_AMBIENT_SOURCE_SHIFT) | + (RADEON_LM_SOURCE_STATE_MULT << RADEON_DIFFUSE_SOURCE_SHIFT) | + (RADEON_LM_SOURCE_STATE_MULT << RADEON_SPECULAR_SOURCE_SHIFT)); for (i = 0 ; i < 8; i++) { struct gl_light *l = &ctx->Light.Light[i]; |