[Mesa-dev] [PATCH v3] mesa: add GL_RED, GL_RG support for floating point textures

Tapani Pälli tapani.palli at intel.com
Tue Jun 9 22:11:51 PDT 2015


On 06/09/2015 08:51 PM, Kenneth Graunke wrote:
> On Tuesday, June 09, 2015 12:26:48 PM Tapani Pälli wrote:
>> Mesa supports EXT_texture_rg and OES_texture_float. This patch adds
>> support for using unsized enums GL_RED and GL_RG for floating point
>> targets and writes proper checks for internalformat when format is
>> GL_RED or GL_RG and type is of GL_FLOAT or GL_HALF_FLOAT.
>>
>> Later, internalformat will get adjusted by adjust_for_oes_float_texture
>> after these checks.
>>
>> v2: simplify to check vs supported enums
>> v3: follow the style and break out if internalFormat ok (Kenneth)
>>
>> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90748
>> ---
>>   src/mesa/main/glformats.c | 37 ++++++++++++++++++++++++++++++++++---
>>   1 file changed, 34 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
>> index 057a5d1..ac69fab 100644
>> --- a/src/mesa/main/glformats.c
>> +++ b/src/mesa/main/glformats.c
>> @@ -2296,8 +2296,18 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
>>            break;
>>   
>>         case GL_HALF_FLOAT:
>> -         if (internalFormat != GL_RG16F)
>> -            return GL_INVALID_OPERATION;
>> +      case GL_HALF_FLOAT_OES:
> Oh wow, I just realized that GL_HALF_FLOAT and GL_HALF_FLOAT_OES are
> actually different hex values.  I think what you've done here by
> treating them both identically is the best solution.
>
> Thanks for fixing this, Tapani!
>
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

Thanks Kenneth; If you have time please take a look at the other patch 
also as both are required to fix this bug:

http://lists.freedesktop.org/archives/mesa-dev/2015-June/085938.html


>> +         switch (internalFormat) {
>> +            case GL_RG16F:
>> +               break;
>> +            case GL_RG:
>> +               if (ctx->Extensions.ARB_texture_rg &&
>> +                   ctx->Extensions.OES_texture_half_float)
>> +                  break;
>> +            /* fallthrough */
>> +            default:
>> +               return GL_INVALID_OPERATION;
>> +         }
>>            break;
>>   
>>         case GL_FLOAT:
>> @@ -2305,6 +2315,11 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
>>            case GL_RG16F:
>>            case GL_RG32F:
>>               break;
>> +         case GL_RG:
>> +            if (ctx->Extensions.ARB_texture_rg &&
>> +                ctx->Extensions.OES_texture_float)
>> +               break;
>> +            /* fallthrough */
>>            default:
>>               return GL_INVALID_OPERATION;
>>            }
>> @@ -2365,8 +2380,19 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
>>            break;
>>   
>>         case GL_HALF_FLOAT:
>> -         if (internalFormat != GL_R16F)
>> +      case GL_HALF_FLOAT_OES:
>> +         switch (internalFormat) {
>> +         case GL_R16F:
>> +            break;
>> +         case GL_RG:
>> +         case GL_RED:
>> +            if (ctx->Extensions.ARB_texture_rg &&
>> +                ctx->Extensions.OES_texture_half_float)
>> +               break;
>> +            /* fallthrough */
>> +         default:
>>               return GL_INVALID_OPERATION;
>> +         }
>>            break;
>>   
>>         case GL_FLOAT:
>> @@ -2374,6 +2400,11 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
>>            case GL_R16F:
>>            case GL_R32F:
>>               break;
>> +         case GL_RED:
>> +            if (ctx->Extensions.ARB_texture_rg &&
>> +                ctx->Extensions.OES_texture_float)
>> +               break;
>> +            /* fallthrough */
>>            default:
>>               return GL_INVALID_OPERATION;
>>            }
>>



More information about the mesa-dev mailing list