asahi: Force linear for SHARED buffers with no/implicit modifier
authorAsahi Lina <lina@asahilina.net>
Sat, 29 Jul 2023 11:05:35 +0000 (20:05 +0900)
committerMarge Bot <emma+marge@anholt.net>
Fri, 11 Aug 2023 20:31:27 +0000 (20:31 +0000)
Consumers might not pass through the modifier information in this case.

Fixes XWayland/mutter using dma-buf v4 feedback (though the fact they
try to use implicit modifiers is likely a bug on their end, and will
decrease performance).

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

src/gallium/drivers/asahi/agx_pipe.c

index 81c0c66..07a4047 100644 (file)
@@ -483,11 +483,12 @@ agx_select_best_modifier(const struct agx_resource *pres)
    if (agx_linear_allowed(pres) && pres->base.usage == PIPE_USAGE_STAGING)
       return DRM_FORMAT_MOD_LINEAR;
 
-   /* For SCANOUT resources with no explicit modifier selection, assume we need
-    * linear.
+   /* For SCANOUT or SHARED resources with no explicit modifier selection, force
+    * linear since we cannot expect consumers to correctly pass through the
+    * modifier (unless linear is not allowed at all).
     */
-   if (pres->base.bind & PIPE_BIND_SCANOUT) {
-      assert(agx_linear_allowed(pres));
+   if (agx_linear_allowed(pres) &&
+       pres->base.bind & (PIPE_BIND_SCANOUT | PIPE_BIND_SHARED)) {
       return DRM_FORMAT_MOD_LINEAR;
    }