panfrost: Align linear renderable resources
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 6 Jun 2019 21:36:41 +0000 (14:36 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 10 Jun 2019 13:48:07 +0000 (06:48 -0700)
It's just -easier- to render to aligned framebuffers. For winsys
targets, we already align, but even for an internal linear FBO we ought
to align everything nicely.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_resource.c

index ef0a3ba1d9f6dee5e7f81d17d43208cf256bc57b..bce3426fd67fe9bc723520690fbd92f5905d7c15 100644 (file)
@@ -183,6 +183,15 @@ panfrost_setup_slices(const struct pipe_resource *tmpl, struct panfrost_bo *bo)
         unsigned height = tmpl->height0;
         unsigned bytes_per_pixel = util_format_get_blocksize(tmpl->format);
 
+        /* Tiled operates blockwise; linear is packed. Also, anything
+         * we render to has to be tile-aligned. Maybe not strictly
+         * necessary, but we're not *that* pressed for memory and it
+         * makes code a lot simpler */
+
+        bool renderable = tmpl->bind & PIPE_BIND_RENDER_TARGET;
+        bool tiled = bo->layout == PAN_TILED;
+        bool should_align = renderable || tiled;
+
         unsigned offset = 0;
 
         for (unsigned l = 0; l <= tmpl->last_level; ++l) {
@@ -191,9 +200,7 @@ panfrost_setup_slices(const struct pipe_resource *tmpl, struct panfrost_bo *bo)
                 unsigned effective_width = width;
                 unsigned effective_height = height;
 
-                /* Tiled operates blockwise; linear is packed */
-
-                if (bo->layout == PAN_TILED) {
+                if (should_align) {
                         effective_width = ALIGN(effective_width, 16);
                         effective_height = ALIGN(effective_height, 16);
                 }