Hmm, I'm not actually sure this will always reduce the state key size. I
think the compiler is still allowed to pad the mode_opt struct out to
whatever it likes (maybe #pragma pack(1) can prevent this), even though
maybe gcc does not.
I don't like pragmas too much, but it looks the only way to do this in
some clean c99 way would be to get rid of the mode_opt struct entirely?

Roland

On 02.09.2009 16:23, Brian Paul wrote:
> Unfortunately gcc (version 4.3.2 anyway) warns on this:
> main/texenvprogram.c:87: warning: type of bit-field ‘Source’ is a GCC 
> extension
> main/texenvprogram.c:88: warning: type of bit-field ‘Operand’ is a GCC 
> extension
> 
> I'm trying to find a #pragma or something to silence the warning...
> 
> -Brian
> 
> Keith Whitwell wrote:
>> Looks great Chris.
>>
>> Keith
>>
>> On Wed, 2009-09-02 at 05:11 -0700, Chris Wilson wrote:
>>> By rearranging the bitfields within the key we can reduce the size
>>> of the key from 644 to 196 bytes, reducing the cost of both the
>>> hashing and equality tests.
>>> ---
>>>  src/mesa/main/texenvprogram.c |    7 ++++---
>>>  1 files changed, 4 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
>>> index 5913957..3851937 100644
>>> --- a/src/mesa/main/texenvprogram.c
>>> +++ b/src/mesa/main/texenvprogram.c
>>> @@ -82,8 +82,8 @@ texenv_doing_secondary_color(GLcontext *ctx)
>>>  #define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM)
>>>  
>>>  struct mode_opt {
>>> -   GLuint Source:4;  /**< SRC_x */
>>> -   GLuint Operand:3; /**< OPR_x */
>>> +   GLubyte Source:4;  /**< SRC_x */
>>> +   GLubyte Operand:3; /**< OPR_x */
>>>  };
>>>  
>>>  struct state_key {
>>> @@ -103,10 +103,11 @@ struct state_key {
>>>  
>>>        GLuint NumArgsRGB:3;  /**< up to MAX_COMBINER_TERMS */
>>>        GLuint ModeRGB:5;     /**< MODE_x */
>>> -      struct mode_opt OptRGB[MAX_COMBINER_TERMS];
>>>  
>>>        GLuint NumArgsA:3;  /**< up to MAX_COMBINER_TERMS */
>>>        GLuint ModeA:5;     /**< MODE_x */
>>> +
>>> +      struct mode_opt OptRGB[MAX_COMBINER_TERMS];
>>>        struct mode_opt OptA[MAX_COMBINER_TERMS];
>>>     } unit[MAX_TEXTURE_UNITS];
>>>  };
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
>> trial. Simplify your report design, integration and deployment - and focus 
>> on 
>> what you do best, core application coding. Discover what's new with 
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Mesa3d-dev mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/mesa3d-dev
>> .
>>
> 
> 
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with 
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Mesa3d-dev mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mesa3d-dev


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to