[Mesa-dev] [PATCH 07/14] mesa: Set green, blue channels to zero only for formats with these components

Anuj Phogat anuj.phogat at gmail.com
Tue Jul 21 11:13:47 PDT 2015


On Tue, Jul 21, 2015 at 12:50 AM, Iago Toral <itoral at igalia.com> wrote:
> On Tue, 2015-06-16 at 11:15 -0700, Anuj Phogat wrote:
>> Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
>> ---
>>  src/mesa/drivers/common/meta.c | 13 ++++++++++---
>>  1 file changed, 10 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
>> index 214a68a..fceb25d 100644
>> --- a/src/mesa/drivers/common/meta.c
>> +++ b/src/mesa/drivers/common/meta.c
>> @@ -3132,9 +3132,16 @@ decompress_texture_image(struct gl_context *ctx,
>>         * returned as red and two-channel texture values are returned as
>>         * red/alpha.
>>         */
>> -      if ((baseTexFormat == GL_LUMINANCE ||
>> -           baseTexFormat == GL_LUMINANCE_ALPHA ||
>> -           baseTexFormat == GL_INTENSITY) ||
>> +      if (((baseTexFormat == GL_LUMINANCE ||
>> +            baseTexFormat == GL_LUMINANCE_ALPHA ||
>> +            baseTexFormat == GL_INTENSITY) &&
>> +           (destBaseFormat == GL_RGBA ||
>> +            destBaseFormat == GL_RGB ||
>> +            destBaseFormat == GL_RG ||
>> +            destBaseFormat == GL_GREEN ||
>> +            destBaseFormat == GL_BLUE ||
>> +            destBaseFormat == GL_BGRA ||
>> +            destBaseFormat == GL_BGR)) ||
>
> Is this needed to achieve correct behavior or just an optimization? I
> would expect that if the dest format does not have G/B channels, setting
> pixel transfer options for these channels would not have any functional
> effect anyway.
>
This is just an optimization. We set pixel transfer operations based on these
conditions and then call _mesa_ReadPixels, which falls back to slower path
if transfer operations are set. I'll bump up the commit message of this patch.

>>            /* If we're reading back an RGB(A) texture (using glGetTexImage) as
>>          * luminance then we need to return L=tex(R).
>>          */
>
>


More information about the mesa-dev mailing list