* [PATCH] nouveau: fix glCompressedTexImage
@ 2014-09-13 22:16 Ilia Mirkin
[not found] ` <1410646604-29966-1-git-send-email-imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Ilia Mirkin @ 2014-09-13 22:16 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
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 <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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] nouveau: fix glCompressedTexImage
[not found] ` <1410646604-29966-1-git-send-email-imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
@ 2014-09-14 7:37 ` Francisco Jerez
[not found] ` <87oauitzxq.fsf-sGOZH3hwPm2sTnJN9+BGXg@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Francisco Jerez @ 2014-09-14 7:37 UTC (permalink / raw)
To: Ilia Mirkin, nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
[-- 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nouveau: fix glCompressedTexImage
[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>
0 siblings, 1 reply; 4+ messages in thread
From: Ilia Mirkin @ 2014-09-14 12:41 UTC (permalink / raw)
To: Francisco Jerez; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
On Sun, Sep 14, 2014 at 3:37 AM, Francisco Jerez <currojerez-sGOZH3hwPm2sTnJN9+BGXg@public.gmane.org> wrote:
> 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?
Hmmm... no reason that I can think of off-hand -- nor do I see one for
not using the default _mesa_store_*image... Perhaps there was before
the AllocTextureImageBuffer thing existed?
>
>> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nouveau: fix glCompressedTexImage
[not found] ` <CAKb7UvgMFpUvgivRACp5_87MBcNaiT4f8JPJTiAEPhDGMtJYPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-09-25 2:26 ` Ilia Mirkin
0 siblings, 0 replies; 4+ messages in thread
From: Ilia Mirkin @ 2014-09-25 2:26 UTC (permalink / raw)
To: Francisco Jerez; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
On Sun, Sep 14, 2014 at 8:41 AM, Ilia Mirkin <imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org> wrote:
> On Sun, Sep 14, 2014 at 3:37 AM, Francisco Jerez <currojerez-sGOZH3hwPm2sTnJN9+BGXg@public.gmane.org> wrote:
>> 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?
>
> Hmmm... no reason that I can think of off-hand -- nor do I see one for
> not using the default _mesa_store_*image... Perhaps there was before
> the AllocTextureImageBuffer thing existed?
Hrmph, well, *actually* testing it, it doesn't work, neither for
Tex*Image nor for CompressedTex*Image. No idea why, and quite frankly
don't feel like investigating. I'm going to check this in as-is. I
suspect the reason points to a more general fail within the driver,
since it _ought_ to work. Perhaps it has to do with the context
dirtying/validate_teximage calls?
>
>>
>>> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-09-25 2:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
[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
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.