lima: Fix lima_screen_query_dmabuf_modifiers()
authorRoman Stratiienko <r.stratiienko@gmail.com>
Sun, 26 Jul 2020 03:37:57 +0000 (06:37 +0300)
committerMarge Bot <eric+marge@anholt.net>
Tue, 4 Aug 2020 13:58:33 +0000 (13:58 +0000)
Incorrect implementation has been found during code surfing.
v3d implementation used for reference.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Reviewed-by: Icenowy Zheng <icenowy@aosc.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6076>

src/gallium/drivers/lima/lima_screen.c

index 1a6ff22dc447526029edf52a5216f39518418fa8..9118212cc609dec99168c272c47b92c052a757a5 100644 (file)
@@ -440,15 +440,18 @@ lima_screen_query_dmabuf_modifiers(struct pipe_screen *pscreen,
       DRM_FORMAT_MOD_LINEAR,
    };
 
+   int num_modifiers = ARRAY_SIZE(available_modifiers);
+
    if (!modifiers) {
-      *count = ARRAY_SIZE(available_modifiers);
+      *count = num_modifiers;
       return;
    }
 
+   *count = MIN2(max, num_modifiers);
    for (int i = 0; i < *count; i++) {
       modifiers[i] = available_modifiers[i];
       if (external_only)
-         external_only = false;
+         external_only[i] = false;
    }
 }