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