From: Ilia Mirkin Date: Wed, 9 Nov 2016 21:41:16 +0000 (-0500) Subject: swr: fix texture layout for compressed formats X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8c0f76e961ae023bbe7c8deed1abd04496e9691b;p=mesa.git swr: fix texture layout for compressed formats Fixes the texsubimage piglit and lets the copyteximage one get further. Signed-off-by: Ilia Mirkin Reviewed-by: Bruce Cherniak --- diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp index 6c0782a40d3..a5ab2362e55 100644 --- a/src/gallium/drivers/swr/swr_context.cpp +++ b/src/gallium/drivers/swr/swr_context.cpp @@ -157,8 +157,9 @@ swr_transfer_map(struct pipe_context *pipe, } } - unsigned offset = box->z * pt->layer_stride + box->y * pt->stride - + box->x * util_format_get_blocksize(format); + unsigned offset = box->z * pt->layer_stride + + util_format_get_nblocksy(format, box->y) * pt->stride + + util_format_get_stride(format, box->x); *transfer = pt; diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp index fa16edd1250..16a8bcf2c4a 100644 --- a/src/gallium/drivers/swr/swr_screen.cpp +++ b/src/gallium/drivers/swr/swr_screen.cpp @@ -796,8 +796,9 @@ swr_texture_layout(struct swr_screen *screen, res->alignedHeight = alignedHeight; } - res->row_stride[level] = alignedWidth * finfo.Bpp; - res->img_stride[level] = res->row_stride[level] * alignedHeight; + res->row_stride[level] = util_format_get_stride(fmt, alignedWidth); + res->img_stride[level] = + res->row_stride[level] * util_format_get_nblocksy(fmt, alignedHeight); res->mip_offsets[level] = total_size; if (pt->target == PIPE_TEXTURE_3D)