diff options
author | Marek Olšák <[email protected]> | 2012-12-20 15:15:15 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2013-01-04 14:06:28 +0100 |
commit | ed86809ac9fe47c07be13ff0b998137f5f687635 (patch) | |
tree | c933882ac3943f984b54cc50dfda1a1ca0beff7e /src/mesa/state_tracker | |
parent | 85cb4f299d8a0a0ebc8fe14d0ccd327375eda99e (diff) |
st/mesa: fix CopyTexSubImage fallback for 1D array textures
- We should use a 3D transfer of size Width x 1 x NumLayers.
- We should use layer_stride instead of stride.
(even though they are likely to be equal with 1D array textures)
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_cb_texture.c | 40 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_texture.c | 11 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_texture.h | 8 |
3 files changed, 42 insertions, 17 deletions
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index c49ca493804..01ed0794583 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -201,7 +201,7 @@ st_MapTextureImage(struct gl_context *ctx, if (mode & GL_MAP_INVALIDATE_RANGE_BIT) pipeMode |= PIPE_TRANSFER_DISCARD_RANGE; - map = st_texture_image_map(st, stImage, slice, pipeMode, x, y, w, h); + map = st_texture_image_map(st, stImage, pipeMode, x, y, slice, w, h, 1); if (map) { *mapOut = map; *rowStrideOut = stImage->transfer->stride; @@ -762,6 +762,9 @@ fallback_copy_texsubimage(struct gl_context *ctx, GLvoid *texDest; enum pipe_transfer_usage transfer_usage; void *map; + unsigned dst_width = width; + unsigned dst_height = height; + unsigned dst_depth = 1; if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s: fallback processing\n", __FUNCTION__); @@ -770,6 +773,14 @@ fallback_copy_texsubimage(struct gl_context *ctx, srcY = strb->Base.Height - srcY - height; } + if (stImage->pt->target == PIPE_TEXTURE_1D_ARRAY) { + /* Move y/height to z/depth for 1D array textures. */ + destZ = destY; + destY = 0; + dst_depth = dst_height; + dst_height = 1; + } + map = pipe_transfer_map(pipe, strb->texture, strb->rtt_level, @@ -785,9 +796,9 @@ fallback_copy_texsubimage(struct gl_context *ctx, else transfer_usage = PIPE_TRANSFER_WRITE; - /* XXX this used to ignore destZ param */ - texDest = st_texture_image_map(st, stImage, destZ, transfer_usage, - destX, destY, width, height); + texDest = st_texture_image_map(st, stImage, transfer_usage, + destX, destY, destZ, + dst_width, dst_height, dst_depth); if (baseFormat == GL_DEPTH_COMPONENT || baseFormat == GL_DEPTH_STENCIL) { @@ -815,8 +826,16 @@ fallback_copy_texsubimage(struct gl_context *ctx, if (scaleOrBias) { _mesa_scale_and_bias_depth_uint(ctx, width, data); } - pipe_put_tile_z(stImage->transfer, texDest, 0, row, width, 1, - data); + + if (stImage->pt->target == PIPE_TEXTURE_1D_ARRAY) { + pipe_put_tile_z(stImage->transfer, + texDest + row*stImage->transfer->layer_stride, + 0, 0, width, 1, data); + } + else { + pipe_put_tile_z(stImage->transfer, texDest, 0, row, width, 1, + data); + } } } else { @@ -832,7 +851,7 @@ fallback_copy_texsubimage(struct gl_context *ctx, if (tempSrc && texDest) { const GLint dims = 2; - const GLint dstRowStride = stImage->transfer->stride; + GLint dstRowStride; struct gl_texture_image *texImage = &stImage->base; struct gl_pixelstore_attrib unpack = ctx->DefaultPacking; @@ -840,6 +859,13 @@ fallback_copy_texsubimage(struct gl_context *ctx, unpack.Invert = GL_TRUE; } + if (stImage->pt->target == PIPE_TEXTURE_1D_ARRAY) { + dstRowStride = stImage->transfer->layer_stride; + } + else { + dstRowStride = stImage->transfer->stride; + } + /* get float/RGBA image from framebuffer */ /* XXX this usually involves a lot of int/float conversion. * try to avoid that someday. diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 5a4dcaab229..ee4d7622d27 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -232,8 +232,9 @@ st_texture_match_image(const struct pipe_resource *pt, */ GLubyte * st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, - GLuint zoffset, enum pipe_transfer_usage usage, - GLuint x, GLuint y, GLuint w, GLuint h) + enum pipe_transfer_usage usage, + GLuint x, GLuint y, GLuint z, + GLuint w, GLuint h, GLuint d) { struct st_texture_object *stObj = st_texture_object(stImage->base.TexObject); @@ -249,9 +250,9 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, else level = stImage->base.Level; - return pipe_transfer_map(st->pipe, stImage->pt, level, - stImage->base.Face + zoffset, - usage, x, y, w, h, &stImage->transfer); + return pipe_transfer_map_3d(st->pipe, stImage->pt, level, usage, + x, y, z + stImage->base.Face, + w, h, d, &stImage->transfer); } diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 62e975bb457..8a701009a51 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -176,12 +176,10 @@ st_texture_match_image(const struct pipe_resource *pt, * well. */ extern GLubyte * -st_texture_image_map(struct st_context *st, - struct st_texture_image *stImage, - GLuint zoffset, +st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, enum pipe_transfer_usage usage, - unsigned x, unsigned y, - unsigned w, unsigned h); + GLuint x, GLuint y, GLuint z, + GLuint w, GLuint h, GLuint d); extern void st_texture_image_unmap(struct st_context *st, |