[Mesa-dev] [PATCH] glsl: s/unsigned/glsl_base_type/ in glsl type code

Ian Romanick idr at freedesktop.org
Tue Nov 7 19:52:48 UTC 2017


On 11/06/2017 02:54 PM, Brian Paul wrote:
> On 11/06/2017 02:27 PM, Ian Romanick wrote:
>> On 11/06/2017 01:00 PM, Brian Paul wrote:
>>> Declare glsl_type::sampled_type as glsl_base_type as we do for the
>>> base_type field.  And make base_type a bitfield to save a few bytes.
>>
>> Hmm... I have mixed feelings about this.  I made a conscious decision to
>> have base_type be "full size" because it's used a lot.  I suspect there
>> will be some increase in code size across this change.  There's probably
>> also some performance difference, but it may not be enough to be
>> measurable.  I do like actually using type names. :)
>>
>> As new base types were added, sampled_type remained 2 bits because GLSL
>> only allows float, int and uint.  This is the reason GLSL_TYPE_UINT64
>> and GLSL_TYPE_INT64 are not grouped with GLSL_TYPE_UINT and
>> GLSL_TYPE_INT.
>>
>> I wonder if it might be more compact (in terms of generated code) to
>> make both fields 8 bits and group them together.
> 
> Probably.  I can do that in a v2.  Otherwise, I'm fine with leaving
> base_type unchanged.  Your call.

I tried my original suggestion, and I also tried using
__attribute__((__packed__)) on the glsl_base_type enum.  Is there an
equivalent to this for Visual Studio?

Here are the results I got for an optimized release build:

   text	   data	    bss	    dec	    hex	filename
10339299 345184	 549312	11233795 ab6a03	lib64/i965_dri.so before
10346970 345184	 549312	11241466 ab87fa	lib64/i965_dri.so this patch
10340979 345184	 549312	11235475 ab7093	lib64/i965_dri.so :8 for both
10339963 345184	 549312	11234459 ab6c9b	lib64/i965_dri.so packed enum

This patch adds about 7.5k, and using :8 for sampled_type and
glsl_base_type adds only 1.5k.  The packed enum is the clear winner.  It
only adds ~600 bytes.

The results for 32-bit are similar.

   text	   data	    bss	    dec	    hex	filename
11599089 270876	 422916	12292881 bb9311	lib/i965_dri.so before
11608245 270876	 422916	12302037 bbb6d5	lib/i965_dri.so this patch
11600549 270876	 422916	12294341 bb98c5	lib/i965_dri.so :8 for both
11600780 270876	 422916	12294572 bb99ac	lib/i965_dri.so packed enum

Here, :8 and packed enum are about the same.  Which, honestly, is what I
would have expected.  8 bits is 8 bits... it really shouldn't matter how
you declare them. *shrug*

> -Brian


More information about the mesa-dev mailing list