[Mesa-dev] [PATCH 1/3] mesa: Add utility function to get base format from a GL compressed format

Ian Romanick idr at freedesktop.org
Sat Jul 23 13:15:24 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/23/2011 07:53 AM, Brian Paul wrote:
> On Sat, Jul 23, 2011 at 2:58 AM, Ian Romanick <idr at freedesktop.org> wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> ---
>>  src/mesa/main/texcompress.c |   63 +++++++++++++++++++++++++++++++++++++++++++
>>  src/mesa/main/texcompress.h |    3 ++
>>  2 files changed, 66 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
>> index d820ae9..4a8094f 100644
>> --- a/src/mesa/main/texcompress.c
>> +++ b/src/mesa/main/texcompress.c
>> @@ -40,6 +40,69 @@
>>
>>
>>  /**
>> + * Get the GL base format of a specified GL compressed texture format
>> + *
>> + * \return
>> + * The base format of \c format if \c format is a compressed format (either
>> + * generic or specific.  Otherwise 0 is returned.
>> + */
>> +GLenum
>> +_mesa_gl_compressed_format_base_format(GLenum format)
>> +{
>> +   switch (format) {
>> +   case GL_COMPRESSED_RGB:
>> +   case GL_COMPRESSED_SRGB:
>> +   case GL_COMPRESSED_RED:
>> +   case GL_COMPRESSED_RG:
>> +   case GL_COMPRESSED_RED_RGTC1:
>> +   case GL_COMPRESSED_SIGNED_RED_RGTC1:
>> +   case GL_COMPRESSED_RG_RGTC2:
>> +   case GL_COMPRESSED_SIGNED_RG_RGTC2:
>> +   case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
>> +   case GL_COMPRESSED_RGB_FXT1_3DFX:
>> +   case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
>> +      return GL_RGB;
> 
> I think these cases need to be split up to return GL_RED and GL_RG
> base formats.  The GL_ARB texture_rg extension defines those base
> formats so I'd assume that the glGetTexLevel query should return them

Arg.

The GL_ARB_texture_rg spec says:

    (Add the following to Table 3.17: "Generic and specific compressed
    internal formats")

    Compressed Internal Format      Base Internal Format    Type
    --------------------------      --------------------    ---------
    COMPRESSED_RED                  RED                     Generic
    COMPRESSED_RG                   RG                      Generic

But, the GL_ARB_texture_compression_rgtc spec says:

    Add to Table 3.17 (page 155):  Specific compressed internal formats

        Compressed Internal Format              Base Internal Format
        ---------------------------------       --------------------
        COMPRESSED_RED_RGTC1                    RGB
        COMPRESSED_SIGNED_RED_RGTC1             RGB
        COMPRESSED_RG_RGTC2              RGB
        COMPRESSED_SIGNED_RG_RGTC2       RGB

Some consistency would have been great.  I used the
GL_ARB_texture_compression_rgtc spec when I wrote the code and the
piglit test case.

The OpenGL 3.3 spec uses RED and RG for the specific compressed formats.
 I'll file a bug against the GL_ARB_texture_compression_rgtc spec (since
it doesn't match the 3.x core spec), and I'll update the patch.

> too.  Though, we should probably check what other vendors do.

I tested both NVIDIA and ATI.  They either return a specific compressed
format (correct if the texture was compressed), a generic compressed
format (wrong), or a sized non-compressed format (wrong).  I haven't
tested Apple, so they might do the right thing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk4rK9wACgkQX1gOwKyEAw8VtwCeIdfgbz/yuvFE2yAppczVWDrl
YwQAn06p1GQog9k3M0Kx3AGpadiq7Y/I
=Qsua
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list