diff options
author | Ilia Mirkin <[email protected]> | 2014-09-13 18:14:46 -0400 |
---|---|---|
committer | Ilia Mirkin <[email protected]> | 2014-09-25 22:15:49 -0400 |
commit | d78b533c29bcd607c5e2d8b51aec6a0da50a3b5b (patch) | |
tree | b035c185fe56d29190342842964c87b02c443f64 /src/mesa/drivers/dri/nouveau | |
parent | 0147c10c5f00b43696ba660aab604d674a75e83c (diff) |
nouveau: fix glCompressedTexImage
mesa_texstore expects pixel data, not compressed data. For compressed
textures, we want to just copy the bits in without any conversion.
Signed-off-by: Ilia Mirkin <[email protected]>
Acked-by: Francisco Jerez <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/nouveau')
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_texture.c | 65 |
1 files changed, 52 insertions, 13 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c index 4626cc30229..dc5699c7680 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c @@ -413,6 +413,31 @@ get_teximage_placement(struct gl_texture_image *ti) } static void +nouveau_compressed_copy(struct gl_context *ctx, GLint dims, + struct gl_texture_image *ti, + GLsizei width, GLsizei height, GLsizei depth, + const GLvoid *src, GLvoid *dst, int row_stride) +{ + struct compressed_pixelstore store; + int i; + + _mesa_compute_compressed_pixelstore(dims, ti->TexFormat, + width, height, depth, + &ctx->Unpack, &store); + + src += store.SkipBytes; + + assert(store.CopySlices == 1); + + /* copy rows of blocks */ + for (i = 0; i < store.CopyRowsPerSlice; i++) { + memcpy(dst, src, store.CopyBytesPerRow); + dst += row_stride; + src += store.TotalBytesPerRow; + } +} + +static void nouveau_teximage(struct gl_context *ctx, GLint dims, struct gl_texture_image *ti, GLsizei imageSize, @@ -451,13 +476,19 @@ nouveau_teximage(struct gl_context *ctx, GLint dims, GL_MAP_WRITE_BIT, &map, &row_stride); - ret = _mesa_texstore(ctx, dims, ti->_BaseFormat, - ti->TexFormat, - row_stride, - &map, - ti->Width, ti->Height, depth, - format, type, pixels, packing); - assert(ret); + if (compressed) { + nouveau_compressed_copy(ctx, dims, ti, + ti->Width, ti->Height, depth, + pixels, map, row_stride); + } else { + ret = _mesa_texstore(ctx, dims, ti->_BaseFormat, + ti->TexFormat, + row_stride, + &map, + ti->Width, ti->Height, depth, + format, type, pixels, packing); + assert(ret); + } nouveau_unmap_texture_image(ctx, ti, 0); _mesa_unmap_teximage_pbo(ctx, packing); @@ -502,7 +533,8 @@ static GLboolean nouveau_teximage_alloc(struct gl_context *ctx, struct gl_texture_image *ti) { nouveau_teximage(ctx, 3, ti, 0, 0, 0, NULL, - &ctx->DefaultPacking, GL_FALSE); + &ctx->DefaultPacking, + _mesa_is_format_compressed(ti->TexFormat)); return GL_TRUE; } @@ -535,11 +567,18 @@ nouveau_texsubimage(struct gl_context *ctx, GLint dims, xoffset, yoffset, width, height, GL_MAP_WRITE_BIT, &map, &row_stride); - ret = _mesa_texstore(ctx, dims, ti->_BaseFormat, ti->TexFormat, - row_stride, &map, - width, height, depth, - format, type, pixels, packing); - assert(ret); + if (compressed) { + nouveau_compressed_copy(ctx, dims, ti, + width, height, depth, + pixels, map, row_stride); + } else { + ret = _mesa_texstore(ctx, dims, ti->_BaseFormat, + ti->TexFormat, + row_stride, &map, + width, height, depth, + format, type, pixels, packing); + assert(ret); + } nouveau_unmap_texture_image(ctx, ti, 0); _mesa_unmap_teximage_pbo(ctx, packing); |