f090fcd734c9c5651900888b9e6459f03a24c243
[mesa.git] / src / mesa / main / texobj.c
1 /* $Id: texobj.c,v 1.35 2000/11/22 07:32:17 joukj Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999-2000 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
27
28 #ifdef PC_HEADER
29 #include "all.h"
30 #else
31 #include "glheader.h"
32 #include "colortab.h"
33 #include "context.h"
34 #include "enums.h"
35 #include "hash.h"
36 #include "macros.h"
37 #include "mem.h"
38 #include "teximage.h"
39 #include "texstate.h"
40 #include "texobj.h"
41 #include "mtypes.h"
42 #endif
43
44
45
46 /*
47 * Allocate a new texture object and add it to the linked list of texture
48 * objects. If name>0 then also insert the new texture object into the hash
49 * table.
50 * Input: shared - the shared GL state structure to contain the texture object
51 * name - integer name for the texture object
52 * dimensions - either 1, 2, 3 or 6 (cube map)
53 * zero is ok for the sake of GenTextures()
54 * Return: pointer to new texture object
55 */
56 struct gl_texture_object *
57 _mesa_alloc_texture_object( struct gl_shared_state *shared, GLuint name,
58 GLuint dimensions)
59 {
60 struct gl_texture_object *obj;
61
62 ASSERT(dimensions <= 3 || dimensions == 6);
63
64 obj = CALLOC_STRUCT(gl_texture_object);
65
66 if (obj) {
67 /* init the non-zero fields */
68 _glthread_INIT_MUTEX(obj->Mutex);
69 obj->RefCount = 1;
70 obj->Name = name;
71 obj->Dimensions = dimensions;
72 obj->Priority = 1.0F;
73 obj->WrapS = GL_REPEAT;
74 obj->WrapT = GL_REPEAT;
75 obj->WrapR = GL_REPEAT;
76 obj->MinFilter = GL_NEAREST_MIPMAP_LINEAR;
77 obj->MagFilter = GL_LINEAR;
78 obj->MinLod = -1000.0;
79 obj->MaxLod = 1000.0;
80 obj->BaseLevel = 0;
81 obj->MaxLevel = 1000;
82 _mesa_init_colortable(&obj->Palette);
83
84 /* insert into linked list */
85 if (shared) {
86 _glthread_LOCK_MUTEX(shared->Mutex);
87 obj->Next = shared->TexObjectList;
88 shared->TexObjectList = obj;
89 _glthread_UNLOCK_MUTEX(shared->Mutex);
90 }
91
92 if (name > 0) {
93 /* insert into hash table */
94 _mesa_HashInsert(shared->TexObjects, name, obj);
95 }
96 }
97 return obj;
98 }
99
100
101 /*
102 * Deallocate a texture object struct and remove it from the given
103 * shared GL state.
104 * Input: shared - the shared GL state to which the object belongs
105 * t - the texture object to delete
106 */
107 void _mesa_free_texture_object( struct gl_shared_state *shared,
108 struct gl_texture_object *t )
109 {
110 struct gl_texture_object *tprev, *tcurr;
111
112 assert(t);
113
114 /* unlink t from the linked list */
115 if (shared) {
116 _glthread_LOCK_MUTEX(shared->Mutex);
117 tprev = NULL;
118 tcurr = shared->TexObjectList;
119 while (tcurr) {
120 if (tcurr==t) {
121 if (tprev) {
122 tprev->Next = t->Next;
123 }
124 else {
125 shared->TexObjectList = t->Next;
126 }
127 break;
128 }
129 tprev = tcurr;
130 tcurr = tcurr->Next;
131 }
132 _glthread_UNLOCK_MUTEX(shared->Mutex);
133 }
134
135 if (t->Name) {
136 /* remove from hash table */
137 _mesa_HashRemove(shared->TexObjects, t->Name);
138 }
139
140 _mesa_free_colortable_data(&t->Palette);
141
142 /* free the texture images */
143 {
144 GLuint i;
145 for (i=0;i<MAX_TEXTURE_LEVELS;i++) {
146 if (t->Image[i]) {
147 _mesa_free_texture_image( t->Image[i] );
148 }
149 }
150 }
151
152 /* free this object */
153 FREE( t );
154 }
155
156
157 /*
158 * Report why a texture object is incomplete. (for debug only)
159 */
160 #if 0
161 static void
162 incomplete(const struct gl_texture_object *t, const char *why)
163 {
164 printf("Texture Obj %d incomplete because: %s\n", t->Name, why);
165 }
166 #else
167 #define incomplete(a, b)
168 #endif
169
170
171 /*
172 * Examine a texture object to determine if it is complete.
173 * The t->Complete flag will be set to GL_TRUE or GL_FALSE accordingly.
174 */
175 void
176 _mesa_test_texobj_completeness( const GLcontext *ctx,
177 struct gl_texture_object *t )
178 {
179 const GLint baseLevel = t->BaseLevel;
180
181 t->Complete = GL_TRUE; /* be optimistic */
182
183 /* Always need the base level image */
184 if (!t->Image[baseLevel]) {
185 incomplete(t, "Image[baseLevel] == NULL");
186 t->Complete = GL_FALSE;
187 return;
188 }
189
190 /* Compute number of mipmap levels */
191 if (t->Dimensions == 1) {
192 t->_P = t->Image[baseLevel]->WidthLog2;
193 }
194 else if (t->Dimensions == 2 || t->Dimensions == 6) {
195 t->_P = MAX2(t->Image[baseLevel]->WidthLog2,
196 t->Image[baseLevel]->HeightLog2);
197 }
198 else if (t->Dimensions == 3) {
199 GLint max = MAX2(t->Image[baseLevel]->WidthLog2,
200 t->Image[baseLevel]->HeightLog2);
201 max = MAX2(max, (GLint)(t->Image[baseLevel]->DepthLog2));
202 t->_P = max;
203 }
204
205 /* Compute M (see the 1.2 spec) used during mipmapping */
206 t->_M = (GLfloat) (MIN2(t->MaxLevel, t->_P) - t->BaseLevel);
207
208
209 if (t->Dimensions == 6) {
210 /* make sure that all six cube map level 0 images are the same size */
211 const GLint w = t->Image[baseLevel]->Width2;
212 const GLint h = t->Image[baseLevel]->Height2;
213 if (!t->NegX[baseLevel] ||
214 t->NegX[baseLevel]->Width2 != w ||
215 t->NegX[baseLevel]->Height2 != h ||
216 !t->PosY[baseLevel] ||
217 t->PosY[baseLevel]->Width2 != w ||
218 t->PosY[baseLevel]->Height2 != h ||
219 !t->NegY[baseLevel] ||
220 t->NegY[baseLevel]->Width2 != w ||
221 t->NegY[baseLevel]->Height2 != h ||
222 !t->PosZ[baseLevel] ||
223 t->PosZ[baseLevel]->Width2 != w ||
224 t->PosZ[baseLevel]->Height2 != h ||
225 !t->NegZ[baseLevel] ||
226 t->NegZ[baseLevel]->Width2 != w ||
227 t->NegZ[baseLevel]->Height2 != h) {
228 t->Complete = GL_FALSE;
229 incomplete(t, "Non-quare cubemap image");
230 return;
231 }
232 }
233
234 if (t->MinFilter != GL_NEAREST && t->MinFilter != GL_LINEAR) {
235 /*
236 * Mipmapping: determine if we have a complete set of mipmaps
237 */
238 GLint i;
239 GLint minLevel = baseLevel;
240 GLint maxLevel = MIN2(t->_P, ctx->Const.MaxTextureLevels-1);
241 maxLevel = MIN2(maxLevel, t->MaxLevel);
242
243 if (minLevel > maxLevel) {
244 t->Complete = GL_FALSE;
245 incomplete(t, "minLevel > maxLevel");
246 return;
247 }
248
249 /* Test dimension-independent attributes */
250 for (i = minLevel; i <= maxLevel; i++) {
251 if (t->Image[i]) {
252 if (t->Image[i]->Format != t->Image[baseLevel]->Format) {
253 t->Complete = GL_FALSE;
254 incomplete(t, "Format[i] != Format[baseLevel]");
255 return;
256 }
257 if (t->Image[i]->Border != t->Image[baseLevel]->Border) {
258 t->Complete = GL_FALSE;
259 incomplete(t, "Border[i] != Border[baseLevel]");
260 return;
261 }
262 }
263 }
264
265 /* Test things which depend on number of texture image dimensions */
266 if (t->Dimensions == 1) {
267 /* Test 1-D mipmaps */
268 GLuint width = t->Image[baseLevel]->Width2;
269 for (i = baseLevel + 1; i < ctx->Const.MaxTextureLevels; i++) {
270 if (width > 1) {
271 width /= 2;
272 }
273 if (i >= minLevel && i <= maxLevel) {
274 if (!t->Image[i]) {
275 t->Complete = GL_FALSE;
276 incomplete(t, "1D Image[i] == NULL");
277 return;
278 }
279 if (t->Image[i]->Width2 != width ) {
280 t->Complete = GL_FALSE;
281 incomplete(t, "1D Image[i] bad width");
282 return;
283 }
284 }
285 if (width == 1) {
286 return; /* found smallest needed mipmap, all done! */
287 }
288 }
289 }
290 else if (t->Dimensions == 2) {
291 /* Test 2-D mipmaps */
292 GLuint width = t->Image[baseLevel]->Width2;
293 GLuint height = t->Image[baseLevel]->Height2;
294 for (i = baseLevel + 1; i < ctx->Const.MaxTextureLevels; i++) {
295 if (width > 1) {
296 width /= 2;
297 }
298 if (height > 1) {
299 height /= 2;
300 }
301 if (i >= minLevel && i <= maxLevel) {
302 if (!t->Image[i]) {
303 t->Complete = GL_FALSE;
304 incomplete(t, "2D Image[i] == NULL");
305 return;
306 }
307 if (t->Image[i]->Width2 != width) {
308 t->Complete = GL_FALSE;
309 incomplete(t, "2D Image[i] bad width");
310 return;
311 }
312 if (t->Image[i]->Height2 != height) {
313 t->Complete = GL_FALSE;
314 incomplete(t, "2D Image[i] bad height");
315 return;
316 }
317 if (width==1 && height==1) {
318 return; /* found smallest needed mipmap, all done! */
319 }
320 }
321 }
322 }
323 else if (t->Dimensions == 3) {
324 /* Test 3-D mipmaps */
325 GLuint width = t->Image[baseLevel]->Width2;
326 GLuint height = t->Image[baseLevel]->Height2;
327 GLuint depth = t->Image[baseLevel]->Depth2;
328 for (i = baseLevel + 1; i < ctx->Const.MaxTextureLevels; i++) {
329 if (width > 1) {
330 width /= 2;
331 }
332 if (height > 1) {
333 height /= 2;
334 }
335 if (depth > 1) {
336 depth /= 2;
337 }
338 if (i >= minLevel && i <= maxLevel) {
339 if (!t->Image[i]) {
340 incomplete(t, "3D Image[i] == NULL");
341 t->Complete = GL_FALSE;
342 return;
343 }
344 if (t->Image[i]->Width2 != width) {
345 t->Complete = GL_FALSE;
346 incomplete(t, "3D Image[i] bad width");
347 return;
348 }
349 if (t->Image[i]->Height2 != height) {
350 t->Complete = GL_FALSE;
351 incomplete(t, "3D Image[i] bad height");
352 return;
353 }
354 if (t->Image[i]->Depth2 != depth) {
355 t->Complete = GL_FALSE;
356 incomplete(t, "3D Image[i] bad depth");
357 return;
358 }
359 }
360 if (width == 1 && height == 1 && depth == 1) {
361 return; /* found smallest needed mipmap, all done! */
362 }
363 }
364 }
365 else if (t->Dimensions == 6) {
366 /* make sure 6 cube faces are consistant */
367 GLuint width = t->Image[baseLevel]->Width2;
368 GLuint height = t->Image[baseLevel]->Height2;
369 for (i = baseLevel + 1; i < ctx->Const.MaxTextureLevels; i++) {
370 if (width > 1) {
371 width /= 2;
372 }
373 if (height > 1) {
374 height /= 2;
375 }
376 if (i >= minLevel && i <= maxLevel) {
377 /* check that we have images defined */
378 if (!t->Image[i] || !t->NegX[i] ||
379 !t->PosY[i] || !t->NegY[i] ||
380 !t->PosZ[i] || !t->NegZ[i]) {
381 t->Complete = GL_FALSE;
382 incomplete(t, "CubeMap Image[i] == NULL");
383 return;
384 }
385 /* check that all six images have same size */
386 if (t->NegX[i]->Width2!=width || t->NegX[i]->Height2!=height ||
387 t->PosY[i]->Width2!=width || t->PosY[i]->Height2!=height ||
388 t->NegY[i]->Width2!=width || t->NegY[i]->Height2!=height ||
389 t->PosZ[i]->Width2!=width || t->PosZ[i]->Height2!=height ||
390 t->NegZ[i]->Width2!=width || t->NegZ[i]->Height2!=height) {
391 t->Complete = GL_FALSE;
392 incomplete(t, "CubeMap Image[i] bad size");
393 return;
394 }
395 }
396 if (width == 1 && height == 1) {
397 return; /* found smallest needed mipmap, all done! */
398 }
399 }
400 }
401 else {
402 /* Dimensions = ??? */
403 gl_problem(NULL, "Bug in gl_test_texture_object_completeness\n");
404 }
405 }
406 }
407
408
409 _glthread_DECLARE_STATIC_MUTEX(GenTexturesLock);
410
411
412 /*
413 * Execute glGenTextures
414 */
415 void
416 _mesa_GenTextures( GLsizei n, GLuint *texName )
417 {
418 GET_CURRENT_CONTEXT(ctx);
419 GLuint first;
420 GLint i;
421
422 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGenTextures");
423 if (n < 0) {
424 gl_error( ctx, GL_INVALID_VALUE, "glGenTextures" );
425 return;
426 }
427
428 if (!texName)
429 return;
430
431 /*
432 * This must be atomic (generation and allocation of texture IDs)
433 */
434 _glthread_LOCK_MUTEX(GenTexturesLock);
435
436 first = _mesa_HashFindFreeKeyBlock(ctx->Shared->TexObjects, n);
437
438 /* Return the texture names */
439 for (i=0;i<n;i++) {
440 texName[i] = first + i;
441 }
442
443 /* Allocate new, empty texture objects */
444 for (i=0;i<n;i++) {
445 GLuint name = first + i;
446 GLuint dims = 0;
447 (void) _mesa_alloc_texture_object(ctx->Shared, name, dims);
448 }
449
450 _glthread_UNLOCK_MUTEX(GenTexturesLock);
451 }
452
453
454
455 /*
456 * Execute glDeleteTextures
457 */
458 void
459 _mesa_DeleteTextures( GLsizei n, const GLuint *texName)
460 {
461 GET_CURRENT_CONTEXT(ctx);
462 GLint i;
463
464 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDeleteTextures");
465
466 if (!texName)
467 return;
468
469 for (i=0;i<n;i++) {
470 if (texName[i] > 0) {
471 struct gl_texture_object *delObj = (struct gl_texture_object *)
472 _mesa_HashLookup(ctx->Shared->TexObjects, texName[i]);
473 if (delObj) {
474 /* First check if this texture is currently bound.
475 * If so, unbind it and decrement the reference count.
476 */
477 GLuint u;
478 for (u = 0; u < MAX_TEXTURE_UNITS; u++) {
479 struct gl_texture_unit *unit = &ctx->Texture.Unit[u];
480 if (delObj == unit->Current1D) {
481 unit->Current1D = ctx->Shared->Default1D;
482 ctx->Shared->Default1D->RefCount++;
483 }
484 else if (delObj == unit->Current2D) {
485 unit->Current2D = ctx->Shared->Default2D;
486 ctx->Shared->Default2D->RefCount++;
487 }
488 else if (delObj == unit->Current3D) {
489 unit->Current3D = ctx->Shared->Default3D;
490 ctx->Shared->Default3D->RefCount++;
491 }
492 else if (delObj == unit->CurrentCubeMap) {
493 unit->CurrentCubeMap = ctx->Shared->DefaultCubeMap;
494 ctx->Shared->DefaultCubeMap->RefCount++;
495 }
496 }
497 ctx->NewState |= _NEW_TEXTURE;
498
499 /* Decrement reference count and delete if zero */
500 delObj->RefCount--;
501 ASSERT( delObj->RefCount >= 0 );
502 if (delObj->RefCount == 0) {
503 if (ctx->Driver.DeleteTexture)
504 (*ctx->Driver.DeleteTexture)( ctx, delObj );
505 _mesa_free_texture_object(ctx->Shared, delObj);
506 }
507 }
508 }
509 }
510 }
511
512
513
514 /*
515 * Execute glBindTexture
516 */
517 void
518 _mesa_BindTexture( GLenum target, GLuint texName )
519 {
520 GET_CURRENT_CONTEXT(ctx);
521 GLuint unit = ctx->Texture.CurrentUnit;
522 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
523 struct gl_texture_object *oldTexObj;
524 struct gl_texture_object *newTexObj;
525 GLuint targetDim;
526
527 if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
528 fprintf(stderr, "glBindTexture %s %d\n",
529 gl_lookup_enum_by_nr(target), (GLint) texName);
530
531 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glBindTexture");
532
533 switch (target) {
534 case GL_TEXTURE_1D:
535 targetDim = 1;
536 oldTexObj = texUnit->Current1D;
537 break;
538 case GL_TEXTURE_2D:
539 targetDim = 2;
540 oldTexObj = texUnit->Current2D;
541 break;
542 case GL_TEXTURE_3D:
543 targetDim = 3;
544 oldTexObj = texUnit->Current3D;
545 break;
546 case GL_TEXTURE_CUBE_MAP_ARB:
547 if (ctx->Extensions.ARB_texture_cube_map) {
548 targetDim = 6;
549 oldTexObj = texUnit->CurrentCubeMap;
550 break;
551 }
552 /* fallthrough */
553 default:
554 gl_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
555 return;
556 }
557
558 if (oldTexObj->Name == texName)
559 return; /* rebinding the same texture- no change */
560
561 /*
562 * Get pointer to new texture object (newTexObj)
563 */
564 if (texName == 0) {
565 /* newTexObj = a default texture object */
566 switch (target) {
567 case GL_TEXTURE_1D:
568 newTexObj = ctx->Shared->Default1D;
569 break;
570 case GL_TEXTURE_2D:
571 newTexObj = ctx->Shared->Default2D;
572 break;
573 case GL_TEXTURE_3D:
574 newTexObj = ctx->Shared->Default3D;
575 break;
576 case GL_TEXTURE_CUBE_MAP_ARB:
577 newTexObj = ctx->Shared->DefaultCubeMap;
578 break;
579 default:
580 ; /* Bad targets are caught above */
581 }
582 }
583 else {
584 /* non-default texture object */
585 const struct _mesa_HashTable *hash = ctx->Shared->TexObjects;
586 newTexObj = (struct gl_texture_object *) _mesa_HashLookup(hash, texName);
587 if (newTexObj) {
588 /* error checking */
589 if (newTexObj->Dimensions > 0 && newTexObj->Dimensions != targetDim) {
590 /* the named texture object's dimensions don't match the target */
591 gl_error( ctx, GL_INVALID_OPERATION, "glBindTexture" );
592 return;
593 }
594 }
595 else {
596 /* if this is a new texture id, allocate a texture object now */
597 newTexObj = _mesa_alloc_texture_object(ctx->Shared, texName, targetDim);
598 if (!newTexObj) {
599 gl_error(ctx, GL_OUT_OF_MEMORY, "glBindTexture");
600 return;
601 }
602 }
603 newTexObj->Dimensions = targetDim;
604 }
605
606 newTexObj->RefCount++;
607
608 /* do the actual binding */
609 switch (target) {
610 case GL_TEXTURE_1D:
611 texUnit->Current1D = newTexObj;
612 break;
613 case GL_TEXTURE_2D:
614 texUnit->Current2D = newTexObj;
615 break;
616 case GL_TEXTURE_3D:
617 texUnit->Current3D = newTexObj;
618 break;
619 case GL_TEXTURE_CUBE_MAP_ARB:
620 texUnit->CurrentCubeMap = newTexObj;
621 break;
622 default:
623 gl_problem(ctx, "bad target in BindTexture");
624 }
625
626 ctx->NewState |= _NEW_TEXTURE;
627
628 /* Pass BindTexture call to device driver */
629 if (ctx->Driver.BindTexture)
630 (*ctx->Driver.BindTexture)( ctx, target, newTexObj );
631
632 if (oldTexObj->Name > 0) {
633 /* never delete default (id=0) texture objects */
634 oldTexObj->RefCount--;
635 if (oldTexObj->RefCount <= 0) {
636 if (ctx->Driver.DeleteTexture) {
637 (*ctx->Driver.DeleteTexture)( ctx, oldTexObj );
638 }
639 _mesa_free_texture_object(ctx->Shared, oldTexObj);
640 }
641 }
642 }
643
644
645
646 /*
647 * Execute glPrioritizeTextures
648 */
649 void
650 _mesa_PrioritizeTextures( GLsizei n, const GLuint *texName,
651 const GLclampf *priorities )
652 {
653 GET_CURRENT_CONTEXT(ctx);
654 GLint i;
655
656 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPrioritizeTextures");
657 if (n < 0) {
658 gl_error( ctx, GL_INVALID_VALUE, "glPrioritizeTextures" );
659 return;
660 }
661
662 if (!priorities)
663 return;
664
665 for (i = 0; i < n; i++) {
666 if (texName[i] > 0) {
667 struct gl_texture_object *t = (struct gl_texture_object *)
668 _mesa_HashLookup(ctx->Shared->TexObjects, texName[i]);
669 if (t) {
670 t->Priority = CLAMP( priorities[i], 0.0F, 1.0F );
671 if (ctx->Driver.PrioritizeTexture)
672 ctx->Driver.PrioritizeTexture( ctx, t, t->Priority );
673 }
674 }
675 }
676
677 ctx->NewState |= _NEW_TEXTURE;
678 }
679
680
681
682 /*
683 * Execute glAreTexturesResident
684 */
685 GLboolean
686 _mesa_AreTexturesResident(GLsizei n, const GLuint *texName,
687 GLboolean *residences)
688 {
689 GET_CURRENT_CONTEXT(ctx);
690 GLboolean allResident = GL_TRUE;
691 GLint i;
692
693 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx,
694 "glAreTexturesResident", GL_FALSE);
695 if (n < 0) {
696 gl_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(n)");
697 return GL_FALSE;
698 }
699
700 if (!texName || !residences)
701 return GL_FALSE;
702
703 for (i = 0; i < n; i++) {
704 struct gl_texture_object *t;
705 if (texName[i] == 0) {
706 gl_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(textures)");
707 return GL_FALSE;
708 }
709 t = (struct gl_texture_object *)
710 _mesa_HashLookup(ctx->Shared->TexObjects, texName[i]);
711 if (t) {
712 if (ctx->Driver.IsTextureResident) {
713 residences[i] = ctx->Driver.IsTextureResident(ctx, t);
714 if (!residences[i])
715 allResident = GL_FALSE;
716 }
717 else {
718 residences[i] = GL_TRUE;
719 }
720 }
721 else {
722 gl_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(textures)");
723 return GL_FALSE;
724 }
725 }
726 return allResident;
727 }
728
729
730
731 /*
732 * Execute glIsTexture
733 */
734 GLboolean
735 _mesa_IsTexture( GLuint texture )
736 {
737 GET_CURRENT_CONTEXT(ctx);
738 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glIsTextures",
739 GL_FALSE);
740 if (texture > 0 && _mesa_HashLookup(ctx->Shared->TexObjects, texture)) {
741 return GL_TRUE;
742 }
743 else {
744 return GL_FALSE;
745 }
746 }
747