summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-01-28 03:31:06 -0800
committerJason Ekstrand <[email protected]>2015-01-30 18:56:56 -0800
commit5c31184cf5fe91d91d9d784a2f89b399a849a935 (patch)
treecb33ee4a59f175c462763ed5dc075f21ed5a2eac
parent837a4c42a6068d73e80055f6d9657358fb95068b (diff)
intel/pixel_read: Properly flip the results for window system buffers
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88841 Reviewed-by: Chad Versace <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/intel_pixel_read.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_pixel_read.c b/src/mesa/drivers/dri/i965/intel_pixel_read.c
index babf8ca0b18..15f9e38d2c0 100644
--- a/src/mesa/drivers/dri/i965/intel_pixel_read.c
+++ b/src/mesa/drivers/dri/i965/intel_pixel_read.c
@@ -155,6 +155,21 @@ intel_readpixels_tiled_memcpy(struct gl_context * ctx,
dst_pitch = _mesa_image_row_stride(pack, width, format, type);
+ /* For a window-system renderbuffer, the buffer is actually flipped
+ * vertically, so we need to handle that. Since the detiling function
+ * can only really work in the forwards direction, we have to be a
+ * little creative. First, we compute the Y-offset of the first row of
+ * the renderbuffer (in renderbuffer coordinates). We then match that
+ * with the last row of the client's data. Finally, we give
+ * tiled_to_linear a negative pitch so that it walks through the
+ * client's data backwards as it walks through the renderbufer forwards.
+ */
+ if (rb->Name == 0) {
+ yoffset = rb->Height - yoffset - height;
+ pixels += (ptrdiff_t) (height - 1) * dst_pitch;
+ dst_pitch = -dst_pitch;
+ }
+
/* We postponed printing this message until having committed to executing
* the function.
*/