aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorTomeu Vizoso <[email protected]>2019-11-18 09:59:17 +0100
committerTomeu Vizoso <[email protected]>2019-11-20 08:03:36 +0100
commit409f6c40ca524262e5c626996b2fb874c1085595 (patch)
tree4592f3c5d0175ce2cc6c828ded2ae384b5b7910d /src/gallium
parent697f02c2a135d4356f0d09b383310957540e8d7d (diff)
panfrost: Rework buffers in SFBD
Support cases such as depth-only renders and only set stencil buffers when needed, to match the blob's behaviour. Signed-off-by: Tomeu Vizoso <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/panfrost/pan_sfbd.c79
1 files changed, 39 insertions, 40 deletions
diff --git a/src/gallium/drivers/panfrost/pan_sfbd.c b/src/gallium/drivers/panfrost/pan_sfbd.c
index 3fe462ee37d..9bbc875d98a 100644
--- a/src/gallium/drivers/panfrost/pan_sfbd.c
+++ b/src/gallium/drivers/panfrost/pan_sfbd.c
@@ -158,43 +158,40 @@ panfrost_sfbd_set_zsbuf(
struct pipe_surface *surf)
{
struct panfrost_resource *rsrc = pan_resource(surf->texture);
+ struct panfrost_context *ctx = pan_context(surf->context);
unsigned level = surf->u.tex.level;
assert(surf->u.tex.first_layer == 0);
- if (rsrc->layout == PAN_LINEAR) {
- if (panfrost_is_z24s8_variant(surf->format)) {
+ if (rsrc->layout != PAN_LINEAR)
+ unreachable("Invalid render layout.");
- 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;
+ /* No stencil? Job done. */
+ if (!ctx->depth_stencil || !ctx->depth_stencil->stencil[0].enabled)
+ return;
- } else if (surf->format == PIPE_FORMAT_Z32_UNORM ||
- surf->format == PIPE_FORMAT_Z32_FLOAT) {
+ if (panfrost_is_z24s8_variant(surf->format)) {
- fb->depth_buffer = rsrc->bo->gpu + rsrc->slices[level].offset;
- fb->depth_stride = rsrc->slices[level].stride;
+ /* Stencil data is interleaved with depth */
+ fb->stencil_buffer = fb->depth_buffer;
+ fb->stencil_stride = fb->depth_stride;
+ } else if (surf->format == PIPE_FORMAT_Z32_UNORM ||
+ surf->format == PIPE_FORMAT_Z32_FLOAT) {
- } else if (surf->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) {
+ /* No stencil, nothing to do */
+ } 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;
+ /* Stencil data in separate buffer */
+ struct panfrost_resource *stencil = rsrc->separate_stencil;
+ struct panfrost_slice stencil_slice = stencil->slices[level];
- 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");
- assert(0);
- }
+ fb->stencil_buffer = stencil->bo->gpu + stencil_slice.offset;
+ fb->stencil_stride = stencil_slice.stride;
+ } else
+ unreachable("Unsupported depth/stencil format.");
}
/* Creates an SFBD for the FRAGMENT section of the bound framebuffer */
@@ -207,8 +204,22 @@ panfrost_sfbd_fragment(struct panfrost_batch *batch, bool has_draws)
panfrost_sfbd_clear(batch, &fb);
/* SFBD does not support MRT natively; sanity check */
- assert(batch->key.nr_cbufs == 1);
- panfrost_sfbd_set_cbuf(&fb, batch->key.cbufs[0]);
+ assert(batch->key.nr_cbufs <= 1);
+ if (batch->key.nr_cbufs) {
+ struct pipe_surface *surf = batch->key.cbufs[0];
+ struct panfrost_resource *rsrc = pan_resource(surf->texture);
+ struct panfrost_bo *bo = rsrc->bo;
+
+ panfrost_sfbd_set_cbuf(&fb, surf);
+
+ if (rsrc->checksummed) {
+ unsigned level = surf->u.tex.level;
+ struct panfrost_slice *slice = &rsrc->slices[level];
+
+ fb.checksum_stride = slice->checksum_stride;
+ fb.checksum = bo->gpu + slice->checksum_offset;
+ }
+ }
if (batch->key.zsbuf)
panfrost_sfbd_set_zsbuf(&fb, batch->key.zsbuf);
@@ -218,17 +229,5 @@ panfrost_sfbd_fragment(struct panfrost_batch *batch, bool has_draws)
fb.format.unk2 |= MALI_SFBD_FORMAT_MSAA_B;
}
- struct pipe_surface *surf = batch->key.cbufs[0];
- struct panfrost_resource *rsrc = pan_resource(surf->texture);
- struct panfrost_bo *bo = rsrc->bo;
-
- if (rsrc->checksummed) {
- unsigned level = surf->u.tex.level;
- struct panfrost_slice *slice = &rsrc->slices[level];
-
- fb.checksum_stride = slice->checksum_stride;
- fb.checksum = bo->gpu + slice->checksum_offset;
- }
-
return panfrost_upload_transient(batch, &fb, sizeof(fb)) | MALI_SFBD;
}