[Mesa-dev] [i965] i965/draw: Move constant formation outside of for loop and use an enum.

Mark Mueller markkmueller at gmail.com
Thu Aug 8 12:19:04 PDT 2013


On Tue, Aug 6, 2013 at 12:31 PM, Ian Romanick <idr at freedesktop.org> wrote:

> On 08/06/2013 12:10 PM, mmueller wrote:Signed-off-by: mmueller <
> MarkKMueller at gmail.com>
>
>> ---
>>   src/mesa/drivers/dri/i965/brw_**draw.c | 18 +++++++++---------
>>   1 file changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/**brw_draw.c
>> b/src/mesa/drivers/dri/i965/**brw_draw.c
>> index 6170d07..e11d0d8 100644
>> --- a/src/mesa/drivers/dri/i965/**brw_draw.c
>> +++ b/src/mesa/drivers/dri/i965/**brw_draw.c
>> @@ -367,6 +367,15 @@ static bool brw_try_draw_prims( struct gl_context
>> *ctx,
>>      bool retval = true;
>>      GLuint i;
>>      bool fail_next = false;
>> +   enum {
>> +       estimated_max_prim_size =
>> +           512 + /* batchbuffer commands */
>> +           ((BRW_MAX_TEX_UNIT * (sizeof(struct brw_sampler_state) +
>> sizeof(struct gen5_sampler_default_color)))) +
>> +           1024 + /* gen6 VS push constants */
>> +           1024 + /* gen6 WM push constants */
>> +           512 /* misc. pad */
>> +   };
>> +
>>
>
> I think this would be better as 'const int estimated_max_prim_size = ...'.
>  Using an enum is mostly the same (but also enforces that it's a
> compile-time constant), but it looks weird. :)
>
>
OK. A new patch is on the way.... *sigh*, I knew this day was coming for
the last 15 years, but I don't feel that was enough time to prepare. Now
I'm forced to come out of the closet - I'm a lifelong member of PETA*.

All too often I clearly communicate something to the compiler yet it still
goes off and does something else. Before I started using enums to replace
#defines and const PODs in my code, I too thought enums were weird and
ugly. After time I came to realized that it was an effective means to get
the compiler to do some useful things. After a while they don't look so
weird.

Obviously in this case it's of no concern.

Cheers

*PETA - Promoting Enums Through Awareness (www.PE.TA, not to be confused
with People Eating Tasty Animals: PETA.org)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130808/8bd5a4ae/attachment.html>


More information about the mesa-dev mailing list