vbo: pass the stream from DrawTransformFeedbackStream to drivers
[mesa.git] / src / mesa / tnl / t_vb_lighttmp.h
index 0a98c6b02a61f626cac681bb6c59ee1a59d2c698..3aebcd4b79949db6375a42adba492977721ef550 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Mesa 3-D graphics library
- * Version:  5.1
  *
  * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
  *
  *
  * Authors:
- *    Brian Paul
- *    Keith Whitwell <keith@tungstengraphics.com>
+ *    Brian Paul Keith Whitwell <keithw@vmware.com>
  */
 
 
@@ -44,7 +43,7 @@
  * stage is the lighting stage-private data
  * input is the vector of eye or object-space vertex coordinates
  */
-static void TAG(light_rgba_spec)( GLcontext *ctx,
+static void TAG(light_rgba_spec)( struct gl_context *ctx,
                                  struct vertex_buffer *VB,
                                  struct tnl_pipeline_stage *stage,
                                  GLvector4f *input )
@@ -69,7 +68,7 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
    const GLuint nr = VB->Count;
 
 #ifdef TRACE
-   fprintf(stderr, "%s\n", __FUNCTION__ );
+   fprintf(stderr, "%s\n", __func__ );
 #endif
 
    VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0];
@@ -113,7 +112,7 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
         GLint side;
         GLfloat contrib[3];
         GLfloat attenuation;
-        GLfloat VP[3];  /* unit vector from vertex to light */
+        GLfloat VP[3];          /* unit vector from vertex to light */
         GLfloat n_dot_VP;       /* n dot VP */
         GLfloat *h;
 
@@ -130,7 +129,7 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
 
            d = (GLfloat) LEN_3FV( VP );
 
-           if (d > 1e-6) {
+           if (d > 1e-6F) {
               GLfloat invd = 1.0F / d;
               SELF_SCALE_SCALAR_3V(VP, invd);
            }
@@ -147,16 +146,13 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
                  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]);
+                  GLfloat spot = powf(PV_dot_dir, light->SpotExponent);
                  attenuation *= spot;
               }
            }
         }
 
-        if (attenuation < 1e-3)
+        if (attenuation < 1e-3F)
            continue;           /* this light makes no contribution */
 
         /* Compute dot product or normal and vector from V to light pos */
@@ -207,11 +203,8 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
         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 );
-
-           if (spec_coef > 1.0e-10) {
+           GLfloat spec_coef = lookup_shininess(ctx, side, n_dot_h);
+           if (spec_coef > 1.0e-10F) {
               spec_coef *= attenuation;
               ACC_SCALE_SCALAR_3V( spec[side], spec_coef,
                                    light->_MatSpecular[side]);
@@ -232,7 +225,7 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
 }
 
 
-static void TAG(light_rgba)( GLcontext *ctx,
+static void TAG(light_rgba)( struct gl_context *ctx,
                             struct vertex_buffer *VB,
                             struct tnl_pipeline_stage *stage,
                             GLvector4f *input )
@@ -256,7 +249,7 @@ static void TAG(light_rgba)( GLcontext *ctx,
    const GLuint nr = VB->Count;
 
 #ifdef TRACE
-   fprintf(stderr, "%s\n", __FUNCTION__ );
+   fprintf(stderr, "%s\n", __func__ );
 #endif
 
    VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0];
@@ -290,12 +283,11 @@ static void TAG(light_rgba)( GLcontext *ctx,
 
       /* Add contribution from each enabled light source */
       foreach (light, &ctx->Light.EnabledList) {
-
         GLfloat n_dot_h;
         GLfloat correction;
         GLint side;
         GLfloat contrib[3];
-        GLfloat attenuation = 1.0;
+        GLfloat attenuation;
         GLfloat VP[3];          /* unit vector from vertex to light */
         GLfloat n_dot_VP;       /* n dot VP */
         GLfloat *h;
@@ -309,12 +301,11 @@ static void TAG(light_rgba)( GLcontext *ctx,
         else {
            GLfloat d;     /* distance from vertex to light */
 
-
            SUB_3V(VP, light->_Position, vertex);
 
            d = (GLfloat) LEN_3FV( VP );
 
-           if ( d > 1e-6) {
+           if (d > 1e-6F) {
               GLfloat invd = 1.0F / d;
               SELF_SCALE_SCALAR_3V(VP, invd);
            }
@@ -331,16 +322,13 @@ static void TAG(light_rgba)( GLcontext *ctx,
                  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]);
+                  GLfloat spot = powf(PV_dot_dir, light->SpotExponent);
                  attenuation *= spot;
               }
            }
         }
 
-        if (attenuation < 1e-3)
+        if (attenuation < 1e-3F)
            continue;           /* this light makes no contribution */
 
         /* Compute dot product or normal and vector from V to light pos */
@@ -391,13 +379,8 @@ static void TAG(light_rgba)( GLcontext *ctx,
 
            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 );
-
+           if (n_dot_h > 0.0F) {
+              GLfloat spec_coef = lookup_shininess(ctx, side, n_dot_h);
               ACC_SCALE_SCALAR_3V( contrib, spec_coef,
                                    light->_MatSpecular[side]);
            }
@@ -421,7 +404,7 @@ static void TAG(light_rgba)( GLcontext *ctx,
 
 /* As below, but with just a single light.
  */
-static void TAG(light_fast_rgba_single)( GLcontext *ctx,
+static void TAG(light_fast_rgba_single)( struct gl_context *ctx,
                                         struct vertex_buffer *VB,
                                         struct tnl_pipeline_stage *stage,
                                         GLvector4f *input )
@@ -444,7 +427,7 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
 #endif
 
 #ifdef TRACE
-   fprintf(stderr, "%s\n", __FUNCTION__ );
+   fprintf(stderr, "%s\n", __func__ );
 #endif
 
    (void) input;               /* doesn't refer to Eye or Obj */
@@ -497,8 +480,7 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
          COPY_3V(sum, base[1]);
          ACC_SCALE_SCALAR_3V(sum, -n_dot_VP, light->_MatDiffuse[1]);
          if (n_dot_h > 0.0F) {
-            GLfloat spec;
-            GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec );
+            GLfloat spec = lookup_shininess(ctx, 1, n_dot_h);
             ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]);
          }
          COPY_3V(Bcolor[j], sum );
@@ -512,10 +494,8 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
         COPY_3V(sum, base[0]);
         ACC_SCALE_SCALAR_3V(sum, n_dot_VP, light->_MatDiffuse[0]);
         if (n_dot_h > 0.0F) {
-           GLfloat spec;
-           GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec );
+            GLfloat spec = lookup_shininess(ctx, 0, n_dot_h);
            ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[0]);
-
         }
         COPY_3V(Fcolor[j], sum );
         Fcolor[j][3] = base[0][3];
@@ -529,7 +509,7 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
 
 /* Light infinite lights
  */
-static void TAG(light_fast_rgba)( GLcontext *ctx,
+static void TAG(light_fast_rgba)( struct gl_context *ctx,
                                  struct vertex_buffer *VB,
                                  struct tnl_pipeline_stage *stage,
                                  GLvector4f *input )
@@ -551,7 +531,7 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
    const struct gl_light *light;
 
 #ifdef TRACE
-   fprintf(stderr, "%s %d\n", __FUNCTION__, nr );
+   fprintf(stderr, "%s %d\n", __func__, nr );
 #endif
 
    (void) input;
@@ -606,8 +586,7 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
            ACC_SCALE_SCALAR_3V(sum[0], n_dot_VP, light->_MatDiffuse[0]);
            n_dot_h = DOT3(normal, light->_h_inf_norm);
            if (n_dot_h > 0.0F) {
-              struct gl_shine_tab *tab = ctx->_ShineTable[0];
-              GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec );
+               spec = lookup_shininess(ctx, 0, n_dot_h);
               ACC_SCALE_SCALAR_3V( sum[0], spec, light->_MatSpecular[0]);
            }
         }
@@ -616,8 +595,7 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
            ACC_SCALE_SCALAR_3V(sum[1], -n_dot_VP, light->_MatDiffuse[1]);
            n_dot_h = -DOT3(normal, light->_h_inf_norm);
            if (n_dot_h > 0.0F) {
-              struct gl_shine_tab *tab = ctx->_ShineTable[1];
-              GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec );
+               spec = lookup_shininess(ctx, 1, n_dot_h);
               ACC_SCALE_SCALAR_3V( sum[1], spec, light->_MatSpecular[1]);
            }
         }