[Piglit] [PATCH 10/15] piglit-dispatch: Code generation script

Paul Berry stereotype441 at gmail.com
Tue Mar 6 13:50:27 PST 2012


On 5 March 2012 23:16, Eric Anholt <eric at anholt.net> wrote:

> On Fri,  2 Mar 2012 15:40:28 -0800, Paul Berry <stereotype441 at gmail.com>
> wrote:
> > This is the first in a series of patches that replaces GLEW with a new
> > mechanism called "piglit-dispatch".  This patch adds the script that
> > will be used by piglit-dispatch to build its generated code.
> >
> > The input to the code generation script is a set of XML files
> > describing the GL API, in the same form as used by Mesa.  For the time
> > being, these files can be found at
> > git://github.com/stereotype441/glapi.git.
>
> From talking today, it sounds like investigating glspec as a source for
> this instead of the XML is very promising.  But I'll review it anyway.
>
> I have to say: This was really nice code to read.  I'm usually not a fan
> of python (I tend to find python code impenetrable), but I feel like I
> understand what this code is doing, and I understand python in general
> better as a result.
>

Thanks :)


>
> > +# Generate a top-of-file comment cautioning that the file is
> > +# auto-generated and should not be manually edited.
> > +def generated_boilerplate():
> > +    return """\
> > +/**
> > + * This file was automatically generated by the script {0!r}.
> > + *
> > + * DO NOT EDIT!
> > + *
> > + * To regenerate, run "make piglit_dispatch_gen" from the toplevel
> directory.
> > + */
> > +""".format(os.path.basename(sys.argv[0]))
>
> Even though the files are generated, and they're describing an API in a
> way that may or may not be copyrightable, it's probably a good idea to
> put a license on it so people know they can at least use it in the usual
> permissive way.
>

Yeah, that's a good point.  I'll put the usual Intel copyright notice in.


>
> > +    # Generate a list of Function objects representing all functions
> > +    # in the API.  The resulting list is sorted by function name.
> > +    def compute_unique_functions(self):
> > +     functions = []
> > +     names_used = set()
> > +     for f in self.__functions:
> > +         if f.name in names_used:
> > +             continue
> > +         functions.append(f)
> > +     functions.sort(key = lambda f: f.name)
> > +     return functions
>
> I was surprised to see this function -- I would have assumed that the
> parsed Api contained uniquely-named Functions in the first place.  Is it
> to do with parsing GL/GLES variants of XML or something?  Are those
> all exact matches in terms of signature?
>
>
>
When I wrote this I wasn't sure whether there were uniquely-named functions
in the XML or not.  It turns out that there currently aren't.  But I expect
we'll need to add a few.  For example, the BindBufferBase() function is
defined in OpenGL 3.0 and in ARB_uniform_buffer_object, and it's allowed
for an implementation to provide either OpenGL 3.0,
ARB_uniform_buffer_object¸ or both.  That means that in order for
piglit-dispatch to handle all three possibilities correctly, we'll have to
specify the XML for BindBufferBase() in both the GL 3.0 and
ARB_uniform_buffer_object categories.  I think there are other examples
like this too, but I haven't done a comprehensive search.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20120306/28b6900b/attachment.htm>


More information about the Piglit mailing list