xserver: Branch 'server-1.20-branch' - 3 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 21 23:26:59 UTC 2020


 glamor/glamor.c                   |   15 +++++++++++++++
 glamor/glamor.h                   |    3 +++
 glamor/glamor_fbo.c               |   12 ++++++++++++
 glamor/glamor_priv.h              |    1 +
 hw/xwayland/xwayland-glamor-gbm.c |    6 +++++-
 hw/xwayland/xwayland.c            |   28 +++++++++++++++++++++++++---
 6 files changed, 61 insertions(+), 4 deletions(-)

New commits:
commit 94dad4f05133171805ee94095bbcd20ece754eba
Author: Dor Askayo <dor.askayo at gmail.com>
Date:   Wed Feb 19 17:22:11 2020 +0100

    xwayland: clear pixmaps after creation in rootless mode
    
    When a pixmap is created with a backing FBO, the FBO should be cleared
    to avoid rendering uninitialized memory. This could happen when the
    pixmap is rendered without being filled in its entirety.
    
    One example is when a top-level window without a background is
    resized. The pixmap would be reallocated to prepare for more pixels,
    but uninitialized memory would be rendered in the resize offset until
    the client sends a frame that fills these additional pixels.
    
    Another example is when a new top-level window is created without a
    background. Uninitialized memory would be rendered after the pixmap is
    allocated and before the client sends its first frame.
    
    This issue is only apparent in OpenGL implementations that don't zero
    the VRAM of allocated buffers by default, such as RadeonSI.
    
    Signed-off-by: Dor Askayo <dor.askayo at gmail.com>
    Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/636
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>
    (cherry picked from commit 0e9a0c203c2ae4eae12bdbb95428f398211c7bee)
    
    [ Michel Dänzer:
    * Squashed in commit ebf549db2d9341d99e0d0847b948dd798d98f7dc
    * Dropped code related to glamor_format, which only exists on master ]

diff --git a/glamor/glamor.c b/glamor/glamor.c
index a6cc798f8..abefef614 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -128,6 +128,21 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
     glamor_pixmap_attach_fbo(pixmap, fbo);
 }
 
+_X_EXPORT void
+glamor_clear_pixmap(PixmapPtr pixmap)
+{
+    ScreenPtr screen = pixmap->drawable.pScreen;
+    glamor_screen_private *glamor_priv;
+    glamor_pixmap_private *pixmap_priv;
+
+    glamor_priv = glamor_get_screen_private(screen);
+    pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+    assert(pixmap_priv->fbo != NULL);
+
+    glamor_pixmap_clear_fbo(glamor_priv, pixmap_priv->fbo);
+}
+
 uint32_t
 glamor_get_pixmap_texture(PixmapPtr pixmap)
 {
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 3f9d265db..be04bf858 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -115,6 +115,9 @@ extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap,
 
 extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap,
                                              glamor_pixmap_type_t type);
+
+extern _X_EXPORT void glamor_clear_pixmap(PixmapPtr pixmap);
+
 extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
 
 extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index e8c4330b3..f939a6c2f 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -239,6 +239,18 @@ glamor_create_fbo_array(glamor_screen_private *glamor_priv,
     return NULL;
 }
 
+void
+glamor_pixmap_clear_fbo(glamor_screen_private *glamor_priv, glamor_pixmap_fbo *fbo)
+{
+    glamor_make_current(glamor_priv);
+
+    assert(fbo->fb != 0 && fbo->tex != 0);
+
+    glamor_set_destination_pixmap_fbo(glamor_priv, fbo, 0, 0, fbo->width, fbo->height);
+    glClearColor(0.0, 0.0, 0.0, 0.0);
+    glClear(GL_COLOR_BUFFER_BIT);
+}
+
 glamor_pixmap_fbo *
 glamor_pixmap_detach_fbo(glamor_pixmap_private *pixmap_priv)
 {
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 1686ef5a4..4353a99f1 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -539,6 +539,7 @@ void glamor_destroy_fbo(glamor_screen_private *glamor_priv,
                         glamor_pixmap_fbo *fbo);
 void glamor_pixmap_destroy_fbo(PixmapPtr pixmap);
 Bool glamor_pixmap_fbo_fixup(ScreenPtr screen, PixmapPtr pixmap);
+void glamor_pixmap_clear_fbo(glamor_screen_private *glamor_priv, glamor_pixmap_fbo *fbo);
 
 /* Return whether 'picture' is alpha-only */
 static inline Bool glamor_picture_is_alpha(PicturePtr picture)
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index febc0b910..c02ba7363 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -242,8 +242,12 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen,
         if (bo) {
             pixmap = xwl_glamor_gbm_create_pixmap_for_bo(screen, bo, depth);
 
-            if (!pixmap)
+            if (!pixmap) {
                 gbm_bo_destroy(bo);
+            }
+            else if (xwl_screen->rootless && hint == CREATE_PIXMAP_USAGE_BACKING_PIXMAP) {
+                glamor_clear_pixmap(pixmap);
+            }
         }
     }
 
commit 0238359bced17f9db0e266111897d154ab117d68
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Fri Feb 7 12:15:07 2020 +0100

    xwayland: Call glamor_block_handler from xwl_screen_post_damage
    
    In between the two phases introduced by the previous change. This makes
    sure all pending drawing to the new buffers is flushed before they're
    committed to the Wayland server.
    (cherry picked from commit a542224ea28e2e8ccaf5e0df85bf6c603e97599a)

diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index de35a5af0..d3a4684d2 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -43,6 +43,10 @@
 _X_EXPORT Bool noXFree86VidModeExtension;
 #endif
 
+#ifdef XWL_HAS_GLAMOR
+#include <glamor.h>
+#endif
+
 void
 ddxGiveUp(enum ExitCode error)
 {
@@ -850,6 +854,13 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen)
     if (xorg_list_is_empty(&commit_window_list))
         return;
 
+#ifdef XWL_HAS_GLAMOR
+    if (xwl_screen->glamor &&
+        xwl_screen->egl_backend == &xwl_screen->gbm_backend) {
+        glamor_block_handler(xwl_screen->screen);
+    }
+#endif
+
     xorg_list_for_each_entry_safe(xwl_window, next_xwl_window,
                                   &commit_window_list, link_damage) {
         wl_surface_commit(xwl_window->surface);
commit a93bce6bfc6c610676a7fbc76639854c5553cb2c
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Fri Feb 7 12:06:39 2020 +0100

    xwayland: Split up xwl_screen_post_damage into two phases
    
    The first phase sets the new surface properties for all damaged
    windows, then the second phase commits all surface updates.
    
    This is preparatory for the next change, there should be no observable
    change in behaviour (other than the order of Wayland protocol
    requests).
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    (cherry picked from commit f88d9b1f779835302e02e255fcd45989db7f488d)

diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 324c68ccf..de35a5af0 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -816,16 +816,16 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
     xwl_window->frame_callback = wl_surface_frame(xwl_window->surface);
     wl_callback_add_listener(xwl_window->frame_callback, &frame_listener, xwl_window);
 
-    wl_surface_commit(xwl_window->surface);
     DamageEmpty(window_get_damage(xwl_window->window));
-
-    xorg_list_del(&xwl_window->link_damage);
 }
 
 static void
 xwl_screen_post_damage(struct xwl_screen *xwl_screen)
 {
     struct xwl_window *xwl_window, *next_xwl_window;
+    struct xorg_list commit_window_list;
+
+    xorg_list_init(&commit_window_list);
 
     xorg_list_for_each_entry_safe(xwl_window, next_xwl_window,
                                   &xwl_screen->damage_window_list, link_damage) {
@@ -843,6 +843,17 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen)
 #endif
 
         xwl_window_post_damage(xwl_window);
+        xorg_list_del(&xwl_window->link_damage);
+        xorg_list_append(&xwl_window->link_damage, &commit_window_list);
+    }
+
+    if (xorg_list_is_empty(&commit_window_list))
+        return;
+
+    xorg_list_for_each_entry_safe(xwl_window, next_xwl_window,
+                                  &commit_window_list, link_damage) {
+        wl_surface_commit(xwl_window->surface);
+        xorg_list_del(&xwl_window->link_damage);
     }
 }
 


More information about the xorg-commit mailing list