summaryrefslogtreecommitdiff
path: root/cogl/cogl-texture.c
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2012-03-22 11:40:16 +0000
committerNeil Roberts <neil@linux.intel.com>2012-04-05 13:51:56 +0100
commitec5009fa23b11f9df9ffeead7bdf0de3fa12cd07 (patch)
tree962cf3c8eed7599a056ebd38ce96fc08cf09a71f /cogl/cogl-texture.c
parentd54111795fee3fd0618c448c5279f2421396a154 (diff)
downloadcogl-ec5009fa23b11f9df9ffeead7bdf0de3fa12cd07.tar.gz
Use GL_PACK_ALIGNMENT of 1 whenever possible
The Intel driver currently has an optimisation when calling glReadPixels into a PBO so that it will use a blit instead of the Mesa fallback path. However this only works if the GL_PACK_ALIGNMENT is exactly 1, even if this would be equivalent to a higher alignment value because the bpp*width is already aligned. To make it more likely to hit this fast path, we now detect this situation and explicitly use an alignment of 1. To make this work the texture driver needs to be passed down the bpp*width as well as the rowstride when configuring the alignment. Reviewed-by: Robert Bragg <robert@linux.intel.com>
Diffstat (limited to 'cogl/cogl-texture.c')
-rw-r--r--cogl/cogl-texture.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index 26173451..29489838 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -274,12 +274,29 @@ _cogl_texture_prep_gl_alignment_for_pixels_upload (int pixels_rowstride)
}
void
-_cogl_texture_prep_gl_alignment_for_pixels_download (int pixels_rowstride)
+_cogl_texture_prep_gl_alignment_for_pixels_download (int bpp,
+ int width,
+ int rowstride)
{
+ int alignment;
+
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
- GE( ctx, glPixelStorei (GL_PACK_ALIGNMENT,
- calculate_alignment (pixels_rowstride)) );
+ /* If no padding is needed then we can always use an alignment of 1.
+ * We want to do this even though it is equivalent to the alignment
+ * of the rowstride because the Intel driver in Mesa currently has
+ * an optimisation when reading data into a PBO that only works if
+ * the alignment is exactly 1.
+ *
+ * https://bugs.freedesktop.org/show_bug.cgi?id=46632
+ */
+
+ if (rowstride == bpp * width)
+ alignment = 1;
+ else
+ alignment = calculate_alignment (rowstride);
+
+ GE( ctx, glPixelStorei (GL_PACK_ALIGNMENT, alignment) );
}
/* FIXME: wrap modes should be set on pipelines not textures */