[Mesa-dev] [PATCH 3/4] mesa: simplify parameters to GetTexImage() driver hook
Brian Paul
brian.e.paul at gmail.com
Thu Sep 29 13:24:47 PDT 2011
From: Brian Paul <brianp at vmware.com>
The target, level and texObj can be obtained through the texImage
parameter. We could make similar changes for the TexImage() hooks too.
---
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 b47eb2c..069eda2 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -3280,9 +3280,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
@@ -3292,6 +3291,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);
@@ -3301,7 +3301,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 3c91792..7ec5683 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 720e4f5..91ecc0b 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 0a393e5..6e695d1 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 e0cc6a2..7325a42 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 d2f25b9..62a55df 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 8612705..02b1cf4 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 a69ed05..76bf78b 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -900,15 +900,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;
@@ -933,7 +932,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,
@@ -1010,9 +1009,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);
@@ -1023,12 +1021,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);
}
}
--
1.7.3.4
More information about the mesa-dev
mailing list