st/texture: Dedent surface setup in CompressedTexSubImage
authorJason Ekstrand <jason@jlekstrand.net>
Tue, 29 Jun 2021 16:44:01 +0000 (11:44 -0500)
committerMarge Bot <eric+marge@anholt.net>
Thu, 30 Sep 2021 03:52:33 +0000 (03:52 +0000)
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11737>

src/mesa/state_tracker/st_cb_texture.c

index 85a23f8..e317774 100644 (file)
@@ -2279,11 +2279,12 @@ st_CompressedTexSubImage(struct gl_context *ctx, GLuint dims,
    struct pipe_context *pipe = st->pipe;
    struct pipe_screen *screen = st->screen;
    struct pipe_resource *dst = stImage->pt;
-   struct pipe_surface *surface = NULL;
+   struct pipe_surface templ, *surface = NULL;
    struct compressed_pixelstore store;
    struct st_pbo_addresses addr;
    enum pipe_format copy_format;
-   unsigned bw, bh;
+   unsigned bw, bh, level, max_layer;
+   int layer;
    intptr_t buf_offset;
    bool success = false;
 
@@ -2363,24 +2364,20 @@ st_CompressedTexSubImage(struct gl_context *ctx, GLuint dims,
       goto fallback;
 
    /* Set up the surface. */
-   {
-      unsigned level = stObj->pt != stImage->pt
-         ? 0 : texImage->TexObject->Attrib.MinLevel + texImage->Level;
-      unsigned max_layer = util_max_layer(texture, level);
-
-      GLint layer = z + texImage->Face + texImage->TexObject->Attrib.MinLayer;
-
-      struct pipe_surface templ;
-      memset(&templ, 0, sizeof(templ));
-      templ.format = copy_format;
-      templ.u.tex.level = level;
-      templ.u.tex.first_layer = MIN2(layer, max_layer);
-      templ.u.tex.last_layer = MIN2(layer + d - 1, max_layer);
-
-      surface = pipe->create_surface(pipe, texture, &templ);
-      if (!surface)
-         goto fallback;
-   }
+   level = stObj->pt != stImage->pt
+      ? 0 : texImage->TexObject->Attrib.MinLevel + texImage->Level;
+   max_layer = util_max_layer(texture, level);
+   layer = z + texImage->Face + texImage->TexObject->Attrib.MinLayer;
+
+   memset(&templ, 0, sizeof(templ));
+   templ.format = copy_format;
+   templ.u.tex.level = level;
+   templ.u.tex.first_layer = MIN2(layer, max_layer);
+   templ.u.tex.last_layer = MIN2(layer + d - 1, max_layer);
+
+   surface = pipe->create_surface(pipe, texture, &templ);
+   if (!surface)
+      goto fallback;
 
    success = try_pbo_upload_common(ctx, surface, &addr, copy_format);