On 5 March 2012 23:16, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net">eric@anholt.net</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Fri, 2 Mar 2012 15:40:28 -0800, Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>> wrote:<br>
> This is the first in a series of patches that replaces GLEW with a new<br>
> mechanism called "piglit-dispatch". This patch adds the script that<br>
> will be used by piglit-dispatch to build its generated code.<br>
><br>
> The input to the code generation script is a set of XML files<br>
> describing the GL API, in the same form as used by Mesa. For the time<br>
> being, these files can be found at<br>
> git://<a href="http://github.com/stereotype441/glapi.git" target="_blank">github.com/stereotype441/glapi.git</a>.<br>
<br>
</div>From talking today, it sounds like investigating glspec as a source for<br>
this instead of the XML is very promising. But I'll review it anyway.<br>
<br>
I have to say: This was really nice code to read. I'm usually not a fan<br>
of python (I tend to find python code impenetrable), but I feel like I<br>
understand what this code is doing, and I understand python in general<br>
better as a result.<br></blockquote><div><br>Thanks :)<br> <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
> +# Generate a top-of-file comment cautioning that the file is<br>
> +# auto-generated and should not be manually edited.<br>
> +def generated_boilerplate():<br>
> + return """\<br>
> +/**<br>
> + * This file was automatically generated by the script {0!r}.<br>
> + *<br>
> + * DO NOT EDIT!<br>
> + *<br>
> + * To regenerate, run "make piglit_dispatch_gen" from the toplevel directory.<br>
> + */<br>
> +""".format(os.path.basename(sys.argv[0]))<br>
<br>
</div>Even though the files are generated, and they're describing an API in a<br>
way that may or may not be copyrightable, it's probably a good idea to<br>
put a license on it so people know they can at least use it in the usual<br>
permissive way.<br></blockquote><div><br>Yeah, that's a good point. I'll put the usual Intel copyright notice in.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
> + # Generate a list of Function objects representing all functions<br>
> + # in the API. The resulting list is sorted by function name.<br>
> + def compute_unique_functions(self):<br>
> + functions = []<br>
> + names_used = set()<br>
> + for f in self.__functions:<br>
> + if <a href="http://f.name" target="_blank">f.name</a> in names_used:<br>
> + continue<br>
> + functions.append(f)<br>
> + functions.sort(key = lambda f: <a href="http://f.name" target="_blank">f.name</a>)<br>
> + return functions<br>
<br>
</div>I was surprised to see this function -- I would have assumed that the<br>
parsed Api contained uniquely-named Functions in the first place. Is it<br>
to do with parsing GL/GLES variants of XML or something? Are those<br>
all exact matches in terms of signature?<br>
<br>
<br>
</blockquote></div><br>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.<br>