From 4368a657670f1f3f13d8497f749cb5439f91529e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 30 Sep 2011 08:15:30 -0600 Subject: [PATCH] mesa: simplify parameters to GetTexImage() driver hook The target, level and texObj can be obtained through the texImage parameter. We could make similar changes for the TexImage() hooks too. Reviewed-by: Eric Anholt --- src/mesa/drivers/common/meta.c | 7 +++---- src/mesa/drivers/common/meta.h | 3 +-- src/mesa/main/dd.h | 3 +-- src/mesa/main/debug.c | 4 +--- src/mesa/main/mipmap.c | 5 +++-- src/mesa/main/texgetimage.c | 22 ++++++++++------------ src/mesa/main/texgetimage.h | 3 +-- src/mesa/state_tracker/st_cb_texture.c | 16 ++++++---------- 8 files changed, 26 insertions(+), 37 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index b6e80d70ab9..02913685e66 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -3260,9 +3260,8 @@ decompress_texture_image(struct gl_context *ctx, * from core Mesa. */ void -_mesa_meta_GetTexImage(struct gl_context *ctx, GLenum target, GLint level, +_mesa_meta_GetTexImage(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, struct gl_texture_image *texImage) { /* We can only use the decompress-with-blit method here if the texels are @@ -3272,6 +3271,7 @@ _mesa_meta_GetTexImage(struct gl_context *ctx, GLenum target, GLint level, if (_mesa_is_format_compressed(texImage->TexFormat) && _mesa_get_format_datatype(texImage->TexFormat) == GL_UNSIGNED_NORMALIZED) { + struct gl_texture_object *texObj = texImage->TexObject; const GLuint slice = 0; /* only 2D compressed textures for now */ /* Need to unlock the texture here to prevent deadlock... */ _mesa_unlock_texture(ctx, texObj); @@ -3281,7 +3281,6 @@ _mesa_meta_GetTexImage(struct gl_context *ctx, GLenum target, GLint level, _mesa_lock_texture(ctx, texObj); } else { - _mesa_get_teximage(ctx, target, level, format, type, pixels, - texObj, texImage); + _mesa_get_teximage(ctx, format, type, pixels, texImage); } } diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h index 3c917924a30..7ec56838831 100644 --- a/src/mesa/drivers/common/meta.h +++ b/src/mesa/drivers/common/meta.h @@ -124,9 +124,8 @@ _mesa_meta_CopyTexSubImage3D(struct gl_context *ctx, GLenum target, GLint level, GLsizei width, GLsizei height); extern void -_mesa_meta_GetTexImage(struct gl_context *ctx, GLenum target, GLint level, +_mesa_meta_GetTexImage(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, struct gl_texture_image *texImage); diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 720e4f53d6a..91ecc0be03f 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -284,9 +284,8 @@ struct dd_function_table { /** * Called by glGetTexImage(). */ - void (*GetTexImage)( struct gl_context *ctx, GLenum target, GLint level, + void (*GetTexImage)( struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, struct gl_texture_image *texImage ); /** diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index 0a393e5fa29..6e695d1474c 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -268,9 +268,7 @@ write_texture_image(struct gl_texture_object *texObj, store = ctx->Pack; /* save */ ctx->Pack = ctx->DefaultPacking; - ctx->Driver.GetTexImage(ctx, texObj->Target, level, - GL_RGBA, GL_UNSIGNED_BYTE, - buffer, texObj, img); + ctx->Driver.GetTexImage(ctx, GL_RGBA, GL_UNSIGNED_BYTE, buffer, img); /* make filename */ _mesa_snprintf(s, sizeof(s), "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face); diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index e0cc6a2ad5f..7325a420f0e 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -2032,9 +2032,10 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target, ctx->Pack = ctx->DefaultPacking; /* Get the uncompressed image */ - ctx->Driver.GetTexImage(ctx, target, texObj->BaseLevel, + assert(srcImage->Level == texObj->BaseLevel); + ctx->Driver.GetTexImage(ctx, temp_base_format, temp_datatype, - temp_src, texObj, srcImage); + temp_src, srcImage); /* restore packing mode */ ctx->Pack = save; } diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index d2f25b9f802..62a55dff8ba 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -373,9 +373,9 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions, static GLboolean get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, struct gl_texture_image *texImage) { + const GLenum target = texImage->TexObject->Target; GLboolean memCopy = GL_FALSE; /* @@ -384,11 +384,11 @@ get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, * so we don't have to worry about those. * XXX more format combinations could be supported here. */ - if ((texObj->Target == GL_TEXTURE_1D || - texObj->Target == GL_TEXTURE_2D || - texObj->Target == GL_TEXTURE_RECTANGLE || - (texObj->Target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && - texObj->Target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) { + if ((target == GL_TEXTURE_1D || + target == GL_TEXTURE_2D || + target == GL_TEXTURE_RECTANGLE || + (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) { if ((texImage->TexFormat == MESA_FORMAT_ARGB8888 || texImage->TexFormat == MESA_FORMAT_SARGB8) && format == GL_BGRA && @@ -471,14 +471,13 @@ get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, * unmap with ctx->Driver.UnmapTextureImage(). */ void -_mesa_get_teximage(struct gl_context *ctx, GLenum target, GLint level, +_mesa_get_teximage(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, struct gl_texture_image *texImage) { GLuint dimensions; - switch (target) { + switch (texImage->TexObject->Target) { case GL_TEXTURE_1D: dimensions = 1; break; @@ -511,7 +510,7 @@ _mesa_get_teximage(struct gl_context *ctx, GLenum target, GLint level, pixels = ADD_POINTERS(buf, pixels); } - if (get_tex_memcpy(ctx, format, type, pixels, texObj, texImage)) { + if (get_tex_memcpy(ctx, format, type, pixels, texImage)) { /* all done */ } else if (format == GL_DEPTH_COMPONENT) { @@ -772,8 +771,7 @@ _mesa_GetnTexImageARB( GLenum target, GLint level, GLenum format, _mesa_lock_texture(ctx, texObj); { - ctx->Driver.GetTexImage(ctx, target, level, format, type, pixels, - texObj, texImage); + ctx->Driver.GetTexImage(ctx, format, type, pixels, texImage); } _mesa_unlock_texture(ctx, texObj); } diff --git a/src/mesa/main/texgetimage.h b/src/mesa/main/texgetimage.h index 8612705ca88..02b1cf4599c 100644 --- a/src/mesa/main/texgetimage.h +++ b/src/mesa/main/texgetimage.h @@ -34,9 +34,8 @@ struct gl_texture_image; struct gl_texture_object; extern void -_mesa_get_teximage(struct gl_context *ctx, GLenum target, GLint level, +_mesa_get_teximage(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, struct gl_texture_image *texImage); diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 260df09f597..b4102478bf4 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -815,15 +815,14 @@ st_CompressedTexImage2D(struct gl_context *ctx, GLenum target, GLint level, * a textured quad. Store the results in the user's buffer. */ static void -decompress_with_blit(struct gl_context * ctx, GLenum target, GLint level, +decompress_with_blit(struct gl_context * ctx, GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, struct gl_texture_image *texImage) { struct st_context *st = st_context(ctx); struct pipe_context *pipe = st->pipe; struct st_texture_image *stImage = st_texture_image(texImage); - struct st_texture_object *stObj = st_texture_object(texObj); + struct st_texture_object *stObj = st_texture_object(texImage->TexObject); struct pipe_sampler_view *src_view = st_get_texture_sampler_view(stObj, pipe); const GLuint width = texImage->Width; @@ -848,7 +847,7 @@ decompress_with_blit(struct gl_context * ctx, GLenum target, GLint level, } /* Choose the source mipmap level */ - src_view->u.tex.first_level = src_view->u.tex.last_level = level; + src_view->u.tex.first_level = src_view->u.tex.last_level = texImage->Level; /* blit/render/decompress */ util_blit_pixels_tex(st->blit, @@ -925,9 +924,8 @@ decompress_with_blit(struct gl_context * ctx, GLenum target, GLint level, * Called via ctx->Driver.GetTexImage() */ static void -st_GetTexImage(struct gl_context * ctx, GLenum target, GLint level, +st_GetTexImage(struct gl_context * ctx, GLenum format, GLenum type, GLvoid * pixels, - struct gl_texture_object *texObj, struct gl_texture_image *texImage) { struct st_texture_image *stImage = st_texture_image(texImage); @@ -938,12 +936,10 @@ st_GetTexImage(struct gl_context * ctx, GLenum target, GLint level, * faster than using the fallback code in texcompress.c. * Note that we only expect RGBA formats (no Z/depth formats). */ - decompress_with_blit(ctx, target, level, format, type, pixels, - texObj, texImage); + decompress_with_blit(ctx, format, type, pixels, texImage); } else { - _mesa_get_teximage(ctx, target, level, format, type, pixels, - texObj, texImage); + _mesa_get_teximage(ctx, format, type, pixels, texImage); } } -- 2.30.2