diff options
author | Brian Paul <[email protected]> | 2012-06-05 16:32:23 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-06-06 07:55:59 -0600 |
commit | 8f5fffe75d2f8ae7c7ee706b53379a25bc673ae4 (patch) | |
tree | 03874713de5f5f611a8d6f7569b658a5ce3f9700 /src/mesa/main | |
parent | 3a62e8bcac75ca296619adb7fe4ea806a98beef9 (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')
-rw-r--r-- | src/mesa/main/dd.h | 44 | ||||
-rw-r--r-- | src/mesa/main/teximage.c | 36 | ||||
-rw-r--r-- | src/mesa/main/texobj.c | 28 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 78 | ||||
-rw-r--r-- | src/mesa/main/texstore.h | 31 |
5 files changed, 41 insertions, 176 deletions
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 582eb5d492b..711143c5594 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -198,43 +198,21 @@ struct dd_function_table { GLenum srcFormat, GLenum srcType ); /** - * Called by glTexImage1D(). Simply copy the source texture data into the - * destination texture memory. The gl_texture_image fields, etc. will be - * fully initialized. - * The parameters are the same as glTexImage1D(), plus: + * Called by glTexImage[123]D() and glCopyTexImage[12]D() + * Allocate texture memory and copy the user's image to the buffer. + * The gl_texture_image fields, etc. will be fully initialized. + * The parameters are the same as glTexImage3D(), plus: + * \param dims 1, 2, or 3 indicating glTexImage1/2/3D() * \param packing describes how to unpack the source data. * \param texImage is the destination texture image. */ - void (*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); + void (*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); - /** - * Called by glTexImage2D(). - * - * \sa dd_function_table::TexImage1D. - */ - void (*TexImage2D)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing); - - /** - * Called by glTexImage3D(). - * - * \sa dd_function_table::TexImage1D. - */ - void (*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 GLvoid *pixels, - const struct gl_pixelstore_attrib *packing); /** * Called by glTexSubImage1D(). Replace a subset of the target texture diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 694f6fa0010..5bb21cd80a8 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2606,26 +2606,9 @@ teximage(struct gl_context *ctx, GLuint dims, border, internalFormat, texFormat); /* Give the texture to the driver. <pixels> may be null. */ - ASSERT(ctx->Driver.TexImage3D); - switch (dims) { - case 1: - ctx->Driver.TexImage1D(ctx, texImage, internalFormat, - width, border, format, - type, pixels, unpack); - break; - case 2: - ctx->Driver.TexImage2D(ctx, texImage, internalFormat, - width, height, border, format, - type, pixels, unpack); - break; - case 3: - ctx->Driver.TexImage3D(ctx, texImage, internalFormat, - width, height, depth, border, format, - type, pixels, unpack); - break; - default: - _mesa_problem(ctx, "invalid dims=%u in teximage()", dims); - } + ctx->Driver.TexImage(ctx, dims, texImage, internalFormat, + width, height, depth, border, format, + type, pixels, unpack); check_gen_mipmap(ctx, target, texObj, level); @@ -2968,16 +2951,9 @@ copyteximage(struct gl_context *ctx, GLuint dims, border, internalFormat, texFormat); /* Allocate texture memory (no pixel data yet) */ - if (dims == 1) { - ctx->Driver.TexImage1D(ctx, texImage, internalFormat, - width, border, GL_NONE, GL_NONE, NULL, - &ctx->Unpack); - } - else { - ctx->Driver.TexImage2D(ctx, texImage, internalFormat, - width, height, border, GL_NONE, GL_NONE, - NULL, &ctx->Unpack); - } + ctx->Driver.TexImage(ctx, dims, texImage, internalFormat, + width, height, 1, border, GL_NONE, GL_NONE, + NULL, &ctx->Unpack); if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY, &width, &height)) { diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index a471bad22b6..e0494c94028 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -807,30 +807,10 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex) 0, /* border */ GL_RGBA, texFormat); - switch (dims) { - case 0: - break; - case 1: - ctx->Driver.TexImage1D(ctx, texImage, GL_RGBA, - width, 0, - GL_RGBA, GL_UNSIGNED_BYTE, texel, - &ctx->DefaultPacking); - break; - case 2: - ctx->Driver.TexImage2D(ctx, texImage, GL_RGBA, - width, height, 0, - GL_RGBA, GL_UNSIGNED_BYTE, texel, - &ctx->DefaultPacking); - break; - case 3: - ctx->Driver.TexImage3D(ctx, texImage, GL_RGBA, - width, height, depth, 0, - GL_RGBA, GL_UNSIGNED_BYTE, texel, - &ctx->DefaultPacking); - break; - default: - _mesa_problem(ctx, "bad dims in _mesa_get_fallback_texture()"); - } + ctx->Driver.TexImage(ctx, dims, texImage, GL_RGBA, + width, height, depth, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texel, + &ctx->DefaultPacking); } _mesa_test_texobj_completeness(ctx, texObj); 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(). */ diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h index 85e33b0fe26..b4995fbc898 100644 --- a/src/mesa/main/texstore.h +++ b/src/mesa/main/texstore.h @@ -90,30 +90,13 @@ _mesa_make_temp_float_image(struct gl_context *ctx, GLuint dims, GLbitfield transferOps); extern 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); - - -extern 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 GLvoid *pixels, - const struct gl_pixelstore_attrib *packing); - - -extern 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 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); extern void |