[Mesa-dev] [PATCH 1/4] mesa: tidy up copyteximage()

Timothy Arceri tarceri at itsqueeze.com
Mon Jun 26 04:30:34 UTC 2017


---
 src/mesa/main/teximage.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index a9086a2..796c8ad 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3808,11 +3808,7 @@ copyteximage(struct gl_context *ctx, GLuint dims,
              GLenum target, GLint level, GLenum internalFormat,
              GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
 {
-   struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
-   const GLuint face = _mesa_tex_target_to_face(target);
-   mesa_format texFormat;
-   struct gl_renderbuffer *rb;
 
    FLUSH_VERTICES(ctx, 0);
 
@@ -3837,11 +3833,12 @@ copyteximage(struct gl_context *ctx, GLuint dims,
       return;
    }
 
-   texObj = _mesa_get_current_tex_object(ctx, target);
+   struct gl_texture_object *texObj = _mesa_get_current_tex_object(ctx, target);
    assert(texObj);
 
-   texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
-                                           internalFormat, GL_NONE, GL_NONE);
+   mesa_format texFormat =
+      _mesa_choose_texture_format(ctx, texObj, target, level, internalFormat,
+                                  GL_NONE, GL_NONE);
 
    /* First check if reallocating the texture buffer can be avoided.
     * Without the realloc the copy can be 20x faster.
@@ -3861,9 +3858,10 @@ copyteximage(struct gl_context *ctx, GLuint dims,
    _mesa_perf_debug(ctx, MESA_DEBUG_SEVERITY_LOW, "glCopyTexImage "
                     "can't avoid reallocating texture storage\n");
 
-   rb = _mesa_get_read_renderbuffer_for_format(ctx, internalFormat);
-
    if (_mesa_is_gles3(ctx)) {
+      struct gl_renderbuffer *rb =
+         _mesa_get_read_renderbuffer_for_format(ctx, internalFormat);
+
       if (_mesa_is_enum_format_unsized(internalFormat)) {
       /* Conversion from GL_RGB10_A2 source buffer format is not allowed in
        * OpenGL ES 3.0. Khronos bug# 9807.
@@ -3923,6 +3921,7 @@ copyteximage(struct gl_context *ctx, GLuint dims,
       }
       else {
          GLint srcX = x, srcY = y, dstX = 0, dstY = 0, dstZ = 0;
+         const GLuint face = _mesa_tex_target_to_face(target);
 
          /* Free old texture image */
          ctx->Driver.FreeTextureImageBuffer(ctx, texImage);
-- 
2.9.4



More information about the mesa-dev mailing list