[Mesa-dev] [PATCH] Allow glTexImage2D with a depth component cube map

Brian Paul brianp at vmware.com
Tue Nov 22 12:47:00 PST 2011


On 11/22/2011 01:21 PM, Kenneth Graunke wrote:
> On 11/22/2011 11:42 AM, Anuj Phogat wrote:
> [snip]
>>   I agree. This is simpler to read and _mesa_is_cube_map_face() can be reused
>>   in mesa. Posting an updated patch with your suggestions.
>>
>>   >  I haven't tested this so the logic might be incorrect.
>>   It worked as it is. Just defined a new function _mesa_is_cube_face().
>>
>>   Thanks
>>   Anuj
>
> Actually, Brian already added that function; it's in teximage.h.
>
>> Signed-off-by: Anuj Phogat<anuj.phogat at gmail.com>
>> ---
>>   src/mesa/main/image.c    |   18 ++++++++++++++++++
>>   src/mesa/main/image.h    |    3 +++
>>   src/mesa/main/teximage.c |   25 ++++++++++++-------------
>>   3 files changed, 33 insertions(+), 13 deletions(-)
>>
>> diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
>> index 7d95dd6..9ba5317 100644
>> --- a/src/mesa/main/image.c
>> +++ b/src/mesa/main/image.c
>> @@ -1086,6 +1086,24 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
>>      }
>>   }
>>
>> +/**
>> + * Test if the given texture target is a cubemap face
>> + */
>> +GLboolean
>> +_mesa_is_cube_map_face(GLenum target)
>> +{
>> +   switch (target) {
>> +      case GL_TEXTURE_CUBE_MAP_POSITIVE_X :
>> +      case GL_TEXTURE_CUBE_MAP_NEGATIVE_X :
>> +      case GL_TEXTURE_CUBE_MAP_POSITIVE_Y :
>> +      case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y :
>> +      case GL_TEXTURE_CUBE_MAP_POSITIVE_Z :
>> +      case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z :
>> +         return GL_TRUE;
>> +      default:
>> +         return GL_FALSE;
>> +   }
>> +}
>>
>>   /**
>>    * Return the address of a specific pixel in an image (1D, 2D or 3D).
>> diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h
>> index 46adaec..2c88578 100644
>> --- a/src/mesa/main/image.h
>> +++ b/src/mesa/main/image.h
>> @@ -84,6 +84,9 @@ _mesa_is_integer_format(GLenum format);
>>   extern GLboolean
>>   _mesa_is_compressed_format(struct gl_context *ctx, GLenum format);
>>
>> +extern GLboolean
>> +_mesa_is_cube_map_face(GLenum target);
>> +
>>   extern GLvoid *
>>   _mesa_image_address( GLuint dimensions,
>>                        const struct gl_pixelstore_attrib *packing,
>> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
>> index acf7187..43eec61 100644
>> --- a/src/mesa/main/teximage.c
>> +++ b/src/mesa/main/teximage.c
>> @@ -1593,28 +1593,27 @@ texture_error_check( struct gl_context *ctx,
>>            return GL_TRUE;
>>         }
>>      }
>> -
>> -   /* additional checks for depth textures */
>> +
>> +  /* additional checks for depth textures */
>>      if (_mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_COMPONENT) {
>> -      /* Only 1D, 2D, rect and array textures supported, not 3D or cubes */
>> +     /* Only 1D, 2D, rect, array and cube textures supported, not 3D
>> +      * Cubemaps are only supported for GL version>  3.0 or with EXT_gpu_shader4 */
>>         if (target != GL_TEXTURE_1D&&
>>             target != GL_PROXY_TEXTURE_1D&&
>>             target != GL_TEXTURE_2D&&
>> -          target != GL_PROXY_TEXTURE_2D&&
>> -          target != GL_TEXTURE_1D_ARRAY&&
>> -          target != GL_PROXY_TEXTURE_1D_ARRAY&&
>> -          target != GL_TEXTURE_2D_ARRAY&&

I don't think you should delete those lines.


>>             target != GL_PROXY_TEXTURE_2D_ARRAY&&
>>             target != GL_TEXTURE_RECTANGLE_ARB&&
>> -          target != GL_PROXY_TEXTURE_RECTANGLE_ARB) {
>> -         if (!isProxy)
>> -            _mesa_error(ctx, GL_INVALID_ENUM,
>> -                        "glTexImage(target/internalFormat)");
>> -         return GL_TRUE;
>> +          target != GL_PROXY_TEXTURE_RECTANGLE_ARB&&
>> +         !((_mesa_is_cube_map_face(target) || target == GL_PROXY_TEXTURE_CUBE_MAP)&&
>> +           (ctx->VersionMajor>= 3 || ctx->Extensions.EXT_gpu_shader4))) {
>> +        if (!isProxy)
>> +           _mesa_error(ctx, GL_INVALID_ENUM,
>> +                       "glTexImage(target/internalFormat)");
>> +        return GL_TRUE;
>>         }
>>      }
>>
>> -   /* additional checks for compressed textures */
>> +  /* additional checks for compressed textures */
>>      if (_mesa_is_compressed_format(ctx, internalFormat)) {
>>         if (!target_can_be_compressed(ctx, target, internalFormat)) {
>>            if (!isProxy)
>
> Seems like some spurious whitespace changes got introduced here...this
> isProxy stuff shouldn't be appearing in the diff.
>
> Mesa coding style is 3-space indentation with 8-space tabs.  (Yeah, it's
> quite unusual... :))

FWIW, I don't indent with tabs.

 From docs/devinfo.html:

    indent -br -i3 -npcs --no-tabs infile.c -o outfile.c

-Brian


More information about the mesa-dev mailing list