[Mesa-dev] [PATCH] mesa/mtypes: repack gl_texture_object.

Marek Olšák maraeo at gmail.com
Mon Sep 4 11:33:58 UTC 2017


On Mon, Sep 4, 2017 at 1:29 PM, Marek Olšák <maraeo at gmail.com> wrote:
> On Sun, Sep 3, 2017 at 1:18 PM, Dave Airlie <airlied at gmail.com> wrote:
>> From: Dave Airlie <airlied at redhat.com>
>>
>> reduces size from 1144 to 1128.
>>
>> Signed-off-by: Dave Airlie <airlied at redhat.com>
>> ---
>>  src/mesa/main/mtypes.h | 10 +++++-----
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
>> index d44897b..3d68a6d 100644
>> --- a/src/mesa/main/mtypes.h
>> +++ b/src/mesa/main/mtypes.h
>> @@ -1012,7 +1012,6 @@ struct gl_texture_object
>>     struct gl_sampler_object Sampler;
>>
>>     GLenum DepthMode;           /**< GL_ARB_depth_texture */
>
> The patch looks good, but here are some ideas for future improvements:
>
> GLenum can be uint16_t everywhere, because GL doesn't set higher bits:
>
> typedef uint16_t GLenum16.
> s/GLenum/GLenum16/
>
>> -   bool StencilSampling;       /**< Should we sample stencil instead of depth? */
>>
>>     GLfloat Priority;           /**< in [0,1] */
>>     GLint BaseLevel;            /**< min mipmap level, OpenGL 1.2 */
>> @@ -1033,12 +1032,17 @@ struct gl_texture_object
>>     GLboolean Immutable;        /**< GL_ARB_texture_storage */
>>     GLboolean _IsFloat;         /**< GL_OES_float_texture */
>>     GLboolean _IsHalfFloat;     /**< GL_OES_half_float_texture */
>> +   bool StencilSampling;       /**< Should we sample stencil instead of depth? */
>> +   bool HandleAllocated;       /**< GL_ARB_bindless_texture */
>
> All bools can be 1 bit:
>
> bool x:1;
> GLboolean y:1;
>
> etc.
>
>>
>>     GLuint MinLevel;            /**< GL_ARB_texture_view */
>>     GLuint MinLayer;            /**< GL_ARB_texture_view */
>>     GLuint NumLevels;           /**< GL_ARB_texture_view */
>>     GLuint NumLayers;           /**< GL_ARB_texture_view */
>
> MinLevel, NumLevels can be ubyte (uint8_t). MinLayer, NumLayers can be
> ushort (uint16_t)... simply by considering the range of possible
> values.

One more: Enums have 4 bytes by default, but you can limit that,
because who wants 2^32 possible values:

enum type var:5;

Marek


More information about the mesa-dev mailing list