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>
This commit is contained in:
Eric Anholt 2016-02-01 13:58:05 -08:00 committed by Adam Jackson
parent a96c6d4658
commit ee7ca670b1
3 changed files with 18 additions and 7 deletions

View File

@ -510,6 +510,7 @@ glamor_pixmap_destroy_fbo(PixmapPtr pixmap)
for (i = 0; i < priv->block_wcnt * priv->block_hcnt; i++) for (i = 0; i < priv->block_wcnt * priv->block_hcnt; i++)
glamor_destroy_fbo(glamor_priv, priv->fbo_array[i]); glamor_destroy_fbo(glamor_priv, priv->fbo_array[i]);
free(priv->fbo_array); free(priv->fbo_array);
priv->fbo_array = NULL;
} }
else { else {
fbo = glamor_pixmap_detach_fbo(priv); fbo = glamor_pixmap_detach_fbo(priv);

View File

@ -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 Bool
glamor_upload_picture_to_texture(PicturePtr picture) 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); glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
GLenum format, type; GLenum format, type;
int no_alpha, revert, swap_rb; int no_alpha, revert, swap_rb;
glamor_pixmap_private *pixmap_priv; glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
Bool force_clip; Bool force_clip;
assert(glamor_pixmap_is_memory(pixmap));
assert(!pixmap_priv->fbo);
if (glamor_get_tex_format_type_from_pixmap(pixmap, if (glamor_get_tex_format_type_from_pixmap(pixmap,
picture->format, picture->format,
&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)) if (glamor_pixmap_upload_prepare(pixmap, format, no_alpha, revert, swap_rb))
return FALSE; return FALSE;
pixmap_priv = glamor_get_pixmap_private(pixmap);
force_clip = glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP; force_clip = glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP;
if (glamor_pixmap_priv_is_large(pixmap_priv) || force_clip) { if (glamor_pixmap_priv_is_large(pixmap_priv) || force_clip) {

View File

@ -1125,7 +1125,7 @@ glamor_composite_with_shader(CARD8 op,
&key, &shader, &op_info, &key, &shader, &op_info,
&saved_source_format, ca_state)) { &saved_source_format, ca_state)) {
glamor_fallback("glamor_composite_choose_shader failed\n"); glamor_fallback("glamor_composite_choose_shader failed\n");
return ret; goto fail;
} }
if (ca_state == CA_TWO_PASS) { if (ca_state == CA_TWO_PASS) {
if (!glamor_composite_choose_shader(PictOpAdd, source, mask, dest, 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, &key_ca, &shader_ca, &op_info_ca,
&saved_source_format, ca_state)) { &saved_source_format, ca_state)) {
glamor_fallback("glamor_composite_choose_shader failed\n"); 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; source->format = saved_source_format;
ret = TRUE; 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; return ret;
} }