summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/panfrost/pan_afbc.c
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2019-06-21 14:54:44 -0700
committerAlyssa Rosenzweig <[email protected]>2019-06-25 13:39:17 -0700
commit3609b50a64430d9eaefd3473d9ad96910e87002c (patch)
tree5d1767cd8f1dbc3f03f8954ff5d37a14e63bbd0b /src/gallium/drivers/panfrost/pan_afbc.c
parentaea3f0ac1d1e281b5d2f2100acad87810ed309c0 (diff)
panfrost: Merge AFBC slab with BO backing
Rather than tracking AFBC memory "specially", just use the same codepath as linear and tiled. Less things to mess up, I figure. This allows us to use the standard setup_slices() call with AFBC resources, allowing mipmapped AFBC resources. Unfortunately, we do have to disable AFBC (and checksumming) in the meantime to avoid functional regressions, as we don't know _a priori_ if we'll need to access a resource from software (which is not yet hooked up with AFBC) and we don't yet have routines to switch the layout of a BO at runtime. Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/gallium/drivers/panfrost/pan_afbc.c')
-rw-r--r--src/gallium/drivers/panfrost/pan_afbc.c43
1 files changed, 7 insertions, 36 deletions
diff --git a/src/gallium/drivers/panfrost/pan_afbc.c b/src/gallium/drivers/panfrost/pan_afbc.c
index 5621d1f333a..c9487b5e943 100644
--- a/src/gallium/drivers/panfrost/pan_afbc.c
+++ b/src/gallium/drivers/panfrost/pan_afbc.c
@@ -101,22 +101,9 @@ panfrost_format_supports_afbc(enum pipe_format format)
return false;
}
-/* AFBC is enabled on a per-resource basis (AFBC enabling is theoretically
- * indepdent between color buffers and depth/stencil). To enable, we allocate
- * the AFBC metadata buffer and mark that it is enabled. We do -not- actually
- * edit the fragment job here. This routine should be called ONCE per
- * AFBC-compressed buffer, rather than on every frame. */
-
-void
-panfrost_enable_afbc(struct panfrost_context *ctx, struct panfrost_resource *rsrc, bool ds)
+unsigned
+panfrost_afbc_header_size(unsigned width, unsigned height)
{
- struct pipe_context *gallium = (struct pipe_context *) ctx;
- struct panfrost_screen *screen = pan_screen(gallium->screen);
-
- unsigned width = rsrc->base.width0;
- unsigned height = rsrc->base.height0;
- unsigned bytes_per_pixel = util_format_get_blocksize(rsrc->base.format);
-
/* Align to tile */
unsigned aligned_width = ALIGN(width, AFBC_TILE_WIDTH);
unsigned aligned_height = ALIGN(height, AFBC_TILE_HEIGHT);
@@ -126,26 +113,10 @@ panfrost_enable_afbc(struct panfrost_context *ctx, struct panfrost_resource *rsr
unsigned tile_count_y = aligned_height / AFBC_TILE_HEIGHT;
unsigned tile_count = tile_count_x * tile_count_y;
+ /* Multiply to find the header size */
unsigned header_bytes = tile_count * AFBC_HEADER_BYTES_PER_TILE;
- unsigned header_size = ALIGN(header_bytes, AFBC_CACHE_ALIGN);
-
- /* The stride is a normal stride, but aligned */
- unsigned unaligned_stride = aligned_width * bytes_per_pixel;
- unsigned stride = ALIGN(unaligned_stride, AFBC_CACHE_ALIGN);
-
- /* Compute the entire buffer size */
- unsigned body_size = stride * aligned_height;
- unsigned buffer_size = header_size + body_size;
-
- /* Allocate the AFBC slab itself, large enough to hold the above */
- panfrost_drm_allocate_slab(screen, &rsrc->bo->afbc_slab,
- ALIGN(buffer_size, 4096) / 4096,
- true, 0, 0, 0);
-
- /* Compressed textured reads use a tagged pointer to the metadata */
- rsrc->bo->layout = PAN_AFBC;
- rsrc->bo->gpu = rsrc->bo->afbc_slab.gpu | (ds ? 0 : 1);
- rsrc->bo->cpu = rsrc->bo->afbc_slab.cpu;
- rsrc->bo->gem_handle = rsrc->bo->afbc_slab.gem_handle;
- rsrc->bo->afbc_metadata_size = header_size;
+
+ /* Align and go */
+ return ALIGN(header_bytes, AFBC_CACHE_ALIGN);
+
}