Re: [Mesa-dev] [PATCH 1/2] glapi: gl_table.py: remove unused variable 'es'

2015-06-19 Thread Dylan Baker
I was planning to do this too.

Reviewed-by: Dylan Baker 
On Jun 19, 2015 5:17 AM, "Emil Velikov"  wrote:

> None of the three build systems ever set it, as such we can clear things
> up a bit.
>
> Cc:  Dylan Baker 
> Cc:  Jose Fonseca 
> Signed-off-by: Emil Velikov 
> ---
>  src/mapi/glapi/gen/gl_table.py | 57
> ++
>  1 file changed, 8 insertions(+), 49 deletions(-)
>
> diff --git a/src/mapi/glapi/gen/gl_table.py
> b/src/mapi/glapi/gen/gl_table.py
> index 3f02902..e25971a 100644
> --- a/src/mapi/glapi/gen/gl_table.py
> +++ b/src/mapi/glapi/gen/gl_table.py
> @@ -33,10 +33,9 @@ import license
>
>
>  class PrintGlTable(gl_XML.gl_print_base):
> -def __init__(self, es=False):
> +def __init__(self):
>  gl_XML.gl_print_base.__init__(self)
>
> -self.es = es
>  self.header_tag = '_GLAPI_TABLE_H_'
>  self.name = "gl_table.py (from Mesa)"
>  self.license = license.bsd_license_template % ( \
> @@ -76,10 +75,9 @@ class PrintGlTable(gl_XML.gl_print_base):
>
>
>  class PrintRemapTable(gl_XML.gl_print_base):
> -def __init__(self, es=False):
> +def __init__(self):
>  gl_XML.gl_print_base.__init__(self)
>
> -self.es = es
>  self.header_tag = '_DISPATCH_H_'
>  self.name = "gl_table.py (from Mesa)"
>  self.license = license.bsd_license_template % (
> @@ -123,7 +121,6 @@ class PrintRemapTable(gl_XML.gl_print_base):
>
>  functions = []
>  abi_functions = []
> -alias_functions = []
>  count = 0
>  for f in api.functionIterateByOffset():
>  if not f.is_abi():
> @@ -132,11 +129,6 @@ class PrintRemapTable(gl_XML.gl_print_base):
>  else:
>  abi_functions.append([f, -1])
>
> -if self.es:
> -# remember functions with aliases
> -if len(f.entry_points) > 1:
> -alias_functions.append(f)
> -
>  print '/* total number of offsets below */'
>  print '#define _gloffset_COUNT %d' % (len(abi_functions +
> functions))
>  print ''
> @@ -144,18 +136,11 @@ class PrintRemapTable(gl_XML.gl_print_base):
>  for f, index in abi_functions:
>  print '#define _gloffset_%s %d' % (f.name, f.offset)
>
> -if self.es:
> -remap_table = "esLocalRemapTable"
> -
> -print '#define %s_size %u' % (remap_table, count)
> -print 'static int %s[ %s_size ];' % (remap_table, remap_table)
> -print ''
> -else:
> -remap_table = "driDispatchRemapTable"
> +remap_table = "driDispatchRemapTable"
>
> -print '#define %s_size %u' % (remap_table, count)
> -print 'extern int %s[ %s_size ];' % (remap_table, remap_table)
> -print ''
> +print '#define %s_size %u' % (remap_table, count)
> +print 'extern int %s[ %s_size ];' % (remap_table, remap_table)
> +print ''
>
>  for f, index in functions:
>  print '#define %s_remap_index %u' % (f.name, index)
> @@ -182,23 +167,6 @@ class PrintRemapTable(gl_XML.gl_print_base):
>  print '}'
>  print
>
> -if alias_functions:
> -print ''
> -print '/* define aliases for compatibility */'
> -for f in alias_functions:
> -for name in f.entry_points:
> -if name != f.name:
> -print '#define CALL_%s(disp, parameters)
> CALL_%s(disp, parameters)' % (name, f.name)
> -print '#define GET_%s(disp) GET_%s(disp)' %
> (name, f.name)
> -print '#define SET_%s(disp, fn) SET_%s(disp, fn)'
> % (name, f.name)
> -print ''
> -
> -for f in alias_functions:
> -for name in f.entry_points:
> -if name != f.name:
> -print '#define %s_remap_index %s_remap_index' %
> (name, f.name)
> -print ''
> -
>  return
>
>
> @@ -215,12 +183,6 @@ def _parser():
>  default='table',
>  metavar="mode",
>  help="Generate either a table or a remap_table")
> -parser.add_argument('

Re: [Mesa-dev] [PATCH 2/2] glapi: remap_helper.py: remove unused argument 'es'

2015-06-19 Thread Dylan Baker
This one is reviewed too. I'm on my phone and typing the reviewed by is
hard though, so you'll have to copy from the last one.

I'm currently in the process of writing a series to replace the mesa XML
with the khronos XML, and as part of that I was planning to rewrite the
underlying representation of the XML. We can delete things now if you like
or we we can wait and they'll jus disappear on their own soon enough.

Dylan
On Jun 19, 2015 5:18 AM, "Emil Velikov"  wrote:

> Identical to the previous commit - unused by neither the Autotools,
> Android or SCons build.
>
> XXX: There are no more users of gl_api.filter_functions_by_api(). Should
> we just nuke it ?
>
> Cc:  Dylan Baker 
> Cc:  Jose Fonseca 
> Signed-off-by: Emil Velikov 
> ---
>  src/mapi/glapi/gen/remap_helper.py | 8 
>  1 file changed, 8 deletions(-)
>
> diff --git a/src/mapi/glapi/gen/remap_helper.py
> b/src/mapi/glapi/gen/remap_helper.py
> index 94ae193..edc6c3e 100644
> --- a/src/mapi/glapi/gen/remap_helper.py
> +++ b/src/mapi/glapi/gen/remap_helper.py
> @@ -174,12 +174,6 @@ def _parser():
>  metavar="input_file_name",
>  dest='file_name',
>  help="An xml description file.")
> -parser.add_argument('-c', '--es-version',
> -choices=[None, 'es1', 'es2'],
> -default=None,
> -metavar='ver',
> -dest='es',
> -help='A GLES version to support')
>  return parser.parse_args()
>
>
> @@ -188,8 +182,6 @@ def main():
>  args = _parser()
>
>  api = gl_XML.parse_GL_API(args.file_name)
> -if args.es is not None:
> -api.filter_functions_by_api(args.es)
>
>  printer = PrintGlRemap()
>  printer.Print(api)
> --
> 2.4.2
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] glapi: remap_helper.py: remove unused argument 'es'

2015-06-21 Thread Dylan Baker
Cleanups are definitely party of the plan. I'm doing three phases. First is
going to mako for generation. Second is using the khronos XML. Finally I
want to clean things up and hybridize for python 3
On Jun 21, 2015 7:34 AM, "Emil Velikov"  wrote:

> On 19/06/15 18:43, Dylan Baker wrote:
> > This one is reviewed too. I'm on my phone and typing the reviewed by is
> > hard though, so you'll have to copy from the last one.
> >
> > I'm currently in the process of writing a series to replace the mesa XML
> > with the khronos XML, and as part of that I was planning to rewrite the
> > underlying representation of the XML. We can delete things now if you
> > like or we we can wait and they'll jus disappear on their own soon
> enough.
> >
> What is your plan with that work - is your main/primary focus on the
> transition to the upstream XML, or you'll be able to do some cleanup
> alongside it ? Would you happen to have any wip branches publicly
> available ?
>
> If these two hinder that work in any way we can drop it.
>
> Thanks
> Emil
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RFC shader-db] Add support for shadertoy tests

2015-06-23 Thread Dylan Baker
I have a couple of python pointers for you, feel free to take them or
leave them.

Dylan

On Tue, Jun 16, 2015 at 03:46:50PM -0400, Rob Clark wrote:
> Attached script grabs shaders from shadertoy, and dumps them out as
> .shader_test files which can be run through shader-db for compiler
> testing.
> 
> shadertoy only gives you a fragment shader (which works based on
> gl_FragCoord), so a generic vertex shader is used.  And a blurb is
> inserted for the pre-defined uniforms and main() function (which just
> calls shadertoy mainImage() fxn).
> 
> ---
> TODO I guess we'd actually have to parse the shader to figure out if
> the sampler uniforms were meant to be 2D/cube/etc.  Maybe we just
> commit samplers we get from the script and massage them by hand?
> 
> PS. don't make fun of my py too much.. I'm a newb and figuring it
> out as I go

I'm trying not to make fun, but I do have quite a few pointers for you.

> 
>  grab-shadertoy.py | 63 
> +++
>  1 file changed, 63 insertions(+)
>  create mode 100755 grab-shadertoy.py
> 
> diff --git a/grab-shadertoy.py b/grab-shadertoy.py
> new file mode 100755
> index 000..74e9d10
> --- /dev/null
> +++ b/grab-shadertoy.py
> @@ -0,0 +1,63 @@
> +#!/usr/bin/env python3
> +
> +
> +import requests, json

You're not actually using json

> +
> +url = 'https://www.shadertoy.com/api/v1/shaders'
> +key = '?key=NdnKw7'
> +
> +# Get the list of shaders
> +r = requests.get(url + key)
> +j = r.json()
> +print('Found ' + str(j['Shaders']) + ' shaders')

If you use format you can avoid calling str() on everything, and make
things more readable using format rather than concatenation:
print('Found {} shaders'.format(j['Shaders']))

> +
> +shader_ids = j['Results']
> +for id in shader_ids:
> +print('Fetching shader: ' + str(id))
> +r = requests.get(url + '/' + id + key)
> +j = r.json()
> +s = j['Shader']
> +info = s['info']
> +print('Name: ' + info['name'])
> +print('Description: ' + info['description'])
> +i = 0;

python has a cool builtin called enumerate for doing this:
for i, p in enmerate(s['renderpass']):

Also, I know it's easy to forget, but python doesn't use ';' at the end
of lines, it allows them, but they look weird to pythonistas

> +for p in s['renderpass']:
> +fobj = open('shaders/shadertoy/' + str(id) + '_' + str(i) + 
> '.shader_test', 'w')

with str.format this would look like:
with open('shaders/shadertoy/{}_{}.shader_test'.format(id, i), 'w') as fobj:

> +#print('Inputs: ' + str(p['inputs']))
> +#print('Outputs: ' + str(p['outputs']))
> +fobj.write('[require]\n')
> +fobj.write('GLSL >= 1.30\n')
> +fobj.write('\n');
> +fobj.write('[fragment shader]\n')
> +fobj.write('#version 130\n')
> +# Shadertoy inserts some uniforms, so we need to do the same:
> +fobj.write('uniform vec3  iResolution;\n');
> +fobj.write('uniform float iGlobalTime;\n');
> +fobj.write('uniform float iChannelTime[4];\n');
> +fobj.write('uniform vec4  iMouse;\n');
> +fobj.write('uniform vec4  iDate;\n');
> +fobj.write('uniform float iSampleRate;\n');
> +fobj.write('uniform vec3  iChannelResolution[4];\n');
> +# TODO probably need to parse the shader to figure out if 
> 2d/cubemap/etc
> +fobj.write('uniform sampler2D iChannel0;\n');
> +fobj.write('uniform sampler2D iChannel1;\n');
> +fobj.write('uniform sampler2D iChannel2;\n');
> +fobj.write('uniform sampler2D iChannel3;\n');
> +# Actual shadertoy shader body:
> +fobj.write(p['code'])
> +# Shadertoy shader uses mainImage(out vec4 fragColor, in vec2 
> fragCoord)
> +# so we need to insert a main:
> +fobj.write('\nvoid main() { mainImage(gl_FragColor, 
> gl_FragCoord.xy); }\n')
> +fobj.write('\n\n')
> +# And a generic vertex shader:
> +fobj.write('[vertex shader]\n')
> +fobj.write('#version 130\n')
> +fobj.write('in vec2 position;\n')
> +fobj.write('\n')
> +fobj.write('void main()\n')
> +fobj.write('{\n')
> +fobj.write('   gl_Position = vec4(position, 0.0, 1.0);\n')
> +fobj.write('}\n')
> +
> +fobj.close()
> +i = 1 + i

You can simplify this quite a bit:

import textwrap

header = textwrap.dedent("""\
[require]
GLSL >= 1.30

[fragment shader]
#version 130
uniform vec3  iResolution;
uniform float iGlobalTime;
uniform float iChannelTime[4];
uniform vec4  iMouse;
uniform vec4  iDate;
uniform float iSampleRate;
uniform vec3  iChannelResolution[4];
uniform sampler2D iChannel0;
uniform sampler2D iChannel1;
uniform sampler2D iChannel2;
uniform sampler2D iChannel3;
""")

footer = textwarp.dedent("""\
void main() { mainImage(gl_FragColor, gl_FragCoord.xy); }

 

[Mesa-dev] [PATCH] glapi: fix argument parsing in glX_proto_recv.py

2015-07-02 Thread Dylan Baker
One of the plugins I use with vim "helpfully" added an underscore to the
front of mode for kicks.

Obviously this isn't a feature used very often because it's been broken
since d986cb7c70db (since May 20th), and no one has noticed.

Signed-off-by: Dylan Baker 
---
 src/mapi/glapi/gen/glX_proto_recv.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mapi/glapi/gen/glX_proto_recv.py 
b/src/mapi/glapi/gen/glX_proto_recv.py
index da468dc..5d95f27 100644
--- a/src/mapi/glapi/gen/glX_proto_recv.py
+++ b/src/mapi/glapi/gen/glX_proto_recv.py
@@ -549,9 +549,9 @@ def main():
 """Main function."""
 args = _parser()
 
-if args._mode == "dispatch_c":
+if args.mode == "dispatch_c":
 printer = PrintGlxDispatchFunctions(args.swap)
-elif args._mode == "dispatch_h":
+elif args.mode == "dispatch_h":
 printer = PrintGlxDispatch_h()
 
 api = gl_XML.parse_GL_API(
-- 
2.4.5

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


Re: [Mesa-dev] [PATCH] glapi: fix argument parsing in glX_proto_recv.py

2015-07-03 Thread Dylan Baker
I asked about dumping them and was told that they would leave mesa only
when x itself died. If be more than happy to see them go if they're not
useful
On Jul 3, 2015 06:28, "Emil Velikov"  wrote:

> On 02/07/15 18:25, Dylan Baker wrote:
> > One of the plugins I use with vim "helpfully" added an underscore to the
> > front of mode for kicks.
> >
> > Obviously this isn't a feature used very often because it's been broken
> > since d986cb7c70db (since May 20th), and no one has noticed.
> >
> Iirc these have a long and boring history with xserver. The short
> version is that they (and many other files reciding in
> XORG_GL{API,X}_DIR) have been dead/unused for a long while.
>
> If you want to avoid the rewriting them a few times, I would suggest
> that we nuke them up first. That's why I've asked about your plans
> earlier :)
>
> -Emil
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] nv50: fix a SIGSEGV with piglit bin/gl-3.1-vao-broken-attrib

2015-07-06 Thread Dylan Baker
On Mon, Jul 06, 2015 at 11:34:23PM +0200, Samuel Pitoiset wrote:
> Before validating vertex arrays we need to check if a VBO is present.
> Checking if vb->buffer is not NULL fixes the issue.
> 
> Signed-off-by: Samuel Pitoiset 
> ---
>  src/gallium/drivers/nouveau/nv50/nv50_vbo.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_vbo.c 
> b/src/gallium/drivers/nouveau/nv50/nv50_vbo.c
> index 1fd33b8..3d200bd 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_vbo.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_vbo.c
> @@ -382,6 +382,11 @@ nv50_vertex_arrays_validate(struct nv50_context *nv50)
>if (nv50->vbo_user & (1 << b)) {
>   address = addrs[b] + ve->pipe.src_offset;
>   limit = addrs[b] + limits[b];
> +  } else
> +  if (!vb->buffer) {

Should the else and if be on the same line?

> + BEGIN_NV04(push, NV50_3D(VERTEX_ARRAY_FETCH(i)), 1);
> + PUSH_DATA (push, 0);
> + continue;
>} else {
>   struct nv04_resource *buf = nv04_resource(vb->buffer);
>   if (!(refd & (1 << b))) {
> -- 
> 2.4.5
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


signature.asc
Description: Digital signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] nv50: fix a SIGSEGV with piglit bin/gl-3.1-vao-broken-attrib

2015-07-06 Thread Dylan Baker
> >> +  } else
> >> +  if (!vb->buffer) {
> >
> > Should the else and if be on the same line?
> 
> The general style elsewhere is to do it in this weird way. Can't say
> I'm a big fan, but I prefer consistency.
> 
> I'd happily take a change that undid that oddity.
> 

Odd, okay.


signature.asc
Description: Digital signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH shader-db] Add support for shadertoy tests

2015-07-09 Thread Dylan Baker
There's a few more cleanups you could do if you wanted, but either way:

Reviewed-by: Dylan Baker 

On Thu, Jul 09, 2015 at 10:41:05AM -0400, Rob Clark wrote:
> Attached script grabs shaders from shadertoy, and dumps them out as
> .shader_test files which can be run through shader-db for compiler
> testing.
> 
> shadertoy only gives you a fragment shader (which works based on
> gl_FragCoord), so a generic vertex shader is used.  And a blurb is
> inserted for the pre-defined uniforms and main() function (which just
> calls shadertoy mainImage() fxn).
> 
> v2: updated w/ python suggestions from Dylan
> 
> ---
> Note: we probably want to pick a couple shadertoy shaders and commit
> them (rather than pulling down *all* shadertoy shaders, which may
> change over time, etc).  I can just pick a couple randomly unless
> anyone has some requests.  Either way, seems useful to have the script
> in git in case anyone else wants to grab new/more shaders.
> 
>  grab-shadertoy.py | 66 
> +++
>  1 file changed, 66 insertions(+)
>  create mode 100755 grab-shadertoy.py
> 
> diff --git a/grab-shadertoy.py b/grab-shadertoy.py
> new file mode 100755
> index 000..04db411
> --- /dev/null
> +++ b/grab-shadertoy.py
> @@ -0,0 +1,66 @@
> +#!/usr/bin/env python3
> +
> +
> +import os, requests, textwrap
> +
> +url = 'https://www.shadertoy.com/api/v1/shaders'
> +key = '?key=NdnKw7'
> +
> +header = textwrap.dedent("""\
> +[require]
> +GLSL >= 1.30
> +
> +[fragment shader]
> +#version 130
> +uniform vec3  iResolution;
> +uniform float iGlobalTime;
> +uniform float iChannelTime[4];
> +uniform vec4  iMouse;
> +uniform vec4  iDate;
> +uniform float iSampleRate;
> +uniform vec3  iChannelResolution[4];
> +uniform sampler2D iChannel0;
> +uniform sampler2D iChannel1;
> +uniform sampler2D iChannel2;
> +uniform sampler2D iChannel3;
> +
> +""")
> +
> +footer = textwrap.dedent("""\
> +
> +void main() { mainImage(gl_FragColor, gl_FragCoord.xy); }
> +
> +[vertex shader]
> +#version 130
> +in vec2 position;
> +
> +void main()
> +{
> +   gl_Position = vec4(position, 0.0, 1.0);
> +}
> +""")
> +
> +# Get the list of shaders
> +r = requests.get(url + key)
> +j = r.json()
> +print('Found {} shaders'.format(j['Shaders']))
> +
> +shader_ids = j['Results']
> +for id in shader_ids:
> +print('Fetching shader: {}'.format(id))
> +print('url: {}/{}{}'.format(url, id, key))
> +r = requests.get(url + '/' + id + key)

You're generating the same value twice, maybe store it?

> +j = r.json()

you could drop the j variable:
r = requests.get(url + '/' + id + key).json()

> +s = j['Shader']
> +info = s['info']
> +print('Name: ' + info['name'])
> +print('Description: ' + info['description'])
> +if not os.path.exists('shaders/shadertoy'):
> +os.makedirs('shaders/shadertoy')
> +for i, p in enumerate(s['renderpass']):
> +#print('Inputs: {}'.format(p['inputs']))
> +#print('Outputs: {}'.format(p['outputs']))

Probably, you should either uncomment, delete these, or put them behind
some kind of guard.

> +with open('shaders/shadertoy/{}_{}.shader_test'.format(id, i), 'w') 
> as fobj:
> +fobj.write(header)
> +fobj.write(p['code'])
> +fobj.write(footer)
> -- 
> 2.4.3
> 


signature.asc
Description: Digital signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] [v3] i965: Split out gen8 push constant state upload

2015-07-13 Thread Dylan Baker
On Fri, Jul 10, 2015 at 02:24:42PM -0700, Ben Widawsky wrote:
> On Fri, Jul 10, 2015 at 12:03:54PM -0700, Matt Turner wrote:
> > I don't think putting Intel-internal links in the commit message is a good 
> > idea.
> > 
> > Ken's made similar comments to me.
> > 
> > Also, so much off the wall commentary...
> 
> Maybe my definition of "off the wall" is different than yours. The only thing
> off the wall to me, was the bit about missing Mark. It was *some* off the wall
> commentary.
> 
> That aside though, I think the internal links is a good point and thing to
> discuss... I've had a couple of cases already where I, or Neil benefited from
> the Jenkins links being there to try to figure out some later regression. I 
> can
> sympathize with not having internal links in the history since it isn't
> accessible to anyone. Earlier, I would have fought somewhat strongly for the
> links, except that when Mark moved servers he didn't preserve the old links, 
> so
> that made me feel like it's a lot more transient than I initially felt.
> 
> However, I think it's really valuable for us to have them in the patches,
> especially for review by some of the internal folks - like isn't it great to 
> see
> for yourself that I ran it? I suppose I can discard the URLs before pushing. 
> The
> cases I mentioned above would have benefited just as well having the links on
> the list and not in the commit history (albeit a bit harder to find). Any
> opposition to that?

It's worth pointing out in this discussion that old results are pruned
after so many days. It's simply not practical for us to store all of the
results forever.

Dylan


signature.asc
Description: Digital signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glapi: fix argument parsing in glX_proto_recv.py

2015-07-21 Thread Dylan Baker
Cool, I was under that impression too, but having it confirmed is great.

Since these do matter and I don't have push access, could you make sure
this lands?
On Jul 21, 2015 15:33, "Emil Velikov"  wrote:

> It seems that I was under the wrong impression on the hole thing.
>
> Some of the files generated from these scripts are used in/by xserver.
> Although they are imported/tracked into version control of the latter in
> order to prevent the xserver build directly diving into mesa source tree.
>
> The XORG_GLAPI_OUTPUTS files on the other hand, are the ones that were
> removed from xserver with commit be6680967a4(glx: convert to direct GL
> dispatch (v2)). Unfortunatelly they only cover ~20 lines of makefile
> rules, thus none of the python scripts can be removed/simplified.
>
> Apologies if I mislead anyone.
>
> -Emil
>
>
> On 04/07/15 10:42, Emil Velikov wrote:
> > Seems like there is a misunderstanding somewhere - perhaps some on my
> > end. Yet I do recall Adam Jackson stating on numerous occasions, on
> > IRC, that we don't want/need any sources from mesa (outside
> > dri_interface.h and the gl* headers) for xserver.
> >
> > Adam can we truly nuke (some of) the generated sources in mesa, or
> > does X/xserver relies on them ?
> >
> > Cheers,
> > Emil
> >
> > On 3 July 2015 at 21:13, Dylan Baker  wrote:
> >> I asked about dumping them and was told that they would leave mesa only
> when
> >> x itself died. If be more than happy to see them go if they're not
> useful
> >>
> >> On Jul 3, 2015 06:28, "Emil Velikov"  wrote:
> >>>
> >>> On 02/07/15 18:25, Dylan Baker wrote:
> >>>> One of the plugins I use with vim "helpfully" added an underscore to
> the
> >>>> front of mode for kicks.
> >>>>
> >>>> Obviously this isn't a feature used very often because it's been
> broken
> >>>> since d986cb7c70db (since May 20th), and no one has noticed.
> >>>>
> >>> Iirc these have a long and boring history with xserver. The short
> >>> version is that they (and many other files reciding in
> >>> XORG_GL{API,X}_DIR) have been dead/unused for a long while.
> >>>
> >>> If you want to avoid the rewriting them a few times, I would suggest
> >>> that we nuke them up first. That's why I've asked about your plans
> >>> earlier :)
> >>>
> >>> -Emil
> >>>
> >>
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH shader-db] check_dependencies: refactor to a python script

2015-10-12 Thread Dylan Baker
On Sat, Oct 10, 2015 at 06:45:08PM +1100, Rhys Kidd wrote:
> Deliver consistency with all other shader-db scripts, which are Python 
> scripts.
> 
> No change in features or output strings.
> 
> Passed pep8, except for two comment lines suggesting commands to add
> dependencies to the [require] section of *.shader_test files.
> 
> Although not a performance critical feature, equivalent performance to
> Perl script other than process_directories() recursive directory traversal.
> 
> os.scandir(item) would be significantly faster than os.walk(item), however
> its use would introduce a minimum dependency on Python 3.5 which is preferably
> avoided at this time.
> 
> Signed-off-by: Rhys Kidd 
> ---
>  check_dependencies.pl | 107 
> --
>  check_dependencies.py |  82 ++
>  2 files changed, 82 insertions(+), 107 deletions(-)
>  delete mode 100755 check_dependencies.pl
>  create mode 100755 check_dependencies.py
> 
> diff --git a/check_dependencies.pl b/check_dependencies.pl
> deleted file mode 100755
> index 3e49f7f..000
> --- a/check_dependencies.pl
> +++ /dev/null
> @@ -1,107 +0,0 @@
> -#!/usr/bin/perl
> -#
> -# Copyright © 2014 Intel Corporation
> -#
> -# Permission is hereby granted, free of charge, to any person obtaining a
> -# copy of this software and associated documentation files (the "Software"),
> -# to deal in the Software without restriction, including without limitation
> -# the rights to use, copy, modify, merge, publish, distribute, sublicense,
> -# and/or sell copies of the Software, and to permit persons to whom the
> -# Software is furnished to do so, subject to the following conditions:
> -#
> -# The above copyright notice and this permission notice (including the next
> -# paragraph) shall be included in all copies or substantial portions of the
> -# Software.
> -#
> -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> DEALINGS
> -# IN THE SOFTWARE.
> -
> -# For checking that shader_test's dependencies are correct.
> -#
> -# Run with
> -#./check_dependencies.pl shaders/
> -#
> -# And then run a command like these to add dependencies to the [require]
> -# section:
> -#
> -# find shaders/ -name '*.shader_test' -exec grep -l '#version 120' {} + | 
> xargs sed -i -e 's/GLSL >= 1.10/GLSL >= 1.20/'
> -# find shaders/ -name '*.shader_test' -exec grep -l '#extension 
> GL_ARB_texture_rectangle : require' {} + | xargs sed -i -e 's/GLSL >= 
> 1.20/GLSL >= 1.20\nGL_ARB_texture_rectangle/'
> -
> -use strict;
> -use File::Find;
> -
> -die("Not enough arguments: specify a directory\n") if ($#ARGV < 0);
> -
> -# The array_diff function is copied from the Array::Utils package and 
> contains
> -# this copyright:
> -#
> -# This module is Copyright (c) 2007 Sergei A. Fedorov.
> -# All rights reserved.
> -#
> -# You may distribute under the terms of either the GNU General Public
> -# License or the Artistic License, as specified in the Perl README file.
> -sub array_diff(\@\@) {
> - my %e = map { $_ => undef } @{$_[1]};
> - return @{[ ( grep { (exists $e{$_}) ? ( delete $e{$_} ) : ( 1 ) } @{ 
> $_[0] } ), keys %e ] };
> -}
> -
> -my @shader_test;
> -
> -sub wanted {
> - push(@shader_test, $File::Find::name) if (/\.shader_test$/);
> -}
> -
> -finddepth(\&wanted,  @ARGV);
> -
> -my $fail = 0;
> -
> -foreach my $shader_test (@shader_test) {
> - my $expected;
> - my $actual;
> - my @expected_ext;
> - my @actual_ext;
> -
> - open(my $fh, "<", $shader_test)
> - or die("cannot open < $shader_test: $!\n");
> - 
> - while (<$fh>) {
> - chomp;
> -
> - if (/^GLSL >= (\d)\.(\d\d)/) {
> - $expected = $1 * 100 + $2;
> - }
> - if (/^\s*#\s*version\s+(\d{3})/) {
> - $actual = $1 if $actual == undef;
> - $actual = $1 if $actual < $1;
> - }
> -
> - if (/^(GL_\S+)/) {
> - next if ($1 eq "GL_ARB_fragment_program" ||
> -  $1 eq "GL_ARB_vertex_program");
> - push(@expected_ext, $1);
> - }
> - if (/^\s*#\s*extension\s+(GL_\S+)\s*:\s*require/) {
> - push(@actual_ext, $1);
> - }
> - }
> -
> - close($fh);
> -
> - if ($actual != undef && $expected != $actual) {
> - print "$shader_test requested $expected, but requires 
> $actual\n";
> - $fail = 1;
> - }
> -
> - my @extension = array_diff(@expect

Re: [Mesa-dev] [PATCH 5/7] nir/algebraic: Support specifying variable as constant or by type

2015-01-29 Thread Dylan Baker
On Thursday, January 29, 2015 17:00:08 Kenneth Graunke wrote:
> On Thursday, January 29, 2015 12:50:20 PM Jason Ekstrand wrote:
> > ---
> >  src/glsl/nir/nir_algebraic.py | 20 +---
> >  src/glsl/nir/nir_opt_algebraic.py | 12 +---
> >  2 files changed, 26 insertions(+), 6 deletions(-)
> > 
> > diff --git a/src/glsl/nir/nir_algebraic.py b/src/glsl/nir/nir_algebraic.py
> > index 75436f4..6e7973d 100644
> > --- a/src/glsl/nir/nir_algebraic.py
> > +++ b/src/glsl/nir/nir_algebraic.py
> > @@ -28,6 +28,7 @@ import itertools
> >  import struct
> >  import sys
> >  import mako.template
> > +import re
> >  
> >  # Represents a set of variables, each with a unique id
> >  class VarSet(object):
> > @@ -65,6 +66,8 @@ static const ${val.c_type} ${val.name} = {
> > { ${hex(val)} /* ${val.value} */ },
> >  % elif isinstance(val, Variable):
> > ${val.index}, /* ${val.var_name} */
> > +   ${'true' if val.is_constant else 'false'},
> > +   nir_type_${'void' if val.required_type is None else val.required_type},
> 
>nir_type_${val.required_type or 'void'}

This is equivalent except in a few cases, namely 'void' will be picked
over any falsy value, not just None. Reasonable falsy values might be 0
or '' (empty string).

> 
> >  % elif isinstance(val, Expression):
> > nir_op_${val.opcode},
> > { ${', '.join(src.c_ptr for src in val.sources)} },
> > @@ -111,12 +114,23 @@ class Constant(Value):
> >else:
> >   assert False
> >  
> > +_var_name_re = re.compile(r"(?P#)?(?P\w+)(?:@(?P\w+))?")
> > +
> >  class Variable(Value):
> > def __init__(self, val, name, varset):
> >Value.__init__(self, name, "variable")
> > -  self.var_name = val
> > -  self.index = varset[val]
> > -  self.name = name
> > +
> > +  m = _var_name_re.match(val)
> > +  assert m and m.group('name') is not None

Can m.group('name') actually be None? I don't think it can.

> > +
> > +  self.var_name = m.group('name')
> > +  self.is_constant = m.group('const') is not None
> > +  self.required_type = m.group('type')
> > +
> > +  if self.required_type is not None:
> > + assert self.required_type in ('float', 'bool', 'int', 'unsigned')
> > +
> > +  self.index = varset[self.var_name]
> >  
> >  class Expression(Value):
> > def __init__(self, expr, name_base, varset):
> > diff --git a/src/glsl/nir/nir_opt_algebraic.py 
> > b/src/glsl/nir/nir_opt_algebraic.py
> > index 9c62b28..1dea42a 100644
> > --- a/src/glsl/nir/nir_opt_algebraic.py
> > +++ b/src/glsl/nir/nir_opt_algebraic.py
> > @@ -36,9 +36,15 @@ d = 'd'
> >  # and  is either an expression or a value.  An expression is
> >  # defined as a tuple of the form (, , , , )
> >  # where each source is either an expression or a value.  A value can be
> > -# either a numeric constant or a string representing a variable name.  For
> > -# constants, you have to be careful to make sure that it is the right type
> > -# because python is unaware of the source and destination types of the
> > +# either a numeric constant or a string representing a variable name.
> > +#
> > +# Variable names are specified as "[#]name[@type]" where "#" inicates that
> > +# the given variable will only match constants and thpe type indicates that
> 
>  typo 
> 
> > +# the given variable will only match values from ALU instructions with the
> > +# given output type.
> > +#
> > +# For constants, you have to be careful to make sure that it is the right
> > +# type because python is unaware of the source and destination types of the
> >  # opcodes.
> >  
> >  optimizations = [


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glsl: Allow compatibility shaders with MESA_GL_VERSION_OVERRIDE=...

2017-02-02 Thread Dylan Baker
Tested-by: Dylan Baker 


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


[Mesa-dev] [PATCH] vulkan/util: Add generator for enum_to_str functions

2017-02-17 Thread Dylan Baker
This adds a python generator to produce enum_to_str functions for
Vulkan from the vk.xml API description. It supports extensions as well
as core API features, and the generator works with both python2 and
python3.

CC: Jason Ekstrand 
Signed-off-by: Dylan Baker 
---
 configure.ac   |   1 +
 src/Makefile.am|   1 +
 src/intel/vulkan/Makefile.am   |   2 +
 src/intel/vulkan/anv_util.c|  36 +---
 src/vulkan/util/.gitignore |   1 +
 src/vulkan/util/Makefile.am|  22 +
 src/vulkan/util/gen_enum_to_str.py | 172 +
 7 files changed, 201 insertions(+), 34 deletions(-)
 create mode 100644 src/vulkan/util/.gitignore
 create mode 100644 src/vulkan/util/Makefile.am
 create mode 100644 src/vulkan/util/gen_enum_to_str.py

diff --git a/configure.ac b/configure.ac
index 7e4544f5bf..c83a5234da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2691,6 +2691,7 @@ AC_CONFIG_FILES([Makefile
src/mesa/main/tests/Makefile
src/util/Makefile
src/util/tests/hash_table/Makefile
+   src/vulkan/util/Makefile
src/vulkan/wsi/Makefile])
 
 AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index 12e5dcdb12..90f95b2265 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -117,6 +117,7 @@ SUBDIRS += intel/tools
 endif
 
 if HAVE_VULKAN_COMMON
+SUBDIRS += vulkan/util
 SUBDIRS += vulkan/wsi
 endif
 EXTRA_DIST += vulkan/registry/vk.xml
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 4197b0e77c..54bf0f5de1 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -49,6 +49,7 @@ AM_CPPFLAGS = \
-I$(top_builddir)/src \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/vulkan/wsi \
+   -I$(top_builddir)/src/vulkan/util \
-I$(top_builddir)/src/compiler \
-I$(top_srcdir)/src/compiler \
-I$(top_builddir)/src/compiler/nir \
@@ -125,6 +126,7 @@ libvulkan_common_la_SOURCES = $(VULKAN_SOURCES)
 
 VULKAN_LIB_DEPS += \
libvulkan_common.la \
+   $(top_builddir)/src/vulkan/util/libvulkan_util.la \
$(top_builddir)/src/vulkan/wsi/libvulkan_wsi.la \
$(top_builddir)/src/mesa/drivers/dri/i965/libi965_compiler.la \
$(top_builddir)/src/compiler/nir/libnir.la \
diff --git a/src/intel/vulkan/anv_util.c b/src/intel/vulkan/anv_util.c
index 6d75187065..ec5c9486d8 100644
--- a/src/intel/vulkan/anv_util.c
+++ b/src/intel/vulkan/anv_util.c
@@ -29,6 +29,7 @@
 #include 
 
 #include "anv_private.h"
+#include "vk_enum_to_str.h"
 
 /** Log an error message.  */
 void anv_printflike(1, 2)
@@ -69,40 +70,7 @@ __vk_errorf(VkResult error, const char *file, int line, 
const char *format, ...)
va_list ap;
char buffer[256];
 
-#define ERROR_CASE(error) case error: error_str = #error; break;
-
-   const char *error_str;
-   switch ((int32_t)error) {
-
-   /* Core errors */
-   ERROR_CASE(VK_ERROR_OUT_OF_HOST_MEMORY)
-   ERROR_CASE(VK_ERROR_OUT_OF_DEVICE_MEMORY)
-   ERROR_CASE(VK_ERROR_INITIALIZATION_FAILED)
-   ERROR_CASE(VK_ERROR_DEVICE_LOST)
-   ERROR_CASE(VK_ERROR_MEMORY_MAP_FAILED)
-   ERROR_CASE(VK_ERROR_LAYER_NOT_PRESENT)
-   ERROR_CASE(VK_ERROR_EXTENSION_NOT_PRESENT)
-   ERROR_CASE(VK_ERROR_FEATURE_NOT_PRESENT)
-   ERROR_CASE(VK_ERROR_INCOMPATIBLE_DRIVER)
-   ERROR_CASE(VK_ERROR_TOO_MANY_OBJECTS)
-   ERROR_CASE(VK_ERROR_FORMAT_NOT_SUPPORTED)
-   ERROR_CASE(VK_ERROR_FRAGMENTED_POOL)
-
-   /* Extension errors */
-   ERROR_CASE(VK_ERROR_SURFACE_LOST_KHR)
-   ERROR_CASE(VK_ERROR_NATIVE_WINDOW_IN_USE_KHR)
-   ERROR_CASE(VK_ERROR_OUT_OF_DATE_KHR)
-   ERROR_CASE(VK_ERROR_INCOMPATIBLE_DISPLAY_KHR)
-   ERROR_CASE(VK_ERROR_VALIDATION_FAILED_EXT)
-   ERROR_CASE(VK_ERROR_INVALID_SHADER_NV)
-   ERROR_CASE(VK_ERROR_OUT_OF_POOL_MEMORY_KHR)
-
-   default:
-  assert(!"Unknown error");
-  error_str = "unknown error";
-   }
-
-#undef ERROR_CASE
+   const char *error_str = vk_Result_to_str(error);
 
if (format) {
   va_start(ap, format);
diff --git a/src/vulkan/util/.gitignore b/src/vulkan/util/.gitignore
new file mode 100644
index 00..5c79217982
--- /dev/null
+++ b/src/vulkan/util/.gitignore
@@ -0,0 +1 @@
+vk_enum_to_str.*
diff --git a/src/vulkan/util/Makefile.am b/src/vulkan/util/Makefile.am
new file mode 100644
index 00..ced83e8873
--- /dev/null
+++ b/src/vulkan/util/Makefile.am
@@ -0,0 +1,22 @@
+vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
+
+AM_CPPFLAGS = \
+   -I$(top_srcdir)/include \
+   -I$(top_srcdir)/src
+
+EXTRA_DIST= \
+   gen_enum_to_str.py
+
+BUILT_SOURCES= \
+   vk_enum_to_str.c \
+   vk_enum_to_str.h
+
+vk_enum_to_str.c vk_enum_to_str.h: gen_enum_to_str.py $(vulkan_api_xml)
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/gen_enum_to_str.py
+
+noinst_LTLIBRARIES = libvulkan_util.la
+
+libvulkan_util_la_SOURCES = \
+   vk_enum_to_str.c \
+   vk_enum

Re: [Mesa-dev] [PATCH] vulkan/util: Add generator for enum_to_str functions

2017-02-17 Thread Dylan Baker
I'll send out a v2 soon.

Quoting Matt Turner (2017-02-17 11:38:17)
> On Fri, Feb 17, 2017 at 10:49 AM, Dylan Baker  wrote:
> > This adds a python generator to produce enum_to_str functions for
> > Vulkan from the vk.xml API description. It supports extensions as well
> > as core API features, and the generator works with both python2 and
> > python3.
> >
> > CC: Jason Ekstrand 
> > Signed-off-by: Dylan Baker 
> > ---
> >  configure.ac   |   1 +
> >  src/Makefile.am|   1 +
> >  src/intel/vulkan/Makefile.am   |   2 +
> >  src/intel/vulkan/anv_util.c|  36 +---
> >  src/vulkan/util/.gitignore |   1 +
> >  src/vulkan/util/Makefile.am|  22 +
> >  src/vulkan/util/gen_enum_to_str.py | 172 
> > +
> >  7 files changed, 201 insertions(+), 34 deletions(-)
> >  create mode 100644 src/vulkan/util/.gitignore
> >  create mode 100644 src/vulkan/util/Makefile.am
> >  create mode 100644 src/vulkan/util/gen_enum_to_str.py
> >
> > diff --git a/configure.ac b/configure.ac
> > index 7e4544f5bf..c83a5234da 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -2691,6 +2691,7 @@ AC_CONFIG_FILES([Makefile
> > src/mesa/main/tests/Makefile
> > src/util/Makefile
> > src/util/tests/hash_table/Makefile
> > +   src/vulkan/util/Makefile
> > src/vulkan/wsi/Makefile])
> 
> These two really don't need to be separate Makefiles.
> 
> Can you try, as a follow-on, to combine them as a unified
> src/vulkan/Makefile.am?

Okay, I'll do that

> 
> >
> >  AC_OUTPUT
> > diff --git a/src/Makefile.am b/src/Makefile.am
> > index 12e5dcdb12..90f95b2265 100644
> > --- a/src/Makefile.am
> > +++ b/src/Makefile.am
> > @@ -117,6 +117,7 @@ SUBDIRS += intel/tools
> >  endif
> >
> >  if HAVE_VULKAN_COMMON
> > +SUBDIRS += vulkan/util
> >  SUBDIRS += vulkan/wsi
> 
> List both on the same line.

done

> 
> >  endif
> >  EXTRA_DIST += vulkan/registry/vk.xml
> > diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
> > index 4197b0e77c..54bf0f5de1 100644
> > --- a/src/intel/vulkan/Makefile.am
> > +++ b/src/intel/vulkan/Makefile.am
> > @@ -49,6 +49,7 @@ AM_CPPFLAGS = \
> > -I$(top_builddir)/src \
> > -I$(top_srcdir)/src \
> > -I$(top_srcdir)/src/vulkan/wsi \
> > +   -I$(top_builddir)/src/vulkan/util \
> > -I$(top_builddir)/src/compiler \
> > -I$(top_srcdir)/src/compiler \
> > -I$(top_builddir)/src/compiler/nir \
> > @@ -125,6 +126,7 @@ libvulkan_common_la_SOURCES = $(VULKAN_SOURCES)
> >
> >  VULKAN_LIB_DEPS += \
> > libvulkan_common.la \
> > +   $(top_builddir)/src/vulkan/util/libvulkan_util.la \
> > $(top_builddir)/src/vulkan/wsi/libvulkan_wsi.la \
> > $(top_builddir)/src/mesa/drivers/dri/i965/libi965_compiler.la \
> > $(top_builddir)/src/compiler/nir/libnir.la \
> > diff --git a/src/intel/vulkan/anv_util.c b/src/intel/vulkan/anv_util.c
> > index 6d75187065..ec5c9486d8 100644
> > --- a/src/intel/vulkan/anv_util.c
> > +++ b/src/intel/vulkan/anv_util.c
> > @@ -29,6 +29,7 @@
> >  #include 
> >
> >  #include "anv_private.h"
> > +#include "vk_enum_to_str.h"
> >
> >  /** Log an error message.  */
> >  void anv_printflike(1, 2)
> > @@ -69,40 +70,7 @@ __vk_errorf(VkResult error, const char *file, int line, 
> > const char *format, ...)
> > va_list ap;
> > char buffer[256];
> >
> > -#define ERROR_CASE(error) case error: error_str = #error; break;
> > -
> > -   const char *error_str;
> > -   switch ((int32_t)error) {
> > -
> > -   /* Core errors */
> > -   ERROR_CASE(VK_ERROR_OUT_OF_HOST_MEMORY)
> > -   ERROR_CASE(VK_ERROR_OUT_OF_DEVICE_MEMORY)
> > -   ERROR_CASE(VK_ERROR_INITIALIZATION_FAILED)
> > -   ERROR_CASE(VK_ERROR_DEVICE_LOST)
> > -   ERROR_CASE(VK_ERROR_MEMORY_MAP_FAILED)
> > -   ERROR_CASE(VK_ERROR_LAYER_NOT_PRESENT)
> > -   ERROR_CASE(VK_ERROR_EXTENSION_NOT_PRESENT)
> > -   ERROR_CASE(VK_ERROR_FEATURE_NOT_PRESENT)
> > -   ERROR_CASE(VK_ERROR_INCOMPATIBLE_DRIVER)
> > -   ERROR_CASE(VK_ERROR_TOO_MANY_OBJECTS)
> > -   ERROR_CASE(VK_ERROR_FORMAT_NOT_SUPPORTED)
> > -   ERROR_CASE(VK_ERROR_FRAGMENTED_POOL)
> > -
> > -   /* Extension errors */
> > -   ERROR_CASE(VK_ERROR_SURFACE_LOST_KHR)
> 

[Mesa-dev] [PATCH v2 2/2] vulkan: Combine wsi and util makefiles

2017-02-17 Thread Dylan Baker
cc: Matt Turner 
Signed-off-by: Dylan Baker 

v2: - add this patch
---
 configure.ac   |  3 +--
 src/Makefile.am|  2 +-
 src/intel/vulkan/Makefile.am   |  4 ++--
 src/vulkan/{wsi => }/Makefile.am   | 16 ++--
 src/vulkan/Makefile.sources| 16 
 src/vulkan/util/Makefile.am| 22 --
 src/vulkan/util/gen_enum_to_str.py |  4 ++--
 src/vulkan/wsi/Makefile.sources| 12 
 8 files changed, 36 insertions(+), 43 deletions(-)
 rename src/vulkan/{wsi => }/Makefile.am (70%)
 create mode 100644 src/vulkan/Makefile.sources
 delete mode 100644 src/vulkan/util/Makefile.am
 delete mode 100644 src/vulkan/wsi/Makefile.sources

diff --git a/configure.ac b/configure.ac
index c83a5234da..44c788377b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2691,8 +2691,7 @@ AC_CONFIG_FILES([Makefile
src/mesa/main/tests/Makefile
src/util/Makefile
src/util/tests/hash_table/Makefile
-   src/vulkan/util/Makefile
-   src/vulkan/wsi/Makefile])
+   src/vulkan/Makefile])
 
 AC_OUTPUT
 
diff --git a/src/Makefile.am b/src/Makefile.am
index cbdf378c54..860be53c01 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -117,7 +117,7 @@ SUBDIRS += intel/tools
 endif
 
 if HAVE_VULKAN_COMMON
-SUBDIRS += vulkan/util vulkan/wsi
+SUBDIRS += vulkan
 endif
 EXTRA_DIST += vulkan/registry/vk.xml
 
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 54bf0f5de1..8089762610 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -126,8 +126,8 @@ libvulkan_common_la_SOURCES = $(VULKAN_SOURCES)
 
 VULKAN_LIB_DEPS += \
libvulkan_common.la \
-   $(top_builddir)/src/vulkan/util/libvulkan_util.la \
-   $(top_builddir)/src/vulkan/wsi/libvulkan_wsi.la \
+   $(top_builddir)/src/vulkan/libvulkan_util.la \
+   $(top_builddir)/src/vulkan/libvulkan_wsi.la \
$(top_builddir)/src/mesa/drivers/dri/i965/libi965_compiler.la \
$(top_builddir)/src/compiler/nir/libnir.la \
$(top_builddir)/src/util/libmesautil.la \
diff --git a/src/vulkan/wsi/Makefile.am b/src/vulkan/Makefile.am
similarity index 70%
rename from src/vulkan/wsi/Makefile.am
rename to src/vulkan/Makefile.am
index a71279947a..df84cfd71d 100644
--- a/src/vulkan/wsi/Makefile.am
+++ b/src/vulkan/Makefile.am
@@ -1,9 +1,21 @@
-
 include Makefile.sources
 
+noinst_LTLIBRARIES = libvulkan_wsi.la libvulkan_util.la 
+
 vulkan_includedir = $(includedir)/vulkan
+vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
+
+EXTRA_DIST = \
+   util/gen_enum_to_str.py
+
+BUILT_SOURCES = \
+   util/vk_enum_to_str.c \
+   util/vk_enum_to_str.h
+
+util/vk_enum_to_str.c util/vk_enum_to_str.h: util/gen_enum_to_str.py 
$(vulkan_api_xml)
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/util/gen_enum_to_str.py
 
-noinst_LTLIBRARIES = libvulkan_wsi.la
+libvulkan_util_la_SOURCES = $(VULKAN_UTIL_FILES)
 
 AM_CPPFLAGS = \
$(DEFINES) \
diff --git a/src/vulkan/Makefile.sources b/src/vulkan/Makefile.sources
new file mode 100644
index 00..fbb8bfc51d
--- /dev/null
+++ b/src/vulkan/Makefile.sources
@@ -0,0 +1,16 @@
+
+VULKAN_WSI_FILES := \
+   wsi/wsi_common.h \
+   wsi/wsi_common_queue.h
+
+VULKAN_WSI_WAYLAND_FILES := \
+   wsi/wsi_common_wayland.c \
+   wsi/wsi_common_wayland.h
+
+VULKAN_WSI_X11_FILES := \
+   wsi/wsi_common_x11.c \
+   wsi/wsi_common_x11.h
+
+VULKAN_UTIL_FILES := \
+   util/vk_enum_to_str.c \
+   util/vk_enum_to_str.h
diff --git a/src/vulkan/util/Makefile.am b/src/vulkan/util/Makefile.am
deleted file mode 100644
index 87c96d5e5b..00
--- a/src/vulkan/util/Makefile.am
+++ /dev/null
@@ -1,22 +0,0 @@
-vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
-
-AM_CPPFLAGS = \
-   -I$(top_srcdir)/include \
-   -I$(top_srcdir)/src
-
-EXTRA_DIST = \
-   gen_enum_to_str.py
-
-BUILT_SOURCES = \
-   vk_enum_to_str.c \
-   vk_enum_to_str.h
-
-vk_enum_to_str.c vk_enum_to_str.h: gen_enum_to_str.py $(vulkan_api_xml)
-   $(AM_V_GEN)$(PYTHON2) $(srcdir)/gen_enum_to_str.py
-
-noinst_LTLIBRARIES = libvulkan_util.la
-
-libvulkan_util_la_SOURCES = \
-   vk_enum_to_str.c \
-   vk_enum_to_str.h
-
diff --git a/src/vulkan/util/gen_enum_to_str.py 
b/src/vulkan/util/gen_enum_to_str.py
index 0564b8e028..4b6fdf3b3d 100644
--- a/src/vulkan/util/gen_enum_to_str.py
+++ b/src/vulkan/util/gen_enum_to_str.py
@@ -159,8 +159,8 @@ def xml_parser(filename):
 
 def main():
 enums = xml_parser(VK_XML)
-for template, file_ in [(C_TEMPLATE, 'vk_enum_to_str.c'),
-(H_TEMPLATE, 'vk_enum_to_str.h')]:
+for template, file_ in [(C_TEMPLATE, 'util/vk_enum_to_str.c'),
+(H_TEMPLATE, 'util/vk_enum_to_str.h')]:
 with open(file_, 'wb') as f:
 f.write(template

[Mesa-dev] [PATCH v2 1/2] vulkan/util: Add generator for enum_to_str functions

2017-02-17 Thread Dylan Baker
This adds a python generator to produce enum_to_str functions for
Vulkan from the vk.xml API description. It supports extensions as well
as core API features, and the generator works with both python2 and
python3.

Signed-off-by: Dylan Baker 

v2: - Fix automake comments from Matt
---
 configure.ac   |   1 +
 src/Makefile.am|   2 +-
 src/intel/vulkan/Makefile.am   |   2 +
 src/intel/vulkan/anv_util.c|  36 +---
 src/vulkan/util/.gitignore |   1 +
 src/vulkan/util/Makefile.am|  22 +
 src/vulkan/util/gen_enum_to_str.py | 172 +
 7 files changed, 201 insertions(+), 35 deletions(-)
 create mode 100644 src/vulkan/util/.gitignore
 create mode 100644 src/vulkan/util/Makefile.am
 create mode 100644 src/vulkan/util/gen_enum_to_str.py

diff --git a/configure.ac b/configure.ac
index 7e4544f5bf..c83a5234da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2691,6 +2691,7 @@ AC_CONFIG_FILES([Makefile
src/mesa/main/tests/Makefile
src/util/Makefile
src/util/tests/hash_table/Makefile
+   src/vulkan/util/Makefile
src/vulkan/wsi/Makefile])
 
 AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index 12e5dcdb12..cbdf378c54 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -117,7 +117,7 @@ SUBDIRS += intel/tools
 endif
 
 if HAVE_VULKAN_COMMON
-SUBDIRS += vulkan/wsi
+SUBDIRS += vulkan/util vulkan/wsi
 endif
 EXTRA_DIST += vulkan/registry/vk.xml
 
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 4197b0e77c..54bf0f5de1 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -49,6 +49,7 @@ AM_CPPFLAGS = \
-I$(top_builddir)/src \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/vulkan/wsi \
+   -I$(top_builddir)/src/vulkan/util \
-I$(top_builddir)/src/compiler \
-I$(top_srcdir)/src/compiler \
-I$(top_builddir)/src/compiler/nir \
@@ -125,6 +126,7 @@ libvulkan_common_la_SOURCES = $(VULKAN_SOURCES)
 
 VULKAN_LIB_DEPS += \
libvulkan_common.la \
+   $(top_builddir)/src/vulkan/util/libvulkan_util.la \
$(top_builddir)/src/vulkan/wsi/libvulkan_wsi.la \
$(top_builddir)/src/mesa/drivers/dri/i965/libi965_compiler.la \
$(top_builddir)/src/compiler/nir/libnir.la \
diff --git a/src/intel/vulkan/anv_util.c b/src/intel/vulkan/anv_util.c
index 6d75187065..ec5c9486d8 100644
--- a/src/intel/vulkan/anv_util.c
+++ b/src/intel/vulkan/anv_util.c
@@ -29,6 +29,7 @@
 #include 
 
 #include "anv_private.h"
+#include "vk_enum_to_str.h"
 
 /** Log an error message.  */
 void anv_printflike(1, 2)
@@ -69,40 +70,7 @@ __vk_errorf(VkResult error, const char *file, int line, 
const char *format, ...)
va_list ap;
char buffer[256];
 
-#define ERROR_CASE(error) case error: error_str = #error; break;
-
-   const char *error_str;
-   switch ((int32_t)error) {
-
-   /* Core errors */
-   ERROR_CASE(VK_ERROR_OUT_OF_HOST_MEMORY)
-   ERROR_CASE(VK_ERROR_OUT_OF_DEVICE_MEMORY)
-   ERROR_CASE(VK_ERROR_INITIALIZATION_FAILED)
-   ERROR_CASE(VK_ERROR_DEVICE_LOST)
-   ERROR_CASE(VK_ERROR_MEMORY_MAP_FAILED)
-   ERROR_CASE(VK_ERROR_LAYER_NOT_PRESENT)
-   ERROR_CASE(VK_ERROR_EXTENSION_NOT_PRESENT)
-   ERROR_CASE(VK_ERROR_FEATURE_NOT_PRESENT)
-   ERROR_CASE(VK_ERROR_INCOMPATIBLE_DRIVER)
-   ERROR_CASE(VK_ERROR_TOO_MANY_OBJECTS)
-   ERROR_CASE(VK_ERROR_FORMAT_NOT_SUPPORTED)
-   ERROR_CASE(VK_ERROR_FRAGMENTED_POOL)
-
-   /* Extension errors */
-   ERROR_CASE(VK_ERROR_SURFACE_LOST_KHR)
-   ERROR_CASE(VK_ERROR_NATIVE_WINDOW_IN_USE_KHR)
-   ERROR_CASE(VK_ERROR_OUT_OF_DATE_KHR)
-   ERROR_CASE(VK_ERROR_INCOMPATIBLE_DISPLAY_KHR)
-   ERROR_CASE(VK_ERROR_VALIDATION_FAILED_EXT)
-   ERROR_CASE(VK_ERROR_INVALID_SHADER_NV)
-   ERROR_CASE(VK_ERROR_OUT_OF_POOL_MEMORY_KHR)
-
-   default:
-  assert(!"Unknown error");
-  error_str = "unknown error";
-   }
-
-#undef ERROR_CASE
+   const char *error_str = vk_Result_to_str(error);
 
if (format) {
   va_start(ap, format);
diff --git a/src/vulkan/util/.gitignore b/src/vulkan/util/.gitignore
new file mode 100644
index 00..5c79217982
--- /dev/null
+++ b/src/vulkan/util/.gitignore
@@ -0,0 +1 @@
+vk_enum_to_str.*
diff --git a/src/vulkan/util/Makefile.am b/src/vulkan/util/Makefile.am
new file mode 100644
index 00..87c96d5e5b
--- /dev/null
+++ b/src/vulkan/util/Makefile.am
@@ -0,0 +1,22 @@
+vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
+
+AM_CPPFLAGS = \
+   -I$(top_srcdir)/include \
+   -I$(top_srcdir)/src
+
+EXTRA_DIST = \
+   gen_enum_to_str.py
+
+BUILT_SOURCES = \
+   vk_enum_to_str.c \
+   vk_enum_to_str.h
+
+vk_enum_to_str.c vk_enum_to_str.h: gen_enum_to_str.py $(vulkan_api_xml)
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/gen_enum_to_str.py
+
+noinst_LTLIBRARIES = libvulkan_util.la
+
+libvulkan_util_la_SOURCES = \
+   vk_

[Mesa-dev] [PATCH 06/13] anv: convert header generation in anv_entrypoints_gen.py to mako

2017-02-22 Thread Dylan Baker
This produces an identical file except for whitespace.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 75 ++---
 1 file changed, 41 insertions(+), 34 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 3f7b5589e5..1b15b13b2f 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -27,6 +27,8 @@ import sys
 import textwrap
 import xml.etree.ElementTree as et
 
+from mako.template import Template
+
 VK_XML = os.path.join(
 os.path.dirname(__file__), '..', '..', 'vulkan', 'registry', 'vk.xml')
 
@@ -49,6 +51,44 @@ SUPPORTED_EXTENSIONS = [
 # function and a power-of-two size table. The prime numbers are determined
 # experimentally.
 
+TEMPLATE_H = Template(textwrap.dedent("""\
+/* This file generated from vk_gen.py, don't edit directly. */
+
+struct anv_dispatch_table {
+   union {
+  void *entrypoints[${len(entrypoints)}];
+  struct {
+  % for _, name, _, _, _, guard in entrypoints:
+% if guard is not None:
+#ifdef ${guard}
+  PFN_vk${name} ${name};
+#else
+  void *${name};
+# endif
+% else:
+  PFN_vk${name} ${name};
+% endif
+  % endfor
+  };
+   };
+};
+
+void anv_set_dispatch_devinfo(const struct gen_device_info *info);
+% for type_, name, args, num, h, guard in entrypoints:
+  % if guard is not None:
+#ifdef ${guard}
+  % endif
+  ${type_} anv_${name}(${args});
+  ${type_} gen7_${name}(${args});
+  ${type_} gen75_${name}(${args});
+  ${type_} gen8_${name}(${args});
+  ${type_} gen9_${name}(${args});
+  % if guard is not None:
+#endif // ${guard}
+  % endif
+% endfor
+"""))
+
 NONE = 0x
 HASH_SIZE = 256
 U32_MASK = 2**32 - 1
@@ -141,39 +181,6 @@ def get_entrypoints_defines(doc):
 return entrypoints_to_defines
 
 
-def gen_header(entrypoints):
-print "/* This file generated from vk_gen.py, don't edit directly. */\n"
-
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
-
-for type, name, args, num, h, guard in entrypoints:
-if guard is not None:
-print "#ifdef {0}".format(guard)
-print " PFN_vk{0} {0};".format(name)
-print "#else"
-print " void *{0};".format(name)
-print "#endif"
-else:
-print " PFN_vk{0} {0};".format(name)
-print "  };\n"
-print "   };\n"
-print "};\n"
-
-print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
-
-for type, name, args, num, h, guard in entrypoints:
-print_guard_start(guard)
-print "%s anv_%s(%s);" % (type, name, args)
-print "%s gen7_%s(%s);" % (type, name, args)
-print "%s gen75_%s(%s);" % (type, name, args)
-print "%s gen8_%s(%s);" % (type, name, args)
-print "%s gen9_%s(%s);" % (type, name, args)
-print_guard_end(guard)
-
-
 def gen_code(entrypoints):
 print textwrap.dedent("""\
 /*
@@ -376,7 +383,7 @@ def main():
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
 if opt_header:
-gen_header(entrypoints)
+print TEMPLATE_H.render(entrypoints=entrypoints)
 else:
 gen_code(entrypoints)
 
-- 
2.11.1

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


[Mesa-dev] [PATCH 02/13] anv: Use python style in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
These are all fairly small cleanups/tweaks that don't really deserve
their own patch.

- Prefer comprehensions to map() and filter(), since they're faster
- replace unused variables with _
- Use 4 spaces of indent
- drop semicolons from the end of lines
- Don't use parens around if conditions
- don't put spaces around brackets
- don't import modules as caps (ET -> et)
- Use docstrings instead of comments

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 63 ++---
 1 file changed, 34 insertions(+), 29 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 3f7a1ce294..358cf1e1e2 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -24,20 +24,20 @@
 
 import sys
 import textwrap
-import xml.etree.ElementTree as ET
+import xml.etree.ElementTree as et
 
 max_api_version = 1.0
 
 supported_extensions = [
-   'VK_KHR_get_physical_device_properties2',
-   'VK_KHR_maintenance1',
-   'VK_KHR_sampler_mirror_clamp_to_edge',
-   'VK_KHR_shader_draw_parameters',
-   'VK_KHR_surface',
-   'VK_KHR_swapchain',
-   'VK_KHR_wayland_surface',
-   'VK_KHR_xcb_surface',
-   'VK_KHR_xlib_surface',
+'VK_KHR_get_physical_device_properties2',
+'VK_KHR_maintenance1',
+'VK_KHR_sampler_mirror_clamp_to_edge',
+'VK_KHR_shader_draw_parameters',
+'VK_KHR_surface',
+'VK_KHR_swapchain',
+'VK_KHR_wayland_surface',
+'VK_KHR_xcb_surface',
+'VK_KHR_xlib_surface',
 ]
 
 # We generate a static hash table for entry point lookup
@@ -53,33 +53,37 @@ hash_mask = hash_size - 1
 prime_factor = 5024183
 prime_step = 19
 
+opt_header = False
+opt_code = False
+
+if sys.argv[1] == "header":
+opt_header = True
+sys.argv.pop()
+elif sys.argv[1] == "code":
+opt_code = True
+sys.argv.pop()
+
+
 def hash(name):
-h = 0;
+h = 0
 for c in name:
 h = (h * prime_factor + ord(c)) & u32_mask
 
 return h
 
+
 def print_guard_start(guard):
 if guard is not None:
 print "#ifdef {0}".format(guard)
 
+
 def print_guard_end(guard):
 if guard is not None:
 print "#endif // {0}".format(guard)
 
-opt_header = False
-opt_code = False
 
-if (sys.argv[1] == "header"):
-opt_header = True
-sys.argv.pop()
-elif (sys.argv[1] == "code"):
-opt_code = True
-sys.argv.pop()
-
-# Extract the entry points from the registry
 def get_entrypoints(doc, entrypoints_to_defines):
+"""Extract the entry points from the registry."""
 entrypoints = []
 
 enabled_commands = set()
@@ -108,7 +112,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 continue
 
 shortname = fullname[2:]
-params = map(lambda p: "".join(p.itertext()), 
command.findall('./param'))
+params = (''.join(p.itertext()) for p in command.findall('./param'))
 params = ', '.join(params)
 if fullname in entrypoints_to_defines:
 guard = entrypoints_to_defines[fullname]
@@ -119,8 +123,9 @@ def get_entrypoints(doc, entrypoints_to_defines):
 
 return entrypoints
 
-# Maps entry points to extension defines
+
 def get_entrypoints_defines(doc):
+"""Maps entry points to extension defines."""
 entrypoints_to_defines = {}
 extensions = doc.findall('./extensions/extension')
 for extension in extensions:
@@ -133,7 +138,7 @@ def get_entrypoints_defines(doc):
 
 
 def main():
-doc = ET.parse(sys.stdin)
+doc = et.parse(sys.stdin)
 entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
 
 # Manually add CreateDmaBufImageINTEL for which we don't have an extension
@@ -225,7 +230,7 @@ def main():
 static const char strings[] =""")
 
 offsets = []
-i = 0;
+i = 0
 for type, name, args, num, h, guard in entrypoints:
 print "   \"vk%s\\0\"" % name
 offsets.append(i)
@@ -247,7 +252,7 @@ def main():
  */
 """)
 
-for layer in [ "anv", "gen7", "gen75", "gen8", "gen9" ]:
+for layer in ["anv", "gen7", "gen75", "gen8", "gen9"]:
 for type, name, args, num, h, guard in entrypoints:
 print_guard_start(guard)
 print "%s %s_%s(%s) __attribute__ ((weak));" % (type, layer, name, 
args)
@@ -295,8 +300,8 @@ def main():
 # uint16_t table of entry point indices. We use 0x to indicate an entry
 # in the hash table i

[Mesa-dev] [PATCH 01/13] anv: anv_entrypoints_gen.py: use a main function

2017-02-22 Thread Dylan Baker
This is just good practice.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 458 
 1 file changed, 233 insertions(+), 225 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 93511ec95e..3f7a1ce294 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -1,6 +1,6 @@
 # coding=utf-8
 #
-# Copyright ?? 2015 Intel Corporation
+# Copyright ?? 2015, 2017 Intel Corporation
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -23,6 +23,7 @@
 #
 
 import sys
+import textwrap
 import xml.etree.ElementTree as ET
 
 max_api_version = 1.0
@@ -130,235 +131,242 @@ def get_entrypoints_defines(doc):
 entrypoints_to_defines[fullname] = define
 return entrypoints_to_defines
 
-doc = ET.parse(sys.stdin)
-entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
-
-# Manually add CreateDmaBufImageINTEL for which we don't have an extension
-# defined.
-entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
-'VkDevice device, ' +
-'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
-'const VkAllocationCallbacks* pAllocator,' +
-'VkDeviceMemory* pMem,' +
-'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
-
-# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
-# per entry point.
-
-if opt_header:
-print "/* This file generated from vk_gen.py, don't edit directly. */\n"
-
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
 
+def main():
+doc = ET.parse(sys.stdin)
+entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
+
+# Manually add CreateDmaBufImageINTEL for which we don't have an extension
+# defined.
+entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
+'VkDevice device, ' +
+'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
+'const VkAllocationCallbacks* pAllocator,' +
+'VkDeviceMemory* pMem,' +
+'VkImage* pImage', len(entrypoints),
+hash('vkCreateDmaBufImageINTEL'), None))
+
+# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
+# per entry point.
+
+if opt_header:
+print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
+
+print "struct anv_dispatch_table {"
+print "   union {"
+print "  void *entrypoints[%d];" % len(entrypoints)
+print "  struct {"
+
+for type, name, args, num, h, guard in entrypoints:
+if guard is not None:
+print "#ifdef {0}".format(guard)
+print " PFN_vk{0} {0};".format(name)
+print "#else"
+print " void *{0};".format(name)
+print "#endif"
+else:
+print " PFN_vk{0} {0};".format(name)
+print "  };\n"
+print "   };\n"
+print "};\n"
+
+print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
+
+for type, name, args, num, h, guard in entrypoints:
+print_guard_start(guard)
+print "%s anv_%s(%s);" % (type, name, args)
+print "%s gen7_%s(%s);" % (type, name, args)
+print "%s gen75_%s(%s);" % (type, name, args)
+print "%s gen8_%s(%s);" % (type, name, args)
+print "%s gen9_%s(%s);" % (type, name, args)
+print_guard_end(guard)
+exit()
+
+
+
+print textwrap.dedent("""\
+/*
+ * Copyright ?? 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the 
"Software"),
+ * to deal in the Software without restriction, including without 
limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+

[Mesa-dev] [PATCH 00/13] cleanup anv_entrpoints_gen.py

2017-02-22 Thread Dylan Baker
There are a number of small style cleanups and simplifications in this series,
but the main changes are:
 - use a mako template to generate the header and code rather than prints
 - be python 3.x ready (the goal isn't to write python 3 code, but to write code
   that is easy to port or hybridize)
 - generate the header and the code in one go

I've put emphasis on the readability of the template rather than the readability
of the output code, it's relatively easy to pipe the code through 'indent' to
make it more readable.

Dylan Baker (13):
  anv: anv_entrypoints_gen.py: use a main function
  anv: Use python style in anv_entrypoints_gen.py
  anv: make constants capitals in anv_entrypoints_gen.py
  anv: don't pass xmlfile via stdin anv_entrypoints_gen.py
  anv: split main into two functions in anv_entrypoints_gen.py
  anv: convert header generation in anv_entrypoints_gen.py to mako
  anv: convert C generation to template in anv_entrypoints_gen.py
  anv: generate anv_entrypoints.{h,c} in one command
  anv: anv-entrypoints_gen.py: rename hash to cal_hash.
  anv: anv_entrypoints_gen.py: use reduce function.
  anv: use dict.get in anv_entrypoints_gen.py
  anv: don't use Element.get in anv_entrypoints_gen.py
  anv: use cElementTree in anv_entrypoints_gen.py

 src/intel/vulkan/Makefile.am|   9 +-
 src/intel/vulkan/anv_entrypoints_gen.py | 597 
 2 files changed, 306 insertions(+), 300 deletions(-)

-- 
2.11.1

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


[Mesa-dev] [PATCH 05/13] anv: split main into two functions in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
This is groundwork for the next patches, it will allows porting the
header and the code to mako separately, and will also allow both to be
run simultaneously.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 96 +
 1 file changed, 50 insertions(+), 46 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 5403bcb4bc..3f7b5589e5 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -141,58 +141,40 @@ def get_entrypoints_defines(doc):
 return entrypoints_to_defines
 
 
-def main():
-doc = et.parse(VK_XML)
-entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
-
-# Manually add CreateDmaBufImageINTEL for which we don't have an extension
-# defined.
-entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
-'VkDevice device, ' +
-'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
-'const VkAllocationCallbacks* pAllocator,' +
-'VkDeviceMemory* pMem,' +
-'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
-
-# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
-# per entry point.
-
-if opt_header:
-print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
+def gen_header(entrypoints):
+print "/* This file generated from vk_gen.py, don't edit directly. */\n"
 
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
+print "struct anv_dispatch_table {"
+print "   union {"
+print "  void *entrypoints[%d];" % len(entrypoints)
+print "  struct {"
 
-for type, name, args, num, h, guard in entrypoints:
-if guard is not None:
-print "#ifdef {0}".format(guard)
-print " PFN_vk{0} {0};".format(name)
-print "#else"
-print " void *{0};".format(name)
-print "#endif"
-else:
-print " PFN_vk{0} {0};".format(name)
-print "  };\n"
-print "   };\n"
-print "};\n"
-
-print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
+for type, name, args, num, h, guard in entrypoints:
+if guard is not None:
+print "#ifdef {0}".format(guard)
+print " PFN_vk{0} {0};".format(name)
+print "#else"
+print " void *{0};".format(name)
+print "#endif"
+else:
+print " PFN_vk{0} {0};".format(name)
+print "  };\n"
+print "   };\n"
+print "};\n"
 
-for type, name, args, num, h, guard in entrypoints:
-print_guard_start(guard)
-print "%s anv_%s(%s);" % (type, name, args)
-print "%s gen7_%s(%s);" % (type, name, args)
-print "%s gen75_%s(%s);" % (type, name, args)
-print "%s gen8_%s(%s);" % (type, name, args)
-print "%s gen9_%s(%s);" % (type, name, args)
-print_guard_end(guard)
-exit()
+print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
 
+for type, name, args, num, h, guard in entrypoints:
+print_guard_start(guard)
+print "%s anv_%s(%s);" % (type, name, args)
+print "%s gen7_%s(%s);" % (type, name, args)
+print "%s gen75_%s(%s);" % (type, name, args)
+print "%s gen8_%s(%s);" % (type, name, args)
+print "%s gen9_%s(%s);" % (type, name, args)
+print_guard_end(guard)
 
 
+def gen_code(entrypoints):
 print textwrap.dedent("""\
 /*
  * Copyright ?? 2015 Intel Corporation
@@ -377,5 +359,27 @@ def main():
 """) % (PRIME_FACTOR, PRIME_STEP, HASH_MASK)
 
 
+def main():
+doc = et.parse(VK_XML)
+entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
+
+# Manually add CreateDmaBufImageINTEL for which we don't have an extension
+# defined.
+entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
+'VkDevice device, ' +
+  

[Mesa-dev] [RESEND 12/13] anv: don't use Element.get in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
This has the potential to mask errors, since Element.get works like
dict.get, returning None if the element isn't found. I think the reason
that Element.get was used is that vulkan has one extension that isn't
really an extension, and thus is missing the 'protect' field.

This patch changes the behavior slightly by replacing get with explicit
lookup in the Element.attrib dictionary, and using xpath to only iterate
over extensions with a "protect" attribute.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 47e3a4651f..a9b9f134a9 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -306,13 +306,14 @@ def get_entrypoints(doc, entrypoints_to_defines):
 def get_entrypoints_defines(doc):
 """Maps entry points to extension defines."""
 entrypoints_to_defines = {}
-extensions = doc.findall('./extensions/extension')
-for extension in extensions:
-define = extension.get('protect')
-entrypoints = extension.findall('./require/command')
-for entrypoint in entrypoints:
-fullname = entrypoint.get('name')
+
+for extension in doc.findall('./extensions/extension[@protect]'):
+define = extension.attrib['protect']
+
+for entrypoint in extension.findall('./require/command'):
+fullname = entrypoint.attrib['name']
 entrypoints_to_defines[fullname] = define
+
 return entrypoints_to_defines
 
 
-- 
2.11.1

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


[Mesa-dev] [RESEND 04/13] anv: don't pass xmlfile via stdin anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
It's slow, and has the potential for encoding issues.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/Makefile.am| 6 ++
 src/intel/vulkan/anv_entrypoints_gen.py | 6 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 449188fe1e..5a0e4ef4ff 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -146,12 +146,10 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
 vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 
 anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN) cat $(vulkan_api_xml) |\
-   $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
 
 anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN) cat $(vulkan_api_xml) |\
-   $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
 
 BUILT_SOURCES = $(VULKAN_GENERATED_FILES)
 CLEANFILES = $(BUILT_SOURCES) dev_icd.json intel_icd.@host_cpu@.json
diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 40b8c805d5..5403bcb4bc 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -22,10 +22,14 @@
 # IN THE SOFTWARE.
 #
 
+import os
 import sys
 import textwrap
 import xml.etree.ElementTree as et
 
+VK_XML = os.path.join(
+os.path.dirname(__file__), '..', '..', 'vulkan', 'registry', 'vk.xml')
+
 MAX_API_VERSION = 1.0
 
 SUPPORTED_EXTENSIONS = [
@@ -138,7 +142,7 @@ def get_entrypoints_defines(doc):
 
 
 def main():
-doc = et.parse(sys.stdin)
+doc = et.parse(VK_XML)
 entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
 
 # Manually add CreateDmaBufImageINTEL for which we don't have an extension
-- 
2.11.1

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


[Mesa-dev] [RESEND 03/13] anv: make constants capitals in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
Again, it's standard python style.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 38 -
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 358cf1e1e2..40b8c805d5 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -26,9 +26,9 @@ import sys
 import textwrap
 import xml.etree.ElementTree as et
 
-max_api_version = 1.0
+MAX_API_VERSION = 1.0
 
-supported_extensions = [
+SUPPORTED_EXTENSIONS = [
 'VK_KHR_get_physical_device_properties2',
 'VK_KHR_maintenance1',
 'VK_KHR_sampler_mirror_clamp_to_edge',
@@ -45,13 +45,13 @@ supported_extensions = [
 # function and a power-of-two size table. The prime numbers are determined
 # experimentally.
 
-none = 0x
-hash_size = 256
-u32_mask = 2**32 - 1
-hash_mask = hash_size - 1
+NONE = 0x
+HASH_SIZE = 256
+U32_MASK = 2**32 - 1
+HASH_MASK = HASH_SIZE - 1
 
-prime_factor = 5024183
-prime_step = 19
+PRIME_FACTOR = 5024183
+PRIME_STEP = 19
 
 opt_header = False
 opt_code = False
@@ -67,7 +67,7 @@ elif sys.argv[1] == "code":
 def hash(name):
 h = 0
 for c in name:
-h = (h * prime_factor + ord(c)) & u32_mask
+h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
 
 return h
 
@@ -89,14 +89,14 @@ def get_entrypoints(doc, entrypoints_to_defines):
 enabled_commands = set()
 for feature in doc.findall('./feature'):
 assert feature.attrib['api'] == 'vulkan'
-if float(feature.attrib['number']) > max_api_version:
+if float(feature.attrib['number']) > MAX_API_VERSION:
 continue
 
 for command in feature.findall('./require/command'):
 enabled_commands.add(command.attrib['name'])
 
 for extension in doc.findall('.extensions/extension'):
-if extension.attrib['name'] not in supported_extensions:
+if extension.attrib['name'] not in SUPPORTED_EXTENSIONS:
 continue
 
 assert extension.attrib['supported'] == 'vulkan'
@@ -300,21 +300,21 @@ def main():
 # uint16_t table of entry point indices. We use 0x to indicate an entry
 # in the hash table is empty.
 
-map = [none for _ in xrange(hash_size)]
+map = [NONE for _ in xrange(HASH_SIZE)]
 collisions = [0 for _ in xrange(10)]
 for type, name, args, num, h, guard in entrypoints:
 level = 0
-while map[h & hash_mask] != none:
-h = h + prime_step
+while map[h & HASH_MASK] != NONE:
+h = h + PRIME_STEP
 level = level + 1
 if level > 9:
 collisions[9] += 1
 else:
 collisions[level] += 1
-map[h & hash_mask] = num
+map[h & HASH_MASK] = num
 
 print "/* Hash table stats:"
-print " * size %d entries" % hash_size
+print " * size %d entries" % HASH_SIZE
 print " * collisions  entries"
 for i in xrange(10):
 if i == 9:
@@ -325,10 +325,10 @@ def main():
 print " * %2d%s %4d" % (i, plus, collisions[i])
 print " */\n"
 
-print "#define none 0x%04x\n" % none
+print "#define none 0x%04x\n" % NONE
 
 print "static const uint16_t map[] = {"
-for i in xrange(0, hash_size, 8):
+for i in xrange(0, HASH_SIZE, 8):
 print "   ",
 for j in xrange(i, i + 8):
 if map[j] & 0x == 0x:
@@ -370,7 +370,7 @@ def main():
 
return anv_resolve_entrypoint(devinfo, i);
 }
-""") % (prime_factor, prime_step, hash_mask)
+""") % (PRIME_FACTOR, PRIME_STEP, HASH_MASK)
 
 
 if __name__ == '__main__':
-- 
2.11.1

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


[Mesa-dev] [RESEND 01/13] anv: anv_entrypoints_gen.py: use a main function

2017-02-22 Thread Dylan Baker
This is just good practice.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 458 
 1 file changed, 233 insertions(+), 225 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 93511ec95e..3f7a1ce294 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -1,6 +1,6 @@
 # coding=utf-8
 #
-# Copyright ?? 2015 Intel Corporation
+# Copyright ?? 2015, 2017 Intel Corporation
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -23,6 +23,7 @@
 #
 
 import sys
+import textwrap
 import xml.etree.ElementTree as ET
 
 max_api_version = 1.0
@@ -130,235 +131,242 @@ def get_entrypoints_defines(doc):
 entrypoints_to_defines[fullname] = define
 return entrypoints_to_defines
 
-doc = ET.parse(sys.stdin)
-entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
-
-# Manually add CreateDmaBufImageINTEL for which we don't have an extension
-# defined.
-entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
-'VkDevice device, ' +
-'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
-'const VkAllocationCallbacks* pAllocator,' +
-'VkDeviceMemory* pMem,' +
-'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
-
-# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
-# per entry point.
-
-if opt_header:
-print "/* This file generated from vk_gen.py, don't edit directly. */\n"
-
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
 
+def main():
+doc = ET.parse(sys.stdin)
+entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
+
+# Manually add CreateDmaBufImageINTEL for which we don't have an extension
+# defined.
+entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
+'VkDevice device, ' +
+'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
+'const VkAllocationCallbacks* pAllocator,' +
+'VkDeviceMemory* pMem,' +
+'VkImage* pImage', len(entrypoints),
+hash('vkCreateDmaBufImageINTEL'), None))
+
+# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
+# per entry point.
+
+if opt_header:
+print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
+
+print "struct anv_dispatch_table {"
+print "   union {"
+print "  void *entrypoints[%d];" % len(entrypoints)
+print "  struct {"
+
+for type, name, args, num, h, guard in entrypoints:
+if guard is not None:
+print "#ifdef {0}".format(guard)
+print " PFN_vk{0} {0};".format(name)
+print "#else"
+print " void *{0};".format(name)
+print "#endif"
+else:
+print " PFN_vk{0} {0};".format(name)
+print "  };\n"
+print "   };\n"
+print "};\n"
+
+print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
+
+for type, name, args, num, h, guard in entrypoints:
+print_guard_start(guard)
+print "%s anv_%s(%s);" % (type, name, args)
+print "%s gen7_%s(%s);" % (type, name, args)
+print "%s gen75_%s(%s);" % (type, name, args)
+print "%s gen8_%s(%s);" % (type, name, args)
+print "%s gen9_%s(%s);" % (type, name, args)
+print_guard_end(guard)
+exit()
+
+
+
+print textwrap.dedent("""\
+/*
+ * Copyright ?? 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the 
"Software"),
+ * to deal in the Software without restriction, including without 
limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+

[Mesa-dev] [RESEND 11/13] anv: use dict.get in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
Instead of using an if and a check, use dict.get, which does the same
thing, but more succinctly.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index e1c5ac6ddf..47e3a4651f 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -296,10 +296,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 shortname = fullname[2:]
 params = (''.join(p.itertext()) for p in command.findall('./param'))
 params = ', '.join(params)
-if fullname in entrypoints_to_defines:
-guard = entrypoints_to_defines[fullname]
-else:
-guard = None
+guard = entrypoints_to_defines.get(fullname)
 entrypoints.append((type, shortname, params, index, 
cal_hash(fullname), guard))
 index += 1
 
-- 
2.11.1

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


[Mesa-dev] [RESEND 05/13] anv: split main into two functions in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
This is groundwork for the next patches, it will allows porting the
header and the code to mako separately, and will also allow both to be
run simultaneously.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 96 +
 1 file changed, 50 insertions(+), 46 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 5403bcb4bc..3f7b5589e5 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -141,58 +141,40 @@ def get_entrypoints_defines(doc):
 return entrypoints_to_defines
 
 
-def main():
-doc = et.parse(VK_XML)
-entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
-
-# Manually add CreateDmaBufImageINTEL for which we don't have an extension
-# defined.
-entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
-'VkDevice device, ' +
-'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
-'const VkAllocationCallbacks* pAllocator,' +
-'VkDeviceMemory* pMem,' +
-'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
-
-# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
-# per entry point.
-
-if opt_header:
-print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
+def gen_header(entrypoints):
+print "/* This file generated from vk_gen.py, don't edit directly. */\n"
 
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
+print "struct anv_dispatch_table {"
+print "   union {"
+print "  void *entrypoints[%d];" % len(entrypoints)
+print "  struct {"
 
-for type, name, args, num, h, guard in entrypoints:
-if guard is not None:
-print "#ifdef {0}".format(guard)
-print " PFN_vk{0} {0};".format(name)
-print "#else"
-print " void *{0};".format(name)
-print "#endif"
-else:
-print " PFN_vk{0} {0};".format(name)
-print "  };\n"
-print "   };\n"
-print "};\n"
-
-print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
+for type, name, args, num, h, guard in entrypoints:
+if guard is not None:
+print "#ifdef {0}".format(guard)
+print " PFN_vk{0} {0};".format(name)
+print "#else"
+print " void *{0};".format(name)
+print "#endif"
+else:
+print " PFN_vk{0} {0};".format(name)
+print "  };\n"
+print "   };\n"
+print "};\n"
 
-for type, name, args, num, h, guard in entrypoints:
-print_guard_start(guard)
-print "%s anv_%s(%s);" % (type, name, args)
-print "%s gen7_%s(%s);" % (type, name, args)
-print "%s gen75_%s(%s);" % (type, name, args)
-print "%s gen8_%s(%s);" % (type, name, args)
-print "%s gen9_%s(%s);" % (type, name, args)
-print_guard_end(guard)
-exit()
+print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
 
+for type, name, args, num, h, guard in entrypoints:
+print_guard_start(guard)
+print "%s anv_%s(%s);" % (type, name, args)
+print "%s gen7_%s(%s);" % (type, name, args)
+print "%s gen75_%s(%s);" % (type, name, args)
+print "%s gen8_%s(%s);" % (type, name, args)
+print "%s gen9_%s(%s);" % (type, name, args)
+print_guard_end(guard)
 
 
+def gen_code(entrypoints):
 print textwrap.dedent("""\
 /*
  * Copyright ?? 2015 Intel Corporation
@@ -377,5 +359,27 @@ def main():
 """) % (PRIME_FACTOR, PRIME_STEP, HASH_MASK)
 
 
+def main():
+doc = et.parse(VK_XML)
+entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
+
+# Manually add CreateDmaBufImageINTEL for which we don't have an extension
+# defined.
+entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
+'VkDevice device, ' +
+  

[Mesa-dev] [RESEND 08/13] anv: generate anv_entrypoints.{h, c} in one command

2017-02-22 Thread Dylan Baker
This changes the python generator to write the files itself, rather than
piping them out. This has a couple of advantages: first, it encapsulates
the encoding. Second, it ensures that the header file and code file are
generated at the same time with the same data.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/Makefile.am|  7 ++
 src/intel/vulkan/anv_entrypoints_gen.py | 38 -
 2 files changed, 16 insertions(+), 29 deletions(-)

diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 5a0e4ef4ff..68bc5ccf86 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -145,11 +145,8 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
 
 vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 
-anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
-
-anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
+anv_entrypoints.h anv_entrypoints.c: anv_entrypoints_gen.py $(vulkan_api_xml)
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py
 
 BUILT_SOURCES = $(VULKAN_GENERATED_FILES)
 CLEANFILES = $(BUILT_SOURCES) dev_icd.json intel_icd.@host_cpu@.json
diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 0f943a0de1..9ccd9497a2 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -87,7 +87,7 @@ TEMPLATE_H = Template(textwrap.dedent("""\
 #endif // ${guard}
   % endif
 % endfor
-"""))
+"""), output_encoding='utf-8')
 
 TEMPLATE_C = Template(textwrap.dedent(u"""\
 /*
@@ -256,16 +256,6 @@ HASH_MASK = HASH_SIZE - 1
 PRIME_FACTOR = 5024183
 PRIME_STEP = 19
 
-opt_header = False
-opt_code = False
-
-if sys.argv[1] == "header":
-opt_header = True
-sys.argv.pop()
-elif sys.argv[1] == "code":
-opt_code = True
-sys.argv.pop()
-
 
 def hash(name):
 h = 0
@@ -351,15 +341,16 @@ def gen_code(entrypoints):
 collisions[level] += 1
 mapping[h & HASH_MASK] = num
 
-print TEMPLATE_C.render(entrypoints=entrypoints,
-offsets=offsets,
-collisions=collisions,
-mapping=mapping,
-hash_mask=HASH_MASK,
-prime_step=PRIME_STEP,
-prime_factor=PRIME_FACTOR,
-none=NONE,
-hash_size=HASH_SIZE)
+with open('anv_entrypoints.c', 'wb') as f:
+f.write(TEMPLATE_C.render(entrypoints=entrypoints,
+  offsets=offsets,
+  collisions=collisions,
+  mapping=mapping,
+  hash_mask=HASH_MASK,
+  prime_step=PRIME_STEP,
+  prime_factor=PRIME_FACTOR,
+  none=NONE,
+  hash_size=HASH_SIZE))
 
 
 def main():
@@ -378,10 +369,9 @@ def main():
 
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
-if opt_header:
-print TEMPLATE_H.render(entrypoints=entrypoints)
-else:
-gen_code(entrypoints)
+with open('anv_entrypoints.h', 'wb') as f:
+f.write(TEMPLATE_H.render(entrypoints=entrypoints))
+gen_code(entrypoints)
 
 
 if __name__ == '__main__':
-- 
2.11.1

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


[Mesa-dev] [RESEND 02/13] anv: Use python style in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
These are all fairly small cleanups/tweaks that don't really deserve
their own patch.

- Prefer comprehensions to map() and filter(), since they're faster
- replace unused variables with _
- Use 4 spaces of indent
- drop semicolons from the end of lines
- Don't use parens around if conditions
- don't put spaces around brackets
- don't import modules as caps (ET -> et)
- Use docstrings instead of comments

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 63 ++---
 1 file changed, 34 insertions(+), 29 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 3f7a1ce294..358cf1e1e2 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -24,20 +24,20 @@
 
 import sys
 import textwrap
-import xml.etree.ElementTree as ET
+import xml.etree.ElementTree as et
 
 max_api_version = 1.0
 
 supported_extensions = [
-   'VK_KHR_get_physical_device_properties2',
-   'VK_KHR_maintenance1',
-   'VK_KHR_sampler_mirror_clamp_to_edge',
-   'VK_KHR_shader_draw_parameters',
-   'VK_KHR_surface',
-   'VK_KHR_swapchain',
-   'VK_KHR_wayland_surface',
-   'VK_KHR_xcb_surface',
-   'VK_KHR_xlib_surface',
+'VK_KHR_get_physical_device_properties2',
+'VK_KHR_maintenance1',
+'VK_KHR_sampler_mirror_clamp_to_edge',
+'VK_KHR_shader_draw_parameters',
+'VK_KHR_surface',
+'VK_KHR_swapchain',
+'VK_KHR_wayland_surface',
+'VK_KHR_xcb_surface',
+'VK_KHR_xlib_surface',
 ]
 
 # We generate a static hash table for entry point lookup
@@ -53,33 +53,37 @@ hash_mask = hash_size - 1
 prime_factor = 5024183
 prime_step = 19
 
+opt_header = False
+opt_code = False
+
+if sys.argv[1] == "header":
+opt_header = True
+sys.argv.pop()
+elif sys.argv[1] == "code":
+opt_code = True
+sys.argv.pop()
+
+
 def hash(name):
-h = 0;
+h = 0
 for c in name:
 h = (h * prime_factor + ord(c)) & u32_mask
 
 return h
 
+
 def print_guard_start(guard):
 if guard is not None:
 print "#ifdef {0}".format(guard)
 
+
 def print_guard_end(guard):
 if guard is not None:
 print "#endif // {0}".format(guard)
 
-opt_header = False
-opt_code = False
 
-if (sys.argv[1] == "header"):
-opt_header = True
-sys.argv.pop()
-elif (sys.argv[1] == "code"):
-opt_code = True
-sys.argv.pop()
-
-# Extract the entry points from the registry
 def get_entrypoints(doc, entrypoints_to_defines):
+"""Extract the entry points from the registry."""
 entrypoints = []
 
 enabled_commands = set()
@@ -108,7 +112,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 continue
 
 shortname = fullname[2:]
-params = map(lambda p: "".join(p.itertext()), 
command.findall('./param'))
+params = (''.join(p.itertext()) for p in command.findall('./param'))
 params = ', '.join(params)
 if fullname in entrypoints_to_defines:
 guard = entrypoints_to_defines[fullname]
@@ -119,8 +123,9 @@ def get_entrypoints(doc, entrypoints_to_defines):
 
 return entrypoints
 
-# Maps entry points to extension defines
+
 def get_entrypoints_defines(doc):
+"""Maps entry points to extension defines."""
 entrypoints_to_defines = {}
 extensions = doc.findall('./extensions/extension')
 for extension in extensions:
@@ -133,7 +138,7 @@ def get_entrypoints_defines(doc):
 
 
 def main():
-doc = ET.parse(sys.stdin)
+doc = et.parse(sys.stdin)
 entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
 
 # Manually add CreateDmaBufImageINTEL for which we don't have an extension
@@ -225,7 +230,7 @@ def main():
 static const char strings[] =""")
 
 offsets = []
-i = 0;
+i = 0
 for type, name, args, num, h, guard in entrypoints:
 print "   \"vk%s\\0\"" % name
 offsets.append(i)
@@ -247,7 +252,7 @@ def main():
  */
 """)
 
-for layer in [ "anv", "gen7", "gen75", "gen8", "gen9" ]:
+for layer in ["anv", "gen7", "gen75", "gen8", "gen9"]:
 for type, name, args, num, h, guard in entrypoints:
 print_guard_start(guard)
 print "%s %s_%s(%s) __attribute__ ((weak));" % (type, layer, name, 
args)
@@ -295,8 +300,8 @@ def main():
 # uint16_t table of entry point indices. We use 0x to indicate an entry
 # in the hash table i

[Mesa-dev] [RESEND 07/13] anv: convert C generation to template in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
This produces a file that is identical except for whitespace, there is a
table that has 8 columns in the original and is easy to do with prints,
but is ugly using mako, so it doesn't have columns; the data is not
inherently tabular.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 350 
 1 file changed, 173 insertions(+), 177 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 1b15b13b2f..0f943a0de1 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -89,100 +89,7 @@ TEMPLATE_H = Template(textwrap.dedent("""\
 % endfor
 """))
 
-NONE = 0x
-HASH_SIZE = 256
-U32_MASK = 2**32 - 1
-HASH_MASK = HASH_SIZE - 1
-
-PRIME_FACTOR = 5024183
-PRIME_STEP = 19
-
-opt_header = False
-opt_code = False
-
-if sys.argv[1] == "header":
-opt_header = True
-sys.argv.pop()
-elif sys.argv[1] == "code":
-opt_code = True
-sys.argv.pop()
-
-
-def hash(name):
-h = 0
-for c in name:
-h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
-
-return h
-
-
-def print_guard_start(guard):
-if guard is not None:
-print "#ifdef {0}".format(guard)
-
-
-def print_guard_end(guard):
-if guard is not None:
-print "#endif // {0}".format(guard)
-
-
-def get_entrypoints(doc, entrypoints_to_defines):
-"""Extract the entry points from the registry."""
-entrypoints = []
-
-enabled_commands = set()
-for feature in doc.findall('./feature'):
-assert feature.attrib['api'] == 'vulkan'
-if float(feature.attrib['number']) > MAX_API_VERSION:
-continue
-
-for command in feature.findall('./require/command'):
-enabled_commands.add(command.attrib['name'])
-
-for extension in doc.findall('.extensions/extension'):
-if extension.attrib['name'] not in SUPPORTED_EXTENSIONS:
-continue
-
-assert extension.attrib['supported'] == 'vulkan'
-for command in extension.findall('./require/command'):
-enabled_commands.add(command.attrib['name'])
-
-index = 0
-for command in doc.findall('./commands/command'):
-type = command.find('./proto/type').text
-fullname = command.find('./proto/name').text
-
-if fullname not in enabled_commands:
-continue
-
-shortname = fullname[2:]
-params = (''.join(p.itertext()) for p in command.findall('./param'))
-params = ', '.join(params)
-if fullname in entrypoints_to_defines:
-guard = entrypoints_to_defines[fullname]
-else:
-guard = None
-entrypoints.append((type, shortname, params, index, hash(fullname), 
guard))
-index += 1
-
-return entrypoints
-
-
-def get_entrypoints_defines(doc):
-"""Maps entry points to extension defines."""
-entrypoints_to_defines = {}
-extensions = doc.findall('./extensions/extension')
-for extension in extensions:
-define = extension.get('protect')
-entrypoints = extension.findall('./require/command')
-for entrypoint in entrypoints:
-fullname = entrypoint.get('name')
-entrypoints_to_defines[fullname] = define
-return entrypoints_to_defines
-
-
-def gen_code(entrypoints):
-print textwrap.dedent("""\
+TEMPLATE_C = Template(textwrap.dedent(u"""\
 /*
  * Copyright ?? 2015 Intel Corporation
  *
@@ -220,44 +127,47 @@ def gen_code(entrypoints):
  * store the index into this big string.
  */
 
-static const char strings[] =""")
-
-offsets = []
-i = 0
-for type, name, args, num, h, guard in entrypoints:
-print "   \"vk%s\\0\"" % name
-offsets.append(i)
-i += 2 + len(name) + 1
-print "   ;"
-
-# Now generate the table of all entry points
-
-print "\nstatic const struct anv_entrypoint entrypoints[] = {"
-for type, name, args, num, h, guard in entrypoints:
-print "   { %5d, 0x%08x }," % (offsets[num], h)
-print "};\n"
+static const char strings[] =
+% for _, name, _, _, _, _ in entrypoints:
+"vk${name}\\0"
+% endfor
+;
 
-print textwrap.dedent("""
+static const struct anv_entrypoint entrypoints[] = {
+% for _, _, _, num, h, _ in entrypoints:
+{ ${offsets[num]}, ${'{:0=#8x}'.format(h)} },
+% endfor
+};
 
 /* Weak aliases for all potential implementations. These wil

[Mesa-dev] [RESEND 10/13] anv: anv_entrypoints_gen.py: use reduce function.

2017-02-22 Thread Dylan Baker
Reduce is it's own reward.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 0c9812a846..e1c5ac6ddf 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -22,6 +22,7 @@
 # IN THE SOFTWARE.
 #
 
+import functools
 import os
 import sys
 import textwrap
@@ -259,11 +260,8 @@ PRIME_STEP = 19
 
 def cal_hash(name):
 """Calculate the same hash value that Mesa will calculate in C."""
-h = 0
-for c in name:
-h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
-
-return h
+return functools.reduce(
+lambda h, c: (h * PRIME_FACTOR + ord(c)) & U32_MASK, name, 0)
 
 
 def get_entrypoints(doc, entrypoints_to_defines):
-- 
2.11.1

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


[Mesa-dev] [RESEND 06/13] anv: convert header generation in anv_entrypoints_gen.py to mako

2017-02-22 Thread Dylan Baker
This produces an identical file except for whitespace.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 75 ++---
 1 file changed, 41 insertions(+), 34 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 3f7b5589e5..1b15b13b2f 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -27,6 +27,8 @@ import sys
 import textwrap
 import xml.etree.ElementTree as et
 
+from mako.template import Template
+
 VK_XML = os.path.join(
 os.path.dirname(__file__), '..', '..', 'vulkan', 'registry', 'vk.xml')
 
@@ -49,6 +51,44 @@ SUPPORTED_EXTENSIONS = [
 # function and a power-of-two size table. The prime numbers are determined
 # experimentally.
 
+TEMPLATE_H = Template(textwrap.dedent("""\
+/* This file generated from vk_gen.py, don't edit directly. */
+
+struct anv_dispatch_table {
+   union {
+  void *entrypoints[${len(entrypoints)}];
+  struct {
+  % for _, name, _, _, _, guard in entrypoints:
+% if guard is not None:
+#ifdef ${guard}
+  PFN_vk${name} ${name};
+#else
+  void *${name};
+# endif
+% else:
+  PFN_vk${name} ${name};
+% endif
+  % endfor
+  };
+   };
+};
+
+void anv_set_dispatch_devinfo(const struct gen_device_info *info);
+% for type_, name, args, num, h, guard in entrypoints:
+  % if guard is not None:
+#ifdef ${guard}
+  % endif
+  ${type_} anv_${name}(${args});
+  ${type_} gen7_${name}(${args});
+  ${type_} gen75_${name}(${args});
+  ${type_} gen8_${name}(${args});
+  ${type_} gen9_${name}(${args});
+  % if guard is not None:
+#endif // ${guard}
+  % endif
+% endfor
+"""))
+
 NONE = 0x
 HASH_SIZE = 256
 U32_MASK = 2**32 - 1
@@ -141,39 +181,6 @@ def get_entrypoints_defines(doc):
 return entrypoints_to_defines
 
 
-def gen_header(entrypoints):
-print "/* This file generated from vk_gen.py, don't edit directly. */\n"
-
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
-
-for type, name, args, num, h, guard in entrypoints:
-if guard is not None:
-print "#ifdef {0}".format(guard)
-print " PFN_vk{0} {0};".format(name)
-print "#else"
-print " void *{0};".format(name)
-print "#endif"
-else:
-print " PFN_vk{0} {0};".format(name)
-print "  };\n"
-print "   };\n"
-print "};\n"
-
-print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
-
-for type, name, args, num, h, guard in entrypoints:
-print_guard_start(guard)
-print "%s anv_%s(%s);" % (type, name, args)
-print "%s gen7_%s(%s);" % (type, name, args)
-print "%s gen75_%s(%s);" % (type, name, args)
-print "%s gen8_%s(%s);" % (type, name, args)
-print "%s gen9_%s(%s);" % (type, name, args)
-print_guard_end(guard)
-
-
 def gen_code(entrypoints):
 print textwrap.dedent("""\
 /*
@@ -376,7 +383,7 @@ def main():
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
 if opt_header:
-gen_header(entrypoints)
+print TEMPLATE_H.render(entrypoints=entrypoints)
 else:
 gen_code(entrypoints)
 
-- 
2.11.1

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


[Mesa-dev] [RESEND 09/13] anv: anv-entrypoints_gen.py: rename hash to cal_hash.

2017-02-22 Thread Dylan Baker
hash is reserved name in python, it's the interface to access an
object's hash protocol.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 9ccd9497a2..0c9812a846 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -257,7 +257,8 @@ PRIME_FACTOR = 5024183
 PRIME_STEP = 19
 
 
-def hash(name):
+def cal_hash(name):
+"""Calculate the same hash value that Mesa will calculate in C."""
 h = 0
 for c in name:
 h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
@@ -301,7 +302,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 guard = entrypoints_to_defines[fullname]
 else:
 guard = None
-entrypoints.append((type, shortname, params, index, hash(fullname), 
guard))
+entrypoints.append((type, shortname, params, index, 
cal_hash(fullname), guard))
 index += 1
 
 return entrypoints
@@ -365,7 +366,7 @@ def main():
 'const VkAllocationCallbacks* pAllocator,' +
 'VkDeviceMemory* pMem,' +
 'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
+cal_hash('vkCreateDmaBufImageINTEL'), None))
 
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
-- 
2.11.1

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


[Mesa-dev] [RESEND 13/13] anv: use cElementTree in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
It's written in C rather than pure python and is strictly faster, the
only reason not to use it that it's classes cannot be subclassed.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index a9b9f134a9..6426cc02ab 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -26,7 +26,7 @@ import functools
 import os
 import sys
 import textwrap
-import xml.etree.ElementTree as et
+import xml.etree.cElementTree as et
 
 from mako.template import Template
 
-- 
2.11.1

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


[Mesa-dev] [RESEND 04/13] anv: don't pass xmlfile via stdin anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
It's slow, and has the potential for encoding issues.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/Makefile.am| 6 ++
 src/intel/vulkan/anv_entrypoints_gen.py | 6 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 449188fe1e..5a0e4ef4ff 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -146,12 +146,10 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
 vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 
 anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN) cat $(vulkan_api_xml) |\
-   $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
 
 anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN) cat $(vulkan_api_xml) |\
-   $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
 
 BUILT_SOURCES = $(VULKAN_GENERATED_FILES)
 CLEANFILES = $(BUILT_SOURCES) dev_icd.json intel_icd.@host_cpu@.json
diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 40b8c805d5..5403bcb4bc 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -22,10 +22,14 @@
 # IN THE SOFTWARE.
 #
 
+import os
 import sys
 import textwrap
 import xml.etree.ElementTree as et
 
+VK_XML = os.path.join(
+os.path.dirname(__file__), '..', '..', 'vulkan', 'registry', 'vk.xml')
+
 MAX_API_VERSION = 1.0
 
 SUPPORTED_EXTENSIONS = [
@@ -138,7 +142,7 @@ def get_entrypoints_defines(doc):
 
 
 def main():
-doc = et.parse(sys.stdin)
+doc = et.parse(VK_XML)
 entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
 
 # Manually add CreateDmaBufImageINTEL for which we don't have an extension
-- 
2.11.1

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


[Mesa-dev] [RESEND 08/13] anv: generate anv_entrypoints.{h, c} in one command

2017-02-22 Thread Dylan Baker
This changes the python generator to write the files itself, rather than
piping them out. This has a couple of advantages: first, it encapsulates
the encoding. Second, it ensures that the header file and code file are
generated at the same time with the same data.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/Makefile.am|  7 ++
 src/intel/vulkan/anv_entrypoints_gen.py | 38 -
 2 files changed, 16 insertions(+), 29 deletions(-)

diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 5a0e4ef4ff..68bc5ccf86 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -145,11 +145,8 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
 
 vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 
-anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
-
-anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
+anv_entrypoints.h anv_entrypoints.c: anv_entrypoints_gen.py $(vulkan_api_xml)
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py
 
 BUILT_SOURCES = $(VULKAN_GENERATED_FILES)
 CLEANFILES = $(BUILT_SOURCES) dev_icd.json intel_icd.@host_cpu@.json
diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 0f943a0de1..9ccd9497a2 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -87,7 +87,7 @@ TEMPLATE_H = Template(textwrap.dedent("""\
 #endif // ${guard}
   % endif
 % endfor
-"""))
+"""), output_encoding='utf-8')
 
 TEMPLATE_C = Template(textwrap.dedent(u"""\
 /*
@@ -256,16 +256,6 @@ HASH_MASK = HASH_SIZE - 1
 PRIME_FACTOR = 5024183
 PRIME_STEP = 19
 
-opt_header = False
-opt_code = False
-
-if sys.argv[1] == "header":
-opt_header = True
-sys.argv.pop()
-elif sys.argv[1] == "code":
-opt_code = True
-sys.argv.pop()
-
 
 def hash(name):
 h = 0
@@ -351,15 +341,16 @@ def gen_code(entrypoints):
 collisions[level] += 1
 mapping[h & HASH_MASK] = num
 
-print TEMPLATE_C.render(entrypoints=entrypoints,
-offsets=offsets,
-collisions=collisions,
-mapping=mapping,
-hash_mask=HASH_MASK,
-prime_step=PRIME_STEP,
-prime_factor=PRIME_FACTOR,
-none=NONE,
-hash_size=HASH_SIZE)
+with open('anv_entrypoints.c', 'wb') as f:
+f.write(TEMPLATE_C.render(entrypoints=entrypoints,
+  offsets=offsets,
+  collisions=collisions,
+  mapping=mapping,
+  hash_mask=HASH_MASK,
+  prime_step=PRIME_STEP,
+  prime_factor=PRIME_FACTOR,
+  none=NONE,
+  hash_size=HASH_SIZE))
 
 
 def main():
@@ -378,10 +369,9 @@ def main():
 
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
-if opt_header:
-print TEMPLATE_H.render(entrypoints=entrypoints)
-else:
-gen_code(entrypoints)
+with open('anv_entrypoints.h', 'wb') as f:
+f.write(TEMPLATE_H.render(entrypoints=entrypoints))
+gen_code(entrypoints)
 
 
 if __name__ == '__main__':
-- 
2.11.1

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


[Mesa-dev] [RESEND 12/13] anv: don't use Element.get in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
This has the potential to mask errors, since Element.get works like
dict.get, returning None if the element isn't found. I think the reason
that Element.get was used is that vulkan has one extension that isn't
really an extension, and thus is missing the 'protect' field.

This patch changes the behavior slightly by replacing get with explicit
lookup in the Element.attrib dictionary, and using xpath to only iterate
over extensions with a "protect" attribute.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 47e3a4651f..a9b9f134a9 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -306,13 +306,14 @@ def get_entrypoints(doc, entrypoints_to_defines):
 def get_entrypoints_defines(doc):
 """Maps entry points to extension defines."""
 entrypoints_to_defines = {}
-extensions = doc.findall('./extensions/extension')
-for extension in extensions:
-define = extension.get('protect')
-entrypoints = extension.findall('./require/command')
-for entrypoint in entrypoints:
-fullname = entrypoint.get('name')
+
+for extension in doc.findall('./extensions/extension[@protect]'):
+define = extension.attrib['protect']
+
+for entrypoint in extension.findall('./require/command'):
+fullname = entrypoint.attrib['name']
 entrypoints_to_defines[fullname] = define
+
 return entrypoints_to_defines
 
 
-- 
2.11.1

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


[Mesa-dev] [RESEND 05/13] anv: split main into two functions in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
This is groundwork for the next patches, it will allows porting the
header and the code to mako separately, and will also allow both to be
run simultaneously.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 96 +
 1 file changed, 50 insertions(+), 46 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 5403bcb4bc..3f7b5589e5 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -141,58 +141,40 @@ def get_entrypoints_defines(doc):
 return entrypoints_to_defines
 
 
-def main():
-doc = et.parse(VK_XML)
-entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
-
-# Manually add CreateDmaBufImageINTEL for which we don't have an extension
-# defined.
-entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
-'VkDevice device, ' +
-'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
-'const VkAllocationCallbacks* pAllocator,' +
-'VkDeviceMemory* pMem,' +
-'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
-
-# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
-# per entry point.
-
-if opt_header:
-print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
+def gen_header(entrypoints):
+print "/* This file generated from vk_gen.py, don't edit directly. */\n"
 
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
+print "struct anv_dispatch_table {"
+print "   union {"
+print "  void *entrypoints[%d];" % len(entrypoints)
+print "  struct {"
 
-for type, name, args, num, h, guard in entrypoints:
-if guard is not None:
-print "#ifdef {0}".format(guard)
-print " PFN_vk{0} {0};".format(name)
-print "#else"
-print " void *{0};".format(name)
-print "#endif"
-else:
-print " PFN_vk{0} {0};".format(name)
-print "  };\n"
-print "   };\n"
-print "};\n"
-
-print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
+for type, name, args, num, h, guard in entrypoints:
+if guard is not None:
+print "#ifdef {0}".format(guard)
+print " PFN_vk{0} {0};".format(name)
+print "#else"
+print " void *{0};".format(name)
+print "#endif"
+else:
+print " PFN_vk{0} {0};".format(name)
+print "  };\n"
+print "   };\n"
+print "};\n"
 
-for type, name, args, num, h, guard in entrypoints:
-print_guard_start(guard)
-print "%s anv_%s(%s);" % (type, name, args)
-print "%s gen7_%s(%s);" % (type, name, args)
-print "%s gen75_%s(%s);" % (type, name, args)
-print "%s gen8_%s(%s);" % (type, name, args)
-print "%s gen9_%s(%s);" % (type, name, args)
-print_guard_end(guard)
-exit()
+print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
 
+for type, name, args, num, h, guard in entrypoints:
+print_guard_start(guard)
+print "%s anv_%s(%s);" % (type, name, args)
+print "%s gen7_%s(%s);" % (type, name, args)
+print "%s gen75_%s(%s);" % (type, name, args)
+print "%s gen8_%s(%s);" % (type, name, args)
+print "%s gen9_%s(%s);" % (type, name, args)
+print_guard_end(guard)
 
 
+def gen_code(entrypoints):
 print textwrap.dedent("""\
 /*
  * Copyright ?? 2015 Intel Corporation
@@ -377,5 +359,27 @@ def main():
 """) % (PRIME_FACTOR, PRIME_STEP, HASH_MASK)
 
 
+def main():
+doc = et.parse(VK_XML)
+entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
+
+# Manually add CreateDmaBufImageINTEL for which we don't have an extension
+# defined.
+entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
+'VkDevice device, ' +
+  

[Mesa-dev] [RESEND 09/13] anv: anv-entrypoints_gen.py: rename hash to cal_hash.

2017-02-22 Thread Dylan Baker
hash is reserved name in python, it's the interface to access an
object's hash protocol.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 9ccd9497a2..0c9812a846 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -257,7 +257,8 @@ PRIME_FACTOR = 5024183
 PRIME_STEP = 19
 
 
-def hash(name):
+def cal_hash(name):
+"""Calculate the same hash value that Mesa will calculate in C."""
 h = 0
 for c in name:
 h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
@@ -301,7 +302,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 guard = entrypoints_to_defines[fullname]
 else:
 guard = None
-entrypoints.append((type, shortname, params, index, hash(fullname), 
guard))
+entrypoints.append((type, shortname, params, index, 
cal_hash(fullname), guard))
 index += 1
 
 return entrypoints
@@ -365,7 +366,7 @@ def main():
 'const VkAllocationCallbacks* pAllocator,' +
 'VkDeviceMemory* pMem,' +
 'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
+cal_hash('vkCreateDmaBufImageINTEL'), None))
 
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
-- 
2.11.1

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


[Mesa-dev] [RESEND 01/13] anv: anv_entrypoints_gen.py: use a main function

2017-02-22 Thread Dylan Baker
This is just good practice.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 458 
 1 file changed, 233 insertions(+), 225 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 93511ec95e..3f7a1ce294 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -1,6 +1,6 @@
 # coding=utf-8
 #
-# Copyright ?? 2015 Intel Corporation
+# Copyright ?? 2015, 2017 Intel Corporation
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -23,6 +23,7 @@
 #
 
 import sys
+import textwrap
 import xml.etree.ElementTree as ET
 
 max_api_version = 1.0
@@ -130,235 +131,242 @@ def get_entrypoints_defines(doc):
 entrypoints_to_defines[fullname] = define
 return entrypoints_to_defines
 
-doc = ET.parse(sys.stdin)
-entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
-
-# Manually add CreateDmaBufImageINTEL for which we don't have an extension
-# defined.
-entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
-'VkDevice device, ' +
-'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
-'const VkAllocationCallbacks* pAllocator,' +
-'VkDeviceMemory* pMem,' +
-'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
-
-# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
-# per entry point.
-
-if opt_header:
-print "/* This file generated from vk_gen.py, don't edit directly. */\n"
-
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
 
+def main():
+doc = ET.parse(sys.stdin)
+entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
+
+# Manually add CreateDmaBufImageINTEL for which we don't have an extension
+# defined.
+entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
+'VkDevice device, ' +
+'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
+'const VkAllocationCallbacks* pAllocator,' +
+'VkDeviceMemory* pMem,' +
+'VkImage* pImage', len(entrypoints),
+hash('vkCreateDmaBufImageINTEL'), None))
+
+# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
+# per entry point.
+
+if opt_header:
+print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
+
+print "struct anv_dispatch_table {"
+print "   union {"
+print "  void *entrypoints[%d];" % len(entrypoints)
+print "  struct {"
+
+for type, name, args, num, h, guard in entrypoints:
+if guard is not None:
+print "#ifdef {0}".format(guard)
+print " PFN_vk{0} {0};".format(name)
+print "#else"
+print " void *{0};".format(name)
+print "#endif"
+else:
+print " PFN_vk{0} {0};".format(name)
+print "  };\n"
+print "   };\n"
+print "};\n"
+
+print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
+
+for type, name, args, num, h, guard in entrypoints:
+print_guard_start(guard)
+print "%s anv_%s(%s);" % (type, name, args)
+print "%s gen7_%s(%s);" % (type, name, args)
+print "%s gen75_%s(%s);" % (type, name, args)
+print "%s gen8_%s(%s);" % (type, name, args)
+print "%s gen9_%s(%s);" % (type, name, args)
+print_guard_end(guard)
+exit()
+
+
+
+print textwrap.dedent("""\
+/*
+ * Copyright ?? 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the 
"Software"),
+ * to deal in the Software without restriction, including without 
limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+

[Mesa-dev] [RESEND 07/13] anv: convert C generation to template in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
This produces a file that is identical except for whitespace, there is a
table that has 8 columns in the original and is easy to do with prints,
but is ugly using mako, so it doesn't have columns; the data is not
inherently tabular.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 350 
 1 file changed, 173 insertions(+), 177 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 1b15b13b2f..0f943a0de1 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -89,100 +89,7 @@ TEMPLATE_H = Template(textwrap.dedent("""\
 % endfor
 """))
 
-NONE = 0x
-HASH_SIZE = 256
-U32_MASK = 2**32 - 1
-HASH_MASK = HASH_SIZE - 1
-
-PRIME_FACTOR = 5024183
-PRIME_STEP = 19
-
-opt_header = False
-opt_code = False
-
-if sys.argv[1] == "header":
-opt_header = True
-sys.argv.pop()
-elif sys.argv[1] == "code":
-opt_code = True
-sys.argv.pop()
-
-
-def hash(name):
-h = 0
-for c in name:
-h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
-
-return h
-
-
-def print_guard_start(guard):
-if guard is not None:
-print "#ifdef {0}".format(guard)
-
-
-def print_guard_end(guard):
-if guard is not None:
-print "#endif // {0}".format(guard)
-
-
-def get_entrypoints(doc, entrypoints_to_defines):
-"""Extract the entry points from the registry."""
-entrypoints = []
-
-enabled_commands = set()
-for feature in doc.findall('./feature'):
-assert feature.attrib['api'] == 'vulkan'
-if float(feature.attrib['number']) > MAX_API_VERSION:
-continue
-
-for command in feature.findall('./require/command'):
-enabled_commands.add(command.attrib['name'])
-
-for extension in doc.findall('.extensions/extension'):
-if extension.attrib['name'] not in SUPPORTED_EXTENSIONS:
-continue
-
-assert extension.attrib['supported'] == 'vulkan'
-for command in extension.findall('./require/command'):
-enabled_commands.add(command.attrib['name'])
-
-index = 0
-for command in doc.findall('./commands/command'):
-type = command.find('./proto/type').text
-fullname = command.find('./proto/name').text
-
-if fullname not in enabled_commands:
-continue
-
-shortname = fullname[2:]
-params = (''.join(p.itertext()) for p in command.findall('./param'))
-params = ', '.join(params)
-if fullname in entrypoints_to_defines:
-guard = entrypoints_to_defines[fullname]
-else:
-guard = None
-entrypoints.append((type, shortname, params, index, hash(fullname), 
guard))
-index += 1
-
-return entrypoints
-
-
-def get_entrypoints_defines(doc):
-"""Maps entry points to extension defines."""
-entrypoints_to_defines = {}
-extensions = doc.findall('./extensions/extension')
-for extension in extensions:
-define = extension.get('protect')
-entrypoints = extension.findall('./require/command')
-for entrypoint in entrypoints:
-fullname = entrypoint.get('name')
-entrypoints_to_defines[fullname] = define
-return entrypoints_to_defines
-
-
-def gen_code(entrypoints):
-print textwrap.dedent("""\
+TEMPLATE_C = Template(textwrap.dedent(u"""\
 /*
  * Copyright ?? 2015 Intel Corporation
  *
@@ -220,44 +127,47 @@ def gen_code(entrypoints):
  * store the index into this big string.
  */
 
-static const char strings[] =""")
-
-offsets = []
-i = 0
-for type, name, args, num, h, guard in entrypoints:
-print "   \"vk%s\\0\"" % name
-offsets.append(i)
-i += 2 + len(name) + 1
-print "   ;"
-
-# Now generate the table of all entry points
-
-print "\nstatic const struct anv_entrypoint entrypoints[] = {"
-for type, name, args, num, h, guard in entrypoints:
-print "   { %5d, 0x%08x }," % (offsets[num], h)
-print "};\n"
+static const char strings[] =
+% for _, name, _, _, _, _ in entrypoints:
+"vk${name}\\0"
+% endfor
+;
 
-print textwrap.dedent("""
+static const struct anv_entrypoint entrypoints[] = {
+% for _, _, _, num, h, _ in entrypoints:
+{ ${offsets[num]}, ${'{:0=#8x}'.format(h)} },
+% endfor
+};
 
 /* Weak aliases for all potential implementations. These wil

[Mesa-dev] [RESEND 10/13] anv: anv_entrypoints_gen.py: use reduce function.

2017-02-22 Thread Dylan Baker
Reduce is it's own reward.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 0c9812a846..e1c5ac6ddf 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -22,6 +22,7 @@
 # IN THE SOFTWARE.
 #
 
+import functools
 import os
 import sys
 import textwrap
@@ -259,11 +260,8 @@ PRIME_STEP = 19
 
 def cal_hash(name):
 """Calculate the same hash value that Mesa will calculate in C."""
-h = 0
-for c in name:
-h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
-
-return h
+return functools.reduce(
+lambda h, c: (h * PRIME_FACTOR + ord(c)) & U32_MASK, name, 0)
 
 
 def get_entrypoints(doc, entrypoints_to_defines):
-- 
2.11.1

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


[Mesa-dev] [RESEND 02/13] anv: Use python style in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
These are all fairly small cleanups/tweaks that don't really deserve
their own patch.

- Prefer comprehensions to map() and filter(), since they're faster
- replace unused variables with _
- Use 4 spaces of indent
- drop semicolons from the end of lines
- Don't use parens around if conditions
- don't put spaces around brackets
- don't import modules as caps (ET -> et)
- Use docstrings instead of comments

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 63 ++---
 1 file changed, 34 insertions(+), 29 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 3f7a1ce294..358cf1e1e2 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -24,20 +24,20 @@
 
 import sys
 import textwrap
-import xml.etree.ElementTree as ET
+import xml.etree.ElementTree as et
 
 max_api_version = 1.0
 
 supported_extensions = [
-   'VK_KHR_get_physical_device_properties2',
-   'VK_KHR_maintenance1',
-   'VK_KHR_sampler_mirror_clamp_to_edge',
-   'VK_KHR_shader_draw_parameters',
-   'VK_KHR_surface',
-   'VK_KHR_swapchain',
-   'VK_KHR_wayland_surface',
-   'VK_KHR_xcb_surface',
-   'VK_KHR_xlib_surface',
+'VK_KHR_get_physical_device_properties2',
+'VK_KHR_maintenance1',
+'VK_KHR_sampler_mirror_clamp_to_edge',
+'VK_KHR_shader_draw_parameters',
+'VK_KHR_surface',
+'VK_KHR_swapchain',
+'VK_KHR_wayland_surface',
+'VK_KHR_xcb_surface',
+'VK_KHR_xlib_surface',
 ]
 
 # We generate a static hash table for entry point lookup
@@ -53,33 +53,37 @@ hash_mask = hash_size - 1
 prime_factor = 5024183
 prime_step = 19
 
+opt_header = False
+opt_code = False
+
+if sys.argv[1] == "header":
+opt_header = True
+sys.argv.pop()
+elif sys.argv[1] == "code":
+opt_code = True
+sys.argv.pop()
+
+
 def hash(name):
-h = 0;
+h = 0
 for c in name:
 h = (h * prime_factor + ord(c)) & u32_mask
 
 return h
 
+
 def print_guard_start(guard):
 if guard is not None:
 print "#ifdef {0}".format(guard)
 
+
 def print_guard_end(guard):
 if guard is not None:
 print "#endif // {0}".format(guard)
 
-opt_header = False
-opt_code = False
 
-if (sys.argv[1] == "header"):
-opt_header = True
-sys.argv.pop()
-elif (sys.argv[1] == "code"):
-opt_code = True
-sys.argv.pop()
-
-# Extract the entry points from the registry
 def get_entrypoints(doc, entrypoints_to_defines):
+"""Extract the entry points from the registry."""
 entrypoints = []
 
 enabled_commands = set()
@@ -108,7 +112,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 continue
 
 shortname = fullname[2:]
-params = map(lambda p: "".join(p.itertext()), 
command.findall('./param'))
+params = (''.join(p.itertext()) for p in command.findall('./param'))
 params = ', '.join(params)
 if fullname in entrypoints_to_defines:
 guard = entrypoints_to_defines[fullname]
@@ -119,8 +123,9 @@ def get_entrypoints(doc, entrypoints_to_defines):
 
 return entrypoints
 
-# Maps entry points to extension defines
+
 def get_entrypoints_defines(doc):
+"""Maps entry points to extension defines."""
 entrypoints_to_defines = {}
 extensions = doc.findall('./extensions/extension')
 for extension in extensions:
@@ -133,7 +138,7 @@ def get_entrypoints_defines(doc):
 
 
 def main():
-doc = ET.parse(sys.stdin)
+doc = et.parse(sys.stdin)
 entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
 
 # Manually add CreateDmaBufImageINTEL for which we don't have an extension
@@ -225,7 +230,7 @@ def main():
 static const char strings[] =""")
 
 offsets = []
-i = 0;
+i = 0
 for type, name, args, num, h, guard in entrypoints:
 print "   \"vk%s\\0\"" % name
 offsets.append(i)
@@ -247,7 +252,7 @@ def main():
  */
 """)
 
-for layer in [ "anv", "gen7", "gen75", "gen8", "gen9" ]:
+for layer in ["anv", "gen7", "gen75", "gen8", "gen9"]:
 for type, name, args, num, h, guard in entrypoints:
 print_guard_start(guard)
 print "%s %s_%s(%s) __attribute__ ((weak));" % (type, layer, name, 
args)
@@ -295,8 +300,8 @@ def main():
 # uint16_t table of entry point indices. We use 0x to indicate an entry
 # in the hash table i

[Mesa-dev] [RESEND 13/13] anv: use cElementTree in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
It's written in C rather than pure python and is strictly faster, the
only reason not to use it that it's classes cannot be subclassed.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index a9b9f134a9..6426cc02ab 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -26,7 +26,7 @@ import functools
 import os
 import sys
 import textwrap
-import xml.etree.ElementTree as et
+import xml.etree.cElementTree as et
 
 from mako.template import Template
 
-- 
2.11.1

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


[Mesa-dev] [RESEND 06/13] anv: convert header generation in anv_entrypoints_gen.py to mako

2017-02-22 Thread Dylan Baker
This produces an identical file except for whitespace.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 75 ++---
 1 file changed, 41 insertions(+), 34 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 3f7b5589e5..1b15b13b2f 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -27,6 +27,8 @@ import sys
 import textwrap
 import xml.etree.ElementTree as et
 
+from mako.template import Template
+
 VK_XML = os.path.join(
 os.path.dirname(__file__), '..', '..', 'vulkan', 'registry', 'vk.xml')
 
@@ -49,6 +51,44 @@ SUPPORTED_EXTENSIONS = [
 # function and a power-of-two size table. The prime numbers are determined
 # experimentally.
 
+TEMPLATE_H = Template(textwrap.dedent("""\
+/* This file generated from vk_gen.py, don't edit directly. */
+
+struct anv_dispatch_table {
+   union {
+  void *entrypoints[${len(entrypoints)}];
+  struct {
+  % for _, name, _, _, _, guard in entrypoints:
+% if guard is not None:
+#ifdef ${guard}
+  PFN_vk${name} ${name};
+#else
+  void *${name};
+# endif
+% else:
+  PFN_vk${name} ${name};
+% endif
+  % endfor
+  };
+   };
+};
+
+void anv_set_dispatch_devinfo(const struct gen_device_info *info);
+% for type_, name, args, num, h, guard in entrypoints:
+  % if guard is not None:
+#ifdef ${guard}
+  % endif
+  ${type_} anv_${name}(${args});
+  ${type_} gen7_${name}(${args});
+  ${type_} gen75_${name}(${args});
+  ${type_} gen8_${name}(${args});
+  ${type_} gen9_${name}(${args});
+  % if guard is not None:
+#endif // ${guard}
+  % endif
+% endfor
+"""))
+
 NONE = 0x
 HASH_SIZE = 256
 U32_MASK = 2**32 - 1
@@ -141,39 +181,6 @@ def get_entrypoints_defines(doc):
 return entrypoints_to_defines
 
 
-def gen_header(entrypoints):
-print "/* This file generated from vk_gen.py, don't edit directly. */\n"
-
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
-
-for type, name, args, num, h, guard in entrypoints:
-if guard is not None:
-print "#ifdef {0}".format(guard)
-print " PFN_vk{0} {0};".format(name)
-print "#else"
-print " void *{0};".format(name)
-print "#endif"
-else:
-print " PFN_vk{0} {0};".format(name)
-print "  };\n"
-print "   };\n"
-print "};\n"
-
-print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
-
-for type, name, args, num, h, guard in entrypoints:
-print_guard_start(guard)
-print "%s anv_%s(%s);" % (type, name, args)
-print "%s gen7_%s(%s);" % (type, name, args)
-print "%s gen75_%s(%s);" % (type, name, args)
-print "%s gen8_%s(%s);" % (type, name, args)
-print "%s gen9_%s(%s);" % (type, name, args)
-print_guard_end(guard)
-
-
 def gen_code(entrypoints):
 print textwrap.dedent("""\
 /*
@@ -376,7 +383,7 @@ def main():
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
 if opt_header:
-gen_header(entrypoints)
+print TEMPLATE_H.render(entrypoints=entrypoints)
 else:
 gen_code(entrypoints)
 
-- 
2.11.1

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


[Mesa-dev] [RESEND 11/13] anv: use dict.get in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
Instead of using an if and a check, use dict.get, which does the same
thing, but more succinctly.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index e1c5ac6ddf..47e3a4651f 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -296,10 +296,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 shortname = fullname[2:]
 params = (''.join(p.itertext()) for p in command.findall('./param'))
 params = ', '.join(params)
-if fullname in entrypoints_to_defines:
-guard = entrypoints_to_defines[fullname]
-else:
-guard = None
+guard = entrypoints_to_defines.get(fullname)
 entrypoints.append((type, shortname, params, index, 
cal_hash(fullname), guard))
 index += 1
 
-- 
2.11.1

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


[Mesa-dev] [RESEND 03/13] anv: make constants capitals in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
Again, it's standard python style.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 38 -
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 358cf1e1e2..40b8c805d5 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -26,9 +26,9 @@ import sys
 import textwrap
 import xml.etree.ElementTree as et
 
-max_api_version = 1.0
+MAX_API_VERSION = 1.0
 
-supported_extensions = [
+SUPPORTED_EXTENSIONS = [
 'VK_KHR_get_physical_device_properties2',
 'VK_KHR_maintenance1',
 'VK_KHR_sampler_mirror_clamp_to_edge',
@@ -45,13 +45,13 @@ supported_extensions = [
 # function and a power-of-two size table. The prime numbers are determined
 # experimentally.
 
-none = 0x
-hash_size = 256
-u32_mask = 2**32 - 1
-hash_mask = hash_size - 1
+NONE = 0x
+HASH_SIZE = 256
+U32_MASK = 2**32 - 1
+HASH_MASK = HASH_SIZE - 1
 
-prime_factor = 5024183
-prime_step = 19
+PRIME_FACTOR = 5024183
+PRIME_STEP = 19
 
 opt_header = False
 opt_code = False
@@ -67,7 +67,7 @@ elif sys.argv[1] == "code":
 def hash(name):
 h = 0
 for c in name:
-h = (h * prime_factor + ord(c)) & u32_mask
+h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
 
 return h
 
@@ -89,14 +89,14 @@ def get_entrypoints(doc, entrypoints_to_defines):
 enabled_commands = set()
 for feature in doc.findall('./feature'):
 assert feature.attrib['api'] == 'vulkan'
-if float(feature.attrib['number']) > max_api_version:
+if float(feature.attrib['number']) > MAX_API_VERSION:
 continue
 
 for command in feature.findall('./require/command'):
 enabled_commands.add(command.attrib['name'])
 
 for extension in doc.findall('.extensions/extension'):
-if extension.attrib['name'] not in supported_extensions:
+if extension.attrib['name'] not in SUPPORTED_EXTENSIONS:
 continue
 
 assert extension.attrib['supported'] == 'vulkan'
@@ -300,21 +300,21 @@ def main():
 # uint16_t table of entry point indices. We use 0x to indicate an entry
 # in the hash table is empty.
 
-map = [none for _ in xrange(hash_size)]
+map = [NONE for _ in xrange(HASH_SIZE)]
 collisions = [0 for _ in xrange(10)]
 for type, name, args, num, h, guard in entrypoints:
 level = 0
-while map[h & hash_mask] != none:
-h = h + prime_step
+while map[h & HASH_MASK] != NONE:
+h = h + PRIME_STEP
 level = level + 1
 if level > 9:
 collisions[9] += 1
 else:
 collisions[level] += 1
-map[h & hash_mask] = num
+map[h & HASH_MASK] = num
 
 print "/* Hash table stats:"
-print " * size %d entries" % hash_size
+print " * size %d entries" % HASH_SIZE
 print " * collisions  entries"
 for i in xrange(10):
 if i == 9:
@@ -325,10 +325,10 @@ def main():
 print " * %2d%s %4d" % (i, plus, collisions[i])
 print " */\n"
 
-print "#define none 0x%04x\n" % none
+print "#define none 0x%04x\n" % NONE
 
 print "static const uint16_t map[] = {"
-for i in xrange(0, hash_size, 8):
+for i in xrange(0, HASH_SIZE, 8):
 print "   ",
 for j in xrange(i, i + 8):
 if map[j] & 0x == 0x:
@@ -370,7 +370,7 @@ def main():
 
return anv_resolve_entrypoint(devinfo, i);
 }
-""") % (prime_factor, prime_step, hash_mask)
+""") % (PRIME_FACTOR, PRIME_STEP, HASH_MASK)
 
 
 if __name__ == '__main__':
-- 
2.11.1

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


Re: [Mesa-dev] [PATCH 02/13] anv: Use python style in anv_entrypoints_gen.py

2017-02-22 Thread Dylan Baker
Quoting Jason Ekstrand (2017-02-22 15:28:50)
> On Wed, Feb 22, 2017 at 3:15 PM, Dylan Baker  wrote:
> 
> These are all fairly small cleanups/tweaks that don't really deserve
> their own patch.
> 
> - Prefer comprehensions to map() and filter(), since they're faster
> - replace unused variables with _
> - Use 4 spaces of indent
> - drop semicolons from the end of lines
> - Don't use parens around if conditions
> - don't put spaces around brackets
> - don't import modules as caps (ET -> et)
> - Use docstrings instead of comments
> 
> Signed-off-by: Dylan Baker 
> ---
>  src/intel/vulkan/anv_entrypoints_gen.py | 63
> ++---
>  1 file changed, 34 insertions(+), 29 deletions(-)
> 
> diff --git a/src/intel/vulkan/anv_entrypoints_gen.py b/src/intel/vulkan/
> anv_entrypoints_gen.py
> index 3f7a1ce294..358cf1e1e2 100644
> --- a/src/intel/vulkan/anv_entrypoints_gen.py
> +++ b/src/intel/vulkan/anv_entrypoints_gen.py
> @@ -24,20 +24,20 @@
> 
>  import sys
>  import textwrap
> -import xml.etree.ElementTree as ET
> +import xml.etree.ElementTree as et
> 
>  max_api_version = 1.0
> 
>  supported_extensions = [
> -   'VK_KHR_get_physical_device_properties2',
> -   'VK_KHR_maintenance1',
> -   'VK_KHR_sampler_mirror_clamp_to_edge',
> -   'VK_KHR_shader_draw_parameters',
> -   'VK_KHR_surface',
> -   'VK_KHR_swapchain',
> -   'VK_KHR_wayland_surface',
> -   'VK_KHR_xcb_surface',
> -   'VK_KHR_xlib_surface',
> +    'VK_KHR_get_physical_device_properties2',
> +    'VK_KHR_maintenance1',
> +    'VK_KHR_sampler_mirror_clamp_to_edge',
> +    'VK_KHR_shader_draw_parameters',
> +    'VK_KHR_surface',
> +    'VK_KHR_swapchain',
> +    'VK_KHR_wayland_surface',
> +    'VK_KHR_xcb_surface',
> +    'VK_KHR_xlib_surface',
>  ]
> 
>  # We generate a static hash table for entry point lookup
> @@ -53,33 +53,37 @@ hash_mask = hash_size - 1
>  prime_factor = 5024183
>  prime_step = 19
> 
> +opt_header = False
> +opt_code = False
> +
> +if sys.argv[1] == "header":
> +    opt_header = True
> +    sys.argv.pop()
> +elif sys.argv[1] == "code":
> +    opt_code = True
> +    sys.argv.pop()
> +
> +
>  def hash(name):
> -    h = 0;
> +    h = 0
>      for c in name:
>          h = (h * prime_factor + ord(c)) & u32_mask
> 
>      return h
> 
> +
>  def print_guard_start(guard):
>      if guard is not None:
>          print "#ifdef {0}".format(guard)
> 
> +
>  def print_guard_end(guard):
>      if guard is not None:
>          print "#endif // {0}".format(guard)
> 
> -opt_header = False
> -opt_code = False
> 
> -if (sys.argv[1] == "header"):
> -    opt_header = True
> -    sys.argv.pop()
> -elif (sys.argv[1] == "code"):
> -    opt_code = True
> -    sys.argv.pop()
> -
> -# Extract the entry points from the registry
>  def get_entrypoints(doc, entrypoints_to_defines):
> +    """Extract the entry points from the registry."""
>      entrypoints = []
> 
>      enabled_commands = set()
> @@ -108,7 +112,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
>              continue
> 
>          shortname = fullname[2:]
> -        params = map(lambda p: "".join(p.itertext()), command.findall('./
> param'))
> +        params = (''.join(p.itertext()) for p in command.findall('./
> param'))
>          params = ', '.join(params)
>          if fullname in entrypoints_to_defines:
>              guard = entrypoints_to_defines[fullname]
> @@ -119,8 +123,9 @@ def get_entrypoints(doc, entrypoints_to_defines):
> 
>      return entrypoints
> 
> -# Maps entry points to extension defines
> +
>  def get_entrypoints_defines(doc):
> +    """Maps entry points to extension defines."""
>      entrypoints_to_defines = {}
>      extensions = doc.findall('./extensions/extension')
>      for extension in extensions:
> @@ -133,7 +138,7 @@ def get_entrypoi

[Mesa-dev] [PATCH] vulkan: Fix gen_enum_to_str in out of tree builds

2017-02-22 Thread Dylan Baker
In some configurations the util directory is created when building out
of tree, but not others. This patch ensures that it's created.

cc: Matt Turner 
Signed-off-by: Dylan Baker 
---
 src/vulkan/Makefile.am | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/vulkan/Makefile.am b/src/vulkan/Makefile.am
index fa72d63d65..5cdffbf901 100644
--- a/src/vulkan/Makefile.am
+++ b/src/vulkan/Makefile.am
@@ -5,6 +5,9 @@ noinst_LTLIBRARIES = libvulkan_wsi.la libvulkan_util.la
 vulkan_includedir = $(includedir)/vulkan
 vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 
+MKDIR_GEN = $(AM_V_at)$(MKDIR_P) $(@D)
+PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)
+
 EXTRA_DIST = \
util/gen_enum_to_str.py
 
@@ -13,7 +16,8 @@ BUILT_SOURCES = \
util/vk_enum_to_str.h
 
 util/vk_enum_to_str.c util/vk_enum_to_str.h: util/gen_enum_to_str.py 
$(vulkan_api_xml)
-   $(AM_V_GEN)$(PYTHON2) $(srcdir)/util/gen_enum_to_str.py
+   $(MKDIR_GEN)
+   $(PYTHON_GEN) $(srcdir)/util/gen_enum_to_str.py
 
 libvulkan_util_la_SOURCES = $(VULKAN_UTIL_FILES)
 
-- 
2.11.1

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


Re: [Mesa-dev] [RESEND 08/13] anv: generate anv_entrypoints.{h, c} in one command

2017-02-23 Thread Dylan Baker
Quoting Emil Velikov (2017-02-23 02:32:17)
> On 22 February 2017 at 23:35, Dylan Baker  wrote:
> > This changes the python generator to write the files itself, rather than
> > piping them out. This has a couple of advantages: first, it encapsulates
> > the encoding. Second, it ensures that the header file and code file are
> > generated at the same time with the same data.
> >
> Last time there were some serious objections to doing this. Glad that
> you got those covered ;-)
> 
> > Signed-off-by: Dylan Baker 
> > ---
> >  src/intel/vulkan/Makefile.am|  7 ++
> >  src/intel/vulkan/anv_entrypoints_gen.py | 38 
> > -
> >  2 files changed, 16 insertions(+), 29 deletions(-)
> >
> > diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
> > index 5a0e4ef4ff..68bc5ccf86 100644
> > --- a/src/intel/vulkan/Makefile.am
> > +++ b/src/intel/vulkan/Makefile.am
> > @@ -145,11 +145,8 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
> >
> >  vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
> >
> > -anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
> > -   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
> > -
> > -anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
> > -   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
> > +anv_entrypoints.h anv_entrypoints.c: anv_entrypoints_gen.py 
> > $(vulkan_api_xml)
> > +   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py
> >
> Please pass a "-o $dst_dir" type of argument. It will be/is broken otherwise.

So you want an option for where the output files are going to be placed?

> 
> Small suggestion to update the Android.mk file. Feel free to Cc
> Tapani/Mauro so that they can test/address any concerns.
> 
> Mauro, Tapani,
> Afaict earlier series [1] have broken things on your end, but do
> suggest some fixes that one can squash with this batch.
> 
> Thanks
> Emil
> 
> [1]
> e9dcb17962f7e58a81c93bae7bd33885675b1043
> 8e03250fcf4fc5de31e92ca4919959d932888a69


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


Re: [Mesa-dev] [RESEND 04/13] anv: don't pass xmlfile via stdin anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
Quoting Emil Velikov (2017-02-23 02:24:21)
> Hi Dylan,
> 
> General question - have you considered porting the series to the radv ?
> Alternatively - Bas, Dave you might find these interesting/useful ;-)

Yeah, I'm getting there. My goal is mako + python3 readiness for all of mesa.

> 
> On 22 February 2017 at 23:36, Dylan Baker  wrote:
> > It's slow, and has the potential for encoding issues.
> >
> > Signed-off-by: Dylan Baker 
> > ---
> >  src/intel/vulkan/Makefile.am| 6 ++
> >  src/intel/vulkan/anv_entrypoints_gen.py | 6 +-
> >  2 files changed, 7 insertions(+), 5 deletions(-)
> >
> > diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
> > index 449188fe1e..5a0e4ef4ff 100644
> > --- a/src/intel/vulkan/Makefile.am
> > +++ b/src/intel/vulkan/Makefile.am
> > @@ -146,12 +146,10 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
> >  vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
> >
> >  anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
> > -   $(AM_V_GEN) cat $(vulkan_api_xml) |\
> > -   $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
> > +   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
> >
> >  anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
> > -   $(AM_V_GEN) cat $(vulkan_api_xml) |\
> > -   $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
> > +   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
> >
> Can you please apply similar [trivial] fix for Android.mk ?

Sure

> 
> >  BUILT_SOURCES = $(VULKAN_GENERATED_FILES)
> >  CLEANFILES = $(BUILT_SOURCES) dev_icd.json intel_icd.@host_cpu@.json
> > diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
> > b/src/intel/vulkan/anv_entrypoints_gen.py
> > index 40b8c805d5..5403bcb4bc 100644
> > --- a/src/intel/vulkan/anv_entrypoints_gen.py
> > +++ b/src/intel/vulkan/anv_entrypoints_gen.py
> > @@ -22,10 +22,14 @@
> >  # IN THE SOFTWARE.
> >  #
> >
> > +import os
> >  import sys
> >  import textwrap
> >  import xml.etree.ElementTree as et
> >
> > +VK_XML = os.path.join(
> > +os.path.dirname(__file__), '..', '..', 'vulkan', 'registry', 'vk.xml')
> Hard-coded paths is very, very bad idea. Please feed it in as argument.

Well, technically it's hard-coded no matter where we do it, but I'll hard-code 
it
in the build systems instead ;)

> 
> Thanks
> Emil


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


Re: [Mesa-dev] [RESEND 06/13] anv: convert header generation in anv_entrypoints_gen.py to mako

2017-02-23 Thread Dylan Baker
Sure, I'll add a patch for v2

Quoting Emil Velikov (2017-02-23 03:14:49)
> On 22 February 2017 at 23:36, Dylan Baker  wrote:
> 
> > +void anv_set_dispatch_devinfo(const struct gen_device_info *info);
> Dead declaration since commit 6d557ae4032adafc85a4cb5a76d8653bf0cf6639.
> 
> Worth fixing before, with or after this patch/series ?
> 
> -Emil


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


Re: [Mesa-dev] [RESEND 08/13] anv: generate anv_entrypoints.{h, c} in one command

2017-02-23 Thread Dylan Baker
Quoting Emil Velikov (2017-02-23 09:29:40)
> On 23 February 2017 at 17:22, Dylan Baker  wrote:
> > Quoting Emil Velikov (2017-02-23 02:32:17)
> >> On 22 February 2017 at 23:35, Dylan Baker  wrote:
> >> > This changes the python generator to write the files itself, rather than
> >> > piping them out. This has a couple of advantages: first, it encapsulates
> >> > the encoding. Second, it ensures that the header file and code file are
> >> > generated at the same time with the same data.
> >> >
> >> Last time there were some serious objections to doing this. Glad that
> >> you got those covered ;-)
> >>
> >> > Signed-off-by: Dylan Baker 
> >> > ---
> >> >  src/intel/vulkan/Makefile.am|  7 ++
> >> >  src/intel/vulkan/anv_entrypoints_gen.py | 38 
> >> > -
> >> >  2 files changed, 16 insertions(+), 29 deletions(-)
> >> >
> >> > diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
> >> > index 5a0e4ef4ff..68bc5ccf86 100644
> >> > --- a/src/intel/vulkan/Makefile.am
> >> > +++ b/src/intel/vulkan/Makefile.am
> >> > @@ -145,11 +145,8 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
> >> >
> >> >  vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
> >> >
> >> > -anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
> >> > -   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > 
> >> > $@
> >> > -
> >> > -anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
> >> > -   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
> >> > +anv_entrypoints.h anv_entrypoints.c: anv_entrypoints_gen.py 
> >> > $(vulkan_api_xml)
> >> > +   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py
> >> >
> >> Please pass a "-o $dst_dir" type of argument. It will be/is broken 
> >> otherwise.
> >
> > So you want an option for where the output files are going to be placed?
> >
> Precisely. To elaborate a bit - as-is (if I'm reading it properly)
> you'll end up generating the files to srcdir.
> srcdir should be considered immutable and this will fail a bunch of tests.
> 
> Generated files should be stored in $builddir.

On my system as-is they end up in $builddir, however, we discovered yesterday
that some out-of-tree builds work on my system, but fail on everybody else's, so
I'll go ahead and add that switch.

> 
> Thanks
> Emil


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


[Mesa-dev] [PATCH v2 3/14] anv: make constants capitals in anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
Again, it's standard python style.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 38 +-
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index b4cead9..d3f028e 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -26,9 +26,9 @@ import sys
 import textwrap
 import xml.etree.ElementTree as et
 
-max_api_version = 1.0
+MAX_API_VERSION = 1.0
 
-supported_extensions = [
+SUPPORTED_EXTENSIONS = [
 'VK_KHR_get_physical_device_properties2',
 'VK_KHR_maintenance1',
 'VK_KHR_sampler_mirror_clamp_to_edge',
@@ -45,13 +45,13 @@ supported_extensions = [
 # function and a power-of-two size table. The prime numbers are determined
 # experimentally.
 
-none = 0x
-hash_size = 256
-u32_mask = 2**32 - 1
-hash_mask = hash_size - 1
+NONE = 0x
+HASH_SIZE = 256
+U32_MASK = 2**32 - 1
+HASH_MASK = HASH_SIZE - 1
 
-prime_factor = 5024183
-prime_step = 19
+PRIME_FACTOR = 5024183
+PRIME_STEP = 19
 
 opt_header = False
 opt_code = False
@@ -67,7 +67,7 @@ elif sys.argv[1] == "code":
 def hash(name):
 h = 0
 for c in name:
-h = (h * prime_factor + ord(c)) & u32_mask
+h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
 
 return h
 
@@ -89,14 +89,14 @@ def get_entrypoints(doc, entrypoints_to_defines):
 enabled_commands = set()
 for feature in doc.findall('./feature'):
 assert feature.attrib['api'] == 'vulkan'
-if float(feature.attrib['number']) > max_api_version:
+if float(feature.attrib['number']) > MAX_API_VERSION:
 continue
 
 for command in feature.findall('./require/command'):
 enabled_commands.add(command.attrib['name'])
 
 for extension in doc.findall('.extensions/extension'):
-if extension.attrib['name'] not in supported_extensions:
+if extension.attrib['name'] not in SUPPORTED_EXTENSIONS:
 continue
 
 assert extension.attrib['supported'] == 'vulkan'
@@ -300,21 +300,21 @@ def main():
 # uint16_t table of entry point indices. We use 0x to indicate an entry
 # in the hash table is empty.
 
-map = [none] * hash_size
+map = [NONE] * HASH_SIZE
 collisions = [0] * 10
 for type, name, args, num, h, guard in entrypoints:
 level = 0
-while map[h & hash_mask] != none:
-h = h + prime_step
+while map[h & HASH_MASK] != NONE:
+h = h + PRIME_STEP
 level = level + 1
 if level > 9:
 collisions[9] += 1
 else:
 collisions[level] += 1
-map[h & hash_mask] = num
+map[h & HASH_MASK] = num
 
 print "/* Hash table stats:"
-print " * size %d entries" % hash_size
+print " * size %d entries" % HASH_SIZE
 print " * collisions  entries"
 for i in xrange(10):
 if i == 9:
@@ -325,10 +325,10 @@ def main():
 print " * %2d%s %4d" % (i, plus, collisions[i])
 print " */\n"
 
-print "#define none 0x%04x\n" % none
+print "#define none 0x%04x\n" % NONE
 
 print "static const uint16_t map[] = {"
-for i in xrange(0, hash_size, 8):
+for i in xrange(0, HASH_SIZE, 8):
 print "   ",
 for j in xrange(i, i + 8):
 if map[j] & 0x == 0x:
@@ -370,7 +370,7 @@ def main():
 
return anv_resolve_entrypoint(devinfo, i);
 }
-""") % (prime_factor, prime_step, hash_mask)
+""") % (PRIME_FACTOR, PRIME_STEP, HASH_MASK)
 
 
 if __name__ == '__main__':
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 4/14] anv: don't pass xmlfile via stdin anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
It's slow, and has the potential for encoding issues.

v2: - pass xml file location via argument
- update Android.mk

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/Android.mk |  4 ++--
 src/intel/vulkan/Makefile.am|  6 ++
 src/intel/vulkan/anv_entrypoints_gen.py | 19 +--
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/intel/vulkan/Android.mk b/src/intel/vulkan/Android.mk
index 1e53970..9dabf1c 100644
--- a/src/intel/vulkan/Android.mk
+++ b/src/intel/vulkan/Android.mk
@@ -61,7 +61,7 @@ $(intermediates)/dummy.c:
$(hide) touch $@
 
 $(intermediates)/anv_entrypoints.h:
-   $(hide) cat $(MESA_TOP)/src/vulkan/registry/vk.xml | 
$(VK_ENTRYPOINTS_SCRIPT) header > $@
+   $(VK_ENTRYPOINTS_SCRIPT) header --xml 
$(MESA_TOP)/src/vulkan/registry/vk.xml > $@
 
 LOCAL_EXPORT_C_INCLUDE_DIRS := \
 $(intermediates)
@@ -177,7 +177,7 @@ LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_anv_entrypoints 
libmesa_genxml
 LOCAL_GENERATED_SOURCES += $(intermediates)/anv_entrypoints.c
 
 $(intermediates)/anv_entrypoints.c:
-   $(hide) cat $(MESA_TOP)/src/vulkan/registry/vk.xml | 
$(VK_ENTRYPOINTS_SCRIPT) code > $@
+   $(VK_ENTRYPOINTS_SCRIPT) code --xml 
$(MESA_TOP)/src/vulkan/registry/vk.xml > $@
 
 LOCAL_SHARED_LIBRARIES := libdrm_intel
 
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 449188f..565559c 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -146,12 +146,10 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
 vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 
 anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN) cat $(vulkan_api_xml) |\
-   $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header --xml 
$(vulkan_api_xml) > $@
 
 anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN) cat $(vulkan_api_xml) |\
-   $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code --xml 
$(vulkan_api_xml) > $@
 
 BUILT_SOURCES = $(VULKAN_GENERATED_FILES)
 CLEANFILES = $(BUILT_SOURCES) dev_icd.json intel_icd.@host_cpu@.json
diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index d3f028e..ea15065 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -22,7 +22,7 @@
 # IN THE SOFTWARE.
 #
 
-import sys
+import argparse
 import textwrap
 import xml.etree.ElementTree as et
 
@@ -56,13 +56,6 @@ PRIME_STEP = 19
 opt_header = False
 opt_code = False
 
-if sys.argv[1] == "header":
-opt_header = True
-sys.argv.pop()
-elif sys.argv[1] == "code":
-opt_code = True
-sys.argv.pop()
-
 
 def hash(name):
 h = 0
@@ -138,7 +131,13 @@ def get_entrypoints_defines(doc):
 
 
 def main():
-doc = et.parse(sys.stdin)
+parser = argparse.ArgumentParser()
+parser.add_argument('target', choices=['header', 'code'],
+help='Which file to generate.')
+parser.add_argument('--xml', help='Vulkan API XML file.')
+args = parser.parse_args()
+
+doc = et.parse(args.xml)
 entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
 
 # Manually add CreateDmaBufImageINTEL for which we don't have an extension
@@ -154,7 +153,7 @@ def main():
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
 
-if opt_header:
+if args.target == 'header':
 print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
 
 print "struct anv_dispatch_table {"
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 1/14] anv: anv_entrypoints_gen.py: use a main function

2017-02-23 Thread Dylan Baker
This is just good practice.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 458 -
 1 file changed, 233 insertions(+), 225 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 93511ec..3f7a1ce 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -1,6 +1,6 @@
 # coding=utf-8
 #
-# Copyright ?? 2015 Intel Corporation
+# Copyright ?? 2015, 2017 Intel Corporation
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -23,6 +23,7 @@
 #
 
 import sys
+import textwrap
 import xml.etree.ElementTree as ET
 
 max_api_version = 1.0
@@ -130,235 +131,242 @@ def get_entrypoints_defines(doc):
 entrypoints_to_defines[fullname] = define
 return entrypoints_to_defines
 
-doc = ET.parse(sys.stdin)
-entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
-
-# Manually add CreateDmaBufImageINTEL for which we don't have an extension
-# defined.
-entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
-'VkDevice device, ' +
-'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
-'const VkAllocationCallbacks* pAllocator,' +
-'VkDeviceMemory* pMem,' +
-'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
-
-# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
-# per entry point.
-
-if opt_header:
-print "/* This file generated from vk_gen.py, don't edit directly. */\n"
-
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
 
+def main():
+doc = ET.parse(sys.stdin)
+entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
+
+# Manually add CreateDmaBufImageINTEL for which we don't have an extension
+# defined.
+entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
+'VkDevice device, ' +
+'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
+'const VkAllocationCallbacks* pAllocator,' +
+'VkDeviceMemory* pMem,' +
+'VkImage* pImage', len(entrypoints),
+hash('vkCreateDmaBufImageINTEL'), None))
+
+# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
+# per entry point.
+
+if opt_header:
+print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
+
+print "struct anv_dispatch_table {"
+print "   union {"
+print "  void *entrypoints[%d];" % len(entrypoints)
+print "  struct {"
+
+for type, name, args, num, h, guard in entrypoints:
+if guard is not None:
+print "#ifdef {0}".format(guard)
+print " PFN_vk{0} {0};".format(name)
+print "#else"
+print " void *{0};".format(name)
+print "#endif"
+else:
+print " PFN_vk{0} {0};".format(name)
+print "  };\n"
+print "   };\n"
+print "};\n"
+
+print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
+
+for type, name, args, num, h, guard in entrypoints:
+print_guard_start(guard)
+print "%s anv_%s(%s);" % (type, name, args)
+print "%s gen7_%s(%s);" % (type, name, args)
+print "%s gen75_%s(%s);" % (type, name, args)
+print "%s gen8_%s(%s);" % (type, name, args)
+print "%s gen9_%s(%s);" % (type, name, args)
+print_guard_end(guard)
+exit()
+
+
+
+print textwrap.dedent("""\
+/*
+ * Copyright ?? 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the 
"Software"),
+ * to deal in the Software without restriction, including without 
limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The abov

[Mesa-dev] [PATCH v2 5/14] anv: split main into two functions in anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
This is groundwork for the next patches, it will allows porting the
header and the code to mako separately, and will also allow both to be
run simultaneously.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 108 -
 1 file changed, 56 insertions(+), 52 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index ea15065..772f3e6 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -130,64 +130,40 @@ def get_entrypoints_defines(doc):
 return entrypoints_to_defines
 
 
-def main():
-parser = argparse.ArgumentParser()
-parser.add_argument('target', choices=['header', 'code'],
-help='Which file to generate.')
-parser.add_argument('--xml', help='Vulkan API XML file.')
-args = parser.parse_args()
-
-doc = et.parse(args.xml)
-entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
-
-# Manually add CreateDmaBufImageINTEL for which we don't have an extension
-# defined.
-entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
-'VkDevice device, ' +
-'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
-'const VkAllocationCallbacks* pAllocator,' +
-'VkDeviceMemory* pMem,' +
-'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
+def gen_header(entrypoints):
+print "/* This file generated from vk_gen.py, don't edit directly. */\n"
 
-# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
-# per entry point.
-
-if args.target == 'header':
-print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
+print "struct anv_dispatch_table {"
+print "   union {"
+print "  void *entrypoints[%d];" % len(entrypoints)
+print "  struct {"
 
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
-
-for type, name, args, num, h, guard in entrypoints:
-if guard is not None:
-print "#ifdef {0}".format(guard)
-print " PFN_vk{0} {0};".format(name)
-print "#else"
-print " void *{0};".format(name)
-print "#endif"
-else:
-print " PFN_vk{0} {0};".format(name)
-print "  };\n"
-print "   };\n"
-print "};\n"
-
-print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
+for type, name, args, num, h, guard in entrypoints:
+if guard is not None:
+print "#ifdef {0}".format(guard)
+print " PFN_vk{0} {0};".format(name)
+print "#else"
+print " void *{0};".format(name)
+print "#endif"
+else:
+print " PFN_vk{0} {0};".format(name)
+print "  };\n"
+print "   };\n"
+print "};\n"
 
-for type, name, args, num, h, guard in entrypoints:
-print_guard_start(guard)
-print "%s anv_%s(%s);" % (type, name, args)
-print "%s gen7_%s(%s);" % (type, name, args)
-print "%s gen75_%s(%s);" % (type, name, args)
-print "%s gen8_%s(%s);" % (type, name, args)
-print "%s gen9_%s(%s);" % (type, name, args)
-print_guard_end(guard)
-exit()
+print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
 
+for type, name, args, num, h, guard in entrypoints:
+print_guard_start(guard)
+print "%s anv_%s(%s);" % (type, name, args)
+print "%s gen7_%s(%s);" % (type, name, args)
+print "%s gen75_%s(%s);" % (type, name, args)
+print "%s gen8_%s(%s);" % (type, name, args)
+print "%s gen9_%s(%s);" % (type, name, args)
+print_guard_end(guard)
 
 
+def gen_code(entrypoints):
 print textwrap.dedent("""\
 /*
  * Copyright ?? 2015 Intel Corporation
@@ -372,5 +348,33 @@ def main():
 """) % (PRIME_FACTOR, PRIME_STEP, HASH_MASK)
 
 
+def main():
+parser = argparse.ArgumentParser(

[Mesa-dev] [PATCH v2 0/14] cleanup anv_entrpoints_gen.py

2017-02-23 Thread Dylan Baker
There are a number of small style cleanups and simplifications in this series,
but the main changes are:
 - use a mako template to generate the header and code rather than prints
 - be python 3.x ready (the goal isn't to write python 3 code, but to write code
   that is easy to port or hybridize)
 - generate the header and the code in one go

I've put emphasis on the readability of the template rather than the readability
of the output code, it's relatively easy to pipe the code through 'indent' to
make it more readable.

Notable changes in Version 2:
- Pass XML file via an argument
- add flag to control output directory
- Attempt to update android makefiles

Dylan Baker (14):
  anv: anv_entrypoints_gen.py: use a main function
  anv: Use python style in anv_entrypoints_gen.py
  anv: make constants capitals in anv_entrypoints_gen.py
  anv: don't pass xmlfile via stdin anv_entrypoints_gen.py
  anv: split main into two functions in anv_entrypoints_gen.py
  anv: convert header generation in anv_entrypoints_gen.py to mako
  anv: convert C generation to template in anv_entrypoints_gen.py
  anv: generate anv_entrypoints.{h,c} in one command
  anv: anv-entrypoints_gen.py: rename hash to cal_hash.
  anv: anv_entrypoints_gen.py: use reduce function.
  anv: use dict.get in anv_entrypoints_gen.py
  anv: don't use Element.get in anv_entrypoints_gen.py
  anv: use cElementTree in anv_entrypoints_gen.py
  anv: Remove dead prototype from entrypoints

 src/intel/vulkan/Android.mk |   7 +-
 src/intel/vulkan/Makefile.am|  10 +-
 src/intel/vulkan/anv_entrypoints_gen.py | 601 -
 3 files changed, 312 insertions(+), 306 deletions(-)

base-commit: a9c488f2858f8a383dd50e557ec8a832bcb35f47
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 11/14] anv: use dict.get in anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
Instead of using an if and a check, use dict.get, which does the same
thing, but more succinctly.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index cb28050..e619ad5 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -293,10 +293,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 shortname = fullname[2:]
 params = (''.join(p.itertext()) for p in command.findall('./param'))
 params = ', '.join(params)
-if fullname in entrypoints_to_defines:
-guard = entrypoints_to_defines[fullname]
-else:
-guard = None
+guard = entrypoints_to_defines.get(fullname)
 entrypoints.append((type, shortname, params, index, 
cal_hash(fullname), guard))
 index += 1
 
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 2/14] anv: Use python style in anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
These are all fairly small cleanups/tweaks that don't really deserve
their own patch.

- Prefer comprehensions to map() and filter(), since they're faster
- replace unused variables with _
- Use 4 spaces of indent
- drop semicolons from the end of lines
- Don't use parens around if conditions
- don't put spaces around brackets
- don't import modules as caps (ET -> et)
- Use docstrings instead of comments

v2: - Replace comprehensions with multiplication

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 63 ++
 1 file changed, 34 insertions(+), 29 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 3f7a1ce..b4cead9 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -24,20 +24,20 @@
 
 import sys
 import textwrap
-import xml.etree.ElementTree as ET
+import xml.etree.ElementTree as et
 
 max_api_version = 1.0
 
 supported_extensions = [
-   'VK_KHR_get_physical_device_properties2',
-   'VK_KHR_maintenance1',
-   'VK_KHR_sampler_mirror_clamp_to_edge',
-   'VK_KHR_shader_draw_parameters',
-   'VK_KHR_surface',
-   'VK_KHR_swapchain',
-   'VK_KHR_wayland_surface',
-   'VK_KHR_xcb_surface',
-   'VK_KHR_xlib_surface',
+'VK_KHR_get_physical_device_properties2',
+'VK_KHR_maintenance1',
+'VK_KHR_sampler_mirror_clamp_to_edge',
+'VK_KHR_shader_draw_parameters',
+'VK_KHR_surface',
+'VK_KHR_swapchain',
+'VK_KHR_wayland_surface',
+'VK_KHR_xcb_surface',
+'VK_KHR_xlib_surface',
 ]
 
 # We generate a static hash table for entry point lookup
@@ -53,33 +53,37 @@ hash_mask = hash_size - 1
 prime_factor = 5024183
 prime_step = 19
 
+opt_header = False
+opt_code = False
+
+if sys.argv[1] == "header":
+opt_header = True
+sys.argv.pop()
+elif sys.argv[1] == "code":
+opt_code = True
+sys.argv.pop()
+
+
 def hash(name):
-h = 0;
+h = 0
 for c in name:
 h = (h * prime_factor + ord(c)) & u32_mask
 
 return h
 
+
 def print_guard_start(guard):
 if guard is not None:
 print "#ifdef {0}".format(guard)
 
+
 def print_guard_end(guard):
 if guard is not None:
 print "#endif // {0}".format(guard)
 
-opt_header = False
-opt_code = False
 
-if (sys.argv[1] == "header"):
-opt_header = True
-sys.argv.pop()
-elif (sys.argv[1] == "code"):
-opt_code = True
-sys.argv.pop()
-
-# Extract the entry points from the registry
 def get_entrypoints(doc, entrypoints_to_defines):
+"""Extract the entry points from the registry."""
 entrypoints = []
 
 enabled_commands = set()
@@ -108,7 +112,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 continue
 
 shortname = fullname[2:]
-params = map(lambda p: "".join(p.itertext()), 
command.findall('./param'))
+params = (''.join(p.itertext()) for p in command.findall('./param'))
 params = ', '.join(params)
 if fullname in entrypoints_to_defines:
 guard = entrypoints_to_defines[fullname]
@@ -119,8 +123,9 @@ def get_entrypoints(doc, entrypoints_to_defines):
 
 return entrypoints
 
-# Maps entry points to extension defines
+
 def get_entrypoints_defines(doc):
+"""Maps entry points to extension defines."""
 entrypoints_to_defines = {}
 extensions = doc.findall('./extensions/extension')
 for extension in extensions:
@@ -133,7 +138,7 @@ def get_entrypoints_defines(doc):
 
 
 def main():
-doc = ET.parse(sys.stdin)
+doc = et.parse(sys.stdin)
 entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
 
 # Manually add CreateDmaBufImageINTEL for which we don't have an extension
@@ -225,7 +230,7 @@ def main():
 static const char strings[] =""")
 
 offsets = []
-i = 0;
+i = 0
 for type, name, args, num, h, guard in entrypoints:
 print "   \"vk%s\\0\"" % name
 offsets.append(i)
@@ -247,7 +252,7 @@ def main():
  */
 """)
 
-for layer in [ "anv", "gen7", "gen75", "gen8", "gen9" ]:
+for layer in ["anv", "gen7", "gen75", "gen8", "gen9"]:
 for type, name, args, num, h, guard in entrypoints:
 print_guard_start(guard)
 print "%s %s_%s(%s) __attribute__ ((weak));" % (type, layer, name, 
args)
@@ -295,8 +300,8 @@ def main():
 # uint16_t table of entry point indices. We use 0x to indicate an entry
 #

[Mesa-dev] [PATCH v2 14/14] anv: Remove dead prototype from entrypoints

2017-02-23 Thread Dylan Baker
Spotted by Emil.

v2: - Add this patch

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index b498176..44b6d2c 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -71,7 +71,6 @@ TEMPLATE_H = Template(textwrap.dedent("""\
};
 };
 
-void anv_set_dispatch_devinfo(const struct gen_device_info *info);
 % for type_, name, args, num, h, guard in entrypoints:
   % if guard is not None:
 #ifdef ${guard}
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 9/14] anv: anv-entrypoints_gen.py: rename hash to cal_hash.

2017-02-23 Thread Dylan Baker
hash is reserved name in python, it's the interface to access an
object's hash protocol.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 5066195..7386b1d 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -254,7 +254,8 @@ PRIME_FACTOR = 5024183
 PRIME_STEP = 19
 
 
-def hash(name):
+def cal_hash(name):
+"""Calculate the same hash value that Mesa will calculate in C."""
 h = 0
 for c in name:
 h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
@@ -298,7 +299,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 guard = entrypoints_to_defines[fullname]
 else:
 guard = None
-entrypoints.append((type, shortname, params, index, hash(fullname), 
guard))
+entrypoints.append((type, shortname, params, index, 
cal_hash(fullname), guard))
 index += 1
 
 return entrypoints
@@ -367,7 +368,7 @@ def main():
 'const VkAllocationCallbacks* pAllocator,' +
 'VkDeviceMemory* pMem,' +
 'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
+cal_hash('vkCreateDmaBufImageINTEL'), None))
 
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 6/14] anv: convert header generation in anv_entrypoints_gen.py to mako

2017-02-23 Thread Dylan Baker
This produces an identical file except for whitespace.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 75 ++
 1 file changed, 41 insertions(+), 34 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 772f3e6..7493fb6 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -26,6 +26,8 @@ import argparse
 import textwrap
 import xml.etree.ElementTree as et
 
+from mako.template import Template
+
 MAX_API_VERSION = 1.0
 
 SUPPORTED_EXTENSIONS = [
@@ -45,6 +47,44 @@ SUPPORTED_EXTENSIONS = [
 # function and a power-of-two size table. The prime numbers are determined
 # experimentally.
 
+TEMPLATE_H = Template(textwrap.dedent("""\
+/* This file generated from vk_gen.py, don't edit directly. */
+
+struct anv_dispatch_table {
+   union {
+  void *entrypoints[${len(entrypoints)}];
+  struct {
+  % for _, name, _, _, _, guard in entrypoints:
+% if guard is not None:
+#ifdef ${guard}
+  PFN_vk${name} ${name};
+#else
+  void *${name};
+# endif
+% else:
+  PFN_vk${name} ${name};
+% endif
+  % endfor
+  };
+   };
+};
+
+void anv_set_dispatch_devinfo(const struct gen_device_info *info);
+% for type_, name, args, num, h, guard in entrypoints:
+  % if guard is not None:
+#ifdef ${guard}
+  % endif
+  ${type_} anv_${name}(${args});
+  ${type_} gen7_${name}(${args});
+  ${type_} gen75_${name}(${args});
+  ${type_} gen8_${name}(${args});
+  ${type_} gen9_${name}(${args});
+  % if guard is not None:
+#endif // ${guard}
+  % endif
+% endfor
+"""))
+
 NONE = 0x
 HASH_SIZE = 256
 U32_MASK = 2**32 - 1
@@ -130,39 +170,6 @@ def get_entrypoints_defines(doc):
 return entrypoints_to_defines
 
 
-def gen_header(entrypoints):
-print "/* This file generated from vk_gen.py, don't edit directly. */\n"
-
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
-
-for type, name, args, num, h, guard in entrypoints:
-if guard is not None:
-print "#ifdef {0}".format(guard)
-print " PFN_vk{0} {0};".format(name)
-print "#else"
-print " void *{0};".format(name)
-print "#endif"
-else:
-print " PFN_vk{0} {0};".format(name)
-print "  };\n"
-print "   };\n"
-print "};\n"
-
-print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
-
-for type, name, args, num, h, guard in entrypoints:
-print_guard_start(guard)
-print "%s anv_%s(%s);" % (type, name, args)
-print "%s gen7_%s(%s);" % (type, name, args)
-print "%s gen75_%s(%s);" % (type, name, args)
-print "%s gen8_%s(%s);" % (type, name, args)
-print "%s gen9_%s(%s);" % (type, name, args)
-print_guard_end(guard)
-
-
 def gen_code(entrypoints):
 print textwrap.dedent("""\
 /*
@@ -371,7 +378,7 @@ def main():
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
 if args.target == 'header':
-gen_header(entrypoints)
+print TEMPLATE_H.render(entrypoints=entrypoints)
 else:
 gen_code(entrypoints)
 
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 7/14] anv: convert C generation to template in anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
This produces a file that is identical except for whitespace, there is a
table that has 8 columns in the original and is easy to do with prints,
but is ugly using mako, so it doesn't have columns; the data is not
inherently tabular.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 333 -
 1 file changed, 163 insertions(+), 170 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 7493fb6..45a463c 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -85,93 +85,7 @@ TEMPLATE_H = Template(textwrap.dedent("""\
 % endfor
 """))
 
-NONE = 0x
-HASH_SIZE = 256
-U32_MASK = 2**32 - 1
-HASH_MASK = HASH_SIZE - 1
-
-PRIME_FACTOR = 5024183
-PRIME_STEP = 19
-
-opt_header = False
-opt_code = False
-
-
-def hash(name):
-h = 0
-for c in name:
-h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
-
-return h
-
-
-def print_guard_start(guard):
-if guard is not None:
-print "#ifdef {0}".format(guard)
-
-
-def print_guard_end(guard):
-if guard is not None:
-print "#endif // {0}".format(guard)
-
-
-def get_entrypoints(doc, entrypoints_to_defines):
-"""Extract the entry points from the registry."""
-entrypoints = []
-
-enabled_commands = set()
-for feature in doc.findall('./feature'):
-assert feature.attrib['api'] == 'vulkan'
-if float(feature.attrib['number']) > MAX_API_VERSION:
-continue
-
-for command in feature.findall('./require/command'):
-enabled_commands.add(command.attrib['name'])
-
-for extension in doc.findall('.extensions/extension'):
-if extension.attrib['name'] not in SUPPORTED_EXTENSIONS:
-continue
-
-assert extension.attrib['supported'] == 'vulkan'
-for command in extension.findall('./require/command'):
-enabled_commands.add(command.attrib['name'])
-
-index = 0
-for command in doc.findall('./commands/command'):
-type = command.find('./proto/type').text
-fullname = command.find('./proto/name').text
-
-if fullname not in enabled_commands:
-continue
-
-shortname = fullname[2:]
-params = (''.join(p.itertext()) for p in command.findall('./param'))
-params = ', '.join(params)
-if fullname in entrypoints_to_defines:
-guard = entrypoints_to_defines[fullname]
-else:
-guard = None
-entrypoints.append((type, shortname, params, index, hash(fullname), 
guard))
-index += 1
-
-return entrypoints
-
-
-def get_entrypoints_defines(doc):
-"""Maps entry points to extension defines."""
-entrypoints_to_defines = {}
-extensions = doc.findall('./extensions/extension')
-for extension in extensions:
-define = extension.get('protect')
-entrypoints = extension.findall('./require/command')
-for entrypoint in entrypoints:
-fullname = entrypoint.get('name')
-entrypoints_to_defines[fullname] = define
-return entrypoints_to_defines
-
-
-def gen_code(entrypoints):
-print textwrap.dedent("""\
+TEMPLATE_C = Template(textwrap.dedent(u"""\
 /*
  * Copyright ?? 2015 Intel Corporation
  *
@@ -209,44 +123,47 @@ def gen_code(entrypoints):
  * store the index into this big string.
  */
 
-static const char strings[] =""")
-
-offsets = []
-i = 0
-for type, name, args, num, h, guard in entrypoints:
-print "   \"vk%s\\0\"" % name
-offsets.append(i)
-i += 2 + len(name) + 1
-print "   ;"
-
-# Now generate the table of all entry points
-
-print "\nstatic const struct anv_entrypoint entrypoints[] = {"
-for type, name, args, num, h, guard in entrypoints:
-print "   { %5d, 0x%08x }," % (offsets[num], h)
-print "};\n"
+static const char strings[] =
+% for _, name, _, _, _, _ in entrypoints:
+"vk${name}\\0"
+% endfor
+;
 
-print textwrap.dedent("""
+static const struct anv_entrypoint entrypoints[] = {
+% for _, _, _, num, h, _ in entrypoints:
+{ ${offsets[num]}, ${'{:0=#8x}'.format(h)} },
+% endfor
+};
 
 /* Weak aliases for all potential implementations. These will resolve to
  * NULL if they're not defined, which lets the resolve_entrypoint() 
function
  * either pick the correct entry point.
  */
-"""

[Mesa-dev] [PATCH v2 13/14] anv: use cElementTree in anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
It's written in C rather than pure python and is strictly faster, the
only reason not to use it that it's classes cannot be subclassed.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 7018262..b498176 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -26,7 +26,7 @@ import argparse
 import functools
 import os
 import textwrap
-import xml.etree.ElementTree as et
+import xml.etree.cElementTree as et
 
 from mako.template import Template
 
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 8/14] anv: generate anv_entrypoints.{h, c} in one command

2017-02-23 Thread Dylan Baker
This changes the python generator to write the files itself, rather than
piping them out. This has a couple of advantages: first, it encapsulates
the encoding. Second, it ensures that the header file and code file are
generated at the same time with the same data.

v2: - Update Android.mk

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/Android.mk |  7 +-
 src/intel/vulkan/Makefile.am|  8 ++
 src/intel/vulkan/anv_entrypoints_gen.py | 33 +-
 3 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/src/intel/vulkan/Android.mk b/src/intel/vulkan/Android.mk
index 9dabf1c..df10141 100644
--- a/src/intel/vulkan/Android.mk
+++ b/src/intel/vulkan/Android.mk
@@ -60,8 +60,8 @@ $(intermediates)/dummy.c:
@echo "Gen Dummy: $(PRIVATE_MODULE) <= $(notdir $(@))"
$(hide) touch $@
 
-$(intermediates)/anv_entrypoints.h:
-   $(VK_ENTRYPOINTS_SCRIPT) header --xml 
$(MESA_TOP)/src/vulkan/registry/vk.xml > $@
+$(intermediates)/anv_entrypoints.h $(intermediates)/anv_entrypoints.c:
+   $(VK_ENTRYPOINTS_SCRIPT) --xml $(MESA_TOP)/src/vulkan/registry/vk.xml
 
 LOCAL_EXPORT_C_INCLUDE_DIRS := \
 $(intermediates)
@@ -176,9 +176,6 @@ LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_anv_entrypoints 
libmesa_genxml
 
 LOCAL_GENERATED_SOURCES += $(intermediates)/anv_entrypoints.c
 
-$(intermediates)/anv_entrypoints.c:
-   $(VK_ENTRYPOINTS_SCRIPT) code --xml 
$(MESA_TOP)/src/vulkan/registry/vk.xml > $@
-
 LOCAL_SHARED_LIBRARIES := libdrm_intel
 
 include $(MESA_COMMON_MK)
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 565559c..38a50c9 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -145,11 +145,9 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
 
 vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 
-anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header --xml 
$(vulkan_api_xml) > $@
-
-anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code --xml 
$(vulkan_api_xml) > $@
+anv_entrypoints.h anv_entrypoints.c: anv_entrypoints_gen.py $(vulkan_api_xml)
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py \
+   --xml $(vulkan_api_xml) --outdir $(builddir)
 
 BUILT_SOURCES = $(VULKAN_GENERATED_FILES)
 CLEANFILES = $(BUILT_SOURCES) dev_icd.json intel_icd.@host_cpu@.json
diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 45a463c..5066195 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -23,6 +23,7 @@
 #
 
 import argparse
+import os
 import textwrap
 import xml.etree.ElementTree as et
 
@@ -83,7 +84,7 @@ TEMPLATE_H = Template(textwrap.dedent("""\
 #endif // ${guard}
   % endif
 % endfor
-"""))
+"""), output_encoding='utf-8')
 
 TEMPLATE_C = Template(textwrap.dedent(u"""\
 /*
@@ -337,22 +338,22 @@ def gen_code(entrypoints):
 collisions[level] += 1
 mapping[h & HASH_MASK] = num
 
-print TEMPLATE_C.render(entrypoints=entrypoints,
-offsets=offsets,
-collisions=collisions,
-mapping=mapping,
-hash_mask=HASH_MASK,
-prime_step=PRIME_STEP,
-prime_factor=PRIME_FACTOR,
-none=NONE,
-hash_size=HASH_SIZE)
+return TEMPLATE_C.render(entrypoints=entrypoints,
+ offsets=offsets,
+ collisions=collisions,
+ mapping=mapping,
+ hash_mask=HASH_MASK,
+ prime_step=PRIME_STEP,
+ prime_factor=PRIME_FACTOR,
+ none=NONE,
+ hash_size=HASH_SIZE)
 
 
 def main():
 parser = argparse.ArgumentParser()
-parser.add_argument('target', choices=['header', 'code'],
-help='Which file to generate.')
 parser.add_argument('--xml', help='Vulkan API XML file.')
+parser.add_argument('--outdir',
+help='Directory to put the generated files in')
 args = parser.parse_args()
 
 doc = et.parse(args.xml)
@@ -370,10 +371,10 @@ def main():
 
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
-if args.target == 'header':
-print TEMPLATE_H.render(entrypoints=entrypoints)
-else:
-gen_code(entrypoints)
+with open(os.path.join(args.outdir, '

[Mesa-dev] [PATCH v2 10/14] anv: anv_entrypoints_gen.py: use reduce function.

2017-02-23 Thread Dylan Baker
Reduce is it's own reward.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 7386b1d..cb28050 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -23,6 +23,7 @@
 #
 
 import argparse
+import functools
 import os
 import textwrap
 import xml.etree.ElementTree as et
@@ -256,11 +257,8 @@ PRIME_STEP = 19
 
 def cal_hash(name):
 """Calculate the same hash value that Mesa will calculate in C."""
-h = 0
-for c in name:
-h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
-
-return h
+return functools.reduce(
+lambda h, c: (h * PRIME_FACTOR + ord(c)) & U32_MASK, name, 0)
 
 
 def get_entrypoints(doc, entrypoints_to_defines):
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 12/14] anv: don't use Element.get in anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
This has the potential to mask errors, since Element.get works like
dict.get, returning None if the element isn't found. I think the reason
that Element.get was used is that vulkan has one extension that isn't
really an extension, and thus is missing the 'protect' field.

This patch changes the behavior slightly by replacing get with explicit
lookup in the Element.attrib dictionary, and using xpath to only iterate
over extensions with a "protect" attribute.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index e619ad5..7018262 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -303,13 +303,14 @@ def get_entrypoints(doc, entrypoints_to_defines):
 def get_entrypoints_defines(doc):
 """Maps entry points to extension defines."""
 entrypoints_to_defines = {}
-extensions = doc.findall('./extensions/extension')
-for extension in extensions:
-define = extension.get('protect')
-entrypoints = extension.findall('./require/command')
-for entrypoint in entrypoints:
-fullname = entrypoint.get('name')
+
+for extension in doc.findall('./extensions/extension[@protect]'):
+define = extension.attrib['protect']
+
+for entrypoint in extension.findall('./require/command'):
+fullname = entrypoint.attrib['name']
 entrypoints_to_defines[fullname] = define
+
 return entrypoints_to_defines
 
 
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 6/14] anv: convert header generation in anv_entrypoints_gen.py to mako

2017-02-24 Thread Dylan Baker
Quoting Emil Velikov (2017-02-24 05:57:24)
> On 24 February 2017 at 10:28, Eric Engestrom  
> wrote:
> > On Thursday, 2017-02-23 10:46:19 -0800, Dylan Baker wrote:
> >> This produces an identical file except for whitespace.
> >>
> >> Signed-off-by: Dylan Baker 
> >> ---
> >>  src/intel/vulkan/anv_entrypoints_gen.py | 75 ++
> >>  1 file changed, 41 insertions(+), 34 deletions(-)
> >>
> >> diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
> >> b/src/intel/vulkan/anv_entrypoints_gen.py
> >> index 772f3e6..7493fb6 100644
> >> --- a/src/intel/vulkan/anv_entrypoints_gen.py
> >> +++ b/src/intel/vulkan/anv_entrypoints_gen.py
> >> @@ -26,6 +26,8 @@ import argparse
> >>  import textwrap
> >>  import xml.etree.ElementTree as et
> >>
> >> +from mako.template import Template
> >> +
> >>  MAX_API_VERSION = 1.0
> >>
> >>  SUPPORTED_EXTENSIONS = [
> >> @@ -45,6 +47,44 @@ SUPPORTED_EXTENSIONS = [
> >>  # function and a power-of-two size table. The prime numbers are determined
> >>  # experimentally.
> >>
> >> +TEMPLATE_H = Template(textwrap.dedent("""\
> >> +/* This file generated from vk_gen.py, don't edit directly. */
> >
> > s/vk_gen.py/anv_entrypoints_gen.py/ :)
> >
> This seems to be rather common across projects. Just an idea -
> sys.argv[0] should work right ?

actually, python has a __file__ constant that I usually use for this. I'll add a
patch.

> 
> IMHO, feel free to address that whenever you prefer.
> Emil


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


[Mesa-dev] [PATCH v3 02/15] anv: Use python style in anv_entrypoints_gen.py

2017-02-24 Thread Dylan Baker
These are all fairly small cleanups/tweaks that don't really deserve
their own patch.

- Prefer comprehensions to map() and filter(), since they're faster
- replace unused variables with _
- Use 4 spaces of indent
- drop semicolons from the end of lines
- Don't use parens around if conditions
- don't put spaces around brackets
- don't import modules as caps (ET -> et)
- Use docstrings instead of comments

v2: - Replace comprehensions with multiplication

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 63 ++
 1 file changed, 34 insertions(+), 29 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 3f7a1ce..b4cead9 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -24,20 +24,20 @@
 
 import sys
 import textwrap
-import xml.etree.ElementTree as ET
+import xml.etree.ElementTree as et
 
 max_api_version = 1.0
 
 supported_extensions = [
-   'VK_KHR_get_physical_device_properties2',
-   'VK_KHR_maintenance1',
-   'VK_KHR_sampler_mirror_clamp_to_edge',
-   'VK_KHR_shader_draw_parameters',
-   'VK_KHR_surface',
-   'VK_KHR_swapchain',
-   'VK_KHR_wayland_surface',
-   'VK_KHR_xcb_surface',
-   'VK_KHR_xlib_surface',
+'VK_KHR_get_physical_device_properties2',
+'VK_KHR_maintenance1',
+'VK_KHR_sampler_mirror_clamp_to_edge',
+'VK_KHR_shader_draw_parameters',
+'VK_KHR_surface',
+'VK_KHR_swapchain',
+'VK_KHR_wayland_surface',
+'VK_KHR_xcb_surface',
+'VK_KHR_xlib_surface',
 ]
 
 # We generate a static hash table for entry point lookup
@@ -53,33 +53,37 @@ hash_mask = hash_size - 1
 prime_factor = 5024183
 prime_step = 19
 
+opt_header = False
+opt_code = False
+
+if sys.argv[1] == "header":
+opt_header = True
+sys.argv.pop()
+elif sys.argv[1] == "code":
+opt_code = True
+sys.argv.pop()
+
+
 def hash(name):
-h = 0;
+h = 0
 for c in name:
 h = (h * prime_factor + ord(c)) & u32_mask
 
 return h
 
+
 def print_guard_start(guard):
 if guard is not None:
 print "#ifdef {0}".format(guard)
 
+
 def print_guard_end(guard):
 if guard is not None:
 print "#endif // {0}".format(guard)
 
-opt_header = False
-opt_code = False
 
-if (sys.argv[1] == "header"):
-opt_header = True
-sys.argv.pop()
-elif (sys.argv[1] == "code"):
-opt_code = True
-sys.argv.pop()
-
-# Extract the entry points from the registry
 def get_entrypoints(doc, entrypoints_to_defines):
+"""Extract the entry points from the registry."""
 entrypoints = []
 
 enabled_commands = set()
@@ -108,7 +112,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 continue
 
 shortname = fullname[2:]
-params = map(lambda p: "".join(p.itertext()), 
command.findall('./param'))
+params = (''.join(p.itertext()) for p in command.findall('./param'))
 params = ', '.join(params)
 if fullname in entrypoints_to_defines:
 guard = entrypoints_to_defines[fullname]
@@ -119,8 +123,9 @@ def get_entrypoints(doc, entrypoints_to_defines):
 
 return entrypoints
 
-# Maps entry points to extension defines
+
 def get_entrypoints_defines(doc):
+"""Maps entry points to extension defines."""
 entrypoints_to_defines = {}
 extensions = doc.findall('./extensions/extension')
 for extension in extensions:
@@ -133,7 +138,7 @@ def get_entrypoints_defines(doc):
 
 
 def main():
-doc = ET.parse(sys.stdin)
+doc = et.parse(sys.stdin)
 entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
 
 # Manually add CreateDmaBufImageINTEL for which we don't have an extension
@@ -225,7 +230,7 @@ def main():
 static const char strings[] =""")
 
 offsets = []
-i = 0;
+i = 0
 for type, name, args, num, h, guard in entrypoints:
 print "   \"vk%s\\0\"" % name
 offsets.append(i)
@@ -247,7 +252,7 @@ def main():
  */
 """)
 
-for layer in [ "anv", "gen7", "gen75", "gen8", "gen9" ]:
+for layer in ["anv", "gen7", "gen75", "gen8", "gen9"]:
 for type, name, args, num, h, guard in entrypoints:
 print_guard_start(guard)
 print "%s %s_%s(%s) __attribute__ ((weak));" % (type, layer, name, 
args)
@@ -295,8 +300,8 @@ def main():
 # uint16_t table of entry point indices. We use 0x to indicate an entry
 #

[Mesa-dev] [PATCH v3 04/15] anv: don't pass xmlfile via stdin anv_entrypoints_gen.py

2017-02-24 Thread Dylan Baker
It's slow, and has the potential for encoding issues.

v2: - pass xml file location via argument
- update Android.mk

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/Android.mk |  4 ++--
 src/intel/vulkan/Makefile.am|  6 ++
 src/intel/vulkan/anv_entrypoints_gen.py | 19 +--
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/intel/vulkan/Android.mk b/src/intel/vulkan/Android.mk
index 1e53970..9dabf1c 100644
--- a/src/intel/vulkan/Android.mk
+++ b/src/intel/vulkan/Android.mk
@@ -61,7 +61,7 @@ $(intermediates)/dummy.c:
$(hide) touch $@
 
 $(intermediates)/anv_entrypoints.h:
-   $(hide) cat $(MESA_TOP)/src/vulkan/registry/vk.xml | 
$(VK_ENTRYPOINTS_SCRIPT) header > $@
+   $(VK_ENTRYPOINTS_SCRIPT) header --xml 
$(MESA_TOP)/src/vulkan/registry/vk.xml > $@
 
 LOCAL_EXPORT_C_INCLUDE_DIRS := \
 $(intermediates)
@@ -177,7 +177,7 @@ LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_anv_entrypoints 
libmesa_genxml
 LOCAL_GENERATED_SOURCES += $(intermediates)/anv_entrypoints.c
 
 $(intermediates)/anv_entrypoints.c:
-   $(hide) cat $(MESA_TOP)/src/vulkan/registry/vk.xml | 
$(VK_ENTRYPOINTS_SCRIPT) code > $@
+   $(VK_ENTRYPOINTS_SCRIPT) code --xml 
$(MESA_TOP)/src/vulkan/registry/vk.xml > $@
 
 LOCAL_SHARED_LIBRARIES := libdrm_intel
 
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 449188f..565559c 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -146,12 +146,10 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
 vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 
 anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN) cat $(vulkan_api_xml) |\
-   $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header --xml 
$(vulkan_api_xml) > $@
 
 anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN) cat $(vulkan_api_xml) |\
-   $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code --xml 
$(vulkan_api_xml) > $@
 
 BUILT_SOURCES = $(VULKAN_GENERATED_FILES)
 CLEANFILES = $(BUILT_SOURCES) dev_icd.json intel_icd.@host_cpu@.json
diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index d3f028e..ea15065 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -22,7 +22,7 @@
 # IN THE SOFTWARE.
 #
 
-import sys
+import argparse
 import textwrap
 import xml.etree.ElementTree as et
 
@@ -56,13 +56,6 @@ PRIME_STEP = 19
 opt_header = False
 opt_code = False
 
-if sys.argv[1] == "header":
-opt_header = True
-sys.argv.pop()
-elif sys.argv[1] == "code":
-opt_code = True
-sys.argv.pop()
-
 
 def hash(name):
 h = 0
@@ -138,7 +131,13 @@ def get_entrypoints_defines(doc):
 
 
 def main():
-doc = et.parse(sys.stdin)
+parser = argparse.ArgumentParser()
+parser.add_argument('target', choices=['header', 'code'],
+help='Which file to generate.')
+parser.add_argument('--xml', help='Vulkan API XML file.')
+args = parser.parse_args()
+
+doc = et.parse(args.xml)
 entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
 
 # Manually add CreateDmaBufImageINTEL for which we don't have an extension
@@ -154,7 +153,7 @@ def main():
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
 
-if opt_header:
+if args.target == 'header':
 print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
 
 print "struct anv_dispatch_table {"
-- 
git-series 0.9.1
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 03/15] anv: make constants capitals in anv_entrypoints_gen.py

2017-02-24 Thread Dylan Baker
Again, it's standard python style.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 38 +-
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index b4cead9..d3f028e 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -26,9 +26,9 @@ import sys
 import textwrap
 import xml.etree.ElementTree as et
 
-max_api_version = 1.0
+MAX_API_VERSION = 1.0
 
-supported_extensions = [
+SUPPORTED_EXTENSIONS = [
 'VK_KHR_get_physical_device_properties2',
 'VK_KHR_maintenance1',
 'VK_KHR_sampler_mirror_clamp_to_edge',
@@ -45,13 +45,13 @@ supported_extensions = [
 # function and a power-of-two size table. The prime numbers are determined
 # experimentally.
 
-none = 0x
-hash_size = 256
-u32_mask = 2**32 - 1
-hash_mask = hash_size - 1
+NONE = 0x
+HASH_SIZE = 256
+U32_MASK = 2**32 - 1
+HASH_MASK = HASH_SIZE - 1
 
-prime_factor = 5024183
-prime_step = 19
+PRIME_FACTOR = 5024183
+PRIME_STEP = 19
 
 opt_header = False
 opt_code = False
@@ -67,7 +67,7 @@ elif sys.argv[1] == "code":
 def hash(name):
 h = 0
 for c in name:
-h = (h * prime_factor + ord(c)) & u32_mask
+h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
 
 return h
 
@@ -89,14 +89,14 @@ def get_entrypoints(doc, entrypoints_to_defines):
 enabled_commands = set()
 for feature in doc.findall('./feature'):
 assert feature.attrib['api'] == 'vulkan'
-if float(feature.attrib['number']) > max_api_version:
+if float(feature.attrib['number']) > MAX_API_VERSION:
 continue
 
 for command in feature.findall('./require/command'):
 enabled_commands.add(command.attrib['name'])
 
 for extension in doc.findall('.extensions/extension'):
-if extension.attrib['name'] not in supported_extensions:
+if extension.attrib['name'] not in SUPPORTED_EXTENSIONS:
 continue
 
 assert extension.attrib['supported'] == 'vulkan'
@@ -300,21 +300,21 @@ def main():
 # uint16_t table of entry point indices. We use 0x to indicate an entry
 # in the hash table is empty.
 
-map = [none] * hash_size
+map = [NONE] * HASH_SIZE
 collisions = [0] * 10
 for type, name, args, num, h, guard in entrypoints:
 level = 0
-while map[h & hash_mask] != none:
-h = h + prime_step
+while map[h & HASH_MASK] != NONE:
+h = h + PRIME_STEP
 level = level + 1
 if level > 9:
 collisions[9] += 1
 else:
 collisions[level] += 1
-map[h & hash_mask] = num
+map[h & HASH_MASK] = num
 
 print "/* Hash table stats:"
-print " * size %d entries" % hash_size
+print " * size %d entries" % HASH_SIZE
 print " * collisions  entries"
 for i in xrange(10):
 if i == 9:
@@ -325,10 +325,10 @@ def main():
 print " * %2d%s %4d" % (i, plus, collisions[i])
 print " */\n"
 
-print "#define none 0x%04x\n" % none
+print "#define none 0x%04x\n" % NONE
 
 print "static const uint16_t map[] = {"
-for i in xrange(0, hash_size, 8):
+for i in xrange(0, HASH_SIZE, 8):
 print "   ",
 for j in xrange(i, i + 8):
 if map[j] & 0x == 0x:
@@ -370,7 +370,7 @@ def main():
 
return anv_resolve_entrypoint(devinfo, i);
 }
-""") % (prime_factor, prime_step, hash_mask)
+""") % (PRIME_FACTOR, PRIME_STEP, HASH_MASK)
 
 
 if __name__ == '__main__':
-- 
git-series 0.9.1
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 15/15] anv: Remove dead prototype from entrypoints

2017-02-24 Thread Dylan Baker
Spotted by Emil.

v2: - Add this patch

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 72d8c17..ecdff13 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -71,7 +71,6 @@ TEMPLATE_H = Template(textwrap.dedent("""\
};
 };
 
-void anv_set_dispatch_devinfo(const struct gen_device_info *info);
 % for type_, name, args, num, h, guard in entrypoints:
   % if guard is not None:
 #ifdef ${guard}
-- 
git-series 0.9.1
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 01/15] anv: anv_entrypoints_gen.py: use a main function

2017-02-24 Thread Dylan Baker
This is just good practice.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 458 -
 1 file changed, 233 insertions(+), 225 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 93511ec..3f7a1ce 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -1,6 +1,6 @@
 # coding=utf-8
 #
-# Copyright ?? 2015 Intel Corporation
+# Copyright ?? 2015, 2017 Intel Corporation
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -23,6 +23,7 @@
 #
 
 import sys
+import textwrap
 import xml.etree.ElementTree as ET
 
 max_api_version = 1.0
@@ -130,235 +131,242 @@ def get_entrypoints_defines(doc):
 entrypoints_to_defines[fullname] = define
 return entrypoints_to_defines
 
-doc = ET.parse(sys.stdin)
-entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
-
-# Manually add CreateDmaBufImageINTEL for which we don't have an extension
-# defined.
-entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
-'VkDevice device, ' +
-'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
-'const VkAllocationCallbacks* pAllocator,' +
-'VkDeviceMemory* pMem,' +
-'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
-
-# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
-# per entry point.
-
-if opt_header:
-print "/* This file generated from vk_gen.py, don't edit directly. */\n"
-
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
 
+def main():
+doc = ET.parse(sys.stdin)
+entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
+
+# Manually add CreateDmaBufImageINTEL for which we don't have an extension
+# defined.
+entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
+'VkDevice device, ' +
+'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
+'const VkAllocationCallbacks* pAllocator,' +
+'VkDeviceMemory* pMem,' +
+'VkImage* pImage', len(entrypoints),
+hash('vkCreateDmaBufImageINTEL'), None))
+
+# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
+# per entry point.
+
+if opt_header:
+print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
+
+print "struct anv_dispatch_table {"
+print "   union {"
+print "  void *entrypoints[%d];" % len(entrypoints)
+print "  struct {"
+
+for type, name, args, num, h, guard in entrypoints:
+if guard is not None:
+print "#ifdef {0}".format(guard)
+print " PFN_vk{0} {0};".format(name)
+print "#else"
+print " void *{0};".format(name)
+print "#endif"
+else:
+print " PFN_vk{0} {0};".format(name)
+print "  };\n"
+print "   };\n"
+print "};\n"
+
+print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
+
+for type, name, args, num, h, guard in entrypoints:
+print_guard_start(guard)
+print "%s anv_%s(%s);" % (type, name, args)
+print "%s gen7_%s(%s);" % (type, name, args)
+print "%s gen75_%s(%s);" % (type, name, args)
+print "%s gen8_%s(%s);" % (type, name, args)
+print "%s gen9_%s(%s);" % (type, name, args)
+print_guard_end(guard)
+exit()
+
+
+
+print textwrap.dedent("""\
+/*
+ * Copyright ?? 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the 
"Software"),
+ * to deal in the Software without restriction, including without 
limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The abov

[Mesa-dev] [PATCH v3 09/15] anv: anv_entrypoints_gen.py: directly write files instead of piping

2017-02-24 Thread Dylan Baker
This changes the output to be written as a file rather than being piped.
This had one critical advantage, it encapsulates the encoding. This
prevents bugs where a symbol (generally unicode like ?? [copyright]) is
printed and the system being built on doesn't have a unicode locale.

v2: - Update Android.mk
v3: - Don't generate both files at once
- Fix Android.mk
- drop --outdir, since the filename is passed in as an argument

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/Android.mk |  5 ++--
 src/intel/vulkan/Makefile.am| 10 
 src/intel/vulkan/anv_entrypoints_gen.py | 31 ++
 3 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/src/intel/vulkan/Android.mk b/src/intel/vulkan/Android.mk
index 9dabf1c..13b4846 100644
--- a/src/intel/vulkan/Android.mk
+++ b/src/intel/vulkan/Android.mk
@@ -61,7 +61,8 @@ $(intermediates)/dummy.c:
$(hide) touch $@
 
 $(intermediates)/anv_entrypoints.h:
-   $(VK_ENTRYPOINTS_SCRIPT) header --xml 
$(MESA_TOP)/src/vulkan/registry/vk.xml > $@
+   $(VK_ENTRYPOINTS_SCRIPT) header $@ --xml 
$(MESA_TOP)/src/vulkan/registry/vk.xml
+
 
 LOCAL_EXPORT_C_INCLUDE_DIRS := \
 $(intermediates)
@@ -177,7 +178,7 @@ LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_anv_entrypoints 
libmesa_genxml
 LOCAL_GENERATED_SOURCES += $(intermediates)/anv_entrypoints.c
 
 $(intermediates)/anv_entrypoints.c:
-   $(VK_ENTRYPOINTS_SCRIPT) code --xml 
$(MESA_TOP)/src/vulkan/registry/vk.xml > $@
+   $(VK_ENTRYPOINTS_SCRIPT) code $@ --xml 
$(MESA_TOP)/src/vulkan/registry/vk.xml
 
 LOCAL_SHARED_LIBRARIES := libdrm_intel
 
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 565559c..f3ae4a0 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -145,11 +145,13 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
 
 vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 
-anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header --xml 
$(vulkan_api_xml) > $@
+anv_entrypoints.h: anv_entrypoints_gen.py $(vulkan_api_xml)
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py \
+   --xml $(vulkan_api_xml) header $@
 
-anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code --xml 
$(vulkan_api_xml) > $@
+anv_entrypoints.c: anv_entrypoints_gen.py $(vulkan_api_xml)
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py \
+   --xml $(vulkan_api_xml) code $@
 
 BUILT_SOURCES = $(VULKAN_GENERATED_FILES)
 CLEANFILES = $(BUILT_SOURCES) dev_icd.json intel_icd.@host_cpu@.json
diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index e4bf002..156a14f 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -84,7 +84,7 @@ TEMPLATE_H = Template(textwrap.dedent("""\
 #endif // ${guard}
   % endif
 % endfor
-"""))
+"""), output_encoding='utf-8')
 
 TEMPLATE_C = Template(textwrap.dedent(u"""\
 /*
@@ -338,22 +338,23 @@ def gen_code(entrypoints):
 collisions[level] += 1
 mapping[h & HASH_MASK] = num
 
-print TEMPLATE_C.render(entrypoints=entrypoints,
-offsets=offsets,
-collisions=collisions,
-mapping=mapping,
-hash_mask=HASH_MASK,
-prime_step=PRIME_STEP,
-prime_factor=PRIME_FACTOR,
-none=NONE,
-hash_size=HASH_SIZE,
-filename=os.path.basename(__file__))
+return TEMPLATE_C.render(entrypoints=entrypoints,
+ offsets=offsets,
+ collisions=collisions,
+ mapping=mapping,
+ hash_mask=HASH_MASK,
+ prime_step=PRIME_STEP,
+ prime_factor=PRIME_FACTOR,
+ none=NONE,
+ hash_size=HASH_SIZE,
+ filename=os.path.basename(__file__))
 
 
 def main():
 parser = argparse.ArgumentParser()
 parser.add_argument('target', choices=['header', 'code'],
 help='Which file to generate.')
+parser.add_argument('file', help='Where to write the file.')
 parser.add_argument('--xml', help='Vulkan API XML file.')
 args = parser.parse_args()
 
@@ -373,10 +374,12 @@ def main():
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
 if args.targe

[Mesa-dev] [PATCH v3 00/15] cleanup anv_entrpoints_gen.py

2017-02-24 Thread Dylan Baker
There are a number of small style cleanups and simplifications in this series,
but the main changes are:
 - use a mako template to generate the header and code rather than prints
 - be python 3.x ready (the goal isn't to write python 3 code, but to write code
   that is easy to port or hybridize)
 - generate the header and the code in one go

I've put emphasis on the readability of the template rather than the readability
of the output code, it's relatively easy to pipe the code through 'indent' to
make it more readable.

Notable changes in Version 2:
- Pass XML file via an argument
- add flag to control output directory
- Attempt to update android makefiles

Notable changes in Version 3:
- Fix "do not edit" message to have proper file name
- More Android.mk changes
- Don't write both files at the same time
- Provide the file name to be written to as an argument

Dylan Baker (15):
  anv: anv_entrypoints_gen.py: use a main function
  anv: Use python style in anv_entrypoints_gen.py
  anv: make constants capitals in anv_entrypoints_gen.py
  anv: don't pass xmlfile via stdin anv_entrypoints_gen.py
  anv: split main into two functions in anv_entrypoints_gen.py
  anv: Update "do not edit" comments with proper filename
  anv: convert header generation in anv_entrypoints_gen.py to mako
  anv: convert C generation to template in anv_entrypoints_gen.py
  anv: anv_entrypoints_gen.py: directly write files instead of piping
  anv: anv-entrypoints_gen.py: rename hash to cal_hash.
  anv: anv_entrypoints_gen.py: use reduce function.
  anv: use dict.get in anv_entrypoints_gen.py
  anv: don't use Element.get in anv_entrypoints_gen.py
  anv: use cElementTree in anv_entrypoints_gen.py
  anv: Remove dead prototype from entrypoints

 src/intel/vulkan/Android.mk |   5 +-
 src/intel/vulkan/Makefile.am|  12 +-
 src/intel/vulkan/anv_entrypoints_gen.py | 600 -
 3 files changed, 318 insertions(+), 299 deletions(-)

base-commit: a9c488f2858f8a383dd50e557ec8a832bcb35f47
-- 
git-series 0.9.1
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 08/15] anv: convert C generation to template in anv_entrypoints_gen.py

2017-02-24 Thread Dylan Baker
This produces a file that is identical except for whitespace, there is a
table that has 8 columns in the original and is easy to do with prints,
but is ugly using mako, so it doesn't have columns; the data is not
inherently tabular.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 340 -
 1 file changed, 167 insertions(+), 173 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index cad94c8..e4bf002 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -86,93 +86,7 @@ TEMPLATE_H = Template(textwrap.dedent("""\
 % endfor
 """))
 
-NONE = 0x
-HASH_SIZE = 256
-U32_MASK = 2**32 - 1
-HASH_MASK = HASH_SIZE - 1
-
-PRIME_FACTOR = 5024183
-PRIME_STEP = 19
-
-opt_header = False
-opt_code = False
-
-
-def hash(name):
-h = 0
-for c in name:
-h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
-
-return h
-
-
-def print_guard_start(guard):
-if guard is not None:
-print "#ifdef {0}".format(guard)
-
-
-def print_guard_end(guard):
-if guard is not None:
-print "#endif // {0}".format(guard)
-
-
-def get_entrypoints(doc, entrypoints_to_defines):
-"""Extract the entry points from the registry."""
-entrypoints = []
-
-enabled_commands = set()
-for feature in doc.findall('./feature'):
-assert feature.attrib['api'] == 'vulkan'
-if float(feature.attrib['number']) > MAX_API_VERSION:
-continue
-
-for command in feature.findall('./require/command'):
-enabled_commands.add(command.attrib['name'])
-
-for extension in doc.findall('.extensions/extension'):
-if extension.attrib['name'] not in SUPPORTED_EXTENSIONS:
-continue
-
-assert extension.attrib['supported'] == 'vulkan'
-for command in extension.findall('./require/command'):
-enabled_commands.add(command.attrib['name'])
-
-index = 0
-for command in doc.findall('./commands/command'):
-type = command.find('./proto/type').text
-fullname = command.find('./proto/name').text
-
-if fullname not in enabled_commands:
-continue
-
-shortname = fullname[2:]
-params = (''.join(p.itertext()) for p in command.findall('./param'))
-params = ', '.join(params)
-if fullname in entrypoints_to_defines:
-guard = entrypoints_to_defines[fullname]
-else:
-guard = None
-entrypoints.append((type, shortname, params, index, hash(fullname), 
guard))
-index += 1
-
-return entrypoints
-
-
-def get_entrypoints_defines(doc):
-"""Maps entry points to extension defines."""
-entrypoints_to_defines = {}
-extensions = doc.findall('./extensions/extension')
-for extension in extensions:
-define = extension.get('protect')
-entrypoints = extension.findall('./require/command')
-for entrypoint in entrypoints:
-fullname = entrypoint.get('name')
-entrypoints_to_defines[fullname] = define
-return entrypoints_to_defines
-
-
-def gen_code(entrypoints):
-print textwrap.dedent("""\
+TEMPLATE_C = Template(textwrap.dedent(u"""\
 /*
  * Copyright ?? 2015 Intel Corporation
  *
@@ -196,58 +110,61 @@ def gen_code(entrypoints):
  * IN THE SOFTWARE.
  */
 
-/* This file generated from {}, don't edit directly. */
+/* This file generated from ${filename}, don't edit directly. */
 
 #include "anv_private.h"
 
-struct anv_entrypoint {{
+struct anv_entrypoint {
uint32_t name;
uint32_t hash;
-}};
+};
 
 /* We use a big string constant to avoid lots of reloctions from the entry
  * point table to lots of little strings. The entries in the entry point 
table
  * store the index into this big string.
  */
 
-static const char strings[] =""".format(os.path.basename(__file__)))
-
-offsets = []
-i = 0
-for type, name, args, num, h, guard in entrypoints:
-print "   \"vk%s\\0\"" % name
-offsets.append(i)
-i += 2 + len(name) + 1
-print "   ;"
-
-# Now generate the table of all entry points
-
-print "\nstatic const struct anv_entrypoint entrypoints[] = {"
-for type, name, args, num, h, guard in entrypoints:
-print "   { %5d, 0x%08x }," % (offsets[num], h)
-print "};\n"
+static const char strings[] =
+% for _, name, _, _, _, _ in entry

[Mesa-dev] [PATCH v3 11/15] anv: anv_entrypoints_gen.py: use reduce function.

2017-02-24 Thread Dylan Baker
Reduce is it's own reward.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 8460bb5..7a5d0a7 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -23,6 +23,7 @@
 #
 
 import argparse
+import functools
 import os
 import textwrap
 import xml.etree.ElementTree as et
@@ -256,11 +257,8 @@ PRIME_STEP = 19
 
 def cal_hash(name):
 """Calculate the same hash value that Mesa will calculate in C."""
-h = 0
-for c in name:
-h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
-
-return h
+return functools.reduce(
+lambda h, c: (h * PRIME_FACTOR + ord(c)) & U32_MASK, name, 0)
 
 
 def get_entrypoints(doc, entrypoints_to_defines):
-- 
git-series 0.9.1
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 07/15] anv: convert header generation in anv_entrypoints_gen.py to mako

2017-02-24 Thread Dylan Baker
This produces an identical file except for whitespace.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 77 ++
 1 file changed, 42 insertions(+), 35 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 05a685d..cad94c8 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -27,6 +27,8 @@ import os
 import textwrap
 import xml.etree.ElementTree as et
 
+from mako.template import Template
+
 MAX_API_VERSION = 1.0
 
 SUPPORTED_EXTENSIONS = [
@@ -46,6 +48,44 @@ SUPPORTED_EXTENSIONS = [
 # function and a power-of-two size table. The prime numbers are determined
 # experimentally.
 
+TEMPLATE_H = Template(textwrap.dedent("""\
+/* This file generated from ${filename}, don't edit directly. */
+
+struct anv_dispatch_table {
+   union {
+  void *entrypoints[${len(entrypoints)}];
+  struct {
+  % for _, name, _, _, _, guard in entrypoints:
+% if guard is not None:
+#ifdef ${guard}
+  PFN_vk${name} ${name};
+#else
+  void *${name};
+# endif
+% else:
+  PFN_vk${name} ${name};
+% endif
+  % endfor
+  };
+   };
+};
+
+void anv_set_dispatch_devinfo(const struct gen_device_info *info);
+% for type_, name, args, num, h, guard in entrypoints:
+  % if guard is not None:
+#ifdef ${guard}
+  % endif
+  ${type_} anv_${name}(${args});
+  ${type_} gen7_${name}(${args});
+  ${type_} gen75_${name}(${args});
+  ${type_} gen8_${name}(${args});
+  ${type_} gen9_${name}(${args});
+  % if guard is not None:
+#endif // ${guard}
+  % endif
+% endfor
+"""))
+
 NONE = 0x
 HASH_SIZE = 256
 U32_MASK = 2**32 - 1
@@ -131,40 +171,6 @@ def get_entrypoints_defines(doc):
 return entrypoints_to_defines
 
 
-def gen_header(entrypoints):
-print "/* This file generated from {}, don't edit directly. */\n".format(
-os.path.basename(__file__))
-
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
-
-for type, name, args, num, h, guard in entrypoints:
-if guard is not None:
-print "#ifdef {0}".format(guard)
-print " PFN_vk{0} {0};".format(name)
-print "#else"
-print " void *{0};".format(name)
-print "#endif"
-else:
-print " PFN_vk{0} {0};".format(name)
-print "  };\n"
-print "   };\n"
-print "};\n"
-
-print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
-
-for type, name, args, num, h, guard in entrypoints:
-print_guard_start(guard)
-print "%s anv_%s(%s);" % (type, name, args)
-print "%s gen7_%s(%s);" % (type, name, args)
-print "%s gen75_%s(%s);" % (type, name, args)
-print "%s gen8_%s(%s);" % (type, name, args)
-print "%s gen9_%s(%s);" % (type, name, args)
-print_guard_end(guard)
-
-
 def gen_code(entrypoints):
 print textwrap.dedent("""\
 /*
@@ -373,7 +379,8 @@ def main():
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
 if args.target == 'header':
-gen_header(entrypoints)
+print TEMPLATE_H.render(entrypoints=entrypoints,
+filename=os.path.basename(__file__))
 else:
 gen_code(entrypoints)
 
-- 
git-series 0.9.1
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 13/15] anv: don't use Element.get in anv_entrypoints_gen.py

2017-02-24 Thread Dylan Baker
This has the potential to mask errors, since Element.get works like
dict.get, returning None if the element isn't found. I think the reason
that Element.get was used is that vulkan has one extension that isn't
really an extension, and thus is missing the 'protect' field.

This patch changes the behavior slightly by replacing get with explicit
lookup in the Element.attrib dictionary, and using xpath to only iterate
over extensions with a "protect" attribute.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 9bec52a..8736eaf 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -303,13 +303,14 @@ def get_entrypoints(doc, entrypoints_to_defines):
 def get_entrypoints_defines(doc):
 """Maps entry points to extension defines."""
 entrypoints_to_defines = {}
-extensions = doc.findall('./extensions/extension')
-for extension in extensions:
-define = extension.get('protect')
-entrypoints = extension.findall('./require/command')
-for entrypoint in entrypoints:
-fullname = entrypoint.get('name')
+
+for extension in doc.findall('./extensions/extension[@protect]'):
+define = extension.attrib['protect']
+
+for entrypoint in extension.findall('./require/command'):
+fullname = entrypoint.attrib['name']
 entrypoints_to_defines[fullname] = define
+
 return entrypoints_to_defines
 
 
-- 
git-series 0.9.1
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 05/15] anv: split main into two functions in anv_entrypoints_gen.py

2017-02-24 Thread Dylan Baker
This is groundwork for the next patches, it will allows porting the
header and the code to mako separately, and will also allow both to be
run simultaneously.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 108 -
 1 file changed, 56 insertions(+), 52 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index ea15065..772f3e6 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -130,64 +130,40 @@ def get_entrypoints_defines(doc):
 return entrypoints_to_defines
 
 
-def main():
-parser = argparse.ArgumentParser()
-parser.add_argument('target', choices=['header', 'code'],
-help='Which file to generate.')
-parser.add_argument('--xml', help='Vulkan API XML file.')
-args = parser.parse_args()
-
-doc = et.parse(args.xml)
-entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
-
-# Manually add CreateDmaBufImageINTEL for which we don't have an extension
-# defined.
-entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
-'VkDevice device, ' +
-'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
-'const VkAllocationCallbacks* pAllocator,' +
-'VkDeviceMemory* pMem,' +
-'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
+def gen_header(entrypoints):
+print "/* This file generated from vk_gen.py, don't edit directly. */\n"
 
-# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
-# per entry point.
-
-if args.target == 'header':
-print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
+print "struct anv_dispatch_table {"
+print "   union {"
+print "  void *entrypoints[%d];" % len(entrypoints)
+print "  struct {"
 
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
-
-for type, name, args, num, h, guard in entrypoints:
-if guard is not None:
-print "#ifdef {0}".format(guard)
-print " PFN_vk{0} {0};".format(name)
-print "#else"
-print " void *{0};".format(name)
-print "#endif"
-else:
-print " PFN_vk{0} {0};".format(name)
-print "  };\n"
-print "   };\n"
-print "};\n"
-
-print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
+for type, name, args, num, h, guard in entrypoints:
+if guard is not None:
+print "#ifdef {0}".format(guard)
+print " PFN_vk{0} {0};".format(name)
+print "#else"
+print " void *{0};".format(name)
+print "#endif"
+else:
+print " PFN_vk{0} {0};".format(name)
+print "  };\n"
+print "   };\n"
+print "};\n"
 
-for type, name, args, num, h, guard in entrypoints:
-print_guard_start(guard)
-print "%s anv_%s(%s);" % (type, name, args)
-print "%s gen7_%s(%s);" % (type, name, args)
-print "%s gen75_%s(%s);" % (type, name, args)
-print "%s gen8_%s(%s);" % (type, name, args)
-print "%s gen9_%s(%s);" % (type, name, args)
-print_guard_end(guard)
-exit()
+print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
 
+for type, name, args, num, h, guard in entrypoints:
+print_guard_start(guard)
+print "%s anv_%s(%s);" % (type, name, args)
+print "%s gen7_%s(%s);" % (type, name, args)
+print "%s gen75_%s(%s);" % (type, name, args)
+print "%s gen8_%s(%s);" % (type, name, args)
+print "%s gen9_%s(%s);" % (type, name, args)
+print_guard_end(guard)
 
 
+def gen_code(entrypoints):
 print textwrap.dedent("""\
 /*
  * Copyright ?? 2015 Intel Corporation
@@ -372,5 +348,33 @@ def main():
 """) % (PRIME_FACTOR, PRIME_STEP, HASH_MASK)
 
 
+def main():
+parser = argparse.ArgumentParser(

[Mesa-dev] [PATCH v3 06/15] anv: Update "do not edit" comments with proper filename

2017-02-24 Thread Dylan Baker
This does two things, first it updates both the .h and the .c file to
have the same do not edit string. Second, it uses __file__ to ensure
that even if the file is moved or renamed that the name will be correct.

One thing to note is the use of '{{' and '}}' in the C template. This is
to instruct python to print a literal '{' and '}' respectively, rather
than treating the contents as a formatter specifier.

v3: - add this patch

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 772f3e6..05a685d 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -23,6 +23,7 @@
 #
 
 import argparse
+import os
 import textwrap
 import xml.etree.ElementTree as et
 
@@ -131,7 +132,8 @@ def get_entrypoints_defines(doc):
 
 
 def gen_header(entrypoints):
-print "/* This file generated from vk_gen.py, don't edit directly. */\n"
+print "/* This file generated from {}, don't edit directly. */\n".format(
+os.path.basename(__file__))
 
 print "struct anv_dispatch_table {"
 print "   union {"
@@ -188,21 +190,21 @@ def gen_code(entrypoints):
  * IN THE SOFTWARE.
  */
 
-/* DO NOT EDIT! This is a generated file. */
+/* This file generated from {}, don't edit directly. */
 
 #include "anv_private.h"
 
-struct anv_entrypoint {
+struct anv_entrypoint {{
uint32_t name;
uint32_t hash;
-};
+}};
 
 /* We use a big string constant to avoid lots of reloctions from the entry
  * point table to lots of little strings. The entries in the entry point 
table
  * store the index into this big string.
  */
 
-static const char strings[] =""")
+static const char strings[] =""".format(os.path.basename(__file__)))
 
 offsets = []
 i = 0
-- 
git-series 0.9.1
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 14/15] anv: use cElementTree in anv_entrypoints_gen.py

2017-02-24 Thread Dylan Baker
It's written in C rather than pure python and is strictly faster, the
only reason not to use it that it's classes cannot be subclassed.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 8736eaf..72d8c17 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -26,7 +26,7 @@ import argparse
 import functools
 import os
 import textwrap
-import xml.etree.ElementTree as et
+import xml.etree.cElementTree as et
 
 from mako.template import Template
 
-- 
git-series 0.9.1
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 10/15] anv: anv-entrypoints_gen.py: rename hash to cal_hash.

2017-02-24 Thread Dylan Baker
hash is reserved name in python, it's the interface to access an
object's hash protocol.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 156a14f..8460bb5 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -254,7 +254,8 @@ PRIME_FACTOR = 5024183
 PRIME_STEP = 19
 
 
-def hash(name):
+def cal_hash(name):
+"""Calculate the same hash value that Mesa will calculate in C."""
 h = 0
 for c in name:
 h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
@@ -298,7 +299,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 guard = entrypoints_to_defines[fullname]
 else:
 guard = None
-entrypoints.append((type, shortname, params, index, hash(fullname), 
guard))
+entrypoints.append((type, shortname, params, index, 
cal_hash(fullname), guard))
 index += 1
 
 return entrypoints
@@ -369,7 +370,7 @@ def main():
 'const VkAllocationCallbacks* pAllocator,' +
 'VkDeviceMemory* pMem,' +
 'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
+cal_hash('vkCreateDmaBufImageINTEL'), None))
 
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
-- 
git-series 0.9.1
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 12/15] anv: use dict.get in anv_entrypoints_gen.py

2017-02-24 Thread Dylan Baker
Instead of using an if and a check, use dict.get, which does the same
thing, but more succinctly.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 7a5d0a7..9bec52a 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -293,10 +293,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 shortname = fullname[2:]
 params = (''.join(p.itertext()) for p in command.findall('./param'))
 params = ', '.join(params)
-if fullname in entrypoints_to_defines:
-guard = entrypoints_to_defines[fullname]
-else:
-guard = None
+guard = entrypoints_to_defines.get(fullname)
 entrypoints.append((type, shortname, params, index, 
cal_hash(fullname), guard))
 index += 1
 
-- 
git-series 0.9.1
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 0/4] glsl/tests: completely broken or strange design ?

2017-02-24 Thread Dylan Baker
Quoting Emil Velikov (2017-02-23 08:43:06)
> Hi all,
> 
> As some of you may know we have a bunch of interesting tests in glsl.
> 
> A bit earlier I've spotted that they are competely broken, as they would
> happily return "success" even when 0 tests were generated.
> 
> As an example I will take optimisation-test, which this series sort of
> fixes. Here is the design flow:
>  - optimisation-test (SH1) assumes that we're in the right location and 
> opens a python script (PY1).
>  - if found (only in corner cases) - the PY1 is executed and generates 
> a bunch of bash scripts (SH2) which are stored in the srcdir (fails on
> make distcheck).
>  - PY1 also hardcodes the location of the glsl_test binary, based on 
> some magically derived value (hint srcdir not used and wrong to use)
>  - the return status of PY1 is unchecked.
>  - thus as PY1 fails (and we often do) no tests are generated and SH1 
> reports "SUCCESS"
>  - alternatively, SH1 executes SH2 to produce the to-be-tested files
>  - then it (SH1) proceeds to execute PY2
>  - latter of which decodes and saves the [to a temporary location] the
> template and the file under test and calls "diff" on the resulting
> files.
> 
> With the following patches I've addressed all usecases, but the fact that
> srcdir is RO, thus 3/4 will cause "make distcheck" to fail (and rightfully 
> so).
> 
> I believe all of us can see how fragile/suboptimal/you name it the
> design is and it need a complete rework.
> 
> Conteplating about giving a shot myself, but I suspect all of it will end up
> in the bin, now that we have Dylan back ;-)
> 
> So the questions are:
>  - Do we care about those tests ?
>  - Dylan any interest in giving it a stab ?

Not particularly, but I'd be happy to review whatever you come up with ;)

> 
> Thanks
> Emil
> 
> Cc: Dylan Baker 
> Cc: Kenneth Graunke 
> Cc: Matt Turner 
> 
> Emil Velikov (4):
>   glsl/tests/optimisation-test: make sure that $PYTHON2 is set/available
>   glsl/tests/optimisation-test: ensure that compare_ir is available
>   glsl/tests/optimization-test: error out if we fail to generate any
> tests
>   glsl/tests/optimization-test: correctly manage srcdir/pwd and co
> 
>  src/compiler/glsl/tests/optimization-test | 50 
> +++
>  1 file changed, 44 insertions(+), 6 deletions(-)
> 
> -- 
> 2.11.0
> 


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


Re: [Mesa-dev] [PATCH v3 00/15] cleanup anv_entrpoints_gen.py

2017-02-27 Thread Dylan Baker
Quoting Emil Velikov (2017-02-26 10:26:24)
> On 24 February 2017 at 18:21, Dylan Baker  wrote:
> > There are a number of small style cleanups and simplifications in this 
> > series,
> > but the main changes are:
> >  - use a mako template to generate the header and code rather than prints
> >  - be python 3.x ready (the goal isn't to write python 3 code, but to write 
> > code
> >that is easy to port or hybridize)
> >  - generate the header and the code in one go
> >
> > I've put emphasis on the readability of the template rather than the 
> > readability
> > of the output code, it's relatively easy to pipe the code through 'indent' 
> > to
> > make it more readable.
> >
> > Notable changes in Version 2:
> > - Pass XML file via an argument
> > - add flag to control output directory
> > - Attempt to update android makefiles
> >
> > Notable changes in Version 3:
> > - Fix "do not edit" message to have proper file name
> > - More Android.mk changes
> 
> > - Don't write both files at the same time
> > - Provide the file name to be written to as an argument
> >
> Not sure why you opted to rewrite this considering that we already
> have such bugs in-tree and the fix was a 2-line change in the
> makefile(s). Perhaps I should have made that clearer :-(

Eric seemed to suggest that this approach was impossible in android makefiles. I
can revert that change easily if that's not the case.

> 
> That aside - tried to pull/test your series, but patchwork has gone
> crazy (doesn't like git series?). Do you have a branch somewhere ?

I can push a branch, just let me know whether I'm wrong about the android
makefile issue first.

> 
> Thanks
> Emil


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


Re: [Mesa-dev] [PATCH] android: vulkan: add support for libmesa_vulkan_{util, wsi}

2017-02-27 Thread Dylan Baker
Quoting Mauro Rossi (2017-02-25 10:31:43)
[snip]
> diff --git a/src/vulkan/util/gen_enum_to_str.py 
> b/src/vulkan/util/gen_enum_to_str.py
> index 4b6fdf3..5d2bc54 100644
> --- a/src/vulkan/util/gen_enum_to_str.py
> +++ b/src/vulkan/util/gen_enum_to_str.py
> @@ -22,6 +22,7 @@
>  """Create enum to string functions for vulking using vk.xml."""
>  
>  from __future__ import print_function
> +import argparse
>  import os
>  import textwrap
>  import xml.etree.cElementTree as et
> @@ -30,6 +31,14 @@ from mako.template import Template
>  
>  VK_XML = os.path.join(os.path.dirname(__file__), '..', 'registry', 'vk.xml')
>  
> +parser = 
> argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
> +parser.add_argument('-o', '--output-path', help=textwrap.dedent('''\
> +   -o $(top_builddir)/src/vulkan/util for Linux builds
> +   -o $(intermediates)/util for Android builds'''),
> +   required=True)

Don't put makefile commands as the help line, either set it to something like
"where to put the output files", or just omit it.

> +argv = parser.parse_args()
> +dst_dir = argv.output_path

Can we call this "args" instead of "argv"? There is an argv in python
(sys.argv), and it's just asking to confuse people who expect C's ARGV.

> +
>  COPYRIGHT = textwrap.dedent(u"""\
>  * Copyright © 2017 Intel Corporation
>  *
> @@ -159,8 +168,8 @@ def xml_parser(filename):
>  
>  def main():
>  enums = xml_parser(VK_XML)
> -for template, file_ in [(C_TEMPLATE, 'util/vk_enum_to_str.c'),
> -(H_TEMPLATE, 'util/vk_enum_to_str.h')]:
> +for template, file_ in [(C_TEMPLATE, 
> os.path.join(dst_dir,'vk_enum_to_str.c')),
> +        (H_TEMPLATE, 
> os.path.join(dst_dir,'vk_enum_to_str.h'))]:

I don't think there's anything wrong with just using 
'os.path.join(args.output_path, ...)

Also, please put a space after the ',' in os.path.join

I'm not really qualified to review the android.mk, but with the above changes:
Reviewed-by: Dylan Baker 


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


Re: [Mesa-dev] [PATCH 5/8] i965: Add script to gen code for OA counter queries

2017-02-27 Thread Dylan Baker
I have some comments below, some of them are a bit of work, some of them should
be pretty easy.

Dylan

Quoting Robert Bragg (2017-02-24 05:58:00)
> --- /dev/null
> +++ b/src/mesa/drivers/dri/i965/brw_oa.py
> @@ -0,0 +1,543 @@
> +#!/usr/bin/env python2
> +#
> +# Copyright (c) 2015 Intel Corporation
> +#
> +# Permission is hereby granted, free of charge, to any person obtaining a
> +# copy of this software and associated documentation files (the "Software"),
> +# to deal in the Software without restriction, including without limitation
> +# the rights to use, copy, modify, merge, publish, distribute, sublicense,
> +# and/or sell copies of the Software, and to permit persons to whom the
> +# Software is furnished to do so, subject to the following conditions:
> +#
> +# The above copyright notice and this permission notice (including the next
> +# paragraph) shall be included in all copies or substantial portions of the
> +# Software.
> +#
> +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> DEALINGS
> +# IN THE SOFTWARE.
> +
> +import xml.etree.ElementTree as ET

use cElementTree, and please import as "et" instead of "ET", ET suggests to me
as a pythonista that this is a class not a module. (I know ElementTree is
capitalized, but that's a legacy thing, modern python style is modules are lower
case with _, classes are CamelCase)

> +import argparse
> +import sys

Also, please sort the imports

> +
> +def print_err(*args):
> +sys.stderr.write(' '.join(map(str,args)) + '\n')

unused function

> +
> +c_file = None
> +_c_indent = 0
> +
> +def c(*args):
> +if c_file:
> +code = ' '.join(map(str,args))
> +for line in code.splitlines():
> +text = ''.rjust(_c_indent) + line
> +c_file.write(text.rstrip() + "\n")
> +
> +# indented, but no trailing newline...
> +def c_line_start(code):
> +if c_file:
> +c_file.write(''.rjust(_c_indent) + code)
> +def c_raw(code):
> +if c_file:
> +c_file.write(code)
> +
> +def c_indent(n):
> +global _c_indent
> +_c_indent = _c_indent + n
> +def c_outdent(n):
> +global _c_indent
> +_c_indent = _c_indent - n
> +
> +header_file = None
> +_h_indent = 0
> +
> +def h(*args):
> +if header_file:
> +code = ' '.join(map(str,args))
> +for line in code.splitlines():
> +text = ''.rjust(_h_indent) + line
> +header_file.write(text.rstrip() + "\n")
> +
> +def h_indent(n):
> +global _c_indent
> +_h_indent = _h_indent + n
> +def h_outdent(n):
> +global _c_indent
> +_h_indent = _h_indent - n
> +
> +
> +def emit_fadd(tmp_id, args):
> +c("double tmp" + str(tmp_id) +" = " + args[1] + " + " + args[0] + ";")

"double tmp {tmp_id} = {args[1]} + {ags[0]};".format(tmp_id=tmp_id, args=args)

This avoids the need to explicitly convert to str, and is much more readable.
I'd really recommend taking this approach for the rest of the file too, as it
will make things much more readable.

> +return tmp_id + 1
> +
> +# Be careful to check for divide by zero...
> +def emit_fdiv(tmp_id, args):
> +c("double tmp" + str(tmp_id) +" = " + args[1] + ";")
> +c("double tmp" + str(tmp_id + 1) +" = " + args[0] + ";")
> +c("double tmp" + str(tmp_id + 2) +" = tmp" + str(tmp_id + 1)  + " ? tmp" 
> + str(tmp_id) + " / tmp" + str(tmp_id + 1) + " : 0;")
> +return tmp_id + 3
> +
> +def emit_fmax(tmp_id, args):
> +c("double tmp" + str(tmp_id) +" = " + args[1] + ";")
> +c("double tmp" + str(tmp_id + 1) +" = " + args[0] + ";")
> +c("double tmp" + str(tmp_id + 2) +" = MAX(tmp" + str(tmp_id) + ", tmp" + 
> str(tmp_id + 1) + ");")
> +return tmp_id + 3
> +
> +def emit_fmul(tmp_id, args):
> +c("double tmp" + str(tmp_id) +" = " + args[1] + " * " + args[0] + ";")
> +return tmp_id + 1
> +
> +def emit_fsub(tmp_id, args):
> +c("double tmp" + str(tmp_id) +" = " + args[1] + " - " + args[0] + ";")
> +return tmp_id + 1
> +
> +def emit_read(tmp_id, args):
> +type = args[1].lower()
> +c("uint64_t tmp" + str(tmp_id) + " = accumulator[query->" + type + 
> "_offset + " + args[0] + "];")
> +return tmp_id + 1
> +
> +def emit_uadd(tmp_id, args):
> +c("uint64_t tmp" + str(tmp_id) +" = " + args[1] + " + " + args[0] + ";")
> +return tmp_id + 1
> +
> +# Be careful to check for divide by zero...
> +def emit_udiv(tmp_id, args):
> +c("uint64_t tmp" + str(tmp_id) +" = " + args[1] + ";")
> +c("uint64_t tmp" + str(tmp_id + 1) +" = " + args[0] + ";")
> +c("uint64_t tmp" + str(tmp_id + 2) +" = tmp" + str(tmp_id + 1)  + " ? 
> tmp" + str(tmp

[Mesa-dev] [PATCH v2] mesa: Implement ARB_shader_viewport_layer_array for i965

2016-09-19 Thread Dylan Baker
This extension is a combination of AMD_vertex_shader_viewport_index and
AMD_vertex_shader_layer, making it rather trivial to implement.

For gallium I *think* this needs a new cap because of the addition of
support in tessellation evaluation shaders, and since I don't have any
hardware to test it on, I've left that for someone else to wire up.

Signed-off-by: Dylan Baker 
Reviewed-by: Ilia Mirkin 
Reviewed-by: Kenneth Graunke 
---

v2: - changed messages to gen6+ instead of gen8+.
- remove GLL from EXT list.

 docs/features.txt|  2 +-
 docs/relnotes/12.1.0.html|  1 +
 src/compiler/glsl/builtin_variables.cpp  | 14 --
 src/compiler/glsl/glsl_parser_extras.cpp |  1 +
 src/compiler/glsl/glsl_parser_extras.h   |  2 ++
 src/mesa/drivers/dri/i965/intel_extensions.c |  1 +
 src/mesa/main/extensions_table.h |  1 +
 src/mesa/main/mtypes.h   |  1 +
 8 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/docs/features.txt b/docs/features.txt
index d6c3240..ac93ec6 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -296,7 +296,7 @@ Khronos, ARB, and OES extensions that are not part of any 
OpenGL or OpenGL ES ve
   GL_ARB_shader_draw_parameters DONE (i965, nvc0, 
radeonsi)
   GL_ARB_shader_group_vote  DONE (nvc0)
   GL_ARB_shader_stencil_export  DONE (i965/gen9+, 
radeonsi, softpipe, llvmpipe, swr)
-  GL_ARB_shader_viewport_layer_arraynot started
+  GL_ARB_shader_viewport_layer_arrayDONE (i965/gen6+)
   GL_ARB_sparse_buffer  not started
   GL_ARB_sparse_texture not started
   GL_ARB_sparse_texture2not started
diff --git a/docs/relnotes/12.1.0.html b/docs/relnotes/12.1.0.html
index bb20e4f..65b8e4c 100644
--- a/docs/relnotes/12.1.0.html
+++ b/docs/relnotes/12.1.0.html
@@ -52,6 +52,7 @@ Note: some of the new features are only available with 
certain drivers.
 GL_ARB_indirect_parameters on radeonsi
 GL_ARB_shader_draw_parameters on radeonsi
 GL_ARB_shader_group_vote on nvc0
+GL_ARB_shader_viewport_layer_array on i965/gen6+
 GL_ARB_stencil_texturing on i965/hsw
 GL_ARB_texture_stencil8 on i965/hsw
 GL_EXT_window_rectangles on nv50, nvc0
diff --git a/src/compiler/glsl/builtin_variables.cpp 
b/src/compiler/glsl/builtin_variables.cpp
index 90278d6..8d6413e 100644
--- a/src/compiler/glsl/builtin_variables.cpp
+++ b/src/compiler/glsl/builtin_variables.cpp
@@ -1000,11 +1000,13 @@ builtin_variable_generator::generate_vs_special_vars()
   add_system_value(SYSTEM_VALUE_BASE_INSTANCE, int_t, 
"gl_BaseInstanceARB");
   add_system_value(SYSTEM_VALUE_DRAW_ID, int_t, "gl_DrawIDARB");
}
-   if (state->AMD_vertex_shader_layer_enable) {
+   if (state->AMD_vertex_shader_layer_enable ||
+   state->ARB_shader_viewport_layer_array_enable) {
   var = add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer");
   var->data.interpolation = INTERP_MODE_FLAT;
}
-   if (state->AMD_vertex_shader_viewport_index_enable) {
+   if (state->AMD_vertex_shader_viewport_index_enable ||
+   state->ARB_shader_viewport_layer_array_enable) {
   var = add_output(VARYING_SLOT_VIEWPORT, int_t, "gl_ViewportIndex");
   var->data.interpolation = INTERP_MODE_FLAT;
}
@@ -1066,6 +1068,8 @@ builtin_variable_generator::generate_tcs_special_vars()
 void
 builtin_variable_generator::generate_tes_special_vars()
 {
+   ir_variable *var;
+
add_system_value(SYSTEM_VALUE_PRIMITIVE_ID, int_t, "gl_PrimitiveID");
add_system_value(SYSTEM_VALUE_VERTICES_IN, int_t, "gl_PatchVerticesIn");
add_system_value(SYSTEM_VALUE_TESS_COORD, vec3_t, "gl_TessCoord");
@@ -1073,6 +1077,12 @@ builtin_variable_generator::generate_tes_special_vars()
 "gl_TessLevelOuter");
add_system_value(SYSTEM_VALUE_TESS_LEVEL_INNER, array(float_t, 2),
 "gl_TessLevelInner");
+   if (state->ARB_shader_viewport_layer_array_enable) {
+  var = add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer");
+  var->data.interpolation = INTERP_MODE_FLAT;
+  var = add_output(VARYING_SLOT_VIEWPORT, int_t, "gl_ViewportIndex");
+  var->data.interpolation = INTERP_MODE_FLAT;
+   }
 }
 
 
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp 
b/src/compiler/glsl/glsl_parser_extras.cpp
index 436ddd0..a21ce50 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -608,6 +608,7 @@ static const _mesa_glsl_extension 
_mesa_glsl_supported_extensions[] = {
EXT(ARB_shader_subroutine),
EXT(ARB_shader_texture_image_samples),
EXT(ARB_shader_texture_lod),
+   EXT(ARB_shader_viewport_layer_array),
EXT(ARB_s

[Mesa-dev] [PATCH 0/3] Update libGLESv2.so to expose GLES 3.2 symbols

2016-09-22 Thread Dylan Baker
This adds the GLES 3.2 symbols to libGLESv2.so. The first two patches (which
have all of the changes in them), do some basic cleanup. The first makes tabs
consistent (this is the giant patch), and the second sorts the list
alphabetically.

Dylan Baker (3):
  mapi: retab static_data.py to be consistent
  mapi: sort static_data.py functions
  mapi: export all GLES 3.2 functions in libGLESv2.so

 src/mapi/glapi/gen/static_data.py | 2586 +++--
 1 file changed, 1301 insertions(+), 1285 deletions(-)

-- 
2.10.0

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


[Mesa-dev] [PATCH 3/3] mapi: export all GLES 3.2 functions in libGLESv2.so

2016-09-22 Thread Dylan Baker
See commit 5921f372c89a68fac6ddefc009442721d9df4db2 for the rational of
this commit.

Signed-off-by: Dylan Baker 
---
 src/mapi/glapi/gen/static_data.py | 16 
 1 file changed, 16 insertions(+)

diff --git a/src/mapi/glapi/gen/static_data.py 
b/src/mapi/glapi/gen/static_data.py
index bb11c1d..fa63ab5 100644
--- a/src/mapi/glapi/gen/static_data.py
+++ b/src/mapi/glapi/gen/static_data.py
@@ -484,17 +484,22 @@ functions = [
 "BindVertexBuffer",
 "BindVertexBuffers",
 "Bitmap",
+"BlendBarrier",
 "BlendColor",
 "BlendColorEXT",
 "BlendEquation",
 "BlendEquationEXT",
 "BlendEquationSeparate",
+"BlendEquationSeparatei",
 "BlendEquationSeparateiARB",
+"BlendEquationi",
 "BlendEquationiARB",
 "BlendFunc",
 "BlendFuncSeparate",
 "BlendFuncSeparateEXT",
+"BlendFuncSeparatei",
 "BlendFuncSeparateiARB",
+"BlendFunci",
 "BlendFunciARB",
 "BlitFramebuffer",
 "BufferData",
@@ -825,6 +830,7 @@ functions = [
 "GetFramebufferAttachmentParameteriv",
 "GetFramebufferAttachmentParameterivEXT",
 "GetFramebufferParameteriv",
+"GetGraphicsResetStatus",
 "GetGraphicsResetStatusARB",
 "GetHandleARB",
 "GetHistogram",
@@ -887,6 +893,7 @@ functions = [
 "GetSamplerParameterIiv",
 "GetSamplerParameterIuiv",
 "GetSamplerParameterfv",
+"GetSamplerParameteri",
 "GetSamplerParameteriv",
 "GetSeparableFilter",
 "GetShaderInfoLog",
@@ -951,8 +958,11 @@ functions = [
 "GetnSeparableFilterARB",
 "GetnTexImageARB",
 "GetnUniformdvARB",
+"GetnUniformfv",
 "GetnUniformfvARB",
+"GetnUniformiv",
 "GetnUniformivARB",
+"GetnUniformuiv",
 "GetnUniformuivARB",
 "Hint",
 "Histogram",
@@ -1160,6 +1170,7 @@ functions = [
 "Orthof",
 "Orthox",
 "PassThrough",
+"PatchParameteri"
 "PauseTransformFeedback",
 "PixelMapfv",
 "PixelMapuiv",
@@ -1191,6 +1202,7 @@ functions = [
 "PopDebugGroup",
 "PopMatrix",
 "PopName",
+"PrimitiveBoundingBox",
 "PrimitiveRestartIndex",
 "PrimitiveRestartIndexNV",
 "PrimitiveRestartNV",
@@ -1274,6 +1286,7 @@ functions = [
 "RasterPos4sv",
 "ReadBuffer",
 "ReadPixels",
+"ReadnPixels",
 "ReadnPixelsARB",
 "Rectd",
 "Rectdv",
@@ -1305,6 +1318,7 @@ functions = [
 "SamplerParameterfv",
 "SamplerParameteri",
 "SamplerParameteriv",
+"SamplerParameterIiv",
 "Scaled",
 "Scalef",
 "Scalex",
@@ -1426,6 +1440,7 @@ functions = [
 "TexParameterIiv",
 "TexParameterIivEXT",
 "TexParameterIuiv",
+"TexParameterIuiv",
 "TexParameterIuivEXT",
 "TexParameterf",
 "TexParameterfv",
@@ -1442,6 +1457,7 @@ functions = [
 "TexSubImage2D",
 "TexSubImage3D",
 "TexSubImage3DEXT",
+"TexbufferRange",
 "TextureBarrierNV",
 "TextureStorage1DEXT",
 "TextureStorage2DEXT",
-- 
2.10.0

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


[Mesa-dev] [PATCH 1/3] mapi: retab static_data.py to be consistent

2016-09-22 Thread Dylan Baker
This file currently uses a mixture of 3 and 4 space indent. I have
changed it all to 4 space indent, matching the settings in
$ROOT/.editorconfig.

Signed-off-by: Dylan Baker 
---
 src/mapi/glapi/gen/static_data.py | 2570 ++---
 1 file changed, 1285 insertions(+), 1285 deletions(-)

diff --git a/src/mapi/glapi/gen/static_data.py 
b/src/mapi/glapi/gen/static_data.py
index b25dab1..396f941 100644
--- a/src/mapi/glapi/gen/static_data.py
+++ b/src/mapi/glapi/gen/static_data.py
@@ -436,1291 +436,1291 @@ offsets = {
 }
 
 functions = [
-   "Accum",
-   "ActiveShaderProgram",
-   "ActiveTexture",
-   "ActiveTextureARB",
-   "AlphaFunc",
-   "AlphaFuncx",
-   "AreTexturesResident",
-   "AreTexturesResidentEXT",
-   "ArrayElement",
-   "ArrayElementEXT",
-   "AttachObjectARB",
-   "AttachShader",
-   "Begin",
-   "BeginConditionalRender",
-   "BeginConditionalRenderNV",
-   "BeginQuery",
-   "BeginQueryARB",
-   "BeginQueryIndexed",
-   "BeginTransformFeedback",
-   "BindAttribLocation",
-   "BindAttribLocationARB",
-   "BindBuffer",
-   "BindBufferARB",
-   "BindBufferBase",
-   "BindBufferRange",
-   "BindBuffersBase",
-   "BindBuffersRange",
-   "BindFragDataLocation",
-   "BindFragDataLocationEXT",
-   "BindFragDataLocationIndexed",
-   "BindFramebuffer",
-   "BindFramebufferEXT",
-   "BindImageTexture",
-   "BindImageTextures",
-   "BindProgramARB",
-   "BindProgramPipeline",
-   "BindRenderbuffer",
-   "BindRenderbufferEXT",
-   "BindSampler",
-   "BindSamplers",
-   "BindTexture",
-   "BindTextureEXT",
-   "BindTextures",
-   "BindTransformFeedback",
-   "BindVertexArray",
-   "BindVertexBuffer",
-   "BindVertexBuffers",
-   "Bitmap",
-   "BlendColor",
-   "BlendColorEXT",
-   "BlendEquation",
-   "BlendEquationEXT",
-   "BlendEquationiARB",
-   "BlendEquationSeparate",
-   "BlendEquationSeparateiARB",
-   "BlendFunc",
-   "BlendFunciARB",
-   "BlendFuncSeparate",
-   "BlendFuncSeparateEXT",
-   "BlendFuncSeparateiARB",
-   "BlitFramebuffer",
-   "BufferData",
-   "BufferDataARB",
-   "BufferStorage",
-   "BufferSubData",
-   "BufferSubDataARB",
-   "CallList",
-   "CallLists",
-   "CheckFramebufferStatus",
-   "CheckFramebufferStatusEXT",
-   "ClampColor",
-   "ClampColorARB",
-   "Clear",
-   "ClearAccum",
-   "ClearBufferData",
-   "ClearBufferfi",
-   "ClearBufferfv",
-   "ClearBufferiv",
-   "ClearBufferSubData",
-   "ClearBufferuiv",
-   "ClearColor",
-   "ClearColorIiEXT",
-   "ClearColorIuiEXT",
-   "ClearColorx",
-   "ClearDepth",
-   "ClearDepthf",
-   "ClearDepthx",
-   "ClearIndex",
-   "ClearStencil",
-   "ClearTexImage",
-   "ClearTexSubImage",
-   "ClientActiveTexture",
-   "ClientActiveTextureARB",
-   "ClientWaitSync",
-   "ClipPlane",
-   "ClipPlanef",
-   "ClipPlanex",
-   "Color3b",
-   "Color3bv",
-   "Color3d",
-   "Color3dv",
-   "Color3f",
-   "Color3fv",
-   "Color3i",
-   "Color3iv",
-   "Color3s",
-   "Color3sv",
-   "Color3ub",
-   "Color3ubv",
-   "Color3ui",
-   "Color3uiv",
-   "Color3us",
-   "Color3usv",
-   "Color4b",
-   "Color4bv",
-   "Color4d",
-   "Color4dv",
-   "Color4f",
-   "Color4fv",
-   "Color4i",
-   "Color4iv",
-   "Color4s",
-   "Color4sv",
-   "Color4ub",
-   "Color4ubv",
-   "Color4ui",
-   "Color4uiv",
-   "Color4us",
-   "Color4usv",
-   "Color4x",
-   "ColorMask",
-   "ColorMaski",
-   "ColorMaskIndexedEXT",
-   "ColorMaterial",
-   "ColorP3ui",
-   "ColorP3uiv",
-   "ColorP4ui",
-   "ColorP4uiv",
-   "ColorPointer",
-   "ColorPointerEXT",
-   "ColorSubTable",
-   "ColorTable",
-   "ColorTableParam

[Mesa-dev] [PATCH 2/3] mapi: sort static_data.py functions

2016-09-22 Thread Dylan Baker
Signed-off-by: Dylan Baker 
---
 src/mapi/glapi/gen/static_data.py | 164 +++---
 1 file changed, 82 insertions(+), 82 deletions(-)

diff --git a/src/mapi/glapi/gen/static_data.py 
b/src/mapi/glapi/gen/static_data.py
index 396f941..bb11c1d 100644
--- a/src/mapi/glapi/gen/static_data.py
+++ b/src/mapi/glapi/gen/static_data.py
@@ -488,14 +488,14 @@ functions = [
 "BlendColorEXT",
 "BlendEquation",
 "BlendEquationEXT",
-"BlendEquationiARB",
 "BlendEquationSeparate",
 "BlendEquationSeparateiARB",
+"BlendEquationiARB",
 "BlendFunc",
-"BlendFunciARB",
 "BlendFuncSeparate",
 "BlendFuncSeparateEXT",
 "BlendFuncSeparateiARB",
+"BlendFunciARB",
 "BlitFramebuffer",
 "BufferData",
 "BufferDataARB",
@@ -511,10 +511,10 @@ functions = [
 "Clear",
 "ClearAccum",
 "ClearBufferData",
+"ClearBufferSubData",
 "ClearBufferfi",
 "ClearBufferfv",
 "ClearBufferiv",
-"ClearBufferSubData",
 "ClearBufferuiv",
 "ClearColor",
 "ClearColorIiEXT",
@@ -567,8 +567,8 @@ functions = [
 "Color4usv",
 "Color4x",
 "ColorMask",
-"ColorMaski",
 "ColorMaskIndexedEXT",
+"ColorMaski",
 "ColorMaterial",
 "ColorP3ui",
 "ColorP3uiv",
@@ -649,17 +649,17 @@ functions = [
 "DepthMask",
 "DepthRange",
 "DepthRangeArrayv",
-"DepthRangef",
 "DepthRangeIndexed",
+"DepthRangef",
 "DepthRangex",
 "DetachObjectARB",
 "DetachShader",
 "Disable",
 "DisableClientState",
-"Disablei",
 "DisableIndexedEXT",
 "DisableVertexAttribArray",
 "DisableVertexAttribArrayARB",
+"Disablei",
 "DispatchCompute",
 "DispatchComputeIndirect",
 "DrawArrays",
@@ -696,10 +696,10 @@ functions = [
 "EdgeFlagv",
 "Enable",
 "EnableClientState",
-"Enablei",
 "EnableIndexedEXT",
 "EnableVertexAttribArray",
 "EnableVertexAttribArrayARB",
+"Enablei",
 "End",
 "EndConditionalRender",
 "EndConditionalRenderNV",
@@ -725,6 +725,8 @@ functions = [
 "Finish",
 "Flush",
 "FlushMappedBufferRange",
+"FogCoordPointer",
+"FogCoordPointerEXT",
 "FogCoordd",
 "FogCoorddEXT",
 "FogCoorddv",
@@ -733,8 +735,6 @@ functions = [
 "FogCoordfEXT",
 "FogCoordfv",
 "FogCoordfvEXT",
-"FogCoordPointer",
-"FogCoordPointerEXT",
 "Fogf",
 "Fogfv",
 "Fogi",
@@ -761,8 +761,6 @@ functions = [
 "Frustumx",
 "GenBuffers",
 "GenBuffersARB",
-"GenerateMipmap",
-"GenerateMipmapEXT",
 "GenFramebuffers",
 "GenFramebuffersEXT",
 "GenLists",
@@ -777,13 +775,15 @@ functions = [
 "GenTexturesEXT",
 "GenTransformFeedbacks",
 "GenVertexArrays",
+"GenerateMipmap",
+"GenerateMipmapEXT",
 "GetActiveAtomicCounterBufferiv",
 "GetActiveAttrib",
 "GetActiveAttribARB",
 "GetActiveUniform",
 "GetActiveUniformARB",
-"GetActiveUniformBlockiv",
 "GetActiveUniformBlockName",
+"GetActiveUniformBlockiv",
 "GetActiveUniformName",
 "GetActiveUniformsiv",
 "GetAttachedObjectsARB",
@@ -849,24 +849,6 @@ functions = [
 "GetMinmaxParameterfv",
 "GetMinmaxParameteriv",
 "GetMultisamplefv",
-"GetnColorTableARB",
-"GetnCompressedTexImageARB",
-"GetnConvolutionFilterARB",
-"GetnHistogramARB",
-"GetnMapdvARB",
-"GetnMapfvARB",
-"GetnMapivARB",
-"GetnMinmaxARB",
-"GetnPixelMapfvARB",
-"GetnPixelMapuivARB",
-"GetnPixelMapusvARB",
-"GetnPolygonStippleARB",
-"GetnSeparableFilterARB",
-"GetnTexImageARB",
-"GetnUniformdvARB",
-"GetnUniformfvARB",
-"GetnUniformivARB",
-"GetnUniformuivAR

Re: [Mesa-dev] [PATCH 3/3] mapi: export all GLES 3.2 functions in libGLESv2.so

2016-09-22 Thread Dylan Baker
Quoting Ilia Mirkin (2016-09-22 11:57:14)
> 2016-09-22 14:53 GMT-04:00 Dylan Baker :
> > See commit 5921f372c89a68fac6ddefc009442721d9df4db2 for the rational of
> > this commit.
> >
> > Signed-off-by: Dylan Baker 
> > ---
> >  src/mapi/glapi/gen/static_data.py | 16 
> >  1 file changed, 16 insertions(+)
> >
> > diff --git a/src/mapi/glapi/gen/static_data.py 
> > b/src/mapi/glapi/gen/static_data.py
> > index bb11c1d..fa63ab5 100644
> > --- a/src/mapi/glapi/gen/static_data.py
> > +++ b/src/mapi/glapi/gen/static_data.py
> > @@ -484,17 +484,22 @@ functions = [
> >  "BindVertexBuffer",
> >  "BindVertexBuffers",
> >  "Bitmap",
> > +"BlendBarrier",
> >  "BlendColor",
> >  "BlendColorEXT",
> >  "BlendEquation",
> >  "BlendEquationEXT",
> >  "BlendEquationSeparate",
> > +"BlendEquationSeparatei",
> >  "BlendEquationSeparateiARB",
> > +"BlendEquationi",
> >  "BlendEquationiARB",
> >  "BlendFunc",
> >  "BlendFuncSeparate",
> >  "BlendFuncSeparateEXT",
> > +"BlendFuncSeparatei",
> >  "BlendFuncSeparateiARB",
> > +"BlendFunci",
> >  "BlendFunciARB",
> >  "BlitFramebuffer",
> >  "BufferData",
> > @@ -825,6 +830,7 @@ functions = [
> >  "GetFramebufferAttachmentParameteriv",
> >  "GetFramebufferAttachmentParameterivEXT",
> >  "GetFramebufferParameteriv",
> > +"GetGraphicsResetStatus",
> >  "GetGraphicsResetStatusARB",
> >  "GetHandleARB",
> >  "GetHistogram",
> > @@ -887,6 +893,7 @@ functions = [
> >  "GetSamplerParameterIiv",
> >  "GetSamplerParameterIuiv",
> >  "GetSamplerParameterfv",
> > +"GetSamplerParameteri",
> >  "GetSamplerParameteriv",
> >  "GetSeparableFilter",
> >  "GetShaderInfoLog",
> > @@ -951,8 +958,11 @@ functions = [
> >  "GetnSeparableFilterARB",
> >  "GetnTexImageARB",
> >  "GetnUniformdvARB",
> > +"GetnUniformfv",
> >  "GetnUniformfvARB",
> > +"GetnUniformiv",
> >  "GetnUniformivARB",
> > +"GetnUniformuiv",
> >  "GetnUniformuivARB",
> >  "Hint",
> >  "Histogram",
> > @@ -1160,6 +1170,7 @@ functions = [
> >  "Orthof",
> >  "Orthox",
> >  "PassThrough",
> > +"PatchParameteri"
> >  "PauseTransformFeedback",
> >  "PixelMapfv",
> >  "PixelMapuiv",
> > @@ -1191,6 +1202,7 @@ functions = [
> >  "PopDebugGroup",
> >  "PopMatrix",
> >  "PopName",
> > +"PrimitiveBoundingBox",
> >  "PrimitiveRestartIndex",
> >  "PrimitiveRestartIndexNV",
> >  "PrimitiveRestartNV",
> > @@ -1274,6 +1286,7 @@ functions = [
> >  "RasterPos4sv",
> >  "ReadBuffer",
> >  "ReadPixels",
> > +"ReadnPixels",
> >  "ReadnPixelsARB",
> >  "Rectd",
> >  "Rectdv",
> > @@ -1305,6 +1318,7 @@ functions = [
> >  "SamplerParameterfv",
> >  "SamplerParameteri",
> >  "SamplerParameteriv",
> > +"SamplerParameterIiv",
> >  "Scaled",
> >  "Scalef",
> >  "Scalex",
> > @@ -1426,6 +1440,7 @@ functions = [
> >  "TexParameterIiv",
> >  "TexParameterIivEXT",
> >  "TexParameterIuiv",
> > +"TexParameterIuiv",
> >  "TexParameterIuivEXT",
> >  "TexParameterf",
> >  "TexParameterfv",
> > @@ -1442,6 +1457,7 @@ functions = [
> >  "TexSubImage2D",
> >  "TexSubImage3D",
> >  "TexSubImage3DEXT",
> > +"TexbufferRange",
> 
> TexBufferRange
> 
> [would probably be good to change whatever processes this array to
> warn about typos like this...]

That would be a good call. I'll see how hard it is to do.

> 
> >  "TextureBarrierNV",
> >  "TextureStorage1DEXT",
> >  "TextureStorage2DEXT",
> > --
> > 2.10.0
> >
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev


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


[Mesa-dev] [PATCH v2 1/3] mapi: retab static_data.py to be consistent

2016-09-22 Thread Dylan Baker
This file currently uses a mixture of 3 and 4 space indent. I have
changed it all to 4 space indent, matching the settings in
$ROOT/.editorconfig.

Signed-off-by: Dylan Baker 
---
 src/mapi/glapi/gen/static_data.py | 2570 ++---
 1 file changed, 1285 insertions(+), 1285 deletions(-)

diff --git a/src/mapi/glapi/gen/static_data.py 
b/src/mapi/glapi/gen/static_data.py
index b25dab1..396f941 100644
--- a/src/mapi/glapi/gen/static_data.py
+++ b/src/mapi/glapi/gen/static_data.py
@@ -436,1291 +436,1291 @@ offsets = {
 }
 
 functions = [
-   "Accum",
-   "ActiveShaderProgram",
-   "ActiveTexture",
-   "ActiveTextureARB",
-   "AlphaFunc",
-   "AlphaFuncx",
-   "AreTexturesResident",
-   "AreTexturesResidentEXT",
-   "ArrayElement",
-   "ArrayElementEXT",
-   "AttachObjectARB",
-   "AttachShader",
-   "Begin",
-   "BeginConditionalRender",
-   "BeginConditionalRenderNV",
-   "BeginQuery",
-   "BeginQueryARB",
-   "BeginQueryIndexed",
-   "BeginTransformFeedback",
-   "BindAttribLocation",
-   "BindAttribLocationARB",
-   "BindBuffer",
-   "BindBufferARB",
-   "BindBufferBase",
-   "BindBufferRange",
-   "BindBuffersBase",
-   "BindBuffersRange",
-   "BindFragDataLocation",
-   "BindFragDataLocationEXT",
-   "BindFragDataLocationIndexed",
-   "BindFramebuffer",
-   "BindFramebufferEXT",
-   "BindImageTexture",
-   "BindImageTextures",
-   "BindProgramARB",
-   "BindProgramPipeline",
-   "BindRenderbuffer",
-   "BindRenderbufferEXT",
-   "BindSampler",
-   "BindSamplers",
-   "BindTexture",
-   "BindTextureEXT",
-   "BindTextures",
-   "BindTransformFeedback",
-   "BindVertexArray",
-   "BindVertexBuffer",
-   "BindVertexBuffers",
-   "Bitmap",
-   "BlendColor",
-   "BlendColorEXT",
-   "BlendEquation",
-   "BlendEquationEXT",
-   "BlendEquationiARB",
-   "BlendEquationSeparate",
-   "BlendEquationSeparateiARB",
-   "BlendFunc",
-   "BlendFunciARB",
-   "BlendFuncSeparate",
-   "BlendFuncSeparateEXT",
-   "BlendFuncSeparateiARB",
-   "BlitFramebuffer",
-   "BufferData",
-   "BufferDataARB",
-   "BufferStorage",
-   "BufferSubData",
-   "BufferSubDataARB",
-   "CallList",
-   "CallLists",
-   "CheckFramebufferStatus",
-   "CheckFramebufferStatusEXT",
-   "ClampColor",
-   "ClampColorARB",
-   "Clear",
-   "ClearAccum",
-   "ClearBufferData",
-   "ClearBufferfi",
-   "ClearBufferfv",
-   "ClearBufferiv",
-   "ClearBufferSubData",
-   "ClearBufferuiv",
-   "ClearColor",
-   "ClearColorIiEXT",
-   "ClearColorIuiEXT",
-   "ClearColorx",
-   "ClearDepth",
-   "ClearDepthf",
-   "ClearDepthx",
-   "ClearIndex",
-   "ClearStencil",
-   "ClearTexImage",
-   "ClearTexSubImage",
-   "ClientActiveTexture",
-   "ClientActiveTextureARB",
-   "ClientWaitSync",
-   "ClipPlane",
-   "ClipPlanef",
-   "ClipPlanex",
-   "Color3b",
-   "Color3bv",
-   "Color3d",
-   "Color3dv",
-   "Color3f",
-   "Color3fv",
-   "Color3i",
-   "Color3iv",
-   "Color3s",
-   "Color3sv",
-   "Color3ub",
-   "Color3ubv",
-   "Color3ui",
-   "Color3uiv",
-   "Color3us",
-   "Color3usv",
-   "Color4b",
-   "Color4bv",
-   "Color4d",
-   "Color4dv",
-   "Color4f",
-   "Color4fv",
-   "Color4i",
-   "Color4iv",
-   "Color4s",
-   "Color4sv",
-   "Color4ub",
-   "Color4ubv",
-   "Color4ui",
-   "Color4uiv",
-   "Color4us",
-   "Color4usv",
-   "Color4x",
-   "ColorMask",
-   "ColorMaski",
-   "ColorMaskIndexedEXT",
-   "ColorMaterial",
-   "ColorP3ui",
-   "ColorP3uiv",
-   "ColorP4ui",
-   "ColorP4uiv",
-   "ColorPointer",
-   "ColorPointerEXT",
-   "ColorSubTable",
-   "ColorTable",
-   "ColorTableParam

[Mesa-dev] [PATCH v2 2/3] mapi: sort static_data.py functions

2016-09-22 Thread Dylan Baker
Signed-off-by: Dylan Baker 
---
 src/mapi/glapi/gen/static_data.py | 164 +++---
 1 file changed, 82 insertions(+), 82 deletions(-)

diff --git a/src/mapi/glapi/gen/static_data.py 
b/src/mapi/glapi/gen/static_data.py
index 396f941..bb11c1d 100644
--- a/src/mapi/glapi/gen/static_data.py
+++ b/src/mapi/glapi/gen/static_data.py
@@ -488,14 +488,14 @@ functions = [
 "BlendColorEXT",
 "BlendEquation",
 "BlendEquationEXT",
-"BlendEquationiARB",
 "BlendEquationSeparate",
 "BlendEquationSeparateiARB",
+"BlendEquationiARB",
 "BlendFunc",
-"BlendFunciARB",
 "BlendFuncSeparate",
 "BlendFuncSeparateEXT",
 "BlendFuncSeparateiARB",
+"BlendFunciARB",
 "BlitFramebuffer",
 "BufferData",
 "BufferDataARB",
@@ -511,10 +511,10 @@ functions = [
 "Clear",
 "ClearAccum",
 "ClearBufferData",
+"ClearBufferSubData",
 "ClearBufferfi",
 "ClearBufferfv",
 "ClearBufferiv",
-"ClearBufferSubData",
 "ClearBufferuiv",
 "ClearColor",
 "ClearColorIiEXT",
@@ -567,8 +567,8 @@ functions = [
 "Color4usv",
 "Color4x",
 "ColorMask",
-"ColorMaski",
 "ColorMaskIndexedEXT",
+"ColorMaski",
 "ColorMaterial",
 "ColorP3ui",
 "ColorP3uiv",
@@ -649,17 +649,17 @@ functions = [
 "DepthMask",
 "DepthRange",
 "DepthRangeArrayv",
-"DepthRangef",
 "DepthRangeIndexed",
+"DepthRangef",
 "DepthRangex",
 "DetachObjectARB",
 "DetachShader",
 "Disable",
 "DisableClientState",
-"Disablei",
 "DisableIndexedEXT",
 "DisableVertexAttribArray",
 "DisableVertexAttribArrayARB",
+"Disablei",
 "DispatchCompute",
 "DispatchComputeIndirect",
 "DrawArrays",
@@ -696,10 +696,10 @@ functions = [
 "EdgeFlagv",
 "Enable",
 "EnableClientState",
-"Enablei",
 "EnableIndexedEXT",
 "EnableVertexAttribArray",
 "EnableVertexAttribArrayARB",
+"Enablei",
 "End",
 "EndConditionalRender",
 "EndConditionalRenderNV",
@@ -725,6 +725,8 @@ functions = [
 "Finish",
 "Flush",
 "FlushMappedBufferRange",
+"FogCoordPointer",
+"FogCoordPointerEXT",
 "FogCoordd",
 "FogCoorddEXT",
 "FogCoorddv",
@@ -733,8 +735,6 @@ functions = [
 "FogCoordfEXT",
 "FogCoordfv",
 "FogCoordfvEXT",
-"FogCoordPointer",
-"FogCoordPointerEXT",
 "Fogf",
 "Fogfv",
 "Fogi",
@@ -761,8 +761,6 @@ functions = [
 "Frustumx",
 "GenBuffers",
 "GenBuffersARB",
-"GenerateMipmap",
-"GenerateMipmapEXT",
 "GenFramebuffers",
 "GenFramebuffersEXT",
 "GenLists",
@@ -777,13 +775,15 @@ functions = [
 "GenTexturesEXT",
 "GenTransformFeedbacks",
 "GenVertexArrays",
+"GenerateMipmap",
+"GenerateMipmapEXT",
 "GetActiveAtomicCounterBufferiv",
 "GetActiveAttrib",
 "GetActiveAttribARB",
 "GetActiveUniform",
 "GetActiveUniformARB",
-"GetActiveUniformBlockiv",
 "GetActiveUniformBlockName",
+"GetActiveUniformBlockiv",
 "GetActiveUniformName",
 "GetActiveUniformsiv",
 "GetAttachedObjectsARB",
@@ -849,24 +849,6 @@ functions = [
 "GetMinmaxParameterfv",
 "GetMinmaxParameteriv",
 "GetMultisamplefv",
-"GetnColorTableARB",
-"GetnCompressedTexImageARB",
-"GetnConvolutionFilterARB",
-"GetnHistogramARB",
-"GetnMapdvARB",
-"GetnMapfvARB",
-"GetnMapivARB",
-"GetnMinmaxARB",
-"GetnPixelMapfvARB",
-"GetnPixelMapuivARB",
-"GetnPixelMapusvARB",
-"GetnPolygonStippleARB",
-"GetnSeparableFilterARB",
-"GetnTexImageARB",
-"GetnUniformdvARB",
-"GetnUniformfvARB",
-"GetnUniformivARB",
-"GetnUniformuivAR

[Mesa-dev] [PATCH v2 3/3] mapi: export all GLES 3.2 functions in libGLESv2.so

2016-09-22 Thread Dylan Baker
See commit 5921f372c89a68fac6ddefc009442721d9df4db2 for the rational of
this commit.

Signed-off-by: Dylan Baker 
---

v2: - fix TexBufferRange typo (Ilia)
- Remove duplicate TexParameterIuiv

 src/mapi/glapi/gen/static_data.py | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/src/mapi/glapi/gen/static_data.py 
b/src/mapi/glapi/gen/static_data.py
index bb11c1d..e355a95 100644
--- a/src/mapi/glapi/gen/static_data.py
+++ b/src/mapi/glapi/gen/static_data.py
@@ -484,17 +484,22 @@ functions = [
 "BindVertexBuffer",
 "BindVertexBuffers",
 "Bitmap",
+"BlendBarrier",
 "BlendColor",
 "BlendColorEXT",
 "BlendEquation",
 "BlendEquationEXT",
 "BlendEquationSeparate",
+"BlendEquationSeparatei",
 "BlendEquationSeparateiARB",
+"BlendEquationi",
 "BlendEquationiARB",
 "BlendFunc",
 "BlendFuncSeparate",
 "BlendFuncSeparateEXT",
+"BlendFuncSeparatei",
 "BlendFuncSeparateiARB",
+"BlendFunci",
 "BlendFunciARB",
 "BlitFramebuffer",
 "BufferData",
@@ -825,6 +830,7 @@ functions = [
 "GetFramebufferAttachmentParameteriv",
 "GetFramebufferAttachmentParameterivEXT",
 "GetFramebufferParameteriv",
+"GetGraphicsResetStatus",
 "GetGraphicsResetStatusARB",
 "GetHandleARB",
 "GetHistogram",
@@ -887,6 +893,7 @@ functions = [
 "GetSamplerParameterIiv",
 "GetSamplerParameterIuiv",
 "GetSamplerParameterfv",
+"GetSamplerParameteri",
 "GetSamplerParameteriv",
 "GetSeparableFilter",
 "GetShaderInfoLog",
@@ -951,8 +958,11 @@ functions = [
 "GetnSeparableFilterARB",
 "GetnTexImageARB",
 "GetnUniformdvARB",
+"GetnUniformfv",
 "GetnUniformfvARB",
+"GetnUniformiv",
 "GetnUniformivARB",
+"GetnUniformuiv",
 "GetnUniformuivARB",
 "Hint",
 "Histogram",
@@ -1160,6 +1170,7 @@ functions = [
 "Orthof",
 "Orthox",
 "PassThrough",
+"PatchParameteri"
 "PauseTransformFeedback",
 "PixelMapfv",
 "PixelMapuiv",
@@ -1191,6 +1202,7 @@ functions = [
 "PopDebugGroup",
 "PopMatrix",
 "PopName",
+"PrimitiveBoundingBox",
 "PrimitiveRestartIndex",
 "PrimitiveRestartIndexNV",
 "PrimitiveRestartNV",
@@ -1274,6 +1286,7 @@ functions = [
 "RasterPos4sv",
 "ReadBuffer",
 "ReadPixels",
+"ReadnPixels",
 "ReadnPixelsARB",
 "Rectd",
 "Rectdv",
@@ -1305,6 +1318,7 @@ functions = [
 "SamplerParameterfv",
 "SamplerParameteri",
 "SamplerParameteriv",
+"SamplerParameterIiv",
 "Scaled",
 "Scalef",
 "Scalex",
@@ -1442,6 +1456,7 @@ functions = [
 "TexSubImage2D",
 "TexSubImage3D",
 "TexSubImage3DEXT",
+"TexBufferRange",
 "TextureBarrierNV",
 "TextureStorage1DEXT",
 "TextureStorage2DEXT",
-- 
2.10.0

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


  1   2   3   4   5   6   7   8   9   10   >