From ee5321f2392f8d98a552750986fa476ab8c13eb3 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Wed, 6 Nov 2019 10:04:36 +0100 Subject: [PATCH] panfrost: Set depth and stencil for SFBD based on the format Signed-off-by: Tomeu Vizoso Reviewed-by: Alyssa Rosenzweig --- src/gallium/drivers/panfrost/pan_format.c | 13 +++++++++++ src/gallium/drivers/panfrost/pan_format.h | 3 +++ src/gallium/drivers/panfrost/pan_mfbd.c | 14 ------------ src/gallium/drivers/panfrost/pan_sfbd.c | 27 +++++++++++++++++------ 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_format.c b/src/gallium/drivers/panfrost/pan_format.c index 2596b41feac..35fa012bed6 100644 --- a/src/gallium/drivers/panfrost/pan_format.c +++ b/src/gallium/drivers/panfrost/pan_format.c @@ -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; + } +} diff --git a/src/gallium/drivers/panfrost/pan_format.h b/src/gallium/drivers/panfrost/pan_format.h index 4baac8a0e59..a881b3721ee 100644 --- a/src/gallium/drivers/panfrost/pan_format.h +++ b/src/gallium/drivers/panfrost/pan_format.h @@ -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 diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c index 75f8887ec6d..38b901a700d 100644 --- a/src/gallium/drivers/panfrost/pan_mfbd.c +++ b/src/gallium/drivers/panfrost/pan_mfbd.c @@ -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, diff --git a/src/gallium/drivers/panfrost/pan_sfbd.c b/src/gallium/drivers/panfrost/pan_sfbd.c index 9fa806a8a1a..dda8a68db76 100644 --- a/src/gallium/drivers/panfrost/pan_sfbd.c +++ b/src/gallium/drivers/panfrost/pan_sfbd.c @@ -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"); -- 2.30.2