[12/12] panfrost: Make hacks a little more obvious

Submitted by Alyssa Rosenzweig on March 10, 2019, 6:50 a.m.

Details

Message ID 20190310065026.3994-13-alyssa@rosenzweig.io
State New
Headers show
Series "Refactors related to BO layouts" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Alyssa Rosenzweig March 10, 2019, 6:50 a.m.
To be clear, the layout switching voodoo is still a hack that needs to
be cleaned up. But that's a job as big as this patch series always-is,
so at least explain _why_ we're working counterintuitively.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
---
 src/gallium/drivers/panfrost/pan_resource.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 0f11b8e5e38..bf2e40e3086 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -212,12 +212,18 @@  panfrost_best_layout(const struct pipe_resource *rsrc)
                 PIPE_BIND_BLENDABLE;
 
         if (rsrc->bind & renderable_bind) {
-                /* TODO: AFBC */
-                return PAN_LINEAR;
-        } else if (rsrc->bind & PIPE_BIND_SAMPLER_VIEW) {
-                return PAN_TILED;
+                /* TODO: AFBC. Currently, on render we switch to AFBC. This is
+                 * a hack, but the correct solution (deferring layout selection
+                 * explicitly, switching upon any constrained use, shadowing if
+                 * necessary) is a lot more complex than needed right now. So
+                 * for now, pretend we're always regular textures;
+                 * set_framebuffer_state has a hack to flip on AFBC later if
+                 * strictly necessary */
         }
 
+        if (rsrc->bind & PIPE_BIND_SAMPLER_VIEW)
+                return PAN_TILED;
+
         /* If all else fails, we default to linear */
 
         return PAN_LINEAR;
@@ -253,7 +259,7 @@  panfrost_create_bo(struct panfrost_screen *screen, const struct pipe_resource *t
 
                 struct panfrost_memory mem;
 
-                unsigned pages = ((sz + 4095) / 4096) * 2;
+                unsigned pages = ((sz + 4095) / 4096);
                 screen->driver->allocate_slab(screen, &mem, pages, true, 0, 0, 0);
 
                 bo->cpu[0] = mem.cpu;