panfrost: Remove hint-based AFBC heuristic
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 11 Aug 2020 21:56:32 +0000 (17:56 -0400)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 12 Aug 2020 13:59:20 +0000 (09:59 -0400)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tested-by: Icecream95 <ixn@keemail.me>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6159>

src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_resource.c
src/gallium/drivers/panfrost/pan_resource.h

index 1e313c999dbe2b849ba24302c5bf8c3c5ab2c695..347111625f37d3d61ade22fe04e950f52bd406f2 100644 (file)
@@ -1115,39 +1115,12 @@ panfrost_set_shader_buffers(
                         buffers, start, count);
 }
 
-/* Hints that a framebuffer should use AFBC where possible */
-
-static void
-panfrost_hint_afbc(
-                struct panfrost_device *device,
-                const struct pipe_framebuffer_state *fb)
-{
-        /* AFBC implemenation incomplete; hide it */
-        if (!(device->debug & PAN_DBG_AFBC)) return;
-
-        /* Hint AFBC to the resources bound to each color buffer */
-
-        for (unsigned i = 0; i < fb->nr_cbufs; ++i) {
-                struct pipe_surface *surf = fb->cbufs[i];
-                struct panfrost_resource *rsrc = pan_resource(surf->texture);
-                panfrost_resource_hint_layout(device, rsrc, MALI_TEXTURE_AFBC, 1);
-        }
-
-        /* Also hint it to the depth buffer */
-
-        if (fb->zsbuf) {
-                struct panfrost_resource *rsrc = pan_resource(fb->zsbuf->texture);
-                panfrost_resource_hint_layout(device, rsrc, MALI_TEXTURE_AFBC, 1);
-        }
-}
-
 static void
 panfrost_set_framebuffer_state(struct pipe_context *pctx,
                                const struct pipe_framebuffer_state *fb)
 {
         struct panfrost_context *ctx = pan_context(pctx);
 
-        panfrost_hint_afbc(pan_device(pctx->screen), fb);
         util_copy_framebuffer_state(&ctx->pipe_framebuffer, fb);
         ctx->batch = NULL;
         panfrost_invalidate_frame(ctx);
index 8a9dd549d7bc32f770cf63052be453651c89f3be..0897e7ca7e76d944bb2ec8a8e61034e0be88869d 100644 (file)
@@ -847,68 +847,6 @@ panfrost_get_texture_address(
         return rsrc->bo->gpu + panfrost_texture_offset(rsrc->slices, is_3d, rsrc->cubemap_stride, level, face, sample);
 }
 
-/* Given a resource that has already been allocated, hint that it should use a
- * given layout. These are suggestions, not commands; it is perfectly legal to
- * stub out this function, but there will be performance implications. */
-
-void
-panfrost_resource_hint_layout(
-                struct panfrost_device *dev,
-                struct panfrost_resource *rsrc,
-                enum mali_texture_layout layout,
-                signed weight)
-{
-        /* Nothing to do, although a sophisticated implementation might store
-         * the hint */
-
-        if (rsrc->layout == layout)
-                return;
-
-        /* We don't use the weight yet, but we should check that it's positive
-         * (semantically meaning that we should choose the given `layout`) */
-
-        if (weight <= 0)
-                return;
-
-        /* Check if the preferred layout is legal for this buffer */
-
-        if (layout == MALI_TEXTURE_AFBC) {
-                bool can_afbc = panfrost_format_supports_afbc(rsrc->internal_format);
-                bool is_scanout = rsrc->base.bind &
-                        (PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_SHARED);
-
-                if (!can_afbc || is_scanout)
-                        return;
-        }
-
-        /* Simple heuristic so far: if the resource is uninitialized, switch to
-         * the hinted layout. If it is initialized, keep the original layout.
-         * This misses some cases where it would be beneficial to switch and
-         * blit. */
-
-        bool is_initialized = false;
-
-        for (unsigned i = 0; i < MAX_MIP_LEVELS; ++i)
-                is_initialized |= rsrc->slices[i].initialized;
-
-        if (is_initialized)
-                return;
-
-        /* We're uninitialized, so do a layout switch. Reinitialize slices. */
-
-        size_t new_size;
-        rsrc->layout = layout;
-        panfrost_setup_slices(rsrc, &new_size);
-
-        /* If we grew in size, reallocate the BO */
-        if (new_size > rsrc->bo->size) {
-                panfrost_bo_unreference(rsrc->bo);
-                rsrc->bo = panfrost_bo_create(dev, new_size, PAN_BO_DELAY_MMAP);
-        }
-
-        /* TODO: If there are textures bound, regenerate their descriptors */
-}
-
 static void
 panfrost_resource_set_stencil(struct pipe_resource *prsrc,
                               struct pipe_resource *stencil)
index 8f801473a0bdad9799eb616d905a229763595c16..31936d77d658c846ff2800fe39cf37e269f7bb49 100644 (file)
@@ -102,13 +102,6 @@ void panfrost_resource_screen_init(struct pipe_screen *screen);
 
 void panfrost_resource_context_init(struct pipe_context *pctx);
 
-void
-panfrost_resource_hint_layout(
-                struct panfrost_device *dev,
-                struct panfrost_resource *rsrc,
-                enum mali_texture_layout layout,
-                signed weight);
-
 /* Blitting */
 
 void