summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2016-02-01 13:58:05 -0800
committerAdam Jackson <ajax@redhat.com>2016-03-10 11:12:42 -0500
commitee7ca670b1695d64bc12cb37302913acc066a569 (patch)
treea79556c2b23d6c6b1f3ee4378f6b22d9d6b0d098
parenta96c6d4658e3f386002f96eede660af3b01e5209 (diff)
glamor: Make sure that GLAMOR_MEMORY pixmaps don't retain an FBO.
glamor_composite_choose_shader() may upload our scratch pixmaps to get a Render operation completed. We don't want to hang onto GL memory for our scratch pixmaps, since we'll just have to reallocate them at a new w/h next time around, and the contents will be updated as well. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Eric Anholt <eric@anholt.net>
-rw-r--r--glamor/glamor_fbo.c1
-rw-r--r--glamor/glamor_picture.c13
-rw-r--r--glamor/glamor_render.c11
3 files changed, 18 insertions, 7 deletions
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index 5bfffe501..0bfc1ddfc 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -510,6 +510,7 @@ glamor_pixmap_destroy_fbo(PixmapPtr pixmap)
for (i = 0; i < priv->block_wcnt * priv->block_hcnt; i++)
glamor_destroy_fbo(glamor_priv, priv->fbo_array[i]);
free(priv->fbo_array);
+ priv->fbo_array = NULL;
}
else {
fbo = glamor_pixmap_detach_fbo(priv);
diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index e91461cc9..9bb2c748c 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -797,9 +797,10 @@ glamor_put_bits(char *dst_bits, int dst_stride, char *src_bits,
}
}
-/* Upload picture to texture. We may need to flip the y axis or
- * wire alpha to 1. So we may conditional create fbo for the picture.
- * */
+/**
+ * Uploads a picture based on a GLAMOR_MEMORY pixmap to a texture in a
+ * temporary FBO.
+ */
Bool
glamor_upload_picture_to_texture(PicturePtr picture)
{
@@ -810,9 +811,12 @@ glamor_upload_picture_to_texture(PicturePtr picture)
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
GLenum format, type;
int no_alpha, revert, swap_rb;
- glamor_pixmap_private *pixmap_priv;
+ glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
Bool force_clip;
+ assert(glamor_pixmap_is_memory(pixmap));
+ assert(!pixmap_priv->fbo);
+
if (glamor_get_tex_format_type_from_pixmap(pixmap,
picture->format,
&format,
@@ -825,7 +829,6 @@ glamor_upload_picture_to_texture(PicturePtr picture)
if (glamor_pixmap_upload_prepare(pixmap, format, no_alpha, revert, swap_rb))
return FALSE;
- pixmap_priv = glamor_get_pixmap_private(pixmap);
force_clip = glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP;
if (glamor_pixmap_priv_is_large(pixmap_priv) || force_clip) {
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index d47e7d729..65f7059a9 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -1125,7 +1125,7 @@ glamor_composite_with_shader(CARD8 op,
&key, &shader, &op_info,
&saved_source_format, ca_state)) {
glamor_fallback("glamor_composite_choose_shader failed\n");
- return ret;
+ goto fail;
}
if (ca_state == CA_TWO_PASS) {
if (!glamor_composite_choose_shader(PictOpAdd, source, mask, dest,
@@ -1135,7 +1135,7 @@ glamor_composite_with_shader(CARD8 op,
&key_ca, &shader_ca, &op_info_ca,
&saved_source_format, ca_state)) {
glamor_fallback("glamor_composite_choose_shader failed\n");
- return ret;
+ goto fail;
}
}
@@ -1267,6 +1267,13 @@ glamor_composite_with_shader(CARD8 op,
source->format = saved_source_format;
ret = TRUE;
+
+fail:
+ if (mask_pixmap && glamor_pixmap_is_memory(mask_pixmap))
+ glamor_pixmap_destroy_fbo(mask_pixmap);
+ if (source_pixmap && glamor_pixmap_is_memory(source_pixmap))
+ glamor_pixmap_destroy_fbo(source_pixmap);
+
return ret;
}