panfrost: Skip shading unaffected tiles
[mesa.git] / src / gallium / drivers / panfrost / pan_tiler.c
index 22482ff1f916144d78ca6befa8a3e158e009a16f..18ab14d9bab5cd473551bb02aea8029499cdf4d6 100644 (file)
@@ -254,3 +254,38 @@ panfrost_tiler_header_size(unsigned width, unsigned height, uint8_t mask)
 
         return panfrost_raw_header_size(width, height, masked_count);
 }
+
+/* The body seems to be about 512 bytes per tile. Noting that the header is
+ * about 8 bytes per tile, we can be a little sloppy and estimate the body size
+ * to be equal to the header size * (512/8). Given the header size is a
+ * considerable overestimate, this is fine. Eventually, we should maybe figure
+ * out how to actually implement this. */
+
+unsigned
+panfrost_tiler_body_size(unsigned width, unsigned height, uint8_t mask)
+{
+        unsigned header_size = panfrost_tiler_header_size(width, height, mask);
+        return ALIGN_POT(header_size * 512 / 8, 512);
+}
+
+
+/* In the future, a heuristic to choose a tiler hierarchy mask would go here.
+ * At the moment, we just default to 0xFF, which enables all possible hierarchy
+ * levels. Overall this yields good performance but presumably incurs a cost in
+ * memory bandwidth / power consumption / etc, at least on smaller scenes that
+ * don't really need all the smaller levels enabled */
+
+unsigned
+panfrost_choose_hierarchy_mask(
+                unsigned width, unsigned height,
+                unsigned vertex_count)
+{
+        /* If there is no geometry, we don't bother enabling anything */
+
+        if (!vertex_count)
+                return 0x00;
+
+        /* Otherwise, default everything on. TODO: Proper tests */
+
+        return 0xFF;
+}