Re: [Mesa-dev] [PATCH mesa] mesa/format_info: use designated initialiser list

2017-06-20 Thread Eric Engestrom
On Tuesday, 2017-06-20 09:47:30 -0700, Ian Romanick wrote:
> On 06/20/2017 07:24 AM, Brian Paul wrote:
> > On 06/19/2017 03:39 PM, Ian Romanick wrote:
> >> On 06/19/2017 04:01 AM, Eric Engestrom wrote:
> >>> Also, make that table const, since no-one is supposed to modify it
> >>> anyway.
> >>
> >> I certainly like this, but I'm not sure we can use designated
> >> initializers in common Mesa code due to MSVC.  Brian?
> > 
> > They should be fine now.  I just did a quick test and both array
> > initializers and named struct field initializers work.
> 
> In that case, this patch is
> 
> Reviewed-by: Ian Romanick 

Thanks, pushed with Emil's r-b as well.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH mesa] mesa/format_info: use designated initialiser list

2017-06-20 Thread Ian Romanick
On 06/20/2017 07:24 AM, Brian Paul wrote:
> On 06/19/2017 03:39 PM, Ian Romanick wrote:
>> On 06/19/2017 04:01 AM, Eric Engestrom wrote:
>>> Also, make that table const, since no-one is supposed to modify it
>>> anyway.
>>
>> I certainly like this, but I'm not sure we can use designated
>> initializers in common Mesa code due to MSVC.  Brian?
> 
> They should be fine now.  I just did a quick test and both array
> initializers and named struct field initializers work.

In that case, this patch is

Reviewed-by: Ian Romanick 

> -Brian
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH mesa] mesa/format_info: use designated initialiser list

2017-06-20 Thread Eric Engestrom
On Tuesday, 2017-06-20 08:24:42 -0600, Brian Paul wrote:
> On 06/19/2017 03:39 PM, Ian Romanick wrote:
> > On 06/19/2017 04:01 AM, Eric Engestrom wrote:
> > > Also, make that table const, since no-one is supposed to modify it anyway.
> > 
> > I certainly like this, but I'm not sure we can use designated
> > initializers in common Mesa code due to MSVC.  Brian?
> 
> They should be fine now.  I just did a quick test and both array
> initializers and named struct field initializers work.

Is that a Tested-by: Brian Paul  ? :)

I'll push it in a hour or two.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH mesa] mesa/format_info: use designated initialiser list

2017-06-20 Thread Brian Paul

On 06/19/2017 03:39 PM, Ian Romanick wrote:

On 06/19/2017 04:01 AM, Eric Engestrom wrote:

Also, make that table const, since no-one is supposed to modify it anyway.


I certainly like this, but I'm not sure we can use designated
initializers in common Mesa code due to MSVC.  Brian?


They should be fine now.  I just did a quick test and both array 
initializers and named struct field initializers work.


-Brian


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH mesa] mesa/format_info: use designated initialiser list

2017-06-20 Thread Emil Velikov
On 19 June 2017 at 22:39, Ian Romanick  wrote:
> On 06/19/2017 04:01 AM, Eric Engestrom wrote:
>> Also, make that table const, since no-one is supposed to modify it anyway.
>
> I certainly like this, but I'm not sure we can use designated
> initializers in common Mesa code due to MSVC.  Brian?
>
Should be perfectly fine as of commit
1cadfe08c4109d2c117cbae2c82edee1293a8016 when the VMWare switched away
from MSVC2008 to MSVC 2013 or later. Latter having almost complete C99
support - see commit for details.
If in doubt I suggest running through Appveyor - seems happy [1].

Reviewed-by: Emil Velikov 
-Emil

[1] https://ci.appveyor.com/project/evelikov/mesa-4up2g/build/174
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH mesa] mesa/format_info: use designated initialiser list

2017-06-19 Thread Ian Romanick
On 06/19/2017 04:01 AM, Eric Engestrom wrote:
> Also, make that table const, since no-one is supposed to modify it anyway.

I certainly like this, but I'm not sure we can use designated
initializers in common Mesa code due to MSVC.  Brian?

> Signed-off-by: Eric Engestrom 
> ---
> 
> I was grepping for a field to see where it was being set, and I couldn't find
> it because it was using positional struct initialisation. Ended up finding it,
> but having the name right there will probably help the next guy :)
> 
> ---
>  src/mesa/main/format_info.py | 37 -
>  1 file changed, 20 insertions(+), 17 deletions(-)
> 
> diff --git a/src/mesa/main/format_info.py b/src/mesa/main/format_info.py
> index 780dc0bec7..b0308efc12 100644
> --- a/src/mesa/main/format_info.py
> +++ b/src/mesa/main/format_info.py
> @@ -165,34 +165,37 @@ def get_channel_bits(fmat, chan_name):
>* manually or commit it into version control.
>*/
>  
> -static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
> +static const struct gl_format_info format_info[MESA_FORMAT_COUNT] =
>  {
>  '''
>  
> +def format_channel_bits(fmat, tuple_list):
> +   return ['.%s = %s' % (field, str(get_channel_bits(fmat, name))) for 
> (field, name) in tuple_list]
> +
> +
>  for fmat in formats:
> print '   {'
> -   print '  {0},'.format(fmat.name)
> -   print '  "{0}",'.format(fmat.name)
> -   print '  {0},'.format('MESA_FORMAT_LAYOUT_' + fmat.layout.upper())
> -   print '  {0},'.format(get_gl_base_format(fmat))
> -   print '  {0},'.format(get_gl_data_type(fmat))
> +   print '  .Name = {0},'.format(fmat.name)
> +   print '  .StrName = "{0}",'.format(fmat.name)
> +   print '  .Layout = {0},'.format('MESA_FORMAT_LAYOUT_' + 
> fmat.layout.upper())
> +   print '  .BaseFormat = {0},'.format(get_gl_base_format(fmat))
> +   print '  .DataType = {0},'.format(get_gl_data_type(fmat))
>  
> -   bits = [ get_channel_bits(fmat, name) for name in ['r', 'g', 'b', 'a']]
> -   print '  {0},'.format(', '.join(map(str, bits)))
> -   bits = [ get_channel_bits(fmat, name) for name in ['l', 'i', 'z', 's']]
> -   print '  {0},'.format(', '.join(map(str, bits)))
> +   bits = [('RedBits', 'r'), ('GreenBits', 'g'), ('BlueBits', 'b'), 
> ('AlphaBits', 'a')]
> +   print '  {0},'.format(', '.join(format_channel_bits(fmat, bits)))
> +   bits = [('LuminanceBits', 'l'), ('IntensityBits', 'i'), ('DepthBits', 
> 'z'), ('StencilBits', 's')]
> +   print '  {0},'.format(', '.join(format_channel_bits(fmat, bits)))
>  
> -   print '  {0:d},'.format(fmat.colorspace == 'srgb')
> +   print '  .IsSRGBFormat = {0:d},'.format(fmat.colorspace == 'srgb')
>  
> -   print '  {0}, {1}, {2}, {3},'.format(fmat.block_width, 
> fmat.block_height,
> -fmat.block_depth,
> -int(fmat.block_size() / 8))
> +   print '  .BlockWidth = {0}, .BlockHeight = {1}, .BlockDepth = 
> {2},'.format(fmat.block_width, fmat.block_height, fmat.block_depth)
> +   print '  .BytesPerBlock = {0},'.format(int(fmat.block_size() / 8))
>  
> -   print '  {{ {0} }},'.format(', '.join(map(str, fmat.swizzle)))
> +   print '  .Swizzle = {{ {0} }},'.format(', '.join(map(str, 
> fmat.swizzle)))
> if fmat.is_array():
>chan = fmat.array_element()
>norm = chan.norm or chan.type == parser.FLOAT
> -  print '  MESA_ARRAY_FORMAT({0}),'.format(', '.join([
> +  print '  .ArrayFormat = MESA_ARRAY_FORMAT({0}),'.format(', '.join([
>   str(chan.size / 8),
>   str(int(chan.sign)),
>   str(int(chan.type == parser.FLOAT)),
> @@ -204,7 +207,7 @@ def get_channel_bits(fmat, chan_name):
>   str(fmat.swizzle[3]),
>]))
> else:
> -  print '  0,'
> +  print '  .ArrayFormat = 0,'
> print '   },'
>  
>  print '};'
> 

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH mesa] mesa/format_info: use designated initialiser list

2017-06-19 Thread Eric Engestrom
Also, make that table const, since no-one is supposed to modify it anyway.

Signed-off-by: Eric Engestrom 
---

I was grepping for a field to see where it was being set, and I couldn't find
it because it was using positional struct initialisation. Ended up finding it,
but having the name right there will probably help the next guy :)

---
 src/mesa/main/format_info.py | 37 -
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/src/mesa/main/format_info.py b/src/mesa/main/format_info.py
index 780dc0bec7..b0308efc12 100644
--- a/src/mesa/main/format_info.py
+++ b/src/mesa/main/format_info.py
@@ -165,34 +165,37 @@ def get_channel_bits(fmat, chan_name):
   * manually or commit it into version control.
   */
 
-static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
+static const struct gl_format_info format_info[MESA_FORMAT_COUNT] =
 {
 '''
 
+def format_channel_bits(fmat, tuple_list):
+   return ['.%s = %s' % (field, str(get_channel_bits(fmat, name))) for (field, 
name) in tuple_list]
+
+
 for fmat in formats:
print '   {'
-   print '  {0},'.format(fmat.name)
-   print '  "{0}",'.format(fmat.name)
-   print '  {0},'.format('MESA_FORMAT_LAYOUT_' + fmat.layout.upper())
-   print '  {0},'.format(get_gl_base_format(fmat))
-   print '  {0},'.format(get_gl_data_type(fmat))
+   print '  .Name = {0},'.format(fmat.name)
+   print '  .StrName = "{0}",'.format(fmat.name)
+   print '  .Layout = {0},'.format('MESA_FORMAT_LAYOUT_' + 
fmat.layout.upper())
+   print '  .BaseFormat = {0},'.format(get_gl_base_format(fmat))
+   print '  .DataType = {0},'.format(get_gl_data_type(fmat))
 
-   bits = [ get_channel_bits(fmat, name) for name in ['r', 'g', 'b', 'a']]
-   print '  {0},'.format(', '.join(map(str, bits)))
-   bits = [ get_channel_bits(fmat, name) for name in ['l', 'i', 'z', 's']]
-   print '  {0},'.format(', '.join(map(str, bits)))
+   bits = [('RedBits', 'r'), ('GreenBits', 'g'), ('BlueBits', 'b'), 
('AlphaBits', 'a')]
+   print '  {0},'.format(', '.join(format_channel_bits(fmat, bits)))
+   bits = [('LuminanceBits', 'l'), ('IntensityBits', 'i'), ('DepthBits', 'z'), 
('StencilBits', 's')]
+   print '  {0},'.format(', '.join(format_channel_bits(fmat, bits)))
 
-   print '  {0:d},'.format(fmat.colorspace == 'srgb')
+   print '  .IsSRGBFormat = {0:d},'.format(fmat.colorspace == 'srgb')
 
-   print '  {0}, {1}, {2}, {3},'.format(fmat.block_width, 
fmat.block_height,
-fmat.block_depth,
-int(fmat.block_size() / 8))
+   print '  .BlockWidth = {0}, .BlockHeight = {1}, .BlockDepth = 
{2},'.format(fmat.block_width, fmat.block_height, fmat.block_depth)
+   print '  .BytesPerBlock = {0},'.format(int(fmat.block_size() / 8))
 
-   print '  {{ {0} }},'.format(', '.join(map(str, fmat.swizzle)))
+   print '  .Swizzle = {{ {0} }},'.format(', '.join(map(str, 
fmat.swizzle)))
if fmat.is_array():
   chan = fmat.array_element()
   norm = chan.norm or chan.type == parser.FLOAT
-  print '  MESA_ARRAY_FORMAT({0}),'.format(', '.join([
+  print '  .ArrayFormat = MESA_ARRAY_FORMAT({0}),'.format(', '.join([
  str(chan.size / 8),
  str(int(chan.sign)),
  str(int(chan.type == parser.FLOAT)),
@@ -204,7 +207,7 @@ def get_channel_bits(fmat, chan_name):
  str(fmat.swizzle[3]),
   ]))
else:
-  print '  0,'
+  print '  .ArrayFormat = 0,'
print '   },'
 
 print '};'
-- 
Cheers,
  Eric

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev