summaryrefslogtreecommitdiff
path: root/glamor/glamor.c
diff options
context:
space:
mode:
authorDor Askayo <dor.askayo@gmail.com>2019-11-07 12:25:42 +0100
committerMichel Dänzer <mdaenzer@redhat.com>2019-11-07 12:25:42 +0100
commit0e9a0c203c2ae4eae12bdbb95428f398211c7bee (patch)
tree391e08c2caea55cc197a3119509f555f61167aa8 /glamor/glamor.c
parenta506b4ecb6c54fd0388e628520eec75ea3bcb27c (diff)
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@gmail.com> Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/636 Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Diffstat (limited to 'glamor/glamor.c')
-rw-r--r--glamor/glamor.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/glamor/glamor.c b/glamor/glamor.c
index 4b935de59..4d6a8394e 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -129,6 +129,23 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
return TRUE;
}
+_X_EXPORT void
+glamor_clear_pixmap(PixmapPtr pixmap)
+{
+ ScreenPtr screen = pixmap->drawable.pScreen;
+ glamor_screen_private *glamor_priv;
+ glamor_pixmap_private *pixmap_priv;
+ const struct glamor_format *pixmap_format;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ pixmap_format = glamor_format_for_pixmap(pixmap);
+
+ assert(pixmap_priv->fbo != NULL);
+
+ glamor_pixmap_clear_fbo(glamor_priv, pixmap_priv->fbo, pixmap_format);
+}
+
uint32_t
glamor_get_pixmap_texture(PixmapPtr pixmap)
{
@@ -781,6 +798,9 @@ glamor_init(ScreenPtr screen, unsigned int flags)
epoxy_has_gl_extension("GL_NV_pack_subimage");
glamor_priv->has_dual_blend =
epoxy_has_gl_extension("GL_ARB_blend_func_extended");
+ glamor_priv->has_clear_texture =
+ epoxy_gl_version() >= 44 ||
+ epoxy_has_gl_extension("GL_ARB_clear_texture");
glamor_priv->can_copyplane = (gl_version >= 30);