From ccdc6b5913885866e100780bfd661672c9a5d23c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Apr 2010 19:23:40 +0100 Subject: llvmpipe: Fix rendering to non 32bpp formats. Tiled layout always used 32bpp, therefore linear/tiled strides are not related. --- src/gallium/drivers/llvmpipe/lp_texture.c | 12 ++++++++---- src/gallium/drivers/llvmpipe/lp_tile_image.c | 22 ++++++++-------------- src/gallium/drivers/llvmpipe/lp_tile_image.h | 8 ++++++-- 3 files changed, 22 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 336a4e4c016..f766ab2300a 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -991,14 +991,16 @@ llvmpipe_get_texture_image(struct llvmpipe_resource *lpr, x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE, lpr->base.format, - lpr->row_stride[level]); + lpr->row_stride[level], + lpr->tiles_per_row[level]); } else { lp_tiled_to_linear(other_data, target_data, x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE, lpr->base.format, - lpr->row_stride[level]); + lpr->row_stride[level], + lpr->tiles_per_row[level]); } } @@ -1087,7 +1089,8 @@ llvmpipe_get_texture_tile_linear(struct llvmpipe_resource *lpr, if (convert) { lp_tiled_to_linear(tiled_image, linear_image, x, y, TILE_SIZE, TILE_SIZE, lpr->base.format, - lpr->row_stride[level]); + lpr->row_stride[level], + lpr->tiles_per_row[level]); } if (new_layout != cur_layout) @@ -1135,7 +1138,8 @@ llvmpipe_get_texture_tile(struct llvmpipe_resource *lpr, if (convert) { lp_linear_to_tiled(linear_image, tiled_image, x, y, TILE_SIZE, TILE_SIZE, lpr->base.format, - lpr->row_stride[level]); + lpr->row_stride[level], + lpr->tiles_per_row[level]); } if (new_layout != cur_layout) diff --git a/src/gallium/drivers/llvmpipe/lp_tile_image.c b/src/gallium/drivers/llvmpipe/lp_tile_image.c index 0852150ba72..af3d1573270 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_image.c +++ b/src/gallium/drivers/llvmpipe/lp_tile_image.c @@ -122,14 +122,15 @@ tile_4_4_uint16(const uint16_t *src, uint16_t *dst, unsigned src_stride) /** * Convert a tiled image into a linear image. - * \param src_stride source row stride in bytes (bytes per row of tiles) * \param dst_stride dest row stride in bytes */ void lp_tiled_to_linear(const void *src, void *dst, unsigned x, unsigned y, unsigned width, unsigned height, - enum pipe_format format, unsigned dst_stride) + enum pipe_format format, + unsigned dst_stride, + unsigned tiles_per_row) { assert(x % TILE_SIZE == 0); assert(y % TILE_SIZE == 0); @@ -141,9 +142,7 @@ lp_tiled_to_linear(const void *src, void *dst, */ if (util_format_is_depth_or_stencil(format)) { const uint bpp = util_format_get_blocksize(format); - const uint src_stride = dst_stride * TILE_VECTOR_WIDTH; const uint tile_w = TILE_VECTOR_WIDTH, tile_h = TILE_VECTOR_HEIGHT; - const uint tiles_per_row = src_stride / (tile_w * tile_h * bpp); dst_stride /= bpp; /* convert from bytes to words */ @@ -191,8 +190,6 @@ lp_tiled_to_linear(const void *src, void *dst, const uint bpp = 4; const uint tile_w = TILE_SIZE, tile_h = TILE_SIZE; const uint bytes_per_tile = tile_w * tile_h * bpp; - const uint src_stride = dst_stride * tile_w; - const uint tiles_per_row = src_stride / bytes_per_tile; uint i, j; for (j = 0; j < height; j += tile_h) { @@ -215,13 +212,14 @@ lp_tiled_to_linear(const void *src, void *dst, /** * Convert a linear image into a tiled image. * \param src_stride source row stride in bytes - * \param dst_stride dest row stride in bytes (bytes per row of tiles) */ void lp_linear_to_tiled(const void *src, void *dst, unsigned x, unsigned y, unsigned width, unsigned height, - enum pipe_format format, unsigned src_stride) + enum pipe_format format, + unsigned src_stride, + unsigned tiles_per_row) { assert(x % TILE_SIZE == 0); assert(y % TILE_SIZE == 0); @@ -232,9 +230,7 @@ lp_linear_to_tiled(const void *src, void *dst, if (util_format_is_depth_or_stencil(format)) { const uint bpp = util_format_get_blocksize(format); - const uint dst_stride = src_stride * TILE_VECTOR_WIDTH; const uint tile_w = TILE_VECTOR_WIDTH, tile_h = TILE_VECTOR_HEIGHT; - const uint tiles_per_row = dst_stride / (tile_w * tile_h * bpp); src_stride /= bpp; /* convert from bytes to words */ @@ -281,8 +277,6 @@ lp_linear_to_tiled(const void *src, void *dst, const uint bpp = 4; const uint tile_w = TILE_SIZE, tile_h = TILE_SIZE; const uint bytes_per_tile = tile_w * tile_h * bpp; - const uint dst_stride = src_stride * tile_w; - const uint tiles_per_row = dst_stride / bytes_per_tile; uint i, j; for (j = 0; j < height; j += TILE_SIZE) { @@ -320,10 +314,10 @@ test_tiled_linear_conversion(void *data, /*unsigned tiled_stride = wt * TILE_SIZE * TILE_SIZE * 4;*/ lp_linear_to_tiled(data, tiled, 0, 0, width, height, format, - stride); + stride, wt); lp_tiled_to_linear(tiled, data, 0, 0, width, height, format, - stride); + stride, wt); free(tiled); } diff --git a/src/gallium/drivers/llvmpipe/lp_tile_image.h b/src/gallium/drivers/llvmpipe/lp_tile_image.h index d74621925d5..8de8efc6c16 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_image.h +++ b/src/gallium/drivers/llvmpipe/lp_tile_image.h @@ -33,14 +33,18 @@ void lp_tiled_to_linear(const void *src, void *dst, unsigned x, unsigned y, unsigned width, unsigned height, - enum pipe_format format, unsigned dst_stride); + enum pipe_format format, + unsigned dst_stride, + unsigned tiles_per_row); void lp_linear_to_tiled(const void *src, void *dst, unsigned x, unsigned y, unsigned width, unsigned height, - enum pipe_format format, unsigned src_stride); + enum pipe_format format, + unsigned src_stride, + unsigned tiles_per_row); void -- cgit v1.2.3