Mesa (master): ilo: refactor separate stencil allocation

Chia-I Wu olv at kemper.freedesktop.org
Wed Jan 8 10:13:10 UTC 2014


Module: Mesa
Branch: master
Commit: e372819589c2a66620e63a2cd11582c6ce5fb8f0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e372819589c2a66620e63a2cd11582c6ce5fb8f0

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Sat Dec 21 21:21:24 2013 +0800

ilo: refactor separate stencil allocation

Move separate stencil allocation code to tex_create_separate_stencil to keep
tex_create sane.

---

 src/gallium/drivers/ilo/ilo_resource.c |   47 ++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c
index 7dd3435..04927d8 100644
--- a/src/gallium/drivers/ilo/ilo_resource.c
+++ b/src/gallium/drivers/ilo/ilo_resource.c
@@ -969,6 +969,30 @@ tex_create_bo(struct ilo_texture *tex,
    return true;
 }
 
+static bool
+tex_create_separate_stencil(struct ilo_texture *tex)
+{
+   struct pipe_resource templ = tex->base;
+   struct pipe_resource *s8;
+
+   /*
+    * Unless PIPE_BIND_DEPTH_STENCIL is set, the resource may have other
+    * tilings.  But that should be fine since it will never be bound as the
+    * stencil buffer, and our transfer code can handle all tilings.
+    */
+   templ.format = PIPE_FORMAT_S8_UINT;
+
+   s8 = tex->base.screen->resource_create(tex->base.screen, &templ);
+   if (!s8)
+      return false;
+
+   tex->separate_s8 = ilo_texture(s8);
+
+   assert(tex->separate_s8->bo_format == PIPE_FORMAT_S8_UINT);
+
+   return true;
+}
+
 static void
 tex_destroy(struct ilo_texture *tex)
 {
@@ -1053,26 +1077,9 @@ tex_create(struct pipe_screen *screen,
    }
 
    /* allocate separate stencil resource */
-   if (layout.separate_stencil) {
-      struct pipe_resource s8_templ = *layout.templ;
-      struct pipe_resource *s8;
-
-      /*
-       * Unless PIPE_BIND_DEPTH_STENCIL is set, the resource may have other
-       * tilings.  But that should be fine since it will never be bound as the
-       * stencil buffer, and our transfer code can handle all tilings.
-       */
-      s8_templ.format = PIPE_FORMAT_S8_UINT;
-
-      s8 = screen->resource_create(screen, &s8_templ);
-      if (!s8) {
-         tex_destroy(tex);
-         return NULL;
-      }
-
-      tex->separate_s8 = ilo_texture(s8);
-
-      assert(tex->separate_s8->bo_format == PIPE_FORMAT_S8_UINT);
+   if (layout.separate_stencil && !tex_create_separate_stencil(tex)) {
+      tex_destroy(tex);
+      return NULL;
    }
 
    return &tex->base;




More information about the mesa-commit mailing list