mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
st/mesa: fix compressed mipmap generation.
If the underlying transfer had a stride wider for hw alignment reasons,
the mipmap generation would generate badly strided images.
this fixes a few problems I found while testing r600g with s3tc
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit fdb4373a20 by Marek)
This fixes the DXT1 tests from fbo-generatemipmap-formats on some drivers.
This commit is contained in:
parent
39865f5c46
commit
08c47e4851
1 changed files with 4 additions and 6 deletions
|
|
@ -114,13 +114,12 @@ st_render_mipmap(struct st_context *st,
|
|||
static void
|
||||
decompress_image(enum pipe_format format,
|
||||
const uint8_t *src, uint8_t *dst,
|
||||
unsigned width, unsigned height)
|
||||
unsigned width, unsigned height, unsigned src_stride)
|
||||
{
|
||||
const struct util_format_description *desc = util_format_description(format);
|
||||
const uint bw = util_format_get_blockwidth(format);
|
||||
const uint bh = util_format_get_blockheight(format);
|
||||
const uint dst_stride = 4 * MAX2(width, bw);
|
||||
const uint src_stride = util_format_get_stride(format, width);
|
||||
|
||||
desc->unpack_rgba_8unorm(dst, dst_stride, src, src_stride, width, height);
|
||||
|
||||
|
|
@ -153,10 +152,9 @@ decompress_image(enum pipe_format format,
|
|||
static void
|
||||
compress_image(enum pipe_format format,
|
||||
const uint8_t *src, uint8_t *dst,
|
||||
unsigned width, unsigned height)
|
||||
unsigned width, unsigned height, unsigned dst_stride)
|
||||
{
|
||||
const struct util_format_description *desc = util_format_description(format);
|
||||
const uint dst_stride = util_format_get_stride(format, width);
|
||||
const uint src_stride = 4 * width;
|
||||
|
||||
desc->pack_rgba_8unorm(dst, dst_stride, src, src_stride, width, height);
|
||||
|
|
@ -245,7 +243,7 @@ fallback_generate_mipmap(struct gl_context *ctx, GLenum target,
|
|||
dstTemp = malloc(dstWidth2 * dstHeight2 * comps + 000);
|
||||
|
||||
/* decompress the src image: srcData -> srcTemp */
|
||||
decompress_image(format, srcData, srcTemp, srcWidth, srcHeight);
|
||||
decompress_image(format, srcData, srcTemp, srcWidth, srcHeight, srcTrans->stride);
|
||||
|
||||
_mesa_generate_mipmap_level(target, datatype, comps,
|
||||
0 /*border*/,
|
||||
|
|
@ -257,7 +255,7 @@ fallback_generate_mipmap(struct gl_context *ctx, GLenum target,
|
|||
dstWidth2); /* stride in texels */
|
||||
|
||||
/* compress the new image: dstTemp -> dstData */
|
||||
compress_image(format, dstTemp, dstData, dstWidth, dstHeight);
|
||||
compress_image(format, dstTemp, dstData, dstWidth, dstHeight, dstTrans->stride);
|
||||
|
||||
free(srcTemp);
|
||||
free(dstTemp);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue