[Mesa-dev] [PATCH] mesa: Return 8 bits for GL_TEXTURE_RED_SIZE on RGTC formats.

Kenneth Graunke kenneth at whitecape.org
Wed Jun 6 20:19:46 CEST 2012


On 06/06/2012 06:43 AM, Brian Paul wrote:
> On 06/06/2012 07:35 AM, Brian Paul wrote:
>> On 06/06/2012 12:57 AM, Kenneth Graunke wrote:
>>> From the issues section of the GL_ARB_texture_compression_rgtc
>>> extension:
>>>
>>> 15) What should glGetTexLevelParameter return for
>>> GL_TEXTURE_GREEN_SIZE and GL_TEXTURE_BLUE_SIZE for the RGTC1
>>> formats? What should glGetTexLevelParameter return for
>>> GL_TEXTURE_BLUE_SIZE for the RGTC2 formats?
>>>
>>> RESOLVED: Zero bits.
>>>
>>> These formats always return 0.0 for these respective components
>>> and have no bits devoted to these components.
>>>
>>> Returning 8 bits for red size of RGTC1 and the red and green
>>> sizes of RGTC2 makes sense because that's the maximum potential
>>> precision for the uncompressed texels.
>>>
>>> Thus, we need to return 8 bits for GL_TEXTURE_RED_SIZE on all RGTC
>>> formats
>>> and 8 bits for GL_TEXTURE_GREEN_SIZE on RGTC2 formats. BLUE should
>>> be 0.
>>>
>>> Fixes oglconform/rgtc/advanced.texture_fetch.tex_param.
>>>
>>> Signed-off-by: Kenneth Graunke<kenneth at whitecape.org>
>>> ---
>>> src/mesa/main/formats.c | 8 ++++----
>>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
>>> index cecb70c..ccc0b17 100644
>>> --- a/src/mesa/main/formats.c
>>> +++ b/src/mesa/main/formats.c
>>> @@ -1319,7 +1319,7 @@ static struct gl_format_info
>>> format_info[MESA_FORMAT_COUNT] =
>>> "MESA_FORMAT_RED_RGTC1",
>>> GL_RED,
>>> GL_UNSIGNED_NORMALIZED,
>>> - 4, 0, 0, 0,
>>> + 8, 0, 0, 0,
>>> 0, 0, 0, 0, 0,
>>> 4, 4, 8 /* 8 bytes per 4x4 block */
>>> },
>>> @@ -1328,7 +1328,7 @@ static struct gl_format_info
>>> format_info[MESA_FORMAT_COUNT] =
>>> "MESA_FORMAT_SIGNED_RED_RGTC1",
>>> GL_RED,
>>> GL_SIGNED_NORMALIZED,
>>> - 4, 0, 0, 0,
>>> + 8, 0, 0, 0,
>>> 0, 0, 0, 0, 0,
>>> 4, 4, 8 /* 8 bytes per 4x4 block */
>>> },
>>> @@ -1337,7 +1337,7 @@ static struct gl_format_info
>>> format_info[MESA_FORMAT_COUNT] =
>>> "MESA_FORMAT_RG_RGTC2",
>>> GL_RG,
>>> GL_UNSIGNED_NORMALIZED,
>>> - 4, 4, 0, 0,
>>> + 8, 8, 0, 0,
>>> 0, 0, 0, 0, 0,
>>> 4, 4, 16 /* 16 bytes per 4x4 block */
>>> },
>>> @@ -1346,7 +1346,7 @@ static struct gl_format_info
>>> format_info[MESA_FORMAT_COUNT] =
>>> "MESA_FORMAT_SIGNED_RG_RGTC2",
>>> GL_RG,
>>> GL_SIGNED_NORMALIZED,
>>> - 4, 4, 0, 0,
>>> + 8, 8, 0, 0,
>>> 0, 0, 0, 0, 0,
>>> 4, 4, 16 /* 16 bytes per 4x4 block */
>>> },
>>
>> Reviewed-by: Brian Paul <brianp at vmware.com>
>>
>> We should also check the DXT formats too...
> 
> The s3tc extension spec doesn't say but the ARB_texture_compression spec
> says:
> 
> """
>     [...]  For texture
>     images with a compressed internal format, the resolutions returned
> specify
>     the component resolution of an uncompressed internal format that
> produces
>     an image of roughly the same quality as the compressed image in
> question.
>     Since the quality of the implementation's compression algorithm is
> likely
>     data-dependent, the returned component sizes should be treated only as
>     rough approximations.  ...
> """
> 
> NVIDIA's driver returns 8 for the size queries.  We return 4.  Want to
> fix those too?
> 
> -Brian

I just checked on my Radeon 3650 and discovered that it returns
something different:

COMPRESSED_RGB_S3TC_DXT1_EXT  - 5, 6, 5, 0
COMPRESSED_RGBA_S3TC_DXT1_EXT - 5, 6, 5, 1
COMPRESSED_RGBA_S3TC_DXT3_EXT - 5, 6, 5, 4
COMPRESSED_RGBA_S3TC_DXT5_EXT - 5, 6, 5, 8

If they both did 8, 8, 8, {0,8}, I'd definitely favor changing it.  But
I'm not sure there really is a right answer, so maybe ours is as good as
any?

(In case anyone wants to reproduce this, I've attached the patch I used
for testing; apply it to piglit, rebuild, and run
.bin/sized-texture-format-channels)
-------------- next part --------------
diff --git a/tests/util/sized-internalformats.c b/tests/util/sized-internalformats.c
index 6d8babc..0883958 100644
--- a/tests/util/sized-internalformats.c
+++ b/tests/util/sized-internalformats.c
@@ -172,6 +172,12 @@ const struct sized_internalformat sized_internalformats[] = {
 	FORMAT(GL_COMPRESSED_RED_RGTC1, UCMP, NONE, NONE, NONE, NONE, NONE, NONE, NONE),
 	FORMAT(GL_COMPRESSED_SIGNED_RED_RGTC1, SCMP, NONE, NONE, NONE, NONE, NONE, NONE, NONE),
 
+	/* S3TC */
+	FORMAT(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, UN8, UN8, UN8, NONE, NONE, NONE, NONE, NONE),
+	FORMAT(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, UN8, UN8, UN8, UN8, NONE, NONE, NONE, NONE),
+	FORMAT(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, UN8, UN8, UN8, UN8, NONE, NONE, NONE, NONE),
+	FORMAT(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, UN8, UN8, UN8, UN8, NONE, NONE, NONE, NONE),
+
 	{ GL_NONE },
 };
 


More information about the mesa-dev mailing list