summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texstore.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-06-05 16:32:23 -0600
committerBrian Paul <[email protected]>2012-06-06 07:55:59 -0600
commit8f5fffe75d2f8ae7c7ee706b53379a25bc673ae4 (patch)
tree03874713de5f5f611a8d6f7569b658a5ce3f9700 /src/mesa/main/texstore.c
parent3a62e8bcac75ca296619adb7fe4ea806a98beef9 (diff)
mesa: consolidate internal glTexImage1/2/3D code
The functions for handling 1D, 2D and 3D texture images were nearly identical. This folds them all together. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/main/texstore.c')
-rw-r--r--src/mesa/main/texstore.c78
1 files changed, 13 insertions, 65 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index d368b1868f2..1aa79625287 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -4261,89 +4261,37 @@ store_texsubimage(struct gl_context *ctx,
/**
- * This is the fallback for Driver.TexImage1D().
+ * Fallback code for ctx->Driver.TexImage().
+ * Basically, allocate storage for the texture image, then copy the
+ * user's image into it.
*/
void
-_mesa_store_teximage1d(struct gl_context *ctx,
- struct gl_texture_image *texImage,
- GLint internalFormat,
- GLint width, GLint border,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing)
+_mesa_store_teximage(struct gl_context *ctx,
+ GLuint dims,
+ struct gl_texture_image *texImage,
+ GLint internalFormat,
+ GLint width, GLint height, GLint depth, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing)
{
- if (width == 0)
- return;
-
- /* allocate storage for texture data */
- if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
- width, 1, 1)) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
- return;
- }
-
- store_texsubimage(ctx, texImage,
- 0, 0, 0, width, 1, 1,
- format, type, pixels, packing, "glTexImage1D");
-}
+ assert(dims == 1 || dims == 2 || dims == 3);
-
-/**
- * This is the fallback for Driver.TexImage2D().
- */
-void
-_mesa_store_teximage2d(struct gl_context *ctx,
- struct gl_texture_image *texImage,
- GLint internalFormat,
- GLint width, GLint height, GLint border,
- GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *packing)
-{
- if (width == 0 || height == 0)
- return;
-
- /* allocate storage for texture data */
- if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
- width, height, 1)) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
- return;
- }
-
- store_texsubimage(ctx, texImage,
- 0, 0, 0, width, height, 1,
- format, type, pixels, packing, "glTexImage2D");
-}
-
-
-
-/**
- * This is the fallback for Driver.TexImage3D().
- */
-void
-_mesa_store_teximage3d(struct gl_context *ctx,
- struct gl_texture_image *texImage,
- GLint internalFormat,
- GLint width, GLint height, GLint depth, GLint border,
- GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *packing)
-{
if (width == 0 || height == 0 || depth == 0)
return;
/* allocate storage for texture data */
if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
width, height, depth)) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims);
return;
}
store_texsubimage(ctx, texImage,
0, 0, 0, width, height, depth,
- format, type, pixels, packing, "glTexImage3D");
+ format, type, pixels, packing, "glTexImage");
}
-
-
/*
* This is the fallback for Driver.TexSubImage1D().
*/