panfrost: Set depth and stencil for SFBD based on the format
authorTomeu Vizoso <tomeu.vizoso@collabora.com>
Wed, 6 Nov 2019 09:04:36 +0000 (10:04 +0100)
committerTomeu Vizoso <tomeu.vizoso@collabora.co.uk>
Mon, 11 Nov 2019 15:23:44 +0000 (15:23 +0000)
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_format.c
src/gallium/drivers/panfrost/pan_format.h
src/gallium/drivers/panfrost/pan_mfbd.c
src/gallium/drivers/panfrost/pan_sfbd.c

index 2596b41feacd516583c1b424029f7fb9c50e510d..35fa012bed60b13465eddbf24c17fe94675c4b41 100644 (file)
@@ -270,3 +270,16 @@ panfrost_invert_swizzle(const unsigned char *in, unsigned char *out)
                 out[idx] = PIPE_SWIZZLE_X + c;
         }
 }
+
+/* Is a format encoded like Z24S8 and therefore compatible for render? */
+bool
+panfrost_is_z24s8_variant(enum pipe_format fmt)
+{
+        switch (fmt) {
+                case PIPE_FORMAT_Z24_UNORM_S8_UINT:
+                case PIPE_FORMAT_Z24X8_UNORM:
+                        return true;
+                default:
+                        return false;
+        }
+}
index 4baac8a0e59595a1d6eedcf26e8de0e7bfdb38c4..a881b3721eec89fb613f874d62ddad18eeb37143 100644 (file)
@@ -40,6 +40,9 @@ panfrost_find_format(const struct util_format_description *desc);
 void
 panfrost_invert_swizzle(const unsigned char *in, unsigned char *out);
 
+bool
+panfrost_is_z24s8_variant(enum pipe_format fmt);
+
 #endif
 
 
index 75f8887ec6d0fbf35bd9c493a31672f14bc26d27..38b901a700d558211777ea6b6fa3d95e0920599f 100644 (file)
@@ -226,20 +226,6 @@ panfrost_mfbd_set_cbuf(
         }
 }
 
-/* Is a format encoded like Z24S8 and therefore compatible for render? */
-
-static bool
-panfrost_is_z24s8_variant(enum pipe_format fmt)
-{
-        switch (fmt) {
-                case PIPE_FORMAT_Z24_UNORM_S8_UINT:
-                case PIPE_FORMAT_Z24X8_UNORM:
-                        return true;
-                default:
-                        return false;
-        }
-}
-
 static void
 panfrost_mfbd_set_zsbuf(
         struct bifrost_framebuffer *fb,
index 9fa806a8a1a1312751df261f7dcaee417edbd973..dda8a68db7687703c448be95190c155846ffb9cd 100644 (file)
@@ -163,20 +163,33 @@ panfrost_sfbd_set_zsbuf(
         assert(surf->u.tex.first_layer == 0);
 
         if (rsrc->layout == PAN_LINEAR) {
-                /* TODO: What about format selection? */
+                if (panfrost_is_z24s8_variant(surf->format)) {
 
-                fb->depth_buffer = rsrc->bo->gpu + rsrc->slices[level].offset;
-                fb->depth_stride = rsrc->slices[level].stride;
+                        fb->depth_buffer = rsrc->bo->gpu + rsrc->slices[level].offset;
+                        fb->depth_stride = rsrc->slices[level].stride;
 
-                fb->stencil_buffer = rsrc->bo->gpu + rsrc->slices[level].offset;
-                fb->stencil_stride = rsrc->slices[level].stride;
+                        fb->stencil_buffer = rsrc->bo->gpu + rsrc->slices[level].offset;
+                        fb->stencil_stride = rsrc->slices[level].stride;
 
-                struct panfrost_resource *stencil = rsrc->separate_stencil;
-                if (stencil) {
+                } else if (surf->format == PIPE_FORMAT_Z32_UNORM ||
+                           surf->format == PIPE_FORMAT_Z32_FLOAT) {
+
+                        fb->depth_buffer = rsrc->bo->gpu + rsrc->slices[level].offset;
+                        fb->depth_stride = rsrc->slices[level].stride;
+
+                } else if (surf->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) {
+
+                        fb->depth_buffer = rsrc->bo->gpu + rsrc->slices[level].offset;
+                        fb->depth_stride = rsrc->slices[level].stride;
+
+                        struct panfrost_resource *stencil = rsrc->separate_stencil;
                         struct panfrost_slice stencil_slice = stencil->slices[level];
 
                         fb->stencil_buffer = stencil->bo->gpu + stencil_slice.offset;
                         fb->stencil_stride = stencil_slice.stride;
+                } else {
+                        fprintf(stderr, "Unsupported depth/stencil format\n");
+                        assert(0);
                 }
         } else {
                 fprintf(stderr, "Invalid render layout\n");