summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2016-06-23 22:27:40 -0400
committerIlia Mirkin <[email protected]>2016-06-24 09:53:13 -0400
commit3f0fa3b32dec4aed3ee3fb95ac7b53cbf4af3091 (patch)
tree6e2d644ffb85eb10b0072fb3e23f31477b0b37e8 /src
parent0da890e62cf14fef273500491d14fb8d980fe452 (diff)
st/mesa: don't assume that the whole surface gets mapped
Under some circumstances, the driver may choose to return a temporary surface instead of a pointer to the original. Make sure to pass the actual view volume to be mapped to the transfer function rather than adjusting the map pointer after-the-fact. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 99d9cd59b0f..8eb839d16a9 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -406,7 +406,7 @@ st_ReadPixels(struct gl_context *ctx, GLint x, GLint y,
unsigned bind = PIPE_BIND_TRANSFER_READ;
struct pipe_transfer *tex_xfer;
ubyte *map = NULL;
- bool window;
+ int dst_x, dst_y;
/* Validate state (to be sure we have up-to-date framebuffer surfaces)
* and flush the bitmap cache prior to reading. */
@@ -483,7 +483,8 @@ st_ReadPixels(struct gl_context *ctx, GLint x, GLint y,
st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP,
width, height, format, src_format, dst_format);
if (dst) {
- window = false;
+ dst_x = x;
+ dst_y = y;
} else {
/* See if the texture format already matches the format and type,
* in which case the memcpy-based fast path will likely be used and
@@ -500,23 +501,21 @@ st_ReadPixels(struct gl_context *ctx, GLint x, GLint y,
if (!dst)
goto fallback;
- window = true;
+ dst_x = 0;
+ dst_y = 0;
}
/* map resources */
pixels = _mesa_map_pbo_dest(ctx, pack, pixels);
map = pipe_transfer_map_3d(pipe, dst, 0, PIPE_TRANSFER_READ,
- 0, 0, 0, width, height, 1, &tex_xfer);
+ dst_x, dst_y, 0, width, height, 1, &tex_xfer);
if (!map) {
_mesa_unmap_pbo_dest(ctx, pack);
pipe_resource_reference(&dst, NULL);
goto fallback;
}
- if (!window)
- map += y * tex_xfer->stride + x * util_format_get_blocksize(dst_format);
-
/* memcpy data into a user buffer */
{
const uint bytesPerRow = width * util_format_get_blocksize(dst_format);