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

Brian Paul brianp at vmware.com
Mon Mar 10 10:07:30 PDT 2014


On 03/09/2014 01:03 PM, Marek Olšák wrote:
> Do you have any opinion on this patch, anyone?
>
> Marek
>
> On Tue, Mar 4, 2014 at 12:32 PM, Marek Olšák <maraeo at gmail.com> 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.

I'm trying to piece together the background info on this.

IIRC, in GL 3.3 core there are no luminance, l/a or intensity textures 
or surfaces anymore.  And yeah, I don't see a 
GL_FRAMEBUFFER_ATTACHMENT_LUMINANCE_SIZE query in the 3.3 compat profile 
spec.

So basically your patch will return a non-zero value if, for example, 
GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE is called on a luminance buffer, right?

Is that what AMD and NVIDIA's drivers do?

-Brian


>>
>> 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:
>> --
>> 1.8.3.2
>>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=lGQMzzTgII0I7jefp2FHq7WtZ%2BTLs8wadB%2BiIj9xpBY%3D%0A&m=qzsd%2FitpSvkUycaHbYW5C6BuRDQW5DNH726e7aozKZ0%3D%0A&s=9780b0841120f7acbe074a803688960e0f3035dfd6afc66104e9776c80f60760
>



More information about the mesa-dev mailing list