On 5 March 2012 23:16, Eric Anholt <span dir="ltr">&lt;<a href="mailto:eric@anholt.net">eric@anholt.net</a>&gt;</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 &lt;<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>&gt; wrote:<br>
&gt; This is the first in a series of patches that replaces GLEW with a new<br>
&gt; mechanism called &quot;piglit-dispatch&quot;.  This patch adds the script that<br>
&gt; will be used by piglit-dispatch to build its generated code.<br>
&gt;<br>
&gt; The input to the code generation script is a set of XML files<br>
&gt; describing the GL API, in the same form as used by Mesa.  For the time<br>
&gt; being, these files can be found at<br>
&gt; 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&#39;ll review it anyway.<br>
<br>
I have to say: This was really nice code to read.  I&#39;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>
&gt; +# Generate a top-of-file comment cautioning that the file is<br>
&gt; +# auto-generated and should not be manually edited.<br>
&gt; +def generated_boilerplate():<br>
&gt; +    return &quot;&quot;&quot;\<br>
&gt; +/**<br>
&gt; + * This file was automatically generated by the script {0!r}.<br>
&gt; + *<br>
&gt; + * DO NOT EDIT!<br>
&gt; + *<br>
&gt; + * To regenerate, run &quot;make piglit_dispatch_gen&quot; from the toplevel directory.<br>
&gt; + */<br>
&gt; +&quot;&quot;&quot;.format(os.path.basename(sys.argv[0]))<br>
<br>
</div>Even though the files are generated, and they&#39;re describing an API in a<br>
way that may or may not be copyrightable, it&#39;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&#39;s a good point.  I&#39;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>
&gt; +    # Generate a list of Function objects representing all functions<br>
&gt; +    # in the API.  The resulting list is sorted by function name.<br>
&gt; +    def compute_unique_functions(self):<br>
&gt; +     functions = []<br>
&gt; +     names_used = set()<br>
&gt; +     for f in self.__functions:<br>
&gt; +         if <a href="http://f.name" target="_blank">f.name</a> in names_used:<br>
&gt; +             continue<br>
&gt; +         functions.append(f)<br>
&gt; +     functions.sort(key = lambda f: <a href="http://f.name" target="_blank">f.name</a>)<br>
&gt; +     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&#39;t sure whether there were uniquely-named functions in the XML or not.  It turns out that there currently aren&#39;t.  But I expect we&#39;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&#39;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&#39;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&#39;t done a comprehensive search.<br>