~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/extras/Mesa/src/tnl/t_vb_lighttmp.h

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 * Mesa 3-D graphics library
 
4
 * Version:  3.5
 
5
 *
 
6
 * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
 
7
 *
 
8
 * Permission is hereby granted, free of charge, to any person obtaining a
 
9
 * copy of this software and associated documentation files (the "Software"),
 
10
 * to deal in the Software without restriction, including without limitation
 
11
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
12
 * and/or sell copies of the Software, and to permit persons to whom the
 
13
 * Software is furnished to do so, subject to the following conditions:
 
14
 *
 
15
 * The above copyright notice and this permission notice shall be included
 
16
 * in all copies or substantial portions of the Software.
 
17
 *
 
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
19
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 
21
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
22
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
23
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
24
 *
 
25
 *
 
26
 * Authors:
 
27
 *    Brian Paul <brianp@valinux.com>
 
28
 *    Keith Whitwell <keithw@valinux.com>
 
29
 */
 
30
 
 
31
 
 
32
#if (IDX & LIGHT_FLAGS)
 
33
#  define VSTRIDE (4 * sizeof(GLfloat))
 
34
#  define NSTRIDE (3 * sizeof(GLfloat))
 
35
#  define CHECK_MATERIAL(x)  (flags[x] & VERT_MATERIAL)
 
36
#  define CHECK_END_VB(x)    (flags[x] & VERT_END_VB)
 
37
#  if (IDX & LIGHT_COLORMATERIAL)
 
38
#    define CMSTRIDE STRIDE_F(CMcolor, CMstride)
 
39
#    define CHECK_COLOR_MATERIAL(x) (flags[x] & VERT_RGBA)
 
40
#    define CHECK_VALIDATE(x) (flags[x] & (VERT_RGBA|VERT_MATERIAL))
 
41
#    define DO_ANOTHER_NORMAL(x) \
 
42
     ((flags[x] & (VERT_RGBA|VERT_NORM|VERT_END_VB|VERT_MATERIAL)) == VERT_NORM)
 
43
#    define REUSE_LIGHT_RESULTS(x) \
 
44
     ((flags[x] & (VERT_RGBA|VERT_NORM|VERT_END_VB|VERT_MATERIAL)) == 0)
 
45
#  else
 
46
#    define CMSTRIDE (void)0
 
47
#    define CHECK_COLOR_MATERIAL(x) 0
 
48
#    define CHECK_VALIDATE(x) (flags[x] & (VERT_MATERIAL))
 
49
#    define DO_ANOTHER_NORMAL(x) \
 
50
      ((flags[x] & (VERT_NORM|VERT_END_VB|VERT_MATERIAL)) == VERT_NORM)
 
51
#    define REUSE_LIGHT_RESULTS(x) \
 
52
      ((flags[x] & (VERT_NORM|VERT_END_VB|VERT_MATERIAL)) == 0)
 
53
#  endif
 
54
#else
 
55
#  define VSTRIDE vstride
 
56
#  define NSTRIDE nstride
 
57
#  define CHECK_MATERIAL(x)   0            /* no materials on array paths */
 
58
#  define CHECK_END_VB(XX)     (XX >= nr)
 
59
#  if (IDX & LIGHT_COLORMATERIAL)
 
60
#     define CMSTRIDE STRIDE_F(CMcolor, CMstride)
 
61
#     define CHECK_COLOR_MATERIAL(x) (x < nr) /* always have colormaterial */
 
62
#     define CHECK_VALIDATE(x) (x < nr)
 
63
#     define DO_ANOTHER_NORMAL(x) 0        /* always stop to recalc colormat */
 
64
#  else
 
65
#     define CMSTRIDE (void)0
 
66
#     define CHECK_COLOR_MATERIAL(x) 0        /* no colormaterial */
 
67
#     define CHECK_VALIDATE(x) (0)
 
68
#     define DO_ANOTHER_NORMAL(XX) (XX < nr) /* keep going to end of vb */
 
69
#  endif
 
70
#  define REUSE_LIGHT_RESULTS(x) 0         /* always have a new normal */
 
71
#endif
 
72
 
 
73
 
 
74
 
 
75
#if (IDX & LIGHT_TWOSIDE)
 
76
#  define NR_SIDES 2
 
77
#else
 
78
#  define NR_SIDES 1
 
79
#endif
 
80
 
 
81
 
 
82
 
 
83
static void TAG(light_rgba_spec)( GLcontext *ctx,
 
84
                                  struct vertex_buffer *VB,
 
85
                                  struct gl_pipeline_stage *stage,
 
86
                                  GLvector4f *input )
 
87
{
 
88
   struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
 
89
   GLfloat (*base)[3] = ctx->Light._BaseColor;
 
90
   GLchan sumA[2];
 
91
 
 
92
   GLuint j;
 
93
 
 
94
   GLuint  vstride = input->stride;
 
95
   const GLfloat *vertex = (GLfloat *)input->data;
 
96
   GLuint  nstride = VB->NormalPtr->stride;
 
97
   const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
 
98
 
 
99
   GLfloat *CMcolor;
 
100
   GLuint CMstride;
 
101
 
 
102
   GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].Ptr;
 
103
   GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].Ptr;
 
104
   GLchan (*Fspec)[4] = (GLchan (*)[4]) store->LitSecondary[0].Ptr;
 
105
   GLchan (*Bspec)[4] = (GLchan (*)[4]) store->LitSecondary[1].Ptr;
 
106
   GLchan (*spec[2])[4];
 
107
 
 
108
   GLuint nr = VB->Count;
 
109
   GLuint *flags = VB->Flag;
 
110
   struct gl_material (*new_material)[2] = VB->Material;
 
111
   GLuint *new_material_mask = VB->MaterialMask;
 
112
 
 
113
   (void) flags;
 
114
   (void) nstride;
 
115
   (void) vstride;
 
116
 
 
117
 
 
118
   if (MESA_VERBOSE & VERBOSE_LIGHTING)
 
119
      fprintf(stderr, "%s\n", __FUNCTION__ );   
 
120
 
 
121
   spec[0] = Fspec;
 
122
   spec[1] = Bspec;
 
123
 
 
124
   if (IDX & LIGHT_COLORMATERIAL) {
 
125
      if (VB->ColorPtr[0]->Type != GL_FLOAT || 
 
126
          VB->ColorPtr[0]->Size != 4)
 
127
         import_color_material( ctx, stage );
 
128
 
 
129
      CMcolor = (GLfloat *) VB->ColorPtr[0]->Ptr;
 
130
      CMstride = VB->ColorPtr[0]->StrideB;
 
131
   }
 
132
 
 
133
   VB->ColorPtr[0] = &store->LitColor[0];
 
134
   VB->SecondaryColorPtr[0] = &store->LitSecondary[0];
 
135
   UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]);
 
136
 
 
137
   if (IDX & LIGHT_TWOSIDE) {
 
138
      VB->ColorPtr[1] = &store->LitColor[1];
 
139
      VB->SecondaryColorPtr[1] = &store->LitSecondary[1];
 
140
      UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]);
 
141
   }
 
142
 
 
143
   /* Side-effects done, can we finish now?
 
144
    */
 
145
   if (stage->changed_inputs == 0)
 
146
      return;
 
147
 
 
148
   for ( j=0 ;
 
149
         j<nr ;
 
150
         j++,STRIDE_F(vertex,VSTRIDE),STRIDE_F(normal,NSTRIDE),CMSTRIDE)
 
151
   {
 
152
      GLfloat sum[2][3], spec[2][3];
 
153
      struct gl_light *light;
 
154
 
 
155
      if ( CHECK_COLOR_MATERIAL(j) )
 
156
         _mesa_update_color_material( ctx, CMcolor );
 
157
 
 
158
      if ( CHECK_MATERIAL(j) )
 
159
         _mesa_update_material( ctx, new_material[j], new_material_mask[j] );
 
160
 
 
161
      if ( CHECK_VALIDATE(j) ) {
 
162
         TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx );
 
163
         UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]);
 
164
         if (IDX & LIGHT_TWOSIDE) 
 
165
            UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]);
 
166
      }
 
167
 
 
168
      COPY_3V(sum[0], base[0]);
 
169
      ZERO_3V(spec[0]);
 
170
 
 
171
      if (IDX & LIGHT_TWOSIDE) {
 
172
         COPY_3V(sum[1], base[1]);
 
173
         ZERO_3V(spec[1]);
 
174
      }
 
175
 
 
176
      /* Add contribution from each enabled light source */
 
177
      foreach (light, &ctx->Light.EnabledList) {
 
178
         GLfloat n_dot_h;
 
179
         GLfloat correction;
 
180
         GLint side;
 
181
         GLfloat contrib[3];
 
182
         GLfloat attenuation;
 
183
         GLfloat VP[3];  /* unit vector from vertex to light */
 
184
         GLfloat n_dot_VP;       /* n dot VP */
 
185
         GLfloat *h;
 
186
 
 
187
         /* compute VP and attenuation */
 
188
         if (!(light->_Flags & LIGHT_POSITIONAL)) {
 
189
            /* directional light */
 
190
            COPY_3V(VP, light->_VP_inf_norm);
 
191
            attenuation = light->_VP_inf_spot_attenuation;
 
192
         }
 
193
         else {
 
194
            GLfloat d;     /* distance from vertex to light */
 
195
 
 
196
            SUB_3V(VP, light->_Position, vertex);
 
197
 
 
198
            d = (GLfloat) LEN_3FV( VP );
 
199
 
 
200
            if (d > 1e-6) {
 
201
               GLfloat invd = 1.0F / d;
 
202
               SELF_SCALE_SCALAR_3V(VP, invd);
 
203
            }
 
204
 
 
205
            attenuation = 1.0F / (light->ConstantAttenuation + d *
 
206
                                  (light->LinearAttenuation + d *
 
207
                                   light->QuadraticAttenuation));
 
208
 
 
209
            /* spotlight attenuation */
 
210
            if (light->_Flags & LIGHT_SPOT) {
 
211
               GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
 
212
 
 
213
               if (PV_dot_dir<light->_CosCutoff) {
 
214
                  continue; /* this light makes no contribution */
 
215
               }
 
216
               else {
 
217
                  GLdouble x = PV_dot_dir * (EXP_TABLE_SIZE-1);
 
218
                  GLint k = (GLint) x;
 
219
                  GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
 
220
                                    + (x-k)*light->_SpotExpTable[k][1]);
 
221
                  attenuation *= spot;
 
222
               }
 
223
            }
 
224
         }
 
225
 
 
226
         if (attenuation < 1e-3)
 
227
            continue;           /* this light makes no contribution */
 
228
 
 
229
         /* Compute dot product or normal and vector from V to light pos */
 
230
         n_dot_VP = DOT3( normal, VP );
 
231
 
 
232
         /* Which side gets the diffuse & specular terms? */
 
233
         if (n_dot_VP < 0.0F) {
 
234
            ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]);
 
235
            if (!(IDX & LIGHT_TWOSIDE)) {
 
236
               continue;
 
237
            }
 
238
            side = 1;
 
239
            correction = -1;
 
240
            n_dot_VP = -n_dot_VP;
 
241
         }
 
242
         else {
 
243
            if (IDX & LIGHT_TWOSIDE) {
 
244
               ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]);
 
245
            }
 
246
            side = 0;
 
247
            correction = 1;
 
248
         }
 
249
 
 
250
         /* diffuse term */
 
251
         COPY_3V(contrib, light->_MatAmbient[side]);
 
252
         ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[side]);
 
253
         ACC_SCALE_SCALAR_3V(sum[side], attenuation, contrib );
 
254
 
 
255
         /* specular term - cannibalize VP... */
 
256
         if (ctx->Light.Model.LocalViewer) {
 
257
            GLfloat v[3];
 
258
            COPY_3V(v, vertex);
 
259
            NORMALIZE_3FV(v);
 
260
            SUB_3V(VP, VP, v);                /* h = VP + VPe */
 
261
            h = VP;
 
262
            NORMALIZE_3FV(h);
 
263
         }
 
264
         else if (light->_Flags & LIGHT_POSITIONAL) {
 
265
            h = VP;
 
266
            ACC_3V(h, ctx->_EyeZDir);
 
267
            NORMALIZE_3FV(h);
 
268
         }
 
269
         else {
 
270
            h = light->_h_inf_norm;
 
271
         }
 
272
 
 
273
         n_dot_h = correction * DOT3(normal, h);
 
274
 
 
275
         if (n_dot_h > 0.0F) {
 
276
            GLfloat spec_coef;
 
277
            struct gl_shine_tab *tab = ctx->_ShineTable[side];
 
278
            GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef );
 
279
 
 
280
            if (spec_coef > 1.0e-10) {
 
281
               spec_coef *= attenuation;
 
282
               ACC_SCALE_SCALAR_3V( spec[side], spec_coef,
 
283
                                    light->_MatSpecular[side]);
 
284
            }
 
285
         }
 
286
      } /*loop over lights*/
 
287
 
 
288
      UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] );
 
289
      UNCLAMPED_FLOAT_TO_RGB_CHAN( Fspec[j], spec[0] );
 
290
      Fcolor[j][3] = sumA[0];
 
291
 
 
292
      if (IDX & LIGHT_TWOSIDE) {
 
293
         UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] );
 
294
         UNCLAMPED_FLOAT_TO_RGB_CHAN( Bspec[j], spec[1] );
 
295
         Bcolor[j][3] = sumA[1];
 
296
      }
 
297
   }
 
298
}
 
299
 
 
300
 
 
301
static void TAG(light_rgba)( GLcontext *ctx,
 
302
                             struct vertex_buffer *VB,
 
303
                             struct gl_pipeline_stage *stage,
 
304
                             GLvector4f *input )
 
305
{
 
306
   struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
 
307
   GLuint j;
 
308
 
 
309
   GLfloat (*base)[3] = ctx->Light._BaseColor;
 
310
   GLchan sumA[2];
 
311
 
 
312
   GLuint  vstride = input->stride;
 
313
   const GLfloat *vertex = (GLfloat *) input->data;
 
314
   GLuint  nstride = VB->NormalPtr->stride;
 
315
   const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
 
316
 
 
317
   GLfloat *CMcolor;
 
318
   GLuint CMstride;
 
319
 
 
320
   GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].Ptr;
 
321
   GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].Ptr;
 
322
   GLchan (*color[2])[4];
 
323
   GLuint *flags = VB->Flag;
 
324
 
 
325
   struct gl_material (*new_material)[2] = VB->Material;
 
326
   GLuint *new_material_mask = VB->MaterialMask;
 
327
   GLuint nr = VB->Count;
 
328
 
 
329
   if (MESA_VERBOSE & VERBOSE_LIGHTING)
 
330
      fprintf(stderr, "%s\n", __FUNCTION__ );   
 
331
 
 
332
   (void) flags;
 
333
   (void) nstride;
 
334
   (void) vstride;
 
335
 
 
336
   color[0] = Fcolor;
 
337
   color[1] = Bcolor;
 
338
 
 
339
   if (IDX & LIGHT_COLORMATERIAL) {
 
340
      if (VB->ColorPtr[0]->Type != GL_FLOAT || 
 
341
          VB->ColorPtr[0]->Size != 4)
 
342
         import_color_material( ctx, stage );
 
343
 
 
344
      CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr;
 
345
      CMstride = VB->ColorPtr[0]->StrideB;
 
346
   }
 
347
 
 
348
   VB->ColorPtr[0] = &store->LitColor[0];
 
349
   UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]);
 
350
 
 
351
   if (IDX & LIGHT_TWOSIDE) {
 
352
      VB->ColorPtr[1] = &store->LitColor[1];
 
353
      UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]);
 
354
   }
 
355
 
 
356
   if (stage->changed_inputs == 0)
 
357
      return;
 
358
 
 
359
   for ( j=0 ;
 
360
         j<nr ;
 
361
         j++,STRIDE_F(vertex,VSTRIDE), STRIDE_F(normal,NSTRIDE),CMSTRIDE)
 
362
   {
 
363
      GLfloat sum[2][3];
 
364
      struct gl_light *light;
 
365
 
 
366
      if ( CHECK_COLOR_MATERIAL(j) )
 
367
         _mesa_update_color_material( ctx, CMcolor );
 
368
 
 
369
      if ( CHECK_MATERIAL(j) )
 
370
         _mesa_update_material( ctx, new_material[j], new_material_mask[j] );
 
371
 
 
372
      if ( CHECK_VALIDATE(j) ) {
 
373
         TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx );
 
374
         UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]);
 
375
         if (IDX & LIGHT_TWOSIDE)
 
376
            UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]);
 
377
      }
 
378
 
 
379
      COPY_3V(sum[0], base[0]);
 
380
 
 
381
      if ( IDX & LIGHT_TWOSIDE )
 
382
         COPY_3V(sum[1], base[1]);
 
383
 
 
384
      /* Add contribution from each enabled light source */
 
385
      foreach (light, &ctx->Light.EnabledList) {
 
386
 
 
387
         GLfloat n_dot_h;
 
388
         GLfloat correction;
 
389
         GLint side;
 
390
         GLfloat contrib[3];
 
391
         GLfloat attenuation = 1.0;
 
392
         GLfloat VP[3];          /* unit vector from vertex to light */
 
393
         GLfloat n_dot_VP;       /* n dot VP */
 
394
         GLfloat *h;
 
395
 
 
396
         /* compute VP and attenuation */
 
397
         if (!(light->_Flags & LIGHT_POSITIONAL)) {
 
398
            /* directional light */
 
399
            COPY_3V(VP, light->_VP_inf_norm);
 
400
            attenuation = light->_VP_inf_spot_attenuation;
 
401
         }
 
402
         else {
 
403
            GLfloat d;     /* distance from vertex to light */
 
404
 
 
405
 
 
406
            SUB_3V(VP, light->_Position, vertex);
 
407
 
 
408
            d = (GLfloat) LEN_3FV( VP );
 
409
 
 
410
            if ( d > 1e-6) {
 
411
               GLfloat invd = 1.0F / d;
 
412
               SELF_SCALE_SCALAR_3V(VP, invd);
 
413
            }
 
414
 
 
415
            attenuation = 1.0F / (light->ConstantAttenuation + d *
 
416
                                  (light->LinearAttenuation + d *
 
417
                                   light->QuadraticAttenuation));
 
418
 
 
419
            /* spotlight attenuation */
 
420
            if (light->_Flags & LIGHT_SPOT) {
 
421
               GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
 
422
 
 
423
               if (PV_dot_dir<light->_CosCutoff) {
 
424
                  continue; /* this light makes no contribution */
 
425
               }
 
426
               else {
 
427
                  GLdouble x = PV_dot_dir * (EXP_TABLE_SIZE-1);
 
428
                  GLint k = (GLint) x;
 
429
                  GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
 
430
                                  + (x-k)*light->_SpotExpTable[k][1]);
 
431
                  attenuation *= spot;
 
432
               }
 
433
            }
 
434
         }
 
435
 
 
436
         if (attenuation < 1e-3)
 
437
            continue;           /* this light makes no contribution */
 
438
 
 
439
         /* Compute dot product or normal and vector from V to light pos */
 
440
         n_dot_VP = DOT3( normal, VP );
 
441
 
 
442
         /* which side are we lighting? */
 
443
         if (n_dot_VP < 0.0F) {
 
444
            ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]);
 
445
 
 
446
            if (!(IDX & LIGHT_TWOSIDE))
 
447
               continue;
 
448
 
 
449
            side = 1;
 
450
            correction = -1;
 
451
            n_dot_VP = -n_dot_VP;
 
452
         }
 
453
         else {
 
454
            if (IDX & LIGHT_TWOSIDE) {
 
455
               ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]);
 
456
            }
 
457
            side = 0;
 
458
            correction = 1;
 
459
         }
 
460
 
 
461
         COPY_3V(contrib, light->_MatAmbient[side]);
 
462
 
 
463
         /* diffuse term */
 
464
         ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[side]);
 
465
 
 
466
         /* specular term - cannibalize VP... */
 
467
         {
 
468
            if (ctx->Light.Model.LocalViewer) {
 
469
               GLfloat v[3];
 
470
               COPY_3V(v, vertex);
 
471
               NORMALIZE_3FV(v);
 
472
               SUB_3V(VP, VP, v);                /* h = VP + VPe */
 
473
               h = VP;
 
474
               NORMALIZE_3FV(h);
 
475
            }
 
476
            else if (light->_Flags & LIGHT_POSITIONAL) {
 
477
               h = VP;
 
478
               ACC_3V(h, ctx->_EyeZDir);
 
479
               NORMALIZE_3FV(h);
 
480
            }
 
481
            else {
 
482
               h = light->_h_inf_norm;
 
483
            }
 
484
 
 
485
            n_dot_h = correction * DOT3(normal, h);
 
486
 
 
487
            if (n_dot_h > 0.0F)
 
488
            {
 
489
               GLfloat spec_coef;
 
490
               struct gl_shine_tab *tab = ctx->_ShineTable[side];
 
491
 
 
492
               GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef );
 
493
 
 
494
               ACC_SCALE_SCALAR_3V( contrib, spec_coef,
 
495
                                    light->_MatSpecular[side]);
 
496
            }
 
497
         }
 
498
 
 
499
         ACC_SCALE_SCALAR_3V( sum[side], attenuation, contrib );
 
500
      }
 
501
 
 
502
      UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] );
 
503
      Fcolor[j][3] = sumA[0];
 
504
 
 
505
      if (IDX & LIGHT_TWOSIDE) {
 
506
         UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] );
 
507
         Bcolor[j][3] = sumA[1];
 
508
      }
 
509
   }
 
510
}
 
511
 
 
512
 
 
513
 
 
514
 
 
515
/* As below, but with just a single light.
 
516
 */
 
517
static void TAG(light_fast_rgba_single)( GLcontext *ctx,
 
518
                                         struct vertex_buffer *VB,
 
519
                                         struct gl_pipeline_stage *stage,
 
520
                                         GLvector4f *input )
 
521
 
 
522
{
 
523
   struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
 
524
   GLuint  nstride = VB->NormalPtr->stride;
 
525
   const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
 
526
   GLfloat *CMcolor;
 
527
   GLuint CMstride;
 
528
   GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].Ptr;
 
529
   GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].Ptr;
 
530
   struct gl_light *light = ctx->Light.EnabledList.next;
 
531
   GLuint *flags = VB->Flag;
 
532
   GLchan basechan[2][4];
 
533
   GLuint j = 0;
 
534
   struct gl_material (*new_material)[2] = VB->Material;
 
535
   GLuint *new_material_mask = VB->MaterialMask;
 
536
   GLfloat base[2][3];
 
537
   GLuint nr = VB->Count;
 
538
 
 
539
   if (MESA_VERBOSE & VERBOSE_LIGHTING)
 
540
      fprintf(stderr, "%s\n", __FUNCTION__ );   
 
541
 
 
542
   (void) input;                /* doesn't refer to Eye or Obj */
 
543
   (void) flags;
 
544
   (void) nr;
 
545
   (void) nstride;
 
546
 
 
547
   if (IDX & LIGHT_COLORMATERIAL) {
 
548
      if (VB->ColorPtr[0]->Type != GL_FLOAT || 
 
549
          VB->ColorPtr[0]->Size != 4)
 
550
         import_color_material( ctx, stage );
 
551
 
 
552
      CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr;
 
553
      CMstride = VB->ColorPtr[0]->StrideB;
 
554
   }
 
555
 
 
556
   VB->ColorPtr[0] = &store->LitColor[0];
 
557
   if (IDX & LIGHT_TWOSIDE)
 
558
      VB->ColorPtr[1] = &store->LitColor[1];
 
559
 
 
560
   if (stage->changed_inputs == 0)
 
561
      return;
 
562
 
 
563
   do {
 
564
      
 
565
      if ( CHECK_COLOR_MATERIAL(j) ) {
 
566
         _mesa_update_color_material( ctx, CMcolor );
 
567
      }
 
568
 
 
569
      if ( CHECK_MATERIAL(j) )
 
570
         _mesa_update_material( ctx, new_material[j], new_material_mask[j] );
 
571
 
 
572
      if ( CHECK_VALIDATE(j) )
 
573
         TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx );
 
574
 
 
575
 
 
576
      /* No attenuation, so incoporate _MatAmbient into base color.
 
577
       */
 
578
      COPY_3V(base[0], light->_MatAmbient[0]);
 
579
      ACC_3V(base[0], ctx->Light._BaseColor[0] );
 
580
      UNCLAMPED_FLOAT_TO_RGB_CHAN( basechan[0], base[0] );
 
581
      UNCLAMPED_FLOAT_TO_CHAN(basechan[0][3], 
 
582
                              ctx->Light.Material[0].Diffuse[3]);
 
583
 
 
584
      if (IDX & LIGHT_TWOSIDE) {
 
585
         COPY_3V(base[1], light->_MatAmbient[1]);
 
586
         ACC_3V(base[1], ctx->Light._BaseColor[1]);
 
587
         UNCLAMPED_FLOAT_TO_RGB_CHAN( basechan[1], base[1]);
 
588
         UNCLAMPED_FLOAT_TO_CHAN(basechan[1][3], 
 
589
                                 ctx->Light.Material[1].Diffuse[3]);
 
590
      }
 
591
 
 
592
      do {
 
593
         GLfloat n_dot_VP = DOT3(normal, light->_VP_inf_norm);
 
594
 
 
595
         if (n_dot_VP < 0.0F) {
 
596
            if (IDX & LIGHT_TWOSIDE) {
 
597
               GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm);
 
598
               GLfloat sum[3];
 
599
               COPY_3V(sum, base[1]);
 
600
               ACC_SCALE_SCALAR_3V(sum, -n_dot_VP, light->_MatDiffuse[1]);
 
601
               if (n_dot_h > 0.0F) {
 
602
                  GLfloat spec;
 
603
                  GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec );
 
604
                  ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]);
 
605
               }
 
606
               UNCLAMPED_FLOAT_TO_RGB_CHAN(Bcolor[j], sum );
 
607
               Bcolor[j][3] = basechan[1][3];
 
608
            }
 
609
            COPY_CHAN4(Fcolor[j], basechan[0]);
 
610
         } else {
 
611
            GLfloat n_dot_h = DOT3(normal, light->_h_inf_norm);
 
612
            GLfloat sum[3];
 
613
            COPY_3V(sum, base[0]);
 
614
            ACC_SCALE_SCALAR_3V(sum, n_dot_VP, light->_MatDiffuse[0]);
 
615
            if (n_dot_h > 0.0F) {
 
616
               GLfloat spec;
 
617
               GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec );
 
618
               ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[0]);
 
619
 
 
620
            }
 
621
            UNCLAMPED_FLOAT_TO_RGB_CHAN(Fcolor[j], sum );
 
622
            Fcolor[j][3] = basechan[0][3];
 
623
            if (IDX & LIGHT_TWOSIDE) COPY_CHAN4(Bcolor[j], basechan[1]);
 
624
         }
 
625
 
 
626
         j++;
 
627
         CMSTRIDE;
 
628
         STRIDE_F(normal, NSTRIDE);
 
629
      } while (DO_ANOTHER_NORMAL(j));
 
630
 
 
631
 
 
632
      for ( ; REUSE_LIGHT_RESULTS(j) ; j++, CMSTRIDE, STRIDE_F(normal,NSTRIDE))
 
633
      {
 
634
         COPY_CHAN4(Fcolor[j], Fcolor[j-1]);
 
635
         if (IDX & LIGHT_TWOSIDE)
 
636
            COPY_CHAN4(Bcolor[j], Bcolor[j-1]);
 
637
      }
 
638
 
 
639
   } while (!CHECK_END_VB(j));
 
640
}
 
641
 
 
642
 
 
643
/* Light infinite lights
 
644
 */
 
645
static void TAG(light_fast_rgba)( GLcontext *ctx,
 
646
                                  struct vertex_buffer *VB,
 
647
                                  struct gl_pipeline_stage *stage,
 
648
                                  GLvector4f *input )
 
649
{
 
650
   struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
 
651
   GLchan sumA[2];
 
652
   GLuint  nstride = VB->NormalPtr->stride;
 
653
   const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
 
654
   GLfloat *CMcolor;
 
655
   GLuint CMstride;
 
656
   GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].Ptr;
 
657
   GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].Ptr;
 
658
   GLuint *flags = VB->Flag;
 
659
   GLuint j = 0;
 
660
   struct gl_material (*new_material)[2] = VB->Material;
 
661
   GLuint *new_material_mask = VB->MaterialMask;
 
662
   GLuint nr = VB->Count;
 
663
   struct gl_light *light;
 
664
 
 
665
   if (MESA_VERBOSE & VERBOSE_LIGHTING)
 
666
      fprintf(stderr, "%s\n", __FUNCTION__ );   
 
667
 
 
668
 
 
669
   (void) flags;
 
670
   (void) input;
 
671
   (void) nr;
 
672
   (void) nstride;
 
673
 
 
674
   UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]);
 
675
   UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]);
 
676
 
 
677
   if (IDX & LIGHT_COLORMATERIAL) {
 
678
      if (VB->ColorPtr[0]->Type != GL_FLOAT || 
 
679
          VB->ColorPtr[0]->Size != 4)
 
680
         import_color_material( ctx, stage );
 
681
 
 
682
      CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr;
 
683
      CMstride = VB->ColorPtr[0]->StrideB;
 
684
   }
 
685
 
 
686
   VB->ColorPtr[0] = &store->LitColor[0];
 
687
   if (IDX & LIGHT_TWOSIDE)
 
688
      VB->ColorPtr[1] = &store->LitColor[1];
 
689
 
 
690
   if (stage->changed_inputs == 0)
 
691
      return;
 
692
 
 
693
   do {
 
694
      do {
 
695
         GLfloat sum[2][3];
 
696
 
 
697
         if ( CHECK_COLOR_MATERIAL(j) )
 
698
            _mesa_update_color_material( ctx, CMcolor );
 
699
 
 
700
         if ( CHECK_MATERIAL(j) )
 
701
            _mesa_update_material( ctx, new_material[j], new_material_mask[j] );
 
702
 
 
703
         if ( CHECK_VALIDATE(j) ) {
 
704
            TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx );
 
705
            UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]);
 
706
            if (IDX & LIGHT_TWOSIDE)
 
707
               UNCLAMPED_FLOAT_TO_CHAN(sumA[1], 
 
708
                                       ctx->Light.Material[1].Diffuse[3]);
 
709
         }
 
710
 
 
711
 
 
712
         COPY_3V(sum[0], ctx->Light._BaseColor[0]);
 
713
         if (IDX & LIGHT_TWOSIDE)
 
714
            COPY_3V(sum[1], ctx->Light._BaseColor[1]);
 
715
 
 
716
         foreach (light, &ctx->Light.EnabledList) {
 
717
            GLfloat n_dot_h, n_dot_VP, spec;
 
718
 
 
719
            ACC_3V(sum[0], light->_MatAmbient[0]);
 
720
            if (IDX & LIGHT_TWOSIDE)
 
721
               ACC_3V(sum[1], light->_MatAmbient[1]);
 
722
 
 
723
            n_dot_VP = DOT3(normal, light->_VP_inf_norm);
 
724
 
 
725
            if (n_dot_VP > 0.0F) {
 
726
               ACC_SCALE_SCALAR_3V(sum[0], n_dot_VP, light->_MatDiffuse[0]);
 
727
               n_dot_h = DOT3(normal, light->_h_inf_norm);
 
728
               if (n_dot_h > 0.0F) {
 
729
                  struct gl_shine_tab *tab = ctx->_ShineTable[0];
 
730
                  GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec );
 
731
                  ACC_SCALE_SCALAR_3V( sum[0], spec,
 
732
                                       light->_MatSpecular[0]);
 
733
               }
 
734
            }
 
735
            else if (IDX & LIGHT_TWOSIDE) {
 
736
               ACC_SCALE_SCALAR_3V(sum[1], -n_dot_VP, light->_MatDiffuse[1]);
 
737
               n_dot_h = -DOT3(normal, light->_h_inf_norm);
 
738
               if (n_dot_h > 0.0F) {
 
739
                  struct gl_shine_tab *tab = ctx->_ShineTable[1];
 
740
                  GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec );
 
741
                  ACC_SCALE_SCALAR_3V( sum[1], spec,
 
742
                                       light->_MatSpecular[1]);
 
743
               }
 
744
            }
 
745
         }
 
746
 
 
747
         UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] );
 
748
         Fcolor[j][3] = sumA[0];
 
749
 
 
750
         if (IDX & LIGHT_TWOSIDE) {
 
751
            UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] );
 
752
            Bcolor[j][3] = sumA[1];
 
753
         }
 
754
 
 
755
         j++;
 
756
         CMSTRIDE;
 
757
         STRIDE_F(normal, NSTRIDE);
 
758
      } while (DO_ANOTHER_NORMAL(j));
 
759
 
 
760
      /* Reuse the shading results while there is no change to
 
761
       * normal or material values.
 
762
       */
 
763
      for ( ; REUSE_LIGHT_RESULTS(j) ; j++, CMSTRIDE, STRIDE_F(normal, NSTRIDE))
 
764
      {
 
765
         COPY_CHAN4(Fcolor[j], Fcolor[j-1]);
 
766
         if (IDX & LIGHT_TWOSIDE)
 
767
            COPY_CHAN4(Bcolor[j], Bcolor[j-1]);
 
768
      }
 
769
 
 
770
   } while (!CHECK_END_VB(j));
 
771
}
 
772
 
 
773
 
 
774
 
 
775
 
 
776
 
 
777
/*
 
778
 * Use current lighting/material settings to compute the color indexes
 
779
 * for an array of vertices.
 
780
 * Input:  n - number of vertices to light
 
781
 *         side - 0=use front material, 1=use back material
 
782
 *         vertex - array of [n] vertex position in eye coordinates
 
783
 *         normal - array of [n] surface normal vector
 
784
 * Output:  indexResult - resulting array of [n] color indexes
 
785
 */
 
786
static void TAG(light_ci)( GLcontext *ctx,
 
787
                           struct vertex_buffer *VB,
 
788
                           struct gl_pipeline_stage *stage,
 
789
                           GLvector4f *input )
 
790
{
 
791
   struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
 
792
   GLuint j;
 
793
   GLuint vstride = input->stride;
 
794
   const GLfloat *vertex = (GLfloat *) input->data;
 
795
   GLuint nstride = VB->NormalPtr->stride;
 
796
   const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
 
797
   GLfloat *CMcolor;
 
798
   GLuint CMstride;
 
799
   GLuint *flags = VB->Flag;
 
800
   GLuint *indexResult[2];
 
801
   struct gl_material (*new_material)[2] = VB->Material;
 
802
   GLuint *new_material_mask = VB->MaterialMask;
 
803
   GLuint nr = VB->Count;
 
804
 
 
805
   if (MESA_VERBOSE & VERBOSE_LIGHTING)
 
806
      fprintf(stderr, "%s\n", __FUNCTION__ );   
 
807
 
 
808
   (void) flags;
 
809
   (void) nstride;
 
810
   (void) vstride;
 
811
 
 
812
   VB->IndexPtr[0] = &store->LitIndex[0];
 
813
   if (IDX & LIGHT_TWOSIDE)
 
814
      VB->IndexPtr[1] = &store->LitIndex[1];
 
815
 
 
816
   if (stage->changed_inputs == 0)
 
817
      return;
 
818
 
 
819
   indexResult[0] = VB->IndexPtr[0]->data;
 
820
   if (IDX & LIGHT_TWOSIDE)
 
821
      indexResult[1] = VB->IndexPtr[1]->data;
 
822
 
 
823
   if (IDX & LIGHT_COLORMATERIAL) {
 
824
      if (VB->ColorPtr[0]->Type != GL_FLOAT || 
 
825
          VB->ColorPtr[0]->Size != 4)
 
826
         import_color_material( ctx, stage );
 
827
 
 
828
      CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr;
 
829
      CMstride = VB->ColorPtr[0]->StrideB;
 
830
   }
 
831
 
 
832
   /* loop over vertices */
 
833
   for ( j=0 ;
 
834
         j<nr ;
 
835
         j++,STRIDE_F(vertex,VSTRIDE),STRIDE_F(normal, NSTRIDE), CMSTRIDE)
 
836
   {
 
837
      GLfloat diffuse[2], specular[2];
 
838
      GLuint side = 0;
 
839
      struct gl_light *light;
 
840
 
 
841
      if ( CHECK_COLOR_MATERIAL(j) )
 
842
         _mesa_update_color_material( ctx, CMcolor );
 
843
 
 
844
      if ( CHECK_MATERIAL(j) )
 
845
         _mesa_update_material( ctx, new_material[j], new_material_mask[j] );
 
846
 
 
847
      if ( CHECK_VALIDATE(j) )
 
848
         TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx );
 
849
 
 
850
      diffuse[0] = specular[0] = 0.0F;
 
851
 
 
852
      if ( IDX & LIGHT_TWOSIDE ) {
 
853
         diffuse[1] = specular[1] = 0.0F;
 
854
      }
 
855
 
 
856
      /* Accumulate diffuse and specular from each light source */
 
857
      foreach (light, &ctx->Light.EnabledList) {
 
858
 
 
859
         GLfloat attenuation = 1.0F;
 
860
         GLfloat VP[3];  /* unit vector from vertex to light */
 
861
         GLfloat n_dot_VP;  /* dot product of l and n */
 
862
         GLfloat *h, n_dot_h, correction = 1.0;
 
863
 
 
864
         /* compute l and attenuation */
 
865
         if (!(light->_Flags & LIGHT_POSITIONAL)) {
 
866
            /* directional light */
 
867
            COPY_3V(VP, light->_VP_inf_norm);
 
868
         }
 
869
         else {
 
870
            GLfloat d;     /* distance from vertex to light */
 
871
 
 
872
            SUB_3V(VP, light->_Position, vertex);
 
873
 
 
874
            d = (GLfloat) LEN_3FV( VP );
 
875
            if ( d > 1e-6) {
 
876
               GLfloat invd = 1.0F / d;
 
877
               SELF_SCALE_SCALAR_3V(VP, invd);
 
878
            }
 
879
 
 
880
            attenuation = 1.0F / (light->ConstantAttenuation + d *
 
881
                                  (light->LinearAttenuation + d *
 
882
                                   light->QuadraticAttenuation));
 
883
 
 
884
            /* spotlight attenuation */
 
885
            if (light->_Flags & LIGHT_SPOT) {
 
886
               GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
 
887
               if (PV_dot_dir < light->_CosCutoff) {
 
888
                  continue; /* this light makes no contribution */
 
889
               }
 
890
               else {
 
891
                  GLdouble x = PV_dot_dir * (EXP_TABLE_SIZE-1);
 
892
                  GLint k = (GLint) x;
 
893
                  GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
 
894
                                  + (x-k)*light->_SpotExpTable[k][1]);
 
895
                  attenuation *= spot;
 
896
               }
 
897
            }
 
898
         }
 
899
 
 
900
         if (attenuation < 1e-3)
 
901
            continue;           /* this light makes no contribution */
 
902
 
 
903
         n_dot_VP = DOT3( normal, VP );
 
904
 
 
905
         /* which side are we lighting? */
 
906
         if (n_dot_VP < 0.0F) {
 
907
            if (!(IDX & LIGHT_TWOSIDE))
 
908
               continue;
 
909
            side = 1;
 
910
            correction = -1;
 
911
            n_dot_VP = -n_dot_VP;
 
912
         }
 
913
 
 
914
         /* accumulate diffuse term */
 
915
         diffuse[side] += n_dot_VP * light->_dli * attenuation;
 
916
 
 
917
         /* specular term */
 
918
         if (ctx->Light.Model.LocalViewer) {
 
919
            GLfloat v[3];
 
920
            COPY_3V(v, vertex);
 
921
            NORMALIZE_3FV(v);
 
922
            SUB_3V(VP, VP, v);                /* h = VP + VPe */
 
923
            h = VP;
 
924
            NORMALIZE_3FV(h);
 
925
         }
 
926
         else if (light->_Flags & LIGHT_POSITIONAL) {
 
927
            h = VP;
 
928
            /* Strangely, disabling this addition fixes a conformance
 
929
             * problem.  If this code is enabled, l_sed.c fails.
 
930
             */
 
931
            /*ACC_3V(h, ctx->_EyeZDir);*/
 
932
            NORMALIZE_3FV(h);
 
933
         }
 
934
         else {
 
935
            h = light->_h_inf_norm;
 
936
         }
 
937
 
 
938
         n_dot_h = correction * DOT3(normal, h);
 
939
         if (n_dot_h > 0.0F) {
 
940
            GLfloat spec_coef;
 
941
            struct gl_shine_tab *tab = ctx->_ShineTable[side];
 
942
            GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef);
 
943
            specular[side] += spec_coef * light->_sli * attenuation;
 
944
         }
 
945
      } /*loop over lights*/
 
946
 
 
947
      /* Now compute final color index */
 
948
      for (side = 0 ; side < NR_SIDES ; side++) {
 
949
         struct gl_material *mat = &ctx->Light.Material[side];
 
950
         GLfloat index;
 
951
 
 
952
         if (specular[side] > 1.0F) {
 
953
            index = mat->SpecularIndex;
 
954
         }
 
955
         else {
 
956
            GLfloat d_a = mat->DiffuseIndex - mat->AmbientIndex;
 
957
            GLfloat s_a = mat->SpecularIndex - mat->AmbientIndex;
 
958
 
 
959
            index = mat->AmbientIndex
 
960
               + diffuse[side] * (1.0F-specular[side]) * d_a
 
961
               + specular[side] * s_a;
 
962
 
 
963
            if (index > mat->SpecularIndex) {
 
964
               index = mat->SpecularIndex;
 
965
            }
 
966
         }
 
967
         indexResult[side][j] = (GLuint) (GLint) index;
 
968
      }
 
969
   } /*for vertex*/
 
970
}
 
971
 
 
972
 
 
973
 
 
974
static void TAG(init_light_tab)( void )
 
975
{
 
976
   _tnl_light_tab[IDX] = TAG(light_rgba);
 
977
   _tnl_light_fast_tab[IDX] = TAG(light_fast_rgba);
 
978
   _tnl_light_fast_single_tab[IDX] = TAG(light_fast_rgba_single);
 
979
   _tnl_light_spec_tab[IDX] = TAG(light_rgba_spec);
 
980
   _tnl_light_ci_tab[IDX] = TAG(light_ci);
 
981
}
 
982
 
 
983
 
 
984
#undef TAG
 
985
#undef IDX
 
986
#undef NR_SIDES
 
987
#undef NSTRIDE
 
988
#undef VSTRIDE
 
989
#undef CHECK_MATERIAL
 
990
#undef CHECK_END_VB
 
991
#undef DO_ANOTHER_NORMAL
 
992
#undef REUSE_LIGHT_RESULTS
 
993
#undef CMSTRIDE
 
994
#undef CHECK_COLOR_MATERIAL
 
995
#undef CHECK_VALIDATE