From ec19bdd16c3d4070af69fd865042babe0a627595 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 5 Jun 2012 16:32:23 -0600 Subject: [PATCH] mesa: consolidate internal glCompressedTexSubImage1/2/3D code Reviewed-by: Kenneth Graunke --- src/mesa/drivers/common/driverfuncs.c | 4 +- .../drivers/dri/nouveau/nouveau_texture.c | 12 ++-- src/mesa/main/dd.h | 33 ++------- src/mesa/main/teximage.c | 31 ++------- src/mesa/main/texstore.c | 69 +++++-------------- src/mesa/main/texstore.h | 27 ++------ src/mesa/state_tracker/st_cb_texture.c | 4 +- 7 files changed, 42 insertions(+), 138 deletions(-) diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index 3d689362c61..93fa3c745e7 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -98,9 +98,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->GenerateMipmap = _mesa_meta_GenerateMipmap; driver->TestProxyTexImage = _mesa_test_proxy_teximage; driver->CompressedTexImage = _mesa_store_compressed_teximage; - driver->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d; - driver->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d; - driver->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d; + driver->CompressedTexSubImage = _mesa_store_compressed_texsubimage; driver->GetCompressedTexImage = _mesa_get_compressed_teximage; driver->BindTexture = NULL; driver->NewTextureObject = _mesa_new_texture_object; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c index 281d1dda458..0060f464307 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c @@ -624,15 +624,15 @@ nouveau_texsubimage_123d(struct gl_context *ctx, GLuint dims, } static void -nouveau_compressed_texsubimage_2d(struct gl_context *ctx, +nouveau_compressed_texsubimage(struct gl_context *ctx, GLuint dims, struct gl_texture_image *ti, - GLint xoffset, GLint yoffset, - GLsizei width, GLint height, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLint height, GLint depth, GLenum format, GLint imageSize, const void *data) { - nouveau_texsubimage(ctx, 2, ti, xoffset, yoffset, 0, - width, height, 1, imageSize, format, 0, data, + nouveau_texsubimage(ctx, dims, ti, xoffset, yoffset, zoffset, + width, height, depth, imageSize, format, 0, data, &ctx->Unpack, GL_TRUE); } @@ -709,7 +709,7 @@ nouveau_texture_functions_init(struct dd_function_table *functions) functions->TexImage = nouveau_teximage_123d; functions->TexSubImage = nouveau_texsubimage_123d; functions->CompressedTexImage = nouveau_compressed_teximage; - functions->CompressedTexSubImage2D = nouveau_compressed_texsubimage_2d; + functions->CompressedTexSubImage = nouveau_compressed_texsubimage; functions->BindTexture = nouveau_bind_texture; functions->MapTextureImage = nouveau_map_texture_image; functions->UnmapTextureImage = nouveau_unmap_texture_image; diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 07106ac3684..1582a8c81ec 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -279,33 +279,14 @@ struct dd_function_table { GLsizei imageSize, const GLvoid *data); /** - * Called by glCompressedTexSubImage1D(). + * Called by glCompressedTexSubImage[123]D(). */ - void (*CompressedTexSubImage1D)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLsizei width, - GLenum format, - GLsizei imageSize, const GLvoid *data); - - /** - * Called by glCompressedTexSubImage2D(). - */ - void (*CompressedTexSubImage2D)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, - GLsizei width, GLint height, - GLenum format, - GLsizei imageSize, const GLvoid *data); - - /** - * Called by glCompressedTexSubImage3D(). - */ - void (*CompressedTexSubImage3D)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLint height, GLint depth, - GLenum format, - GLsizei imageSize, const GLvoid *data); + void (*CompressedTexSubImage)(struct gl_context *ctx, GLuint dims, + struct gl_texture_image *texImage, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLint height, GLint depth, + GLenum format, + GLsizei imageSize, const GLvoid *data); /** * Called by glGetCompressedTexImage. diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 290a4e454dc..b16baaf914c 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -3633,33 +3633,10 @@ compressed_tex_sub_image(GLuint dims, GLenum target, GLint level, /* error was recorded */ } else if (width > 0 && height > 0 && depth > 0) { - switch (dims) { - case 1: - if (ctx->Driver.CompressedTexSubImage1D) { - ctx->Driver.CompressedTexSubImage1D(ctx, texImage, - xoffset, width, - format, imageSize, data); - } - break; - case 2: - if (ctx->Driver.CompressedTexSubImage2D) { - ctx->Driver.CompressedTexSubImage2D(ctx, texImage, - xoffset, yoffset, - width, height, - format, imageSize, data); - } - break; - case 3: - if (ctx->Driver.CompressedTexSubImage3D) { - ctx->Driver.CompressedTexSubImage3D(ctx, texImage, - xoffset, yoffset, zoffset, - width, height, depth, - format, imageSize, data); - } - break; - default: - ; - } + ctx->Driver.CompressedTexSubImage(ctx, dims, texImage, + xoffset, yoffset, zoffset, + width, height, depth, + format, imageSize, data); check_gen_mipmap(ctx, target, texObj, level); diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 37ba082a475..1ced8aac98d 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -4342,43 +4342,24 @@ _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims, return; } - _mesa_store_compressed_texsubimage2d(ctx, texImage, - 0, 0, - width, height, - texImage->TexFormat, - imageSize, data); + _mesa_store_compressed_texsubimage(ctx, dims, texImage, + 0, 0, 0, + width, height, depth, + texImage->TexFormat, + imageSize, data); } /** - * Fallback for Driver.CompressedTexSubImage1D() + * Fallback for Driver.CompressedTexSubImage() */ void -_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLsizei width, - GLenum format, - GLsizei imageSize, const GLvoid *data) -{ - /* there are no compressed 1D texture formats yet */ - (void) ctx; - (void) xoffset; (void) width; - (void) format; - (void) imageSize; (void) data; - (void) texImage; -} - - -/** - * Fallback for Driver.CompressedTexSubImage2D() - */ -void -_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, - GLsizei imageSize, const GLvoid *data) +_mesa_store_compressed_texsubimage(struct gl_context *ctx, GLuint dims, + struct gl_texture_image *texImage, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, + GLsizei imageSize, const GLvoid *data) { GLint bytesPerRow, dstRowStride, srcRowStride; GLint i, rows; @@ -4387,6 +4368,11 @@ _mesa_store_compressed_texsubimage2d(struct gl_context *ctx, const gl_format texFormat = texImage->TexFormat; GLuint bw, bh; + if (dims != 2) { + _mesa_problem(ctx, "Unexpected 1D/3D compressed texsubimage call"); + return; + } + _mesa_get_format_block_size(texFormat, &bw, &bh); /* these should have been caught sooner */ @@ -4430,24 +4416,3 @@ _mesa_store_compressed_texsubimage2d(struct gl_context *ctx, _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack); } - - -/** - * Fallback for Driver.CompressedTexSubImage3D() - */ -void -_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, - GLsizei imageSize, const GLvoid *data) -{ - /* there are no compressed 3D texture formats yet */ - (void) ctx; - (void) xoffset; (void) yoffset; (void) zoffset; - (void) width; (void) height; (void) depth; - (void) format; - (void) imageSize; (void) data; - (void) texImage; -} diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h index 68dc4b47960..5a1c014231c 100644 --- a/src/mesa/main/texstore.h +++ b/src/mesa/main/texstore.h @@ -118,27 +118,12 @@ _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims, extern void -_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLsizei width, - GLenum format, - GLsizei imageSize, const GLvoid *data); - -extern void -_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, - GLsizei imageSize, const GLvoid *data); - -extern void -_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, - GLsizei imageSize, const GLvoid *data); +_mesa_store_compressed_texsubimage(struct gl_context *ctx, GLuint dims, + struct gl_texture_image *texImage, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, + GLsizei imageSize, const GLvoid *data); #endif diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 2fc59649423..9d1b7f672f5 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1354,9 +1354,7 @@ st_init_texture_functions(struct dd_function_table *functions) functions->ChooseTextureFormat = st_ChooseTextureFormat; functions->TexImage = st_TexImage; functions->TexSubImage = _mesa_store_texsubimage; - functions->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d; - functions->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d; - functions->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d; + functions->CompressedTexSubImage = _mesa_store_compressed_texsubimage; functions->CopyTexSubImage = st_CopyTexSubImage; functions->GenerateMipmap = st_generate_mipmap; -- 2.30.2