From: Francisco Jerez <currojerez-sGOZH3hwPm2sTnJN9+BGXg@public.gmane.org>
To: Ilia Mirkin <imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>,
nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH] nouveau: fix glCompressedTexImage
Date: Sun, 14 Sep 2014 10:37:53 +0300 [thread overview]
Message-ID: <87oauitzxq.fsf@riseup.net> (raw)
In-Reply-To: <1410646604-29966-1-git-send-email-imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
[-- Attachment #1.1.1: Type: text/plain, Size: 3852 bytes --]
Ilia Mirkin <imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org> writes:
> mesa_texstore expects pixel data, not compressed data. For compressed
> textures, we want to just copy the bits in without any conversion.
>
Any reason we cannot use _mesa_store_compressed_*image for this instead
of rolling our own?
> Signed-off-by: Ilia Mirkin <imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
> ---
> src/mesa/drivers/dri/nouveau/nouveau_texture.c | 65 ++++++++++++++++++++------
> 1 file 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 4626cc3..dc5699c 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);
> --
> 1.8.5.5
[-- Attachment #1.2: Type: application/pgp-signature, Size: 212 bytes --]
[-- Attachment #2: Type: text/plain, Size: 181 bytes --]
_______________________________________________
Nouveau mailing list
Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
next prev parent reply other threads:[~2014-09-14 7:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-13 22:16 [PATCH] nouveau: fix glCompressedTexImage Ilia Mirkin
[not found] ` <1410646604-29966-1-git-send-email-imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
2014-09-14 7:37 ` Francisco Jerez [this message]
[not found] ` <87oauitzxq.fsf-sGOZH3hwPm2sTnJN9+BGXg@public.gmane.org>
2014-09-14 12:41 ` Ilia Mirkin
[not found] ` <CAKb7UvgMFpUvgivRACp5_87MBcNaiT4f8JPJTiAEPhDGMtJYPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-25 2:26 ` Ilia Mirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87oauitzxq.fsf@riseup.net \
--to=currojerez-sgozh3hwpm2stnjn9+bgxg@public.gmane.org \
--cc=imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org \
--cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.