From f91823f026fc5996f9b2ffa1dc48573810f1e4fd Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 19 Apr 2013 14:00:22 -0700 Subject: swrast: Make a teximage's stored RowStride be in terms of bytes per row. For hardware drivers with pitch alignment requirements, a non-power-of-two-sized texture format won't end up being an integer number of pixels per row. Also, avoids having to change our units between MapTextureImage's rowStride and swrast's RowStride. This doesn't fully convert the compressed texel fetch path, but does make sure we don't drop any bits (not that we'd expect to). Reviewed-by: Kenneth Graunke Reviewed-by: Brian Paul --- src/mesa/swrast/s_texfetch.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/mesa/swrast/s_texfetch.c') diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c index a9bc3fad0a2..f6c269d8baf 100644 --- a/src/mesa/swrast/s_texfetch.c +++ b/src/mesa/swrast/s_texfetch.c @@ -98,8 +98,16 @@ static void fetch_compressed(const struct swrast_texture_image *swImage, GLint i, GLint j, GLint k, GLfloat *texel) { + /* The FetchCompressedTexel function takes an integer pixel rowstride, + * while the image's rowstride is bytes per row of blocks. + */ + GLuint bw, bh; + GLuint texelBytes = _mesa_get_format_bytes(swImage->Base.TexFormat); + _mesa_get_format_block_size(swImage->Base.TexFormat, &bw, &bh); + assert(swImage->RowStride * bw % texelBytes == 0); + swImage->FetchCompressedTexel(swImage->ImageSlices[k], - swImage->RowStride, + swImage->RowStride * bw / texelBytes, i, j, texel); } -- cgit v1.2.3