struct gl_texture_attrib Texture; /**< The usual context state */
/** to save per texture object state (wrap modes, filters, etc): */
- struct gl_texture_object Saved1D[MAX_TEXTURE_UNITS];
- struct gl_texture_object Saved2D[MAX_TEXTURE_UNITS];
- struct gl_texture_object Saved3D[MAX_TEXTURE_UNITS];
- struct gl_texture_object SavedCube[MAX_TEXTURE_UNITS];
- struct gl_texture_object SavedRect[MAX_TEXTURE_UNITS];
- struct gl_texture_object Saved1DArray[MAX_TEXTURE_UNITS];
- struct gl_texture_object Saved2DArray[MAX_TEXTURE_UNITS];
+ struct gl_texture_object SavedObj[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS];
/**
* To save references to texture objects (so they don't get accidentally
* deleted while saved in the attribute stack).
*/
- struct gl_texture_object *SavedRef1D[MAX_TEXTURE_UNITS];
- struct gl_texture_object *SavedRef2D[MAX_TEXTURE_UNITS];
- struct gl_texture_object *SavedRef3D[MAX_TEXTURE_UNITS];
- struct gl_texture_object *SavedRefCube[MAX_TEXTURE_UNITS];
- struct gl_texture_object *SavedRefRect[MAX_TEXTURE_UNITS];
- struct gl_texture_object *SavedRef1DArray[MAX_TEXTURE_UNITS];
- struct gl_texture_object *SavedRef2DArray[MAX_TEXTURE_UNITS];
+ struct gl_texture_object *SavedTexRef[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS];
};
* accidentally get deleted while referenced in the attribute stack.
*/
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
- _mesa_reference_texobj(&texstate->SavedRef1D[u], ctx->Texture.Unit[u].Current1D);
- _mesa_reference_texobj(&texstate->SavedRef2D[u], ctx->Texture.Unit[u].Current2D);
- _mesa_reference_texobj(&texstate->SavedRef3D[u], ctx->Texture.Unit[u].Current3D);
- _mesa_reference_texobj(&texstate->SavedRefCube[u], ctx->Texture.Unit[u].CurrentCubeMap);
- _mesa_reference_texobj(&texstate->SavedRefRect[u], ctx->Texture.Unit[u].CurrentRect);
- _mesa_reference_texobj(&texstate->SavedRef1DArray[u], ctx->Texture.Unit[u].Current1DArray);
- _mesa_reference_texobj(&texstate->SavedRef2DArray[u], ctx->Texture.Unit[u].Current2DArray);
+ _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_1D_INDEX],
+ ctx->Texture.Unit[u].Current1D);
+ _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_2D_INDEX],
+ ctx->Texture.Unit[u].Current2D);
+ _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_3D_INDEX],
+ ctx->Texture.Unit[u].Current3D);
+ _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_CUBE_INDEX],
+ ctx->Texture.Unit[u].CurrentCubeMap);
+ _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_RECT_INDEX],
+ ctx->Texture.Unit[u].CurrentRect);
+ _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_1D_ARRAY_INDEX],
+ ctx->Texture.Unit[u].Current1DArray);
+ _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_2D_ARRAY_INDEX],
+ ctx->Texture.Unit[u].Current2DArray);
}
/* copy state/contents of the currently bound texture objects */
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
- _mesa_copy_texture_object(&texstate->Saved1D[u],
+ _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_1D_INDEX],
ctx->Texture.Unit[u].Current1D);
- _mesa_copy_texture_object(&texstate->Saved2D[u],
+ _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_2D_INDEX],
ctx->Texture.Unit[u].Current2D);
- _mesa_copy_texture_object(&texstate->Saved3D[u],
+ _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_3D_INDEX],
ctx->Texture.Unit[u].Current3D);
- _mesa_copy_texture_object(&texstate->SavedCube[u],
+ _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_CUBE_INDEX],
ctx->Texture.Unit[u].CurrentCubeMap);
- _mesa_copy_texture_object(&texstate->SavedRect[u],
+ _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_RECT_INDEX],
ctx->Texture.Unit[u].CurrentRect);
- _mesa_copy_texture_object(&texstate->Saved1DArray[u],
+ _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_1D_ARRAY_INDEX],
ctx->Texture.Unit[u].Current1DArray);
- _mesa_copy_texture_object(&texstate->Saved2DArray[u],
+ _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_2D_ARRAY_INDEX],
ctx->Texture.Unit[u].Current2DArray);
}
GLfloat bordColor[4];
GLenum target;
- switch (tgt) {
- case TEXTURE_1D_INDEX:
- obj = &texstate->Saved1D[u];
- ASSERT(obj->Target == GL_TEXTURE_1D);
- break;
- case TEXTURE_2D_INDEX:
- obj = &texstate->Saved2D[u];
- ASSERT(obj->Target == GL_TEXTURE_2D);
- break;
- case TEXTURE_3D_INDEX:
- obj = &texstate->Saved3D[u];
- ASSERT(obj->Target == GL_TEXTURE_3D);
- break;
- case TEXTURE_CUBE_INDEX:
- if (!ctx->Extensions.ARB_texture_cube_map)
- continue;
- obj = &texstate->SavedCube[u];
- ASSERT(obj->Target == GL_TEXTURE_CUBE_MAP_ARB);
- break;
- case TEXTURE_RECT_INDEX:
- if (!ctx->Extensions.NV_texture_rectangle)
- continue;
- obj = &texstate->SavedRect[u];
- ASSERT(obj->Target == GL_TEXTURE_RECTANGLE_NV);
- break;
- case TEXTURE_1D_ARRAY_INDEX:
- if (!ctx->Extensions.MESA_texture_array)
- continue;
- obj = &texstate->Saved1DArray[u];
- ASSERT(obj->Target == GL_TEXTURE_1D_ARRAY_EXT);
- break;
- case TEXTURE_2D_ARRAY_INDEX:
- if (!ctx->Extensions.MESA_texture_array)
- continue;
- obj = &texstate->Saved2DArray[u];
- ASSERT(obj->Target == GL_TEXTURE_2D_ARRAY_EXT);
- break;
- default:
- _mesa_problem(ctx, "bad texture index in pop_texture_group");
+ obj = &texstate->SavedObj[u][tgt];
+
+ /* don't restore state for unsupported targets to prevent
+ * raising GL errors.
+ */
+ if (obj->Target == GL_TEXTURE_CUBE_MAP_ARB &&
+ !ctx->Extensions.ARB_texture_cube_map) {
+ continue;
+ }
+ else if (obj->Target == GL_TEXTURE_RECTANGLE_NV &&
+ !ctx->Extensions.NV_texture_rectangle) {
+ continue;
+ }
+ else if ((obj->Target == GL_TEXTURE_1D_ARRAY_EXT ||
+ obj->Target == GL_TEXTURE_2D_ARRAY_EXT) &&
+ !ctx->Extensions.MESA_texture_array) {
continue;
}
}
/* remove saved references to the texture objects */
- _mesa_reference_texobj(&texstate->SavedRef1D[u], NULL);
- _mesa_reference_texobj(&texstate->SavedRef2D[u], NULL);
- _mesa_reference_texobj(&texstate->SavedRef3D[u], NULL);
- _mesa_reference_texobj(&texstate->SavedRefCube[u], NULL);
- _mesa_reference_texobj(&texstate->SavedRefRect[u], NULL);
- _mesa_reference_texobj(&texstate->SavedRef1DArray[u], NULL);
- _mesa_reference_texobj(&texstate->SavedRef2DArray[u], NULL);
+ for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
+ _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL);
+ }
}
_mesa_ActiveTextureARB(GL_TEXTURE0_ARB + texstate->Texture.CurrentUnit);
while (attr) {
if (attr->kind == GL_TEXTURE_BIT) {
struct texture_state *texstate = (struct texture_state*)attr->data;
- GLuint u;
+ GLuint u, tgt;
/* clear references to the saved texture objects */
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
- _mesa_reference_texobj(&texstate->SavedRef1D[u], NULL);
- _mesa_reference_texobj(&texstate->SavedRef2D[u], NULL);
- _mesa_reference_texobj(&texstate->SavedRef3D[u], NULL);
- _mesa_reference_texobj(&texstate->SavedRefCube[u], NULL);
- _mesa_reference_texobj(&texstate->SavedRefRect[u], NULL);
- _mesa_reference_texobj(&texstate->SavedRef1DArray[u], NULL);
- _mesa_reference_texobj(&texstate->SavedRef2DArray[u], NULL);
+ for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
+ _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL);
+ }
}
}
else {