Simplification in colortab.c too.
tdfxTexInfo *ti;
int memNeeded;
- tObj = ctx->Texture.Proxy2D;
+ tObj = ctx->Texture.ProxyTex[TEXTURE_2D_INDEX];
if (!tObj->DriverData)
tObj->DriverData = fxAllocTexObjData(fxMesa);
ti = TDFX_TEXTURE_DATA(tObj);
/*
* Mesa 3-D graphics library
- * Version: 6.5.3
+ * Version: 7.1
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
#include "image.h"
#include "macros.h"
#include "state.h"
+#include "teximage.h"
/**
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */
switch (target) {
- case GL_TEXTURE_1D:
- texObj = texUnit->Current1D;
- table = &texObj->Palette;
- break;
- case GL_TEXTURE_2D:
- texObj = texUnit->Current2D;
- table = &texObj->Palette;
- break;
- case GL_TEXTURE_3D:
- texObj = texUnit->Current3D;
- table = &texObj->Palette;
- break;
- case GL_TEXTURE_CUBE_MAP_ARB:
- if (!ctx->Extensions.ARB_texture_cube_map) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
- return;
- }
- texObj = texUnit->CurrentCubeMap;
- table = &texObj->Palette;
- break;
- case GL_PROXY_TEXTURE_1D:
- texObj = ctx->Texture.Proxy1D;
- table = &texObj->Palette;
- proxy = GL_TRUE;
- break;
- case GL_PROXY_TEXTURE_2D:
- texObj = ctx->Texture.Proxy2D;
- table = &texObj->Palette;
- proxy = GL_TRUE;
- break;
- case GL_PROXY_TEXTURE_3D:
- texObj = ctx->Texture.Proxy3D;
- table = &texObj->Palette;
- proxy = GL_TRUE;
- break;
- case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
- if (!ctx->Extensions.ARB_texture_cube_map) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
- return;
- }
- texObj = ctx->Texture.ProxyCubeMap;
- table = &texObj->Palette;
- break;
case GL_SHARED_TEXTURE_PALETTE_EXT:
table = &ctx->Texture.Palette;
break;
proxy = GL_TRUE;
break;
default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
- return;
+ /* try texture targets */
+ {
+ struct gl_texture_object *texobj
+ = _mesa_select_tex_object(ctx, texUnit, target);
+ if (texobj) {
+ table = &texobj->Palette;
+ proxy = _mesa_is_proxy_texture(target);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
+ return;
+ }
+ }
}
assert(table);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
switch (target) {
- case GL_TEXTURE_1D:
- texObj = texUnit->Current1D;
- table = &texObj->Palette;
- break;
- case GL_TEXTURE_2D:
- texObj = texUnit->Current2D;
- table = &texObj->Palette;
- break;
- case GL_TEXTURE_3D:
- texObj = texUnit->Current3D;
- table = &texObj->Palette;
- break;
- case GL_TEXTURE_CUBE_MAP_ARB:
- if (!ctx->Extensions.ARB_texture_cube_map) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
- return;
- }
- texObj = texUnit->CurrentCubeMap;
- table = &texObj->Palette;
- break;
case GL_SHARED_TEXTURE_PALETTE_EXT:
table = &ctx->Texture.Palette;
break;
bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX];
break;
default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
- return;
+ /* try texture targets */
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ if (texObj && !_mesa_is_proxy_texture(target)) {
+ table = &texObj->Palette;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
+ return;
+ }
}
assert(table);
}
switch (target) {
- case GL_TEXTURE_1D:
- table = &texUnit->Current1D->Palette;
- break;
- case GL_TEXTURE_2D:
- table = &texUnit->Current2D->Palette;
- break;
- case GL_TEXTURE_3D:
- table = &texUnit->Current3D->Palette;
- break;
- case GL_TEXTURE_CUBE_MAP_ARB:
- if (!ctx->Extensions.ARB_texture_cube_map) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
- return;
- }
- table = &texUnit->CurrentCubeMap->Palette;
- break;
case GL_SHARED_TEXTURE_PALETTE_EXT:
table = &ctx->Texture.Palette;
break;
table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX];
break;
default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
- return;
+ /* try texture targets */
+ {
+ struct gl_texture_object *texobj
+ = _mesa_select_tex_object(ctx, texUnit, target);
+ if (texobj && !_mesa_is_proxy_texture(target)) {
+ table = &texobj->Palette;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
+ return;
+ }
+ }
}
ASSERT(table);
void GLAPIENTRY
_mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
{
+ GLfloat *scale, *bias;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
switch (target) {
- case GL_COLOR_TABLE_SGI:
- if (pname == GL_COLOR_TABLE_SCALE_SGI) {
- COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION], params);
- }
- else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
- COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION], params);
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
- return;
- }
- break;
- case GL_TEXTURE_COLOR_TABLE_SGI:
- if (!ctx->Extensions.SGI_texture_color_table) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)");
- return;
- }
- if (pname == GL_COLOR_TABLE_SCALE_SGI) {
- COPY_4V(ctx->Pixel.TextureColorTableScale, params);
- }
- else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
- COPY_4V(ctx->Pixel.TextureColorTableBias, params);
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
- return;
- }
- break;
- case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
- if (pname == GL_COLOR_TABLE_SCALE_SGI) {
- COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION], params);
- }
- else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
- COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION], params);
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
- return;
- }
- break;
- case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
- if (pname == GL_COLOR_TABLE_SCALE_SGI) {
- COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX], params);
- }
- else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
- COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX], params);
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
- return;
- }
- break;
- default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)");
- return;
+ case GL_COLOR_TABLE_SGI:
+ scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION];
+ bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION];
+ break;
+ case GL_TEXTURE_COLOR_TABLE_SGI:
+ scale = ctx->Pixel.TextureColorTableScale;
+ bias = ctx->Pixel.TextureColorTableBias;
+ break;
+ case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
+ scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION];
+ bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION];
+ break;
+ case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
+ scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX];
+ bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX];
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)");
+ return;
+ }
+
+ if (pname == GL_COLOR_TABLE_SCALE_SGI) {
+ COPY_4V(scale, params);
+ }
+ else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
+ COPY_4V(bias, params);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
+ return;
}
ctx->NewState |= _NEW_PIXEL;
ASSERT_OUTSIDE_BEGIN_END(ctx);
switch (target) {
- case GL_TEXTURE_1D:
- table = &texUnit->Current1D->Palette;
- break;
- case GL_TEXTURE_2D:
- table = &texUnit->Current2D->Palette;
- break;
- case GL_TEXTURE_3D:
- table = &texUnit->Current3D->Palette;
- break;
- case GL_TEXTURE_CUBE_MAP_ARB:
- if (!ctx->Extensions.ARB_texture_cube_map) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetColorTableParameterfv(target)");
- return;
- }
- table = &texUnit->CurrentCubeMap->Palette;
- break;
- case GL_PROXY_TEXTURE_1D:
- table = &ctx->Texture.Proxy1D->Palette;
- break;
- case GL_PROXY_TEXTURE_2D:
- table = &ctx->Texture.Proxy2D->Palette;
- break;
- case GL_PROXY_TEXTURE_3D:
- table = &ctx->Texture.Proxy3D->Palette;
- break;
- case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
- if (!ctx->Extensions.ARB_texture_cube_map) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetColorTableParameterfv(target)");
- return;
- }
- table = &ctx->Texture.ProxyCubeMap->Palette;
- break;
case GL_SHARED_TEXTURE_PALETTE_EXT:
table = &ctx->Texture.Palette;
break;
table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX];
break;
default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(target)");
- return;
+ /* try texture targets */
+ {
+ struct gl_texture_object *texobj
+ = _mesa_select_tex_object(ctx, texUnit, target);
+ if (texobj) {
+ table = &texobj->Palette;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetColorTableParameterfv(target)");
+ return;
+ }
+ }
}
assert(table);
ASSERT_OUTSIDE_BEGIN_END(ctx);
switch (target) {
- case GL_TEXTURE_1D:
- table = &texUnit->Current1D->Palette;
- break;
- case GL_TEXTURE_2D:
- table = &texUnit->Current2D->Palette;
- break;
- case GL_TEXTURE_3D:
- table = &texUnit->Current3D->Palette;
- break;
- case GL_TEXTURE_CUBE_MAP_ARB:
- if (!ctx->Extensions.ARB_texture_cube_map) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetColorTableParameteriv(target)");
- return;
- }
- table = &texUnit->CurrentCubeMap->Palette;
- break;
- case GL_PROXY_TEXTURE_1D:
- table = &ctx->Texture.Proxy1D->Palette;
- break;
- case GL_PROXY_TEXTURE_2D:
- table = &ctx->Texture.Proxy2D->Palette;
- break;
- case GL_PROXY_TEXTURE_3D:
- table = &ctx->Texture.Proxy3D->Palette;
- break;
- case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
- if (!ctx->Extensions.ARB_texture_cube_map) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetColorTableParameteriv(target)");
- return;
- }
- table = &ctx->Texture.ProxyCubeMap->Palette;
- break;
case GL_SHARED_TEXTURE_PALETTE_EXT:
table = &ctx->Texture.Palette;
break;
table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX];
break;
default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(target)");
- return;
+ /* Try texture targets */
+ {
+ struct gl_texture_object *texobj
+ = _mesa_select_tex_object(ctx, texUnit, target);
+ if (texobj) {
+ table = &texobj->Palette;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetColorTableParameteriv(target)");
+ return;
+ }
+ }
}
assert(table);
struct gl_texture_unit Unit[MAX_TEXTURE_UNITS];
+#if 0
struct gl_texture_object *Proxy1D;
struct gl_texture_object *Proxy2D;
struct gl_texture_object *Proxy3D;
struct gl_texture_object *ProxyRect;
struct gl_texture_object *Proxy1DArray;
struct gl_texture_object *Proxy2DArray;
+#else
+ struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS];
+#endif
/** GL_EXT_shared_texture_palette */
GLboolean SharedPalette;
case GL_TEXTURE_1D:
return texUnit->Current1D;
case GL_PROXY_TEXTURE_1D:
- return ctx->Texture.Proxy1D;
+ return ctx->Texture.ProxyTex[TEXTURE_1D_INDEX];
case GL_TEXTURE_2D:
return texUnit->Current2D;
case GL_PROXY_TEXTURE_2D:
- return ctx->Texture.Proxy2D;
+ return ctx->Texture.ProxyTex[TEXTURE_2D_INDEX];
case GL_TEXTURE_3D:
return texUnit->Current3D;
case GL_PROXY_TEXTURE_3D:
- return ctx->Texture.Proxy3D;
+ return ctx->Texture.ProxyTex[TEXTURE_3D_INDEX];
case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
? texUnit->CurrentCubeMap : NULL;
case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
return ctx->Extensions.ARB_texture_cube_map
- ? ctx->Texture.ProxyCubeMap : NULL;
+ ? ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX] : NULL;
case GL_TEXTURE_RECTANGLE_NV:
return ctx->Extensions.NV_texture_rectangle
? texUnit->CurrentRect : NULL;
case GL_PROXY_TEXTURE_RECTANGLE_NV:
return ctx->Extensions.NV_texture_rectangle
- ? ctx->Texture.ProxyRect : NULL;
+ ? ctx->Texture.ProxyTex[TEXTURE_RECT_INDEX] : NULL;
case GL_TEXTURE_1D_ARRAY_EXT:
return ctx->Extensions.MESA_texture_array
? texUnit->Current1DArray : NULL;
case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
return ctx->Extensions.MESA_texture_array
- ? ctx->Texture.Proxy1DArray : NULL;
+ ? ctx->Texture.ProxyTex[TEXTURE_1D_ARRAY_INDEX] : NULL;
case GL_TEXTURE_2D_ARRAY_EXT:
return ctx->Extensions.MESA_texture_array
? texUnit->Current2DArray : NULL;
case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
return ctx->Extensions.MESA_texture_array
- ? ctx->Texture.Proxy2DArray : NULL;
+ ? ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX] : NULL;
default:
_mesa_problem(NULL, "bad target in _mesa_select_tex_object()");
return NULL;
case GL_PROXY_TEXTURE_1D:
if (level >= ctx->Const.MaxTextureLevels)
return NULL;
- texImage = ctx->Texture.Proxy1D->Image[0][level];
+ texImage = ctx->Texture.ProxyTex[TEXTURE_1D_INDEX]->Image[0][level];
if (!texImage) {
texImage = ctx->Driver.NewTextureImage(ctx);
if (!texImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
return NULL;
}
- ctx->Texture.Proxy1D->Image[0][level] = texImage;
+ ctx->Texture.ProxyTex[TEXTURE_1D_INDEX]->Image[0][level] = texImage;
/* Set the 'back' pointer */
- texImage->TexObject = ctx->Texture.Proxy1D;
+ texImage->TexObject = ctx->Texture.ProxyTex[TEXTURE_1D_INDEX];
}
return texImage;
case GL_PROXY_TEXTURE_2D:
if (level >= ctx->Const.MaxTextureLevels)
return NULL;
- texImage = ctx->Texture.Proxy2D->Image[0][level];
+ texImage = ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]->Image[0][level];
if (!texImage) {
texImage = ctx->Driver.NewTextureImage(ctx);
if (!texImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
return NULL;
}
- ctx->Texture.Proxy2D->Image[0][level] = texImage;
+ ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]->Image[0][level] = texImage;
/* Set the 'back' pointer */
- texImage->TexObject = ctx->Texture.Proxy2D;
+ texImage->TexObject = ctx->Texture.ProxyTex[TEXTURE_2D_INDEX];
}
return texImage;
case GL_PROXY_TEXTURE_3D:
if (level >= ctx->Const.Max3DTextureLevels)
return NULL;
- texImage = ctx->Texture.Proxy3D->Image[0][level];
+ texImage = ctx->Texture.ProxyTex[TEXTURE_3D_INDEX]->Image[0][level];
if (!texImage) {
texImage = ctx->Driver.NewTextureImage(ctx);
if (!texImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
return NULL;
}
- ctx->Texture.Proxy3D->Image[0][level] = texImage;
+ ctx->Texture.ProxyTex[TEXTURE_3D_INDEX]->Image[0][level] = texImage;
/* Set the 'back' pointer */
- texImage->TexObject = ctx->Texture.Proxy3D;
+ texImage->TexObject = ctx->Texture.ProxyTex[TEXTURE_3D_INDEX];
}
return texImage;
case GL_PROXY_TEXTURE_CUBE_MAP:
if (level >= ctx->Const.MaxCubeTextureLevels)
return NULL;
- texImage = ctx->Texture.ProxyCubeMap->Image[0][level];
+ texImage = ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX]->Image[0][level];
if (!texImage) {
texImage = ctx->Driver.NewTextureImage(ctx);
if (!texImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
return NULL;
}
- ctx->Texture.ProxyCubeMap->Image[0][level] = texImage;
+ ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX]->Image[0][level] = texImage;
/* Set the 'back' pointer */
- texImage->TexObject = ctx->Texture.ProxyCubeMap;
+ texImage->TexObject = ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX];
}
return texImage;
case GL_PROXY_TEXTURE_RECTANGLE_NV:
if (level > 0)
return NULL;
- texImage = ctx->Texture.ProxyRect->Image[0][level];
+ texImage = ctx->Texture.ProxyTex[TEXTURE_RECT_INDEX]->Image[0][level];
if (!texImage) {
texImage = ctx->Driver.NewTextureImage(ctx);
if (!texImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
return NULL;
}
- ctx->Texture.ProxyRect->Image[0][level] = texImage;
+ ctx->Texture.ProxyTex[TEXTURE_RECT_INDEX]->Image[0][level] = texImage;
/* Set the 'back' pointer */
- texImage->TexObject = ctx->Texture.ProxyRect;
+ texImage->TexObject = ctx->Texture.ProxyTex[TEXTURE_RECT_INDEX];
}
return texImage;
case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
if (level >= ctx->Const.MaxTextureLevels)
return NULL;
- texImage = ctx->Texture.Proxy1DArray->Image[0][level];
+ texImage = ctx->Texture.ProxyTex[TEXTURE_1D_ARRAY_INDEX]->Image[0][level];
if (!texImage) {
texImage = ctx->Driver.NewTextureImage(ctx);
if (!texImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
return NULL;
}
- ctx->Texture.Proxy1DArray->Image[0][level] = texImage;
+ ctx->Texture.ProxyTex[TEXTURE_1D_ARRAY_INDEX]->Image[0][level] = texImage;
/* Set the 'back' pointer */
- texImage->TexObject = ctx->Texture.Proxy1DArray;
+ texImage->TexObject = ctx->Texture.ProxyTex[TEXTURE_1D_ARRAY_INDEX];
}
return texImage;
case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
if (level >= ctx->Const.MaxTextureLevels)
return NULL;
- texImage = ctx->Texture.Proxy2DArray->Image[0][level];
+ texImage = ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX]->Image[0][level];
if (!texImage) {
texImage = ctx->Driver.NewTextureImage(ctx);
if (!texImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
return NULL;
}
- ctx->Texture.Proxy2DArray->Image[0][level] = texImage;
+ ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX]->Image[0][level] = texImage;
/* Set the 'back' pointer */
- texImage->TexObject = ctx->Texture.Proxy2DArray;
+ texImage->TexObject = ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX];
}
return texImage;
default:
1, border)) {
/* when error, clear all proxy texture image parameters */
if (texImage)
- clear_teximage_fields(ctx->Texture.Proxy2D->Image[0][level]);
+ clear_teximage_fields(ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]->Image[0][level]);
}
else {
/* no error, set the tex image parameters */
static GLboolean
alloc_proxy_textures( GLcontext *ctx )
{
- ctx->Texture.Proxy1D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_1D);
- if (!ctx->Texture.Proxy1D)
- goto cleanup;
-
- ctx->Texture.Proxy2D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_2D);
- if (!ctx->Texture.Proxy2D)
- goto cleanup;
-
- ctx->Texture.Proxy3D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_3D);
- if (!ctx->Texture.Proxy3D)
- goto cleanup;
-
- ctx->Texture.ProxyCubeMap = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_CUBE_MAP_ARB);
- if (!ctx->Texture.ProxyCubeMap)
- goto cleanup;
-
- ctx->Texture.ProxyRect = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_RECTANGLE_NV);
- if (!ctx->Texture.ProxyRect)
- goto cleanup;
-
- ctx->Texture.Proxy1DArray = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_1D_ARRAY_EXT);
- if (!ctx->Texture.Proxy1DArray)
- goto cleanup;
-
- ctx->Texture.Proxy2DArray = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_2D_ARRAY_EXT);
- if (!ctx->Texture.Proxy2DArray)
- goto cleanup;
-
- assert(ctx->Texture.Proxy1D->RefCount == 1);
+ static const GLenum targets[] = {
+ GL_TEXTURE_1D,
+ GL_TEXTURE_2D,
+ GL_TEXTURE_3D,
+ GL_TEXTURE_CUBE_MAP_ARB,
+ GL_TEXTURE_RECTANGLE_NV,
+ GL_TEXTURE_1D_ARRAY_EXT,
+ GL_TEXTURE_2D_ARRAY_EXT
+ };
+ GLint tgt;
+
+ ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS);
+
+ for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
+ if (!(ctx->Texture.ProxyTex[tgt]
+ = ctx->Driver.NewTextureObject(ctx, 0, targets[tgt]))) {
+ /* out of memory, free what we did allocate */
+ while (--tgt >= 0) {
+ ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]);
+ }
+ return GL_FALSE;
+ }
+ }
+ assert(ctx->Texture.ProxyTex[0]->RefCount == 1); /* sanity check */
return GL_TRUE;
-
- cleanup:
- if (ctx->Texture.Proxy1D)
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1D);
- if (ctx->Texture.Proxy2D)
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy2D);
- if (ctx->Texture.Proxy3D)
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy3D);
- if (ctx->Texture.ProxyCubeMap)
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.ProxyCubeMap);
- if (ctx->Texture.ProxyRect)
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.ProxyRect);
- if (ctx->Texture.Proxy1DArray)
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1DArray);
- if (ctx->Texture.Proxy2DArray)
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy2DArray);
- return GL_FALSE;
}
void
_mesa_free_texture_data(GLcontext *ctx)
{
- GLuint u;
+ GLuint u, tgt;
/* unreference current textures */
for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) {
}
/* Free proxy texture objects */
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1D );
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy2D );
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy3D );
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.ProxyCubeMap );
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.ProxyRect );
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1DArray );
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy2DArray );
+ for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++)
+ ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]);
for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++)
_mesa_free_colortable_data( &ctx->Texture.Unit[u].ColorTable );