62238ff6fd4d45850f46a5b765c10978d2ee0f8a
[mesa.git] / src / mesa / main / texobj.c
1 /* $Id: texobj.c,v 1.30 2000/10/29 18:23:16 brianp 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 "types.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 * Return: pointer to new texture object
54 */
55 struct gl_texture_object *
56 gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name,
57 GLuint dimensions)
58 {
59 struct gl_texture_object *obj;
60
61 ASSERT(dimensions <= 3 || dimensions == 6);
62
63 obj = CALLOC_STRUCT(gl_texture_object);
64
65 if (obj) {
66 /* init the non-zero fields */
67 _glthread_INIT_MUTEX(obj->Mutex);
68 obj->RefCount = 1;
69 obj->Name = name;
70 obj->Dimensions = dimensions;
71 obj->Priority = 1.0F;
72 obj->WrapS = GL_REPEAT;
73 obj->WrapT = GL_REPEAT;
74 obj->MinFilter = GL_NEAREST_MIPMAP_LINEAR;
75 obj->MagFilter = GL_LINEAR;
76 obj->MinLod = -1000.0;
77 obj->MaxLod = 1000.0;
78 obj->BaseLevel = 0;
79 obj->MaxLevel = 1000;
80 obj->MinMagThresh = 0.0F;
81 _mesa_init_colortable(&obj->Palette);
82
83 /* insert into linked list */
84 if (shared) {
85 _glthread_LOCK_MUTEX(shared->Mutex);
86 obj->Next = shared->TexObjectList;
87 shared->TexObjectList = obj;
88 _glthread_UNLOCK_MUTEX(shared->Mutex);
89 }
90
91 if (name > 0) {
92 /* insert into hash table */
93 _mesa_HashInsert(shared->TexObjects, name, obj);
94 }
95 }
96 return obj;
97 }
98
99
100 /*
101 * Deallocate a texture object struct and remove it from the given
102 * shared GL state.
103 * Input: shared - the shared GL state to which the object belongs
104 * t - the texture object to delete
105 */
106 void gl_free_texture_object( struct gl_shared_state *shared,
107 struct gl_texture_object *t )
108 {
109 struct gl_texture_object *tprev, *tcurr;
110
111 assert(t);
112
113 /* Remove t from dirty list so we don't touch free'd memory later.
114 * Test for shared since Proxy texture aren't in global linked list.
115 */
116 if (shared)
117 gl_remove_texobj_from_dirty_list( shared, t );
118
119 /* unlink t from the linked list */
120 if (shared) {
121 _glthread_LOCK_MUTEX(shared->Mutex);
122 tprev = NULL;
123 tcurr = shared->TexObjectList;
124 while (tcurr) {
125 if (tcurr==t) {
126 if (tprev) {
127 tprev->Next = t->Next;
128 }
129 else {
130 shared->TexObjectList = t->Next;
131 }
132 break;
133 }
134 tprev = tcurr;
135 tcurr = tcurr->Next;
136 }
137 _glthread_UNLOCK_MUTEX(shared->Mutex);
138 }
139
140 if (t->Name) {
141 /* remove from hash table */
142 _mesa_HashRemove(shared->TexObjects, t->Name);
143 }
144
145 _mesa_free_colortable_data(&t->Palette);
146
147 /* free texture images */
148 {
149 GLuint i;
150 for (i=0;i<MAX_TEXTURE_LEVELS;i++) {
151 if (t->Image[i]) {
152 _mesa_free_texture_image( t->Image[i] );
153 }
154 }
155 }
156 /* free this object */
157 FREE( t );
158 }
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 or not.
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 level zero 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 all six level 0 images are 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) gl_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 struct gl_texture_object *t;
471 if (texName[i]>0) {
472 t = (struct gl_texture_object *)
473 _mesa_HashLookup(ctx->Shared->TexObjects, texName[i]);
474 if (t) {
475 /* First check if this texture is currently bound.
476 * If so, unbind it and decrement the reference count.
477 */
478 GLuint u;
479 for (u = 0; u < MAX_TEXTURE_UNITS; u++) {
480 struct gl_texture_unit *unit = &ctx->Texture.Unit[u];
481 GLuint d;
482 for (d = 1 ; d <= 3 ; d++) {
483 if (unit->CurrentD[d] == t) {
484 unit->CurrentD[d] = ctx->Shared->DefaultD[d];
485 ctx->Shared->DefaultD[d]->RefCount++;
486 t->RefCount--;
487 ASSERT( t->RefCount >= 0 );
488 }
489 }
490 }
491
492 /* Decrement reference count and delete if zero */
493 t->RefCount--;
494 ASSERT( t->RefCount >= 0 );
495 if (t->RefCount == 0) {
496 if (ctx->Driver.DeleteTexture)
497 (*ctx->Driver.DeleteTexture)( ctx, t );
498 gl_free_texture_object(ctx->Shared, t);
499 }
500 }
501 }
502 }
503 }
504
505
506
507 /*
508 * Execute glBindTexture
509 */
510 void
511 _mesa_BindTexture( GLenum target, GLuint texName )
512 {
513 GET_CURRENT_CONTEXT(ctx);
514 GLuint unit = ctx->Texture.CurrentUnit;
515 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
516 struct gl_texture_object *oldTexObj;
517 struct gl_texture_object *newTexObj;
518 GLuint dim;
519
520 if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
521 fprintf(stderr, "glBindTexture %s %d\n",
522 gl_lookup_enum_by_nr(target), (GLint) texName);
523
524 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glBindTexture");
525
526 switch (target) {
527 case GL_TEXTURE_1D:
528 dim = 1;
529 oldTexObj = texUnit->CurrentD[1];
530 break;
531 case GL_TEXTURE_2D:
532 dim = 2;
533 oldTexObj = texUnit->CurrentD[2];
534 break;
535 case GL_TEXTURE_3D:
536 dim = 3;
537 oldTexObj = texUnit->CurrentD[3];
538 break;
539 case GL_TEXTURE_CUBE_MAP_ARB:
540 if (ctx->Extensions.HaveTextureCubeMap) {
541 dim = 6;
542 oldTexObj = texUnit->CurrentCubeMap;
543 break;
544 }
545 /* fallthrough */
546 default:
547 gl_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
548 return;
549 }
550
551 if (oldTexObj->Name == texName)
552 return;
553
554 if (texName == 0) {
555 if (target == GL_TEXTURE_CUBE_MAP_ARB)
556 newTexObj = ctx->Shared->DefaultCubeMap;
557 else
558 newTexObj = ctx->Shared->DefaultD[dim];
559 }
560 else {
561 struct _mesa_HashTable *hash = ctx->Shared->TexObjects;
562 newTexObj = (struct gl_texture_object *) _mesa_HashLookup(hash, texName);
563
564 if (!newTexObj)
565 newTexObj = gl_alloc_texture_object(ctx->Shared, texName, dim);
566
567 if (newTexObj->Dimensions != dim) {
568 if (newTexObj->Dimensions) {
569 /* the named texture object's dimensions don't match the target */
570 gl_error( ctx, GL_INVALID_OPERATION, "glBindTexture" );
571 return;
572 }
573 newTexObj->Dimensions = dim;
574 }
575 }
576
577 newTexObj->RefCount++;
578
579 switch (target) {
580 case GL_TEXTURE_1D:
581 texUnit->CurrentD[1] = newTexObj;
582 break;
583 case GL_TEXTURE_2D:
584 texUnit->CurrentD[2] = newTexObj;
585 break;
586 case GL_TEXTURE_3D:
587 texUnit->CurrentD[3] = newTexObj;
588 break;
589 case GL_TEXTURE_CUBE_MAP_ARB:
590 texUnit->CurrentCubeMap = newTexObj;
591 break;
592 default:
593 gl_problem(ctx, "bad target in BindTexture");
594 }
595
596 /* If we've changed the CurrentD[123] texture object then update the
597 * ctx->Texture.Current pointer to point to the new texture object.
598 */
599 texUnit->Current = texUnit->CurrentD[texUnit->CurrentDimension];
600
601 /* Check if we may have to use a new triangle rasterizer */
602 if ((ctx->IndirectTriangles & DD_SW_RASTERIZE) &&
603 ( oldTexObj->WrapS != newTexObj->WrapS
604 || oldTexObj->WrapT != newTexObj->WrapT
605 || oldTexObj->WrapR != newTexObj->WrapR
606 || oldTexObj->MinFilter != newTexObj->MinFilter
607 || oldTexObj->MagFilter != newTexObj->MagFilter
608 || (oldTexObj->Image[0] && newTexObj->Image[0] &&
609 (oldTexObj->Image[0]->Format!=newTexObj->Image[0]->Format))))
610 {
611 ctx->NewState |= (NEW_RASTER_OPS | NEW_TEXTURING);
612 }
613
614 if (oldTexObj->Complete != newTexObj->Complete)
615 ctx->NewState |= NEW_TEXTURING;
616
617 /* Pass BindTexture call to device driver */
618 if (ctx->Driver.BindTexture) {
619 (*ctx->Driver.BindTexture)( ctx, target, newTexObj );
620 /* Make sure the Driver.UpdateState() function gets called! */
621 ctx->NewState |= NEW_TEXTURING;
622 }
623
624 if (oldTexObj->Name > 0) {
625 /* never delete default (id=0) texture objects */
626 oldTexObj->RefCount--;
627 if (oldTexObj->RefCount <= 0) {
628 if (ctx->Driver.DeleteTexture) {
629 (*ctx->Driver.DeleteTexture)( ctx, oldTexObj );
630 }
631 gl_free_texture_object(ctx->Shared, oldTexObj);
632 }
633 }
634 }
635
636
637
638 /*
639 * Execute glPrioritizeTextures
640 */
641 void
642 _mesa_PrioritizeTextures( GLsizei n, const GLuint *texName,
643 const GLclampf *priorities )
644 {
645 GET_CURRENT_CONTEXT(ctx);
646 GLint i;
647
648 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPrioritizeTextures");
649 if (n < 0) {
650 gl_error( ctx, GL_INVALID_VALUE, "glPrioritizeTextures" );
651 return;
652 }
653
654 if (!priorities)
655 return;
656
657 for (i = 0; i < n; i++) {
658 if (texName[i] > 0) {
659 struct gl_texture_object *t = (struct gl_texture_object *)
660 _mesa_HashLookup(ctx->Shared->TexObjects, texName[i]);
661 if (t) {
662 t->Priority = CLAMP( priorities[i], 0.0F, 1.0F );
663 if (ctx->Driver.PrioritizeTexture)
664 ctx->Driver.PrioritizeTexture( ctx, t, t->Priority );
665 }
666 }
667 }
668 }
669
670
671
672 /*
673 * Execute glAreTexturesResident
674 */
675 GLboolean
676 _mesa_AreTexturesResident(GLsizei n, const GLuint *texName,
677 GLboolean *residences)
678 {
679 GET_CURRENT_CONTEXT(ctx);
680 GLboolean allResident = GL_TRUE;
681 GLint i;
682
683 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx,
684 "glAreTexturesResident", GL_FALSE);
685 if (n < 0) {
686 gl_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(n)");
687 return GL_FALSE;
688 }
689
690 if (!texName || !residences)
691 return GL_FALSE;
692
693 for (i = 0; i < n; i++) {
694 struct gl_texture_object *t;
695 if (texName[i] == 0) {
696 gl_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(textures)");
697 return GL_FALSE;
698 }
699 t = (struct gl_texture_object *)
700 _mesa_HashLookup(ctx->Shared->TexObjects, texName[i]);
701 if (t) {
702 if (ctx->Driver.IsTextureResident) {
703 residences[i] = ctx->Driver.IsTextureResident(ctx, t);
704 if (!residences[i])
705 allResident = GL_FALSE;
706 }
707 else {
708 residences[i] = GL_TRUE;
709 }
710 }
711 else {
712 gl_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(textures)");
713 return GL_FALSE;
714 }
715 }
716 return allResident;
717 }
718
719
720
721 /*
722 * Execute glIsTexture
723 */
724 GLboolean
725 _mesa_IsTexture( GLuint texture )
726 {
727 GET_CURRENT_CONTEXT(ctx);
728 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glIsTextures",
729 GL_FALSE);
730 if (texture > 0 && _mesa_HashLookup(ctx->Shared->TexObjects, texture)) {
731 return GL_TRUE;
732 }
733 else {
734 return GL_FALSE;
735 }
736 }
737