panfrost: Cleanup tiling selection logic
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Sat, 4 Jan 2020 18:00:50 +0000 (13:00 -0500)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 6 Jan 2020 12:49:53 +0000 (07:49 -0500)
Make it a lot more obvious what we're doing and fix more than a few
corner cases in the process.

Fixes
dEQP-GLES3.functional.buffer.map.write.render_as_index_array.pixel*, and
likely others.

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

index 0d49d2bb4f76fb6e9e1e97bc90ace656a4499d40..0ea14a028cdda57370d63deb809d3ca90d773579 100644 (file)
@@ -389,28 +389,29 @@ panfrost_resource_create_bo(struct panfrost_screen *screen, struct panfrost_reso
          * AFBC: Compressed and renderable (so always desirable for non-scanout
          * rendertargets). Cheap to sample from. The format is black box, so we
          * can't read/write from software.
-         */
-
-        /* Tiling textures is almost always faster, unless we only use it once */
-
-        bool is_texture = (res->bind & PIPE_BIND_SAMPLER_VIEW);
-        bool is_2d = res->depth0 == 1 && res->array_size == 1;
-        bool is_streaming = (res->usage != PIPE_USAGE_STREAM);
-        bool is_global = res->bind & PIPE_BIND_GLOBAL;
+         *
+         * Tiling textures is almost always faster, unless we only use it once.
+         * Only a few types of resources can be tiled, ensure the bind is only
+         * (a combination of) one of the following */
 
-        bool should_tile = is_streaming && is_texture && is_2d && !is_global;
+        const unsigned valid_binding =
+                PIPE_BIND_RENDER_TARGET |
+                PIPE_BIND_BLENDABLE |
+                PIPE_BIND_SAMPLER_VIEW |
+                PIPE_BIND_DISPLAY_TARGET;
 
-        /* Depth/stencil can't be tiled, only linear or AFBC */
-        should_tile &= !(res->bind & PIPE_BIND_DEPTH_STENCIL);
+        bool is_2d = (res->target == PIPE_TEXTURE_2D);
+        bool should_tile = (res->usage != PIPE_USAGE_STREAM);
+        bool can_tile = is_2d && ((res->bind & ~valid_binding) == 0);
 
         /* FBOs we would like to checksum, if at all possible */
-        bool can_checksum = !(res->bind & (PIPE_BIND_SCANOUT | PIPE_BIND_SHARED));
+        bool can_checksum = !(res->bind & ~valid_binding);
         bool should_checksum = res->bind & PIPE_BIND_RENDER_TARGET;
 
         pres->checksummed = can_checksum && should_checksum;
 
         /* Set the layout appropriately */
-        pres->layout = should_tile ? PAN_TILED : PAN_LINEAR;
+        pres->layout = (can_tile && should_tile) ? PAN_TILED : PAN_LINEAR;
 
         size_t bo_size;