[Mesa-dev] [PATCH] mesa: fix glGet size queries for L/LA/I color buffers

Marek Olšák maraeo at gmail.com
Mon Mar 10 15:13:59 PDT 2014


I only read the compatibility spec.

Marek

On Mon, Mar 10, 2014 at 11:04 PM, Ian Romanick <idr at freedesktop.org> wrote:
> On 03/04/2014 03:32 AM, Marek Olšák wrote:
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> There is no API for returning the number of luminance and intensity bits and
>> the 3.3 spec doesn't seem to specify any behavior for the queries if the format
>> is one of L, LA, I. It seems to be a spec bug.
>
> Even the compatibility profile spec?  The core profile spec won't say
> anything because L, LA, and I were removed.
>
> GL_EXT_framebuffer_object didn't allow these formats, so it probably
> just got overlooked when rolling into GL_ARB_framebuffer_object / OpenGL
> 3.0...
>
>> This helps to fix piglit tests that rely on the number of color bits to be
>> non-zero, for example:
>>   spec/EXT_texture_integer/multisample-formats <samples> GL_EXT_texture_integer
>> ---
>>  src/mesa/main/formats.c   | 24 ++++++++++++++-------
>>  src/mesa/main/glformats.c | 53 ++++++++++++++++++++++++++++++++++++++++-------
>>  2 files changed, 62 insertions(+), 15 deletions(-)
>>
>> diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
>> index f6c399e..8f847cb 100644
>> --- a/src/mesa/main/formats.c
>> +++ b/src/mesa/main/formats.c
>> @@ -1842,25 +1842,34 @@ _mesa_get_format_bits(mesa_format format, GLenum pname)
>>     const struct gl_format_info *info = _mesa_get_format_info(format);
>>
>>     switch (pname) {
>> +   /* color buffer enums */
>>     case GL_RED_BITS:
>> -   case GL_TEXTURE_RED_SIZE:
>>     case GL_RENDERBUFFER_RED_SIZE_EXT:
>>     case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
>> -      return info->RedBits;
>> +      return info->IntensityBits ? info->IntensityBits :
>> +             info->LuminanceBits ? info->LuminanceBits : info->RedBits;
>>     case GL_GREEN_BITS:
>> -   case GL_TEXTURE_GREEN_SIZE:
>>     case GL_RENDERBUFFER_GREEN_SIZE_EXT:
>>     case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
>> -      return info->GreenBits;
>> +      return info->IntensityBits ? info->IntensityBits :
>> +             info->LuminanceBits ? info->LuminanceBits : info->GreenBits;
>>     case GL_BLUE_BITS:
>> -   case GL_TEXTURE_BLUE_SIZE:
>>     case GL_RENDERBUFFER_BLUE_SIZE_EXT:
>>     case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
>> -      return info->BlueBits;
>> +      return info->IntensityBits ? info->IntensityBits :
>> +             info->LuminanceBits ? info->LuminanceBits : info->BlueBits;
>>     case GL_ALPHA_BITS:
>> -   case GL_TEXTURE_ALPHA_SIZE:
>>     case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
>>     case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
>> +      return info->IntensityBits ? info->IntensityBits : info->AlphaBits;
>> +   /* texture enums */
>> +   case GL_TEXTURE_RED_SIZE:
>> +      return info->RedBits;
>> +   case GL_TEXTURE_GREEN_SIZE:
>> +      return info->GreenBits;
>> +   case GL_TEXTURE_BLUE_SIZE:
>> +      return info->BlueBits;
>> +   case GL_TEXTURE_ALPHA_SIZE:
>>        return info->AlphaBits;
>>     case GL_TEXTURE_INTENSITY_SIZE:
>>        return info->IntensityBits;
>> @@ -1868,6 +1877,7 @@ _mesa_get_format_bits(mesa_format format, GLenum pname)
>>        return info->LuminanceBits;
>>     case GL_INDEX_BITS:
>>        return info->IndexBits;
>> +   /* depth/stencil enums */
>>     case GL_DEPTH_BITS:
>>     case GL_TEXTURE_DEPTH_SIZE_ARB:
>>     case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
>> diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
>> index 77cf263..71064ed 100644
>> --- a/src/mesa/main/glformats.c
>> +++ b/src/mesa/main/glformats.c
>> @@ -984,11 +984,53 @@ GLboolean
>>  _mesa_base_format_has_channel(GLenum base_format, GLenum pname)
>>  {
>>     switch (pname) {
>> -   case GL_TEXTURE_RED_SIZE:
>> -   case GL_TEXTURE_RED_TYPE:
>> +   /* color buffer enums */
>>     case GL_RENDERBUFFER_RED_SIZE_EXT:
>>     case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
>>        if (base_format == GL_RED ||
>> +          base_format == GL_RG ||
>> +          base_format == GL_RGB ||
>> +          base_format == GL_RGBA ||
>> +          base_format == GL_LUMINANCE ||
>> +          base_format == GL_LUMINANCE_ALPHA ||
>> +          base_format == GL_INTENSITY) {
>> +         return GL_TRUE;
>> +      }
>> +      return GL_FALSE;
>> +   case GL_RENDERBUFFER_GREEN_SIZE_EXT:
>> +   case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
>> +      if (base_format == GL_RG ||
>> +          base_format == GL_RGB ||
>> +          base_format == GL_RGBA ||
>> +          base_format == GL_LUMINANCE ||
>> +          base_format == GL_LUMINANCE_ALPHA ||
>> +          base_format == GL_INTENSITY) {
>> +         return GL_TRUE;
>> +      }
>> +      return GL_FALSE;
>> +   case GL_RENDERBUFFER_BLUE_SIZE_EXT:
>> +   case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
>> +      if (base_format == GL_RGB ||
>> +          base_format == GL_RGBA ||
>> +          base_format == GL_LUMINANCE ||
>> +          base_format == GL_LUMINANCE_ALPHA ||
>> +          base_format == GL_INTENSITY) {
>> +         return GL_TRUE;
>> +      }
>> +      return GL_FALSE;
>> +   case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
>> +   case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
>> +      if (base_format == GL_RGBA ||
>> +          base_format == GL_ALPHA ||
>> +          base_format == GL_LUMINANCE_ALPHA ||
>> +          base_format == GL_INTENSITY) {
>> +         return GL_TRUE;
>> +      }
>> +      return GL_FALSE;
>> +   /* texture enums */
>> +   case GL_TEXTURE_RED_SIZE:
>> +   case GL_TEXTURE_RED_TYPE:
>> +      if (base_format == GL_RED ||
>>         base_format == GL_RG ||
>>         base_format == GL_RGB ||
>>         base_format == GL_RGBA) {
>> @@ -997,8 +1039,6 @@ _mesa_base_format_has_channel(GLenum base_format, GLenum pname)
>>        return GL_FALSE;
>>     case GL_TEXTURE_GREEN_SIZE:
>>     case GL_TEXTURE_GREEN_TYPE:
>> -   case GL_RENDERBUFFER_GREEN_SIZE_EXT:
>> -   case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
>>        if (base_format == GL_RG ||
>>         base_format == GL_RGB ||
>>         base_format == GL_RGBA) {
>> @@ -1007,8 +1047,6 @@ _mesa_base_format_has_channel(GLenum base_format, GLenum pname)
>>        return GL_FALSE;
>>     case GL_TEXTURE_BLUE_SIZE:
>>     case GL_TEXTURE_BLUE_TYPE:
>> -   case GL_RENDERBUFFER_BLUE_SIZE_EXT:
>> -   case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
>>        if (base_format == GL_RGB ||
>>         base_format == GL_RGBA) {
>>        return GL_TRUE;
>> @@ -1016,8 +1054,6 @@ _mesa_base_format_has_channel(GLenum base_format, GLenum pname)
>>        return GL_FALSE;
>>     case GL_TEXTURE_ALPHA_SIZE:
>>     case GL_TEXTURE_ALPHA_TYPE:
>> -   case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
>> -   case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
>>        if (base_format == GL_RGBA ||
>>         base_format == GL_ALPHA ||
>>         base_format == GL_LUMINANCE_ALPHA) {
>> @@ -1037,6 +1073,7 @@ _mesa_base_format_has_channel(GLenum base_format, GLenum pname)
>>        return GL_TRUE;
>>        }
>>        return GL_FALSE;
>> +   /* depth/stencil enums */
>>     case GL_TEXTURE_DEPTH_SIZE:
>>     case GL_TEXTURE_DEPTH_TYPE:
>>     case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
>>
>


More information about the mesa-dev mailing list