[Mesa-dev] [v3 7/8] mesa: add texture_view helper function for TexStorage

Courtney Goeltzenleuchter courtney at lunarg.com
Mon Nov 25 13:09:26 PST 2013


On Thu, Nov 21, 2013 at 5:56 PM, Brian Paul <brianp at vmware.com> wrote:

> On 11/19/2013 04:16 PM, Courtney Goeltzenleuchter wrote:
>
>> Add helper function to set texture_view state from TexStorage calls.
>>
>> Signed-off-by: Courtney Goeltzenleuchter <courtney at LunarG.com>
>> ---
>>   src/mesa/main/textureview.c | 59 ++++++++++++++++++++++++++++++
>> +++++++++++++++
>>   src/mesa/main/textureview.h |  4 +++
>>   2 files changed, 63 insertions(+)
>>
>> diff --git a/src/mesa/main/textureview.c b/src/mesa/main/textureview.c
>> index 1858465..a25b928 100644
>> --- a/src/mesa/main/textureview.c
>> +++ b/src/mesa/main/textureview.c
>> @@ -379,6 +379,65 @@ compatible_format(struct gl_context *ctx, struct
>> gl_texture_object *origTexObj,
>>                  _mesa_lookup_enum_by_nr(origInternalFormat));
>>      return GL_FALSE;
>>   }
>> +/**
>> + * Helper function for TexStorage to set TextureView state
>> + */
>>
>
> Could you put a bit more info into that comment?


How about:
/**
 * Helper function for TexStorage and teximagemultisample to set immutable
 * texture state needed by ARB_texture_view.
 */
void
_mesa_set_texture_view_state(struct gl_context *ctx, struct
gl_texture_object *texObj,
                       GLenum target, GLuint levels)
...


>
>
>  +void
>> +set_texture_view_state(struct gl_context *ctx, struct gl_texture_object
>> *texObj,
>> +                       GLenum target, GLuint levels)
>>
>
> non-static functions should be prefixed with "_mesa_".

See above.

>
>
>
>  +{
>> +   struct gl_texture_image *texImage;
>> +
>> +   /* Get a reference to what will become this View's base level */
>> +   texImage = _mesa_select_tex_image(ctx, texObj, target, 0);
>>
>
> Early return if texImage is NULL (out of memory, etc?)?

Immutable textures have all their image levels allocated when they are
created, so teximage should never be null at this point. At least as I
understand things.


>
>
>
>  +
>> +   /* If the command is successful,
>>
>
> If what command is successful?  glTexStorage()?


That is a copy & paste from the ARB_texture_view spec, meaning that if the
glTexStorage command is successful...

Modify subsection 3.9.16 (Immutable-Format Texture Images)

Modify the second to last bullet on p. 258:

If the command is successful, TEXTURE_IMMUTABLE_FORMAT becomes
TRUE,TEXTURE_IMMUTABLE_LEVELS and TEXTURE_VIEW_NUM_LEVELS become
<levels>.

I can change that to something like: When an immutable texture is created
via glTexStorage or glTexImageMultisample,


>
>
>
>  +    * TEXTURE_IMMUTABLE_FORMAT becomes TRUE.
>> +    * TEXTURE_IMMUTABLE_LEVELS and TEXTURE_VIEW_NUM_LEVELS become levels.
>> +    * If the texture target is TEXTURE_1D_ARRAY then
>> +    * TEXTURE_VIEW_NUM_LAYERS becomes height.
>> +    * If the texture target is TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY,
>> +    * or TEXTURE_2D_MULTISAMPLE_ARRAY then TEXTURE_VIEW_NUM_LAYERS
>> becomes depth.
>> +    * If the texture target is TEXTURE_CUBE_MAP, then
>> +    * TEXTURE_VIEW_NUM_LAYERS becomes 6.
>> +    * For any other texture target, TEXTURE_VIEW_NUM_LAYERS becomes 1.
>> +    *
>> +    * ARB_texture_multisample: Multisample textures do
>> +    * not have multiple image levels.
>> +    */
>> +
>> +   texObj->Immutable = GL_TRUE;
>> +   texObj->ImmutableLevels = levels;
>> +   texObj->MinLevel = 0;
>> +   texObj->NumLevels = levels;
>> +   texObj->MinLayer = 0;
>> +   texObj->NumLayers = 1;
>> +   switch (target) {
>> +   case GL_TEXTURE_1D_ARRAY:
>> +      texObj->NumLayers = texImage->Height;
>> +      break;
>> +
>> +   case GL_TEXTURE_2D_MULTISAMPLE:
>> +      texObj->NumLevels = 1;
>> +      texObj->ImmutableLevels = 1;
>> +      break;
>> +
>> +   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
>> +      texObj->NumLevels = 1;
>> +      texObj->ImmutableLevels = 1;
>> +      /* fall through to set NumLayers */
>> +
>> +   case GL_TEXTURE_2D_ARRAY:
>> +   case GL_TEXTURE_CUBE_MAP_ARRAY:
>> +      texObj->NumLayers = texImage->Depth;
>> +      break;
>> +
>> +   case GL_TEXTURE_CUBE_MAP:
>> +      texObj->NumLayers = 6;
>> +      break;
>> +
>> +   }
>> +}
>>
>>   /**
>>    * glTextureView (ARB_texture_view)
>> diff --git a/src/mesa/main/textureview.h b/src/mesa/main/textureview.h
>> index c2f0f32..36a8ed3 100644
>> --- a/src/mesa/main/textureview.h
>> +++ b/src/mesa/main/textureview.h
>> @@ -36,4 +36,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint
>> origtexture,
>>                     GLuint minlevel, GLuint numlevels,
>>                     GLuint minlayer, GLuint numlayers);
>>
>> +extern void
>> +set_texture_view_state(struct gl_context *ctx, struct gl_texture_object
>> *texObj,
>> +                       GLenum target, GLuint levels);
>> +
>>   #endif /* TEXTUREVIEW_H */
>>
>>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>



-- 
Courtney Goeltzenleuchter
LunarG
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20131125/a9e64c65/attachment-0001.html>


More information about the mesa-dev mailing list