diff options
author | Neil Roberts <neil@linux.intel.com> | 2012-02-26 01:33:40 +0000 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2012-03-05 12:53:37 -0700 |
commit | 9664fb70dcda922295e5a2be8571c22bb3f879c3 (patch) | |
tree | e6763fcfc882ef69231cb860e81eb7e02f46284f | |
parent | a30809878f17c183a8c321fb7de6b42861725dbe (diff) |
mesa: Don't disable fast path for normalized types
Mesa has a fast path for the generic fallback when using glReadPixels
for RGBA data which uses memcpy. However it was really difficult to
hit this case because it would not be used if any transferOps are
enabled. Any type apart from floating point or non-normalized integer
types (so any of the common types) would force enabling clamping so
the fast path could not be used. This patch makes it ignore clamping
when determining whether to use the fast path if the data type of the
buffer is an unsigned normalized type because in that case clamping
will not have any effect anyway.
https://bugs.freedesktop.org/show_bug.cgi?id=46631
NOTE: This is a candidate for the 8.0 branch.
Signed-off-by: Brian Paul <brianp@vmware.com>
(cherry picked from commit d9c42097770f173804c7c7c40bf8bc6c4400673b)
-rw-r--r-- | src/mesa/main/readpix.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index c1489d21109..6f401f111dc 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -218,6 +218,16 @@ fast_read_rgba_pixels_memcpy( struct gl_context *ctx, return GL_FALSE; } + /* If the format is unsigned normalized then we can ignore clamping + * because the values are already in the range [0,1] so it won't + * have any effect anyway. + */ + if (_mesa_get_format_datatype(rb->Format) == GL_UNSIGNED_NORMALIZED) + transferOps &= ~IMAGE_CLAMP_BIT; + + if (transferOps) + return GL_FALSE; + dstStride = _mesa_image_row_stride(packing, width, format, type); dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, format, type, 0, 0); @@ -313,13 +323,11 @@ read_rgba_pixels( struct gl_context *ctx, transferOps |= IMAGE_CLAMP_BIT; } - if (!transferOps) { - /* Try the optimized paths first. */ - if (fast_read_rgba_pixels_memcpy(ctx, x, y, width, height, - format, type, pixels, packing, - transferOps)) { - return; - } + /* Try the optimized paths first. */ + if (fast_read_rgba_pixels_memcpy(ctx, x, y, width, height, + format, type, pixels, packing, + transferOps)) { + return; } slow_read_rgba_pixels(ctx, x, y, width, height, |