asahi: Allow explicit non-LINEAR modifiers for scanout
authorAsahi Lina <lina@asahilina.net>
Wed, 5 Apr 2023 12:42:14 +0000 (21:42 +0900)
committerMarge Bot <emma+marge@anholt.net>
Fri, 7 Apr 2023 03:23:04 +0000 (03:23 +0000)
The compositor is responsible for picking the right supported modifiers
for scanout. If we get no modifiers, we have to assume linear, but if we
do, just roll with it and don't attempt to force things.

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

src/gallium/drivers/asahi/agx_pipe.c

index 08360cb..cc29a79 100644 (file)
@@ -372,8 +372,7 @@ static bool
 agx_twiddled_allowed(const struct agx_resource *pres)
 {
    /* Certain binds force linear */
-   if (pres->base.bind &
-       (PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_LINEAR))
+   if (pres->base.bind & (PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_LINEAR))
       return false;
 
    /* Buffers must be linear */
@@ -464,6 +463,14 @@ 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.
+    */
+   if (pres->base.bind & PIPE_BIND_SCANOUT) {
+      assert(agx_linear_allowed(pres));
+      return DRM_FORMAT_MOD_LINEAR;
+   }
+
    if (agx_twiddled_allowed(pres)) {
       if (agx_compression_allowed(pres))
          return DRM_FORMAT_MOD_APPLE_TWIDDLED_COMPRESSED;