X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fswrast%2Fs_texture.c;h=8ae3d5bd0e6c8b285a76219a45502011dac7fdf8;hb=da7029dcb498f80d1837323038617b49cc28431f;hp=8df4b84398ee8e8915017684aaa63ba7b5a029de;hpb=c9a7dfcf92e6adb4b85338c2c8dbbfbaf39fbfe7;p=mesa.git diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index 8df4b84398e..8ae3d5bd0e6 100644 --- a/src/mesa/swrast/s_texture.c +++ b/src/mesa/swrast/s_texture.c @@ -29,6 +29,7 @@ #include "main/context.h" #include "main/fbobject.h" #include "main/teximage.h" +#include "main/texobj.h" #include "swrast/swrast.h" #include "swrast/s_context.h" @@ -82,7 +83,7 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx, * We allocate the array for 1D/2D textures too in order to avoid special- * case code in the texstore routines. */ - swImg->ImageOffsets = (GLuint *) malloc(texImage->Depth * sizeof(GLuint)); + swImg->ImageOffsets = malloc(texImage->Depth * sizeof(GLuint)); if (!swImg->ImageOffsets) return GL_FALSE; @@ -143,10 +144,8 @@ _swrast_free_texture_image_buffer(struct gl_context *ctx, swImage->Buffer = NULL; } - if (swImage->ImageOffsets) { - free(swImage->ImageOffsets); - swImage->ImageOffsets = NULL; - } + free(swImage->ImageOffsets); + swImage->ImageOffsets = NULL; } @@ -246,7 +245,7 @@ _swrast_unmap_teximage(struct gl_context *ctx, void _swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj) { - const GLuint faces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1; + const GLuint faces = _mesa_num_tex_faces(texObj->Target); GLuint face, level; for (face = 0; face < faces; face++) { @@ -267,7 +266,7 @@ _swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj) void _swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj) { - const GLuint faces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1; + const GLuint faces = _mesa_num_tex_faces(texObj->Target); GLuint face, level; for (face = 0; face < faces; face++) {