Commit bc2e1223 authored by Paul Kocialkowski's avatar Paul Kocialkowski
Browse files

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's avatarPaul Kocialkowski <paul.kocialkowski@bootlin.com>
parent c98c7709
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment