summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrice Mandin <[email protected]>2006-12-08 16:39:12 +0000
committerPatrice Mandin <[email protected]>2006-12-08 16:39:12 +0000
commit65c54a685a0ac7d08ad608c25d0e3c318f8be43f (patch)
treeeccd8b785522b4889b0fa80aeed4010c6218f585 /src
parentc04c74bc5da454478fd0dbf3b25dd54190ac0942 (diff)
Resend spot light parameters when part of it changes
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/nouveau/nv10_state.c87
1 files changed, 61 insertions, 26 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c
index da26ccba871..bb9abe98671 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_state.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_state.c
@@ -326,11 +326,18 @@ static void nv10Hint(GLcontext *ctx, GLenum target, GLenum mode)
// void (*IndexMask)(GLcontext *ctx, GLuint mask);
+enum {
+ SPOTLIGHT_UPDATE_EXPONENT,
+ SPOTLIGHT_UPDATE_DIRECTION,
+ SPOTLIGHT_UPDATE_ALL
+};
+
static void nv10Lightfv(GLcontext *ctx, GLenum light, GLenum pname, const GLfloat *params )
{
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
GLint p = light - GL_LIGHT0;
struct gl_light *l = &ctx->Light.Light[p];
+ int spotlightUpdate = -1;
switch(pname)
{
@@ -352,41 +359,20 @@ static void nv10Lightfv(GLcontext *ctx, GLenum light, GLenum pname, const GLfloa
OUT_RING_CACHEf(params[1]);
OUT_RING_CACHEf(params[2]);
break;
- case GL_SPOT_DIRECTION:
- {
- GLfloat x,y,z;
- x = -2.0 * (1.0 + l->_CosCutoff) * l->_NormDirection[0];
- y = -2.0 * (1.0 + l->_CosCutoff) * l->_NormDirection[1];
- z = -2.0 * (1.0 + l->_CosCutoff) * l->_NormDirection[2];
- BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_DIR_X(p), 3);
- OUT_RING_CACHEf(x);
- OUT_RING_CACHEf(y);
- OUT_RING_CACHEf(z);
- }
- break;
case GL_POSITION:
BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_POSITION_X(p), 3);
OUT_RING_CACHEf(params[0]);
OUT_RING_CACHEf(params[1]);
OUT_RING_CACHEf(params[2]);
break;
+ case GL_SPOT_DIRECTION:
+ spotlightUpdate = SPOTLIGHT_UPDATE_DIRECTION;
+ break;
case GL_SPOT_EXPONENT:
- BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_EXPONENT(p), 1);
- OUT_RING_CACHEf(*params);
+ spotlightUpdate = SPOTLIGHT_UPDATE_DIRECTION;
break;
case GL_SPOT_CUTOFF:
- /* you can't factor these */
- {
- GLfloat c;
- c = -2.0 * (0.5 + l->_CosCutoff);
-
- BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_A(p), 1);
- OUT_RING_CACHEf(params[0]);
- BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_B(p), 1);
- OUT_RING_CACHEf(params[1]);
- BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_C(p), 1);
- OUT_RING_CACHEf(c);
- }
+ spotlightUpdate = SPOTLIGHT_UPDATE_ALL;
break;
case GL_CONSTANT_ATTENUATION:
BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_CONSTANT_ATTENUATION(p), 1);
@@ -403,6 +389,55 @@ static void nv10Lightfv(GLcontext *ctx, GLenum light, GLenum pname, const GLfloa
default:
break;
}
+
+ switch(spotlightUpdate) {
+ case SPOTLIGHT_UPDATE_DIRECTION:
+ {
+ GLfloat x,y,z;
+ x = -2.0 * (1.0 + l->_CosCutoff) * l->_NormDirection[0];
+ y = -2.0 * (1.0 + l->_CosCutoff) * l->_NormDirection[1];
+ z = -2.0 * (1.0 + l->_CosCutoff) * l->_NormDirection[2];
+ BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_DIR_X(p), 3);
+ OUT_RING_CACHEf(x);
+ OUT_RING_CACHEf(y);
+ OUT_RING_CACHEf(z);
+ }
+ break;
+ case SPOTLIGHT_UPDATE_EXPONENT:
+ {
+ GLfloat cc,lc,qc;
+ cc = 1.0; /* These need to be correctly computed */
+ lc = 0.0;
+ qc = 2.0;
+ BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_A(p), 3);
+ OUT_RING_CACHEf(cc);
+ OUT_RING_CACHEf(lc);
+ OUT_RING_CACHEf(qc);
+ }
+ break;
+ case SPOTLIGHT_UPDATE_ALL:
+ {
+ GLfloat cc,lc,qc, x,y,z, c;
+ cc = 1.0; /* These need to be correctly computed */
+ lc = 0.0;
+ qc = 2.0;
+ x = -2.0 * (1.0 + l->_CosCutoff) * l->_NormDirection[0];
+ y = -2.0 * (1.0 + l->_CosCutoff) * l->_NormDirection[1];
+ z = -2.0 * (1.0 + l->_CosCutoff) * l->_NormDirection[2];
+ c = -2.0 * (0.5 + l->_CosCutoff);
+ BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_A(p), 7);
+ OUT_RING_CACHEf(cc);
+ OUT_RING_CACHEf(lc);
+ OUT_RING_CACHEf(qc);
+ OUT_RING_CACHEf(x);
+ OUT_RING_CACHEf(y);
+ OUT_RING_CACHEf(z);
+ OUT_RING_CACHEf(c);
+ }
+ break;
+ default:
+ break;
+ }
}
/** Set the lighting model parameters */