xserver: Branch 'master' - 4 commits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Mar 11 16:12:32 UTC 2019
glamor/glamor_copy.c | 8 ++++++--
glamor/glamor_picture.c | 4 +++-
glamor/glamor_prepare.c | 26 ++++++++++++++++++++++----
glamor/glamor_priv.h | 1 +
4 files changed, 32 insertions(+), 7 deletions(-)
New commits:
commit 8c4e8d9eff03cefc987f13c900b0a47403946127
Author: Paul Kocialkowski <paul.kocialkowski at bootlin.com>
Date: Mon Mar 4 11:52:43 2019 +0100
glamor: Fallback to system memory for RW PBO buffer allocation
We currently support two modes of operation for RW PBO buffers: one
that allocates a pack buffer with GL memory and one that uses system
memory when the former is not supported.
Since allocation with system memory is less likely to fail, add a
fallback to system memory when GL memory failed instead of bailing
out.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski at bootlin.com>
diff --git a/glamor/glamor_prepare.c b/glamor/glamor_prepare.c
index 6b35936fc..c1a611f9a 100644
--- a/glamor/glamor_prepare.c
+++ b/glamor/glamor_prepare.c
@@ -107,9 +107,10 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
glDeleteBuffers(1, &priv->pbo);
priv->pbo = 0;
- return FALSE;
}
- } else {
+ }
+
+ if (!priv->pbo) {
pixmap->devPrivate.ptr = xallocarray(pixmap->devKind,
pixmap->drawable.height);
if (!pixmap->devPrivate.ptr)
@@ -123,7 +124,7 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
RegionUninit(®ion);
- if (glamor_priv->has_rw_pbo) {
+ if (priv->pbo) {
if (priv->map_access == GLAMOR_ACCESS_RW)
gl_access = GL_READ_WRITE;
else
@@ -155,7 +156,7 @@ glamor_fini_pixmap(PixmapPtr pixmap)
if (!priv->prepared)
return;
- if (glamor_priv->has_rw_pbo) {
+ if (priv->pbo) {
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, priv->pbo);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
pixmap->devPrivate.ptr = NULL;
@@ -170,7 +171,7 @@ glamor_fini_pixmap(PixmapPtr pixmap)
RegionUninit(&priv->prepare_region);
- if (glamor_priv->has_rw_pbo) {
+ if (priv->pbo) {
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glDeleteBuffers(1, &priv->pbo);
priv->pbo = 0;
commit de6b3fac1f26075ce915006c914c4a4755617715
Author: Paul Kocialkowski <paul.kocialkowski at bootlin.com>
Date: Mon Mar 4 11:38:20 2019 +0100
glamor: Propagate glamor_prepare_access failures in copy helpers
glamor_prepare_access can fail for a few reasons, especially when
failing to allocate a PBO buffer. Take this in account and bail in
the copy helpers that call the helper when a failure happens.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski at bootlin.com>
diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c
index e050c0220..1ab2be6c0 100644
--- a/glamor/glamor_copy.c
+++ b/glamor/glamor_copy.c
@@ -221,7 +221,9 @@ glamor_copy_cpu_fbo(DrawablePtr src,
goto bail;
glamor_make_current(glamor_priv);
- glamor_prepare_access(src, GLAMOR_ACCESS_RO);
+
+ if (!glamor_prepare_access(src, GLAMOR_ACCESS_RO))
+ goto bail;
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_xoff, &dst_yoff);
@@ -309,7 +311,9 @@ glamor_copy_fbo_cpu(DrawablePtr src,
goto bail;
glamor_make_current(glamor_priv);
- glamor_prepare_access(dst, GLAMOR_ACCESS_RW);
+
+ if (!glamor_prepare_access(dst, GLAMOR_ACCESS_RW))
+ goto bail;
glamor_get_drawable_deltas(src, src_pixmap, &src_xoff, &src_yoff);
commit bc2e12239f86e5a4acd220744f42eb83ba55d328
Author: Paul Kocialkowski <paul.kocialkowski at bootlin.com>
Date: Mon Mar 4 11:47:11 2019 +0100
glamor: Error out on out-of-memory when allocating PBO for FBO access
Packed buffer allocation (which happens at glBufferData time with the
buffer bound) can fail when there is no GL memory left.
Pick up the error when it happens, print a proper error message, do
some cleanup and bail.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski at bootlin.com>
diff --git a/glamor/glamor_prepare.c b/glamor/glamor_prepare.c
index 5a73e6c7d..6b35936fc 100644
--- a/glamor/glamor_prepare.c
+++ b/glamor/glamor_prepare.c
@@ -88,10 +88,27 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
gl_usage = GL_STREAM_READ;
+ glamor_priv->suppress_gl_out_of_memory_logging = true;
+
glBindBuffer(GL_PIXEL_PACK_BUFFER, priv->pbo);
glBufferData(GL_PIXEL_PACK_BUFFER,
pixmap->devKind * pixmap->drawable.height, NULL,
gl_usage);
+
+ glamor_priv->suppress_gl_out_of_memory_logging = false;
+
+ if (glGetError() == GL_OUT_OF_MEMORY) {
+ if (!glamor_priv->logged_any_pbo_allocation_failure) {
+ LogMessageVerb(X_WARNING, 0, "glamor: Failed to allocate %d "
+ "bytes PBO due to GL_OUT_OF_MEMORY.\n",
+ pixmap->devKind * pixmap->drawable.height);
+ glamor_priv->logged_any_pbo_allocation_failure = true;
+ }
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
+ glDeleteBuffers(1, &priv->pbo);
+ priv->pbo = 0;
+ return FALSE;
+ }
} else {
pixmap->devPrivate.ptr = xallocarray(pixmap->devKind,
pixmap->drawable.height);
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 68cb24865..978749f54 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -288,6 +288,7 @@ typedef struct glamor_screen_private {
Bool suppress_gl_out_of_memory_logging;
Bool logged_any_fbo_allocation_failure;
+ Bool logged_any_pbo_allocation_failure;
/* xv */
glamor_program xv_prog;
commit c98c7709c67d8ed6b7455ec700a49b58c396ec2c
Author: Paul Kocialkowski <paul.kocialkowski at bootlin.com>
Date: Mon Mar 4 11:24:26 2019 +0100
glamor: Propagate FBO allocation failure for picture to texture upload
When uploading a picture to a texture, glamor_upload_picture_to_texture
calls glamor_pixmap_ensure_fbo to ensure that there is backing FBO.
The FBO will be allocated if the picture's drawable pixmap does not have
one already, which can fail when there is no GL memory left.
glamor_upload_picture_to_texture checks that the call succeeded and will
enter the failure path if it did not. However, unlike many other
functions in glamor, this one has ret set to TRUE initially, so it needs
to be set to FALSE when a failure happens.
Otherwise, the error is not propagated and the failure path return TRUE.
This leads to a fault when trying to access the FBO pointer later on.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski at bootlin.com>
diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 84a33ad6a..685d8d618 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -340,8 +340,10 @@ glamor_upload_picture_to_texture(PicturePtr picture)
else
iformat = format;
- if (!glamor_pixmap_ensure_fbo(pixmap, iformat, GLAMOR_CREATE_FBO_NO_FBO))
+ if (!glamor_pixmap_ensure_fbo(pixmap, iformat, GLAMOR_CREATE_FBO_NO_FBO)) {
+ ret = FALSE;
goto fail;
+ }
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
More information about the xorg-commit
mailing list