<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Nov 6, 2017 at 1:30 PM, Louis-Francis Ratté-Boulianne <span dir="ltr"><<a href="mailto:lfrb@collabora.com" target="_blank">lfrb@collabora.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Using modifier might allow the driver to use a more optimal format<br>
(e.g. tiled/compressed). Let's try to use those if possible.<br>
<br>
Signed-off-by: Louis-Francis Ratté-Boulianne <<a href="mailto:lfrb@collabora.com">lfrb@collabora.com</a>><br>
---<br>
 glamor/glamor_egl.c           | 44 ++++++++++++++++++++++++++++++<wbr>++++++++-----<br>
 hw/xwayland/xwayland-glamor.c | 22 +++++++++++++++++++---<br>
 2 files changed, 58 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c<br>
index bcf36cf9b..fdda56c04 100644<br>
--- a/glamor/glamor_egl.c<br>
+++ b/glamor/glamor_egl.c<br>
@@ -270,13 +270,47 @@ glamor_make_pixmap_exportable(<wbr>PixmapPtr pixmap)<br>
         return FALSE;<br>
     }<br>
<br>
-    bo = gbm_bo_create(glamor_egl->gbm, width, height,<br>
-                       GBM_FORMAT_ARGB8888,<br>
+#ifdef GBM_BO_WITH_MODIFIERS<br>
+    if (glamor_egl->dmabuf_capable) {<br>
+        uint32_t num_modifiers;<br>
+        uint64_t *modifiers = NULL;<br>
+        int i, j;<br>
+<br>
+        glamor_get_modifiers(screen, DRM_FORMAT_ARGB8888,<br>
+                             &num_modifiers, &modifiers);<br>
+<br>
+        /* Filter out multi-plane modifiers */<br>
+        for (i = num_modifiers - 1; i >= 0; i--) {<br>
+            if (gbm_device_get_format_<wbr>modifier_plane_count(glamor_<wbr>egl->gbm,<br>
+                                                           DRM_FORMAT_ARGB8888,<br>
+                                                           modifiers[i]) == 1)<br>
+                continue;<br>
+            for (j = i + 1; j < num_modifiers; j++)<br>
+                modifiers[j - 1] = modifiers[j];<br>
+            num_modifiers--;<br>
+        }<br></blockquote><div><br></div><div>I was browsing through your branch today and was confused by this.  Why are we filtering out multi-planar formats in glamor?  The only time we need to filter out multi-planr formats is when we will be doing front-buffer rendering on a surface that is actively being scanned out.  It should be safe to front-buffer render to multi-planar images that are shared with a compositor because it's unlikely that the 3D engine will race with itself.  This is causing X to disable compression internally for the temporary pixmaps that get handed off to the compositor which is not what we want.  If you did this to fix corruption you may have seen when using a compositor, that would be because we have a nasty texture_from_pixmap bug in mesa related to CCS that I'm currently in the process of fixing.  Patches should be incoming before the end of the week.<br></div><div><br></div><div>There are some theoretical ways this could get messed up if the kernel is preempting too aggressively, but I think it will be ok.  If we do see a problem, then I think we can do something in mesa where we disable preemption whenever texturing from a pixmap or something like that.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+        if (num_modifiers == 0 && modifiers) {<br>
+            free(modifiers);<br>
+            modifiers = NULL;<br>
+        }<br>
+<br>
+        bo = gbm_bo_create_with_modifiers(<wbr>glamor_egl->gbm, width, height,<br>
+                                          GBM_FORMAT_ARGB8888,<br>
+                                          modifiers, num_modifiers);<br>
+        free(modifiers);<br>
+    }<br>
+    else<br>
+#endif<br>
+    {<br>
+        bo = gbm_bo_create(glamor_egl->gbm, width, height,<br>
+                GBM_FORMAT_ARGB8888,<br>
 #ifdef GLAMOR_HAS_GBM_LINEAR<br>
-                       (pixmap->usage_hint == CREATE_PIXMAP_USAGE_SHARED ?<br>
-                        GBM_BO_USE_LINEAR : 0) |<br>
+                (pixmap->usage_hint == CREATE_PIXMAP_USAGE_SHARED ?<br>
+                 GBM_BO_USE_LINEAR : 0) |<br>
 #endif<br>
-                       GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);<br>
+                GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);<br>
+    }<br>
+<br>
     if (!bo) {<br>
         xf86DrvMsg(scrn->scrnIndex, X_ERROR,<br>
                    "Failed to make %dx%dx%dbpp GBM bo\n",<br>
diff --git a/hw/xwayland/xwayland-glamor.<wbr>c b/hw/xwayland/xwayland-glamor.<wbr>c<br>
index e3a7f6b5b..40772fb9a 100644<br>
--- a/hw/xwayland/xwayland-glamor.<wbr>c<br>
+++ b/hw/xwayland/xwayland-glamor.<wbr>c<br>
@@ -226,14 +226,30 @@ xwl_glamor_create_pixmap(<wbr>ScreenPtr screen,<br>
 {<br>
     struct xwl_screen *xwl_screen = xwl_screen_get(screen);<br>
     struct gbm_bo *bo;<br>
+    uint32_t format;<br>
<br>
     if (width > 0 && height > 0 && depth >= 15 &&<br>
         (hint == 0 ||<br>
          hint == CREATE_PIXMAP_USAGE_BACKING_<wbr>PIXMAP ||<br>
          hint == CREATE_PIXMAP_USAGE_SHARED)) {<br>
-        bo = gbm_bo_create(xwl_screen->gbm, width, height,<br>
-                           gbm_format_for_depth(depth),<br>
-                           GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);<br>
+        format = gbm_format_for_depth(depth);<br>
+<br>
+#ifdef GBM_BO_WITH_MODIFIERS<br>
+        if (xwl_screen->dmabuf_capable) {<br>
+            uint32_t num_modifiers;<br>
+            uint64_t *modifiers = NULL;<br>
+<br>
+            glamor_get_modifiers(screen, format, &num_modifiers, &modifiers);<br>
+            bo = gbm_bo_create_with_modifiers(<wbr>xwl_screen->gbm, width, height,<br>
+                                              format, modifiers, num_modifiers);<br>
+            free(modifiers);<br>
+        }<br>
+        else<br>
+#endif<br>
+        {<br>
+            bo = gbm_bo_create(xwl_screen->gbm, width, height, format,<br>
+                               GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);<br>
+        }<br>
<br>
         if (bo)<br>
             return xwl_glamor_create_pixmap_for_<wbr>bo(screen, bo, depth);<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.13.0<br>
<br>
______________________________<wbr>_________________<br>
<a href="mailto:xorg-devel@lists.x.org">xorg-devel@lists.x.org</a>: X.Org development<br>
Archives: <a href="http://lists.x.org/archives/xorg-devel" rel="noreferrer" target="_blank">http://lists.x.org/archives/<wbr>xorg-devel</a><br>
Info: <a href="https://lists.x.org/mailman/listinfo/xorg-devel" rel="noreferrer" target="_blank">https://lists.x.org/mailman/<wbr>listinfo/xorg-devel</a></font></span></blockquote></div><br></div></div>