[Mesa-dev] [PATCH 04/11] meta: Fold the texture setup into _mesa_meta_setup_copypix_texture().

Eric Anholt eric at anholt.net
Wed Feb 5 17:20:07 PST 2014


There was this funny argument passed to setup for "did alloc decide we
need to allocate new texture storage?", which goes away if we don't have
the caller do alloc as a separate step.
---
 src/mesa/drivers/common/meta.c      | 15 +++++++--------
 src/mesa/drivers/common/meta.h      |  1 -
 src/mesa/drivers/common/meta_blit.c |  4 +---
 3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 33ea67f..ea1eb29 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -1067,18 +1067,21 @@ _mesa_meta_alloc_texture(struct temp_texture *tex,
 void
 _mesa_meta_setup_copypix_texture(struct gl_context *ctx,
                                  struct temp_texture *tex,
-                                 GLboolean newTex,
                                  GLint srcX, GLint srcY,
                                  GLsizei width, GLsizei height,
                                  GLenum intFormat,
                                  GLenum filter)
 {
+   bool newTex;
+
    _mesa_BindTexture(tex->Target, tex->TexObj);
    _mesa_TexParameteri(tex->Target, GL_TEXTURE_MIN_FILTER, filter);
    _mesa_TexParameteri(tex->Target, GL_TEXTURE_MAG_FILTER, filter);
    if (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES)
       _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
 
+   newTex = _mesa_meta_alloc_texture(tex, width, height, intFormat);
+
    /* copy framebuffer image to texture */
    if (newTex) {
       /* create new tex image */
@@ -1582,8 +1585,6 @@ _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY,
       GLfloat x, y, z, s, t;
    };
    struct vertex verts[4];
-   GLboolean newTex;
-   GLenum intFormat = GL_RGBA;
 
    if (type != GL_COLOR ||
        ctx->_ImageTransferState ||
@@ -1630,7 +1631,9 @@ _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY,
       _mesa_BindBuffer(GL_ARRAY_BUFFER_ARB, copypix->VBO);
    }
 
-   newTex = _mesa_meta_alloc_texture(tex, width, height, intFormat);
+   /* Alloc/setup texture */
+   _mesa_meta_setup_copypix_texture(ctx, tex, srcX, srcY, width, height,
+                                    GL_RGBA, GL_NEAREST);
 
    /* vertex positions, texcoords (after texture allocation!) */
    {
@@ -1665,10 +1668,6 @@ _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY,
       _mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
    }
 
-   /* Alloc/setup texture */
-   _mesa_meta_setup_copypix_texture(ctx, tex, newTex, srcX, srcY, width, height,
-                                    GL_RGBA, GL_NEAREST);
-
    _mesa_set_enable(ctx, tex->Target, GL_TRUE);
 
    /* draw textured quad */
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 64925ff..f9d1f7c 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -432,7 +432,6 @@ _mesa_meta_setup_drawpix_texture(struct gl_context *ctx,
 void
 _mesa_meta_setup_copypix_texture(struct gl_context *ctx,
                                  struct temp_texture *tex,
-                                 GLboolean newTex,
                                  GLint srcX, GLint srcY,
                                  GLsizei width, GLsizei height,
                                  GLenum intFormat,
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index 5f7cad7..5a0b2ca 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -556,9 +556,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
        * linear filtering along the edges. So, allocate the texture extended along
        * edges by one pixel in x, y directions.
        */
-      newTex = _mesa_meta_alloc_texture(tex, srcW + 2, srcH + 2,
-                                        rb_base_format);
-      _mesa_meta_setup_copypix_texture(ctx, tex, newTex,
+      _mesa_meta_setup_copypix_texture(ctx, tex,
                                        srcX - 1, srcY - 1, srcW + 2, srcH + 2,
                                        rb_base_format, filter);
       /* texcoords (after texture allocation!) */
-- 
1.9.rc1



More information about the mesa-dev mailing list