t_vb_texgen.c revision 5e23af22f708a66695c0e44e599c26f02d8d4dcd
1/* $Id: t_vb_texgen.c,v 1.8 2001/03/30 14:44:44 gareth Exp $ */ 2 3/* 4 * Mesa 3-D graphics library 5 * Version: 3.5 6 * 7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a 10 * copy of this software and associated documentation files (the "Software"), 11 * to deal in the Software without restriction, including without limitation 12 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 * and/or sell copies of the Software, and to permit persons to whom the 14 * Software is furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included 17 * in all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 * Authors: 27 * Brian Paul <brian@valinux.com> 28 * Keith Whitwell <keithw@valinux.com> 29 */ 30 31 32#include "glheader.h" 33#include "colormac.h" 34#include "context.h" 35#include "macros.h" 36#include "mmath.h" 37#include "mem.h" 38#include "mtypes.h" 39 40#include "math/m_xform.h" 41 42#include "t_context.h" 43#include "t_pipeline.h" 44 45 46/*********************************************************************** 47 * Automatic texture coordinate generation (texgen) code. 48 */ 49 50 51struct texgen_stage_data; 52 53typedef void (*texgen_func)( GLcontext *ctx, 54 struct texgen_stage_data *store, 55 GLuint unit); 56 57 58struct texgen_stage_data { 59 60 /* Per-texunit derived state. 61 */ 62 GLuint TexgenSize[MAX_TEXTURE_UNITS]; 63 GLuint TexgenHoles[MAX_TEXTURE_UNITS]; 64 texgen_func TexgenFunc[MAX_TEXTURE_UNITS]; 65 66 /* Temporary values used in texgen. 67 */ 68 GLfloat (*tmp_f)[3]; 69 GLfloat *tmp_m; 70 71 /* Buffered outputs of the stage. 72 */ 73 GLvector4f texcoord[MAX_TEXTURE_UNITS]; 74}; 75 76 77#define TEXGEN_STAGE_DATA(stage) ((struct texgen_stage_data *)stage->privatePtr) 78 79 80 81static GLuint all_bits[5] = { 82 0, 83 VEC_SIZE_1, 84 VEC_SIZE_2, 85 VEC_SIZE_3, 86 VEC_SIZE_4, 87}; 88 89#define VEC_SIZE_FLAGS (VEC_SIZE_1|VEC_SIZE_2|VEC_SIZE_3|VEC_SIZE_4) 90 91#define TEXGEN_NEED_M (TEXGEN_SPHERE_MAP) 92#define TEXGEN_NEED_F (TEXGEN_SPHERE_MAP | \ 93 TEXGEN_REFLECTION_MAP_NV) 94 95 96 97/* 98 */ 99static void build_m3( GLfloat f[][3], GLfloat m[], 100 const GLvector3f *normal, 101 const GLvector4f *eye ) 102{ 103 GLuint stride = eye->stride; 104 GLfloat *coord = (GLfloat *)eye->start; 105 GLuint count = eye->count; 106 const GLfloat *norm = normal->start; 107 GLuint i; 108 109 /* KW: Had to rearrange this loop to avoid a compiler bug with gcc 110 * 2.7.3.1 at -O3 optimization. Using -fno-strength-reduce 111 * also fixed the bug - is this generally necessary? 112 */ 113 for (i=0;i<count;i++,STRIDE_F(coord,stride)) { 114 GLfloat u[3], two_nu, fx, fy, fz; 115 COPY_3V( u, coord ); 116 NORMALIZE_3FV( u ); 117 two_nu = 2.0F * DOT3(norm,u); 118 fx = f[i][0] = u[0] - norm[0] * two_nu; 119 fy = f[i][1] = u[1] - norm[1] * two_nu; 120 fz = f[i][2] = u[2] - norm[2] * two_nu; 121 m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F); 122 if (m[i] != 0.0F) { 123 m[i] = 0.5F / (GLfloat) GL_SQRT(m[i]); 124 } 125 126 STRIDE_F(norm, normal->stride); 127 } 128} 129 130 131 132static void build_m2( GLfloat f[][3], GLfloat m[], 133 const GLvector3f *normal, 134 const GLvector4f *eye ) 135{ 136 GLuint stride = eye->stride; 137 GLfloat *coord = eye->start; 138 GLuint count = eye->count; 139 140 GLfloat *norm = normal->start; 141 GLuint i; 142 143 for (i=0;i<count;i++,STRIDE_F(coord,stride)) { 144 145 GLfloat u[3], two_nu, fx, fy, fz; 146 COPY_2V( u, coord ); 147 u[2] = 0; 148 NORMALIZE_3FV( u ); 149 two_nu = 2.0F * DOT3(norm,u); 150 fx = f[i][0] = u[0] - norm[0] * two_nu; 151 fy = f[i][1] = u[1] - norm[1] * two_nu; 152 fz = f[i][2] = u[2] - norm[2] * two_nu; 153 m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F); 154 if (m[i] != 0.0F) { 155 m[i] = 0.5F / (GLfloat) GL_SQRT(m[i]); 156 } 157 158 STRIDE_F(norm, normal->stride); 159 } 160} 161 162 163 164typedef void (*build_m_func)( GLfloat f[][3], 165 GLfloat m[], 166 const GLvector3f *normal, 167 const GLvector4f *eye ); 168 169 170static build_m_func build_m_tab[5] = { 171 0, 172 0, 173 build_m2, 174 build_m3, 175 build_m3 176}; 177 178 179/* This is unusual in that we respect the stride of the output vector 180 * (f). This allows us to pass in either a texcoord vector4f, or a 181 * temporary vector3f. 182 */ 183static void build_f3( GLfloat *f, 184 GLuint fstride, 185 const GLvector3f *normal, 186 const GLvector4f *eye ) 187{ 188 GLuint stride = eye->stride; 189 GLfloat *coord = eye->start; 190 GLuint count = eye->count; 191 192 GLfloat *norm = normal->start; 193 GLuint i; 194 195 for (i=0;i<count;i++) { 196 GLfloat u[3], two_nu; 197 COPY_3V( u, coord ); 198 NORMALIZE_3FV( u ); 199 two_nu = 2.0F * DOT3(norm,u); 200 f[0] = u[0] - norm[0] * two_nu; 201 f[1] = u[1] - norm[1] * two_nu; 202 f[2] = u[2] - norm[2] * two_nu; 203 STRIDE_F(coord,stride); 204 STRIDE_F(f,fstride); 205 STRIDE_F(norm, normal->stride); 206 } 207} 208 209 210static void build_f2( GLfloat *f, 211 GLuint fstride, 212 const GLvector3f *normal, 213 const GLvector4f *eye ) 214{ 215 GLuint stride = eye->stride; 216 GLfloat *coord = eye->start; 217 GLuint count = eye->count; 218 GLfloat *norm = normal->start; 219 GLuint i; 220 221 for (i=0;i<count;i++) { 222 223 GLfloat u[3], two_nu; 224 COPY_2V( u, coord ); 225 u[2] = 0; 226 NORMALIZE_3FV( u ); 227 two_nu = 2.0F * DOT3(norm,u); 228 f[0] = u[0] - norm[0] * two_nu; 229 f[1] = u[1] - norm[1] * two_nu; 230 f[2] = u[2] - norm[2] * two_nu; 231 232 STRIDE_F(coord,stride); 233 STRIDE_F(f,fstride); 234 STRIDE_F(norm, normal->stride); 235 } 236} 237 238typedef void (*build_f_func)( GLfloat *f, 239 GLuint fstride, 240 const GLvector3f *normal_vec, 241 const GLvector4f *eye ); 242 243 244 245/* Just treat 4-vectors as 3-vectors. 246 */ 247static build_f_func build_f_tab[5] = { 248 0, 249 0, 250 build_f2, 251 build_f3, 252 build_f3 253}; 254 255 256/* Special case texgen functions. 257 */ 258static void texgen_reflection_map_nv( GLcontext *ctx, 259 struct texgen_stage_data *store, 260 GLuint unit ) 261{ 262 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; 263 GLvector4f *in = VB->TexCoordPtr[unit]; 264 GLvector4f *out = &store->texcoord[unit]; 265 266 build_f_tab[VB->EyePtr->size]( out->start, 267 out->stride, 268 VB->NormalPtr, 269 VB->EyePtr ); 270 271 if (in) { 272 out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_3; 273 out->count = in->count; 274 out->size = MAX2(in->size, 3); 275 if (in->size == 4) 276 _mesa_copy_tab[0x8]( out, in ); 277 } 278 else { 279 out->flags |= VEC_SIZE_3; 280 out->size = 3; 281 out->count = in->count; 282 } 283 284} 285 286 287 288static void texgen_normal_map_nv( GLcontext *ctx, 289 struct texgen_stage_data *store, 290 GLuint unit ) 291{ 292 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; 293 GLvector4f *in = VB->TexCoordPtr[unit]; 294 GLvector4f *out = &store->texcoord[unit]; 295 GLvector3f *normal = VB->NormalPtr; 296 GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->start; 297 GLuint count = VB->Count; 298 GLuint i; 299 const GLfloat *norm = normal->start; 300 301 for (i=0;i<count;i++, STRIDE_F(norm, normal->stride)) { 302 texcoord[i][0] = norm[0]; 303 texcoord[i][1] = norm[1]; 304 texcoord[i][2] = norm[2]; 305 } 306 307 308 if (in) { 309 out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_3; 310 out->count = in->count; 311 out->size = MAX2(in->size, 3); 312 if (in->size == 4) 313 _mesa_copy_tab[0x8]( out, in ); 314 } 315 else { 316 out->flags |= VEC_SIZE_3; 317 out->size = 3; 318 out->count = in->count; 319 } 320} 321 322 323static void texgen_sphere_map( GLcontext *ctx, 324 struct texgen_stage_data *store, 325 GLuint unit ) 326{ 327 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; 328 GLvector4f *in = VB->TexCoordPtr[unit]; 329 GLvector4f *out = &store->texcoord[unit]; 330 GLfloat (*texcoord)[4] = (GLfloat (*)[4]) out->start; 331 GLuint count = VB->Count; 332 GLuint i; 333 GLfloat (*f)[3] = store->tmp_f; 334 GLfloat *m = store->tmp_m; 335 336 (build_m_tab[VB->EyePtr->size])( store->tmp_f, 337 store->tmp_m, 338 VB->NormalPtr, 339 VB->EyePtr ); 340 341 for (i=0;i<count;i++) { 342 texcoord[i][0] = f[i][0] * m[i] + 0.5F; 343 texcoord[i][1] = f[i][1] * m[i] + 0.5F; 344 } 345 346 if (in) { 347 out->size = MAX2(in->size,2); 348 out->count = in->count; 349 out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_2; 350 if (in->size > 2) 351 _mesa_copy_tab[all_bits[in->size] & ~0x3]( out, in ); 352 } else { 353 out->size = 2; 354 out->flags |= VEC_SIZE_2; 355 out->count = in->count; 356 } 357} 358 359 360 361static void texgen( GLcontext *ctx, 362 struct texgen_stage_data *store, 363 GLuint unit ) 364{ 365 TNLcontext *tnl = TNL_CONTEXT(ctx); 366 struct vertex_buffer *VB = &tnl->vb; 367 GLvector4f *in = VB->TexCoordPtr[unit]; 368 GLvector4f *out = &store->texcoord[unit]; 369 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; 370 const GLvector4f *obj = VB->ObjPtr; 371 const GLvector4f *eye = VB->EyePtr; 372 const GLvector3f *normal = VB->NormalPtr; 373 GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->data; 374 GLfloat *indata; 375 GLuint count = VB->Count; 376 GLfloat (*f)[3] = store->tmp_f; 377 GLfloat *m = store->tmp_m; 378 GLuint holes = 0; 379 380 381 if (texUnit->_GenFlags & TEXGEN_NEED_M) { 382 build_m_tab[in->size]( store->tmp_f, store->tmp_m, normal, eye ); 383 } else if (texUnit->_GenFlags & TEXGEN_NEED_F) { 384 build_f_tab[in->size]( (GLfloat *)store->tmp_f, 3, normal, eye ); 385 } 386 387 if (!in) { 388 ASSERT(0); 389 in = out; 390 in->count = VB->Count; 391 392 out->size = store->TexgenSize[unit]; 393 out->flags |= texUnit->TexGenEnabled; 394 out->count = VB->Count; 395 holes = store->TexgenHoles[unit]; 396 } 397 else { 398 GLuint copy = (all_bits[in->size] & ~texUnit->TexGenEnabled); 399 if (copy) 400 _mesa_copy_tab[copy]( out, in ); 401 402 out->size = MAX2(in->size, store->TexgenSize[unit]); 403 out->flags |= (in->flags & VEC_SIZE_FLAGS) | texUnit->TexGenEnabled; 404 out->count = in->count; 405 406 holes = ~all_bits[in->size] & store->TexgenHoles[unit]; 407 } 408 409 if (holes) { 410 if (holes & VEC_DIRTY_2) _mesa_vector4f_clean_elem(out, count, 2); 411 if (holes & VEC_DIRTY_1) _mesa_vector4f_clean_elem(out, count, 1); 412 if (holes & VEC_DIRTY_0) _mesa_vector4f_clean_elem(out, count, 0); 413 } 414 415 if (texUnit->TexGenEnabled & S_BIT) { 416 GLuint i; 417 switch (texUnit->GenModeS) { 418 case GL_OBJECT_LINEAR: 419 _mesa_dotprod_tab[obj->size]( (GLfloat *)out->data, 420 sizeof(out->data[0]), obj, 421 texUnit->ObjectPlaneS ); 422 break; 423 case GL_EYE_LINEAR: 424 _mesa_dotprod_tab[eye->size]( (GLfloat *)out->data, 425 sizeof(out->data[0]), eye, 426 texUnit->EyePlaneS ); 427 break; 428 case GL_SPHERE_MAP: 429 for (indata=in->start,i=0 ; i<count ;i++, STRIDE_F(indata,in->stride)) 430 texcoord[i][0] = indata[0] * m[i] + 0.5F; 431 break; 432 case GL_REFLECTION_MAP_NV: 433 for (i=0;i<count;i++) 434 texcoord[i][0] = f[i][0]; 435 break; 436 case GL_NORMAL_MAP_NV: { 437 const GLfloat *norm = normal->start; 438 for (i=0;i<count;i++, STRIDE_F(norm, normal->stride)) { 439 texcoord[i][0] = norm[0]; 440 } 441 break; 442 } 443 default: 444 _mesa_problem(ctx, "Bad S texgen"); 445 } 446 } 447 448 if (texUnit->TexGenEnabled & T_BIT) { 449 GLuint i; 450 switch (texUnit->GenModeT) { 451 case GL_OBJECT_LINEAR: 452 _mesa_dotprod_tab[obj->size]( &(out->data[0][1]), 453 sizeof(out->data[0]), obj, 454 texUnit->ObjectPlaneT ); 455 break; 456 case GL_EYE_LINEAR: 457 _mesa_dotprod_tab[eye->size]( &(out->data[0][1]), 458 sizeof(out->data[0]), eye, 459 texUnit->EyePlaneT ); 460 break; 461 case GL_SPHERE_MAP: 462 for (indata=in->start,i=0; i<count ;i++,STRIDE_F(indata,in->stride)) 463 texcoord[i][1] = indata[1] * m[i] + 0.5F; 464 break; 465 case GL_REFLECTION_MAP_NV: 466 for (i=0;i<count;i++) 467 texcoord[i][0] = f[i][0]; 468 break; 469 case GL_NORMAL_MAP_NV: { 470 const GLfloat *norm = normal->start; 471 for (i=0;i<count;i++, STRIDE_F(norm, normal->stride)) { 472 texcoord[i][1] = norm[1]; 473 } 474 break; 475 } 476 default: 477 _mesa_problem(ctx, "Bad T texgen"); 478 } 479 } 480 481 if (texUnit->TexGenEnabled & R_BIT) { 482 GLuint i; 483 switch (texUnit->GenModeR) { 484 case GL_OBJECT_LINEAR: 485 _mesa_dotprod_tab[obj->size]( &(out->data[0][2]), 486 sizeof(out->data[0]), obj, 487 texUnit->ObjectPlaneR ); 488 break; 489 case GL_EYE_LINEAR: 490 _mesa_dotprod_tab[eye->size]( &(out->data[0][2]), 491 sizeof(out->data[0]), eye, 492 texUnit->EyePlaneR ); 493 break; 494 case GL_REFLECTION_MAP_NV: 495 for (i=0;i<count;i++) 496 texcoord[i][2] = f[i][2]; 497 break; 498 case GL_NORMAL_MAP_NV: { 499 const GLfloat *norm = normal->start; 500 for (i=0;i<count;i++,STRIDE_F(norm, normal->stride)) { 501 texcoord[i][2] = norm[2]; 502 } 503 break; 504 } 505 default: 506 _mesa_problem(ctx, "Bad R texgen"); 507 } 508 } 509 510 if (texUnit->TexGenEnabled & Q_BIT) { 511 switch (texUnit->GenModeQ) { 512 case GL_OBJECT_LINEAR: 513 _mesa_dotprod_tab[obj->size]( &(out->data[0][3]), 514 sizeof(out->data[0]), obj, 515 texUnit->ObjectPlaneQ ); 516 break; 517 case GL_EYE_LINEAR: 518 _mesa_dotprod_tab[eye->size]( &(out->data[0][3]), 519 sizeof(out->data[0]), eye, 520 texUnit->EyePlaneQ ); 521 break; 522 default: 523 _mesa_problem(ctx, "Bad Q texgen"); 524 } 525 } 526} 527 528 529 530static GLboolean run_texgen_stage( GLcontext *ctx, 531 struct gl_pipeline_stage *stage ) 532{ 533 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; 534 struct texgen_stage_data *store = TEXGEN_STAGE_DATA( stage ); 535 GLuint i; 536 537 for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) 538 if (ctx->Texture._TexGenEnabled & ENABLE_TEXGEN(i)) { 539 if (stage->changed_inputs & (VERT_EYE | VERT_NORM | VERT_TEX(i))) 540 store->TexgenFunc[i]( ctx, store, i ); 541 542 VB->TexCoordPtr[i] = &store->texcoord[i]; 543 } 544 545 return GL_TRUE; 546} 547 548 549 550 551static GLboolean run_validate_texgen_stage( GLcontext *ctx, 552 struct gl_pipeline_stage *stage ) 553{ 554 struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage); 555 GLuint i; 556 557 for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { 558 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; 559 560 if (texUnit->TexGenEnabled) { 561 GLuint sz; 562 563 if (texUnit->TexGenEnabled & R_BIT) 564 sz = 4; 565 else if (texUnit->TexGenEnabled & Q_BIT) 566 sz = 3; 567 else if (texUnit->TexGenEnabled & T_BIT) 568 sz = 2; 569 else 570 sz = 1; 571 572 store->TexgenSize[i] = sz; 573 store->TexgenHoles[i] = (all_bits[sz] & ~texUnit->TexGenEnabled); 574 store->TexgenFunc[i] = texgen; 575 576 if (texUnit->TexGenEnabled == (S_BIT|T_BIT|R_BIT)) { 577 if (texUnit->_GenFlags == TEXGEN_REFLECTION_MAP_NV) { 578 store->TexgenFunc[i] = texgen_reflection_map_nv; 579 } 580 else if (texUnit->_GenFlags == TEXGEN_NORMAL_MAP_NV) { 581 store->TexgenFunc[i] = texgen_normal_map_nv; 582 } 583 } 584 else if (texUnit->TexGenEnabled == (S_BIT|T_BIT) && 585 texUnit->_GenFlags == TEXGEN_SPHERE_MAP) { 586 store->TexgenFunc[i] = texgen_sphere_map; 587 } 588 } 589 } 590 591 stage->run = run_texgen_stage; 592 return stage->run( ctx, stage ); 593} 594 595 596static void check_texgen( GLcontext *ctx, struct gl_pipeline_stage *stage ) 597{ 598 GLuint i; 599 stage->active = 0; 600 601 if (ctx->Texture._TexGenEnabled) { 602 GLuint inputs = 0; 603 GLuint outputs = 0; 604 605 if (ctx->Texture._GenFlags & TEXGEN_OBJ_LINEAR) 606 inputs |= VERT_OBJ; 607 608 if (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) 609 inputs |= VERT_EYE; 610 611 if (ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS) 612 inputs |= VERT_NORM; 613 614 for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) 615 if (ctx->Texture._TexGenEnabled & ENABLE_TEXGEN(i)) 616 { 617 outputs |= VERT_TEX(i); 618 619 /* Need the original input in case it contains a Q coord: 620 * (sigh) 621 */ 622/* if ((ctx->Texture.Unit[i]._ReallyEnabled|Q_BIT) & */ 623/* ~ctx->Texture.Unit[i].TexGenEnabled) */ 624 inputs |= VERT_TEX(i); 625 626 /* Something for Feedback? */ 627 } 628 629 if (stage->privatePtr) 630 stage->run = run_validate_texgen_stage; 631 stage->active = 1; 632 stage->inputs = inputs; 633 stage->outputs = outputs; 634 } 635} 636 637 638 639 640/* Called the first time stage->run() is invoked. 641 */ 642static GLboolean alloc_texgen_data( GLcontext *ctx, 643 struct gl_pipeline_stage *stage ) 644{ 645 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; 646 struct texgen_stage_data *store; 647 GLuint i; 648 649 stage->privatePtr = CALLOC(sizeof(*store)); 650 store = TEXGEN_STAGE_DATA(stage); 651 if (!store) 652 return GL_FALSE; 653 654 for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) 655 _mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 ); 656 657 store->tmp_f = (GLfloat (*)[3]) MALLOC(VB->Size * sizeof(GLfloat) * 3); 658 store->tmp_m = (GLfloat *) MALLOC(VB->Size * sizeof(GLfloat)); 659 660 /* Now validate and run the stage. 661 */ 662 stage->run = run_validate_texgen_stage; 663 return stage->run( ctx, stage ); 664} 665 666 667static void free_texgen_data( struct gl_pipeline_stage *stage ) 668 669{ 670 struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage); 671 GLuint i; 672 673 if (store) { 674 for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++) 675 if (store->texcoord[i].data) 676 _mesa_vector4f_free( &store->texcoord[i] ); 677 678 679 if (store->tmp_f) FREE( store->tmp_f ); 680 if (store->tmp_m) FREE( store->tmp_m ); 681 FREE( store ); 682 stage->privatePtr = NULL; 683 } 684} 685 686 687 688const struct gl_pipeline_stage _tnl_texgen_stage = 689{ 690 "texgen", 691 _NEW_TEXTURE, /* when to call check() */ 692 _NEW_TEXTURE, /* when to invalidate stored data */ 693 0,0,0, /* active, inputs, outputs */ 694 0,0, /* changed_inputs, private */ 695 free_texgen_data, /* destructor */ 696 check_texgen, /* check */ 697 alloc_texgen_data /* run -- initially set to alloc data */ 698}; 699