ARB prog lexer: Fix lexer to eat both DOS and Unix line endings
[mesa.git] / src / mesa / tnl / t_vb_lighttmp.h
index 2eaf61ff4d093acb035168104e165391d8b688dd..124ca3c74fe258b21616263979db681910ffc267 100644 (file)
@@ -56,8 +56,8 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
 
    const GLuint vstride = input->stride;
    const GLfloat *vertex = (GLfloat *)input->data;
-   const GLuint nstride = VB->NormalPtr->stride;
-   const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
+   const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
+   const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
 
    GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
    GLfloat (*Fspec)[4] = (GLfloat (*)[4]) store->LitSecondary[0].data;
@@ -68,9 +68,6 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
 
    const GLuint nr = VB->Count;
 
-   (void) nstride;
-   (void) vstride;
-
 #ifdef TRACE
    fprintf(stderr, "%s\n", __FUNCTION__ );
 #endif
@@ -85,10 +82,9 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
    sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
 #endif
 
-   /* Side-effects done, can we finish now?
-    */
-   if (stage->changed_inputs == 0)
-      return;
+
+   store->LitColor[0].stride = 16;
+   store->LitColor[1].stride = 16;
 
    for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) {
       GLfloat sum[2][3], spec[2][3];
@@ -145,7 +141,7 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
 
            /* spotlight attenuation */
            if (light->_Flags & LIGHT_SPOT) {
-              GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
+              GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection);
 
               if (PV_dot_dir<light->_CosCutoff) {
                  continue; /* this light makes no contribution */
@@ -249,12 +245,13 @@ static void TAG(light_rgba)( GLcontext *ctx,
 
    const GLuint vstride = input->stride;
    const GLfloat *vertex = (GLfloat *) input->data;
-   const GLuint nstride = VB->NormalPtr->stride;
-   const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
+   const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
+   const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
 
    GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
+#if IDX & LIGHT_TWOSIDE
    GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
-   GLfloat (*color[2])[4];
+#endif
 
    const GLuint nr = VB->Count;
 
@@ -262,12 +259,6 @@ static void TAG(light_rgba)( GLcontext *ctx,
    fprintf(stderr, "%s\n", __FUNCTION__ );
 #endif
 
-   (void) nstride;
-   (void) vstride;
-
-   color[0] = Fcolor;
-   color[1] = Bcolor;
-
    VB->ColorPtr[0] = &store->LitColor[0];
    sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
 
@@ -276,8 +267,8 @@ static void TAG(light_rgba)( GLcontext *ctx,
    sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
 #endif
 
-   if (stage->changed_inputs == 0)
-      return;
+   store->LitColor[0].stride = 16;
+   store->LitColor[1].stride = 16;
 
    for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) {
       GLfloat sum[2][3];
@@ -334,7 +325,7 @@ static void TAG(light_rgba)( GLcontext *ctx,
 
            /* spotlight attenuation */
            if (light->_Flags & LIGHT_SPOT) {
-              GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
+              GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection);
 
               if (PV_dot_dir<light->_CosCutoff) {
                  continue; /* this light makes no contribution */
@@ -437,8 +428,8 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
 
 {
    struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
-   const GLuint nstride = VB->NormalPtr->stride;
-   const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
+   const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
+   const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
    GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
 #if IDX & LIGHT_TWOSIDE
    GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
@@ -446,23 +437,31 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
    const struct gl_light *light = ctx->Light.EnabledList.next;
    GLuint j = 0;
    GLfloat base[2][4];
+#if IDX & LIGHT_MATERIAL
    const GLuint nr = VB->Count;
+#else
+   const GLuint nr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->count;
+#endif
 
 #ifdef TRACE
    fprintf(stderr, "%s\n", __FUNCTION__ );
 #endif
 
    (void) input;               /* doesn't refer to Eye or Obj */
-   (void) nr;
-   (void) nstride;
 
    VB->ColorPtr[0] = &store->LitColor[0];
 #if IDX & LIGHT_TWOSIDE
    VB->ColorPtr[1] = &store->LitColor[1];
 #endif
 
-   if (stage->changed_inputs == 0)
-      return;
+   if (nr > 1) {
+      store->LitColor[0].stride = 16;
+      store->LitColor[1].stride = 16;
+   }
+   else {
+      store->LitColor[0].stride = 0;
+      store->LitColor[1].stride = 0;
+   }
 
    for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) {
 
@@ -537,14 +536,18 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
 {
    struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
    GLfloat sumA[2];
-   const GLuint nstride = VB->NormalPtr->stride;
-   const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
+   const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
+   const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
    GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
 #if IDX & LIGHT_TWOSIDE
    GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
 #endif
    GLuint j = 0;
+#if IDX & LIGHT_MATERIAL
    const GLuint nr = VB->Count;
+#else
+   const GLuint nr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->count;
+#endif
    const struct gl_light *light;
 
 #ifdef TRACE
@@ -552,8 +555,6 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
 #endif
 
    (void) input;
-   (void) nr;
-   (void) nstride;
 
    sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
    sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
@@ -563,8 +564,14 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
    VB->ColorPtr[1] = &store->LitColor[1];
 #endif
 
-   if (stage->changed_inputs == 0)
-      return;
+   if (nr > 1) {
+      store->LitColor[0].stride = 16;
+      store->LitColor[1].stride = 16;
+   }
+   else {
+      store->LitColor[0].stride = 0;
+      store->LitColor[1].stride = 0;
+   }
 
    for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) {
 
@@ -649,8 +656,8 @@ static void TAG(light_ci)( GLcontext *ctx,
    GLuint j;
    const GLuint vstride = input->stride;
    const GLfloat *vertex = (GLfloat *) input->data;
-   const GLuint nstride = VB->NormalPtr->stride;
-   const GLfloat *normal = (GLfloat *)VB->NormalPtr->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;
 
@@ -658,17 +665,11 @@ static void TAG(light_ci)( GLcontext *ctx,
    fprintf(stderr, "%s\n", __FUNCTION__ );
 #endif
 
-   (void) nstride;
-   (void) vstride;
-
    VB->IndexPtr[0] = &store->LitIndex[0];
 #if IDX & LIGHT_TWOSIDE
    VB->IndexPtr[1] = &store->LitIndex[1];
 #endif
 
-   if (stage->changed_inputs == 0)
-      return;
-
    indexResult[0] = (GLfloat *)VB->IndexPtr[0]->data;
 #if IDX & LIGHT_TWOSIDE
    indexResult[1] = (GLfloat *)VB->IndexPtr[1]->data;
@@ -720,7 +721,7 @@ static void TAG(light_ci)( GLcontext *ctx,
 
            /* spotlight attenuation */
            if (light->_Flags & LIGHT_SPOT) {
-              GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
+              GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection);
               if (PV_dot_dir < light->_CosCutoff) {
                  continue; /* this light makes no contribution */
               }