On 21 May 2012 11:08, Pauli Nieminen <span dir="ltr"><<a href="mailto:pauli.nieminen@linux.intel.com" target="_blank">pauli.nieminen@linux.intel.com</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">
There is extensions that have been pulled as is into core. Those<br>
extensions only declare extension functions in gl.spec. To allow stub<br>
loader know that required function is supported because of GL version we<br>
need to add core version to the extension functions.<br></blockquote><div><br>Can you explain in more detail why this is necessary? I thought that when an extension is pulled into core, the implementation was required to list that extension in its extension string. So the stub loader should already know that these functions are supported.<br>
</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Signed-off-by: Pauli Nieminen <<a href="mailto:pauli.nieminen@linux.intel.com" target="_blank">pauli.nieminen@linux.intel.com</a>><br>
---<br>
glapi/parse_glspec.py | 34 ++++++++++++++++++++++++++++++++--<br>
1 files changed, 32 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/glapi/parse_glspec.py b/glapi/parse_glspec.py<br>
index f513164..1097e3c 100644<br>
--- a/glapi/parse_glspec.py<br>
+++ b/glapi/parse_glspec.py<br>
@@ -126,6 +126,8 @@ import sys<br>
<br>
GLSPEC_HEADER_REGEXP = re.compile(r'^(\w+)\((.*)\)$')<br>
GLSPEC_ATTRIBUTE_REGEXP = re.compile(r'^\s+(\w+)\s+(.*)$')<br>
+GLSPEC_EXT_VERSION_REGEXP = re.compile(r'^passthru:\s+/\*\sOpenGL\s+([0-9.]+)\s+.*reuses')<br>
+GLSPEC_EXT_REGEXP = re.compile(r'^passthru:\s+/\*\s+(\w+)')<br></blockquote><div><br>I'm concerned about extracting this information out of the "passthru:" comment lines, since they're intended for human consumption, not machine consumption. It looks to me like the same information is present in the "version" field underneath each function declaration--I would prefer to extract the information from there.<br>
</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
GL_VERSION_REGEXP = re.compile('^VERSION_([0-9])_([0-9])(_DEPRECATED)?$')<br>
ENUM_REGEXP = re.compile(r'^\s+(\w+)\s+=\s+(\w+)$')<br>
<br>
@@ -284,6 +286,10 @@ class Api(object):<br>
# 'extension_name': 'GL_ARB_sync' }<br>
self.categories = {}<br>
<br>
+ # Api.core_exts is a dict to map backport extension to GL version<br>
+ # 'GL_ARB_sync': ['3.3']<br>
+ self.core_exts = {}<br>
+<br></blockquote><div><br>Is this intended to represent:<br>(a). only those extensions that were written after version X of GL was created, for the purpose of allowing implementations that don't fully support GL version X to expose a subset of its functionality?<br>
(b). all extensions that are required to be present in a conformant implementation of GL version X?<br><br>Your use of the term "backport extension" makes it sound like it's (a), but the name "core_exts" makes it sound like it's (b). I would recommend changing the comment to clarify what the intent is, as well as to clarify which GL version is being referred to (e.g. "Api.core_exts is a dict to map an extension name to the first GL version in which that extension is required. Extensions that are not required by any version of GL do not appear in this dict.")<br>
<br>Also, it looks like the values in the dict are actually lists of versions. Can you explain what it would mean to have multiple entries in the list?<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
# Convert each line in the <a href="http://gl.tm" target="_blank">gl.tm</a> file into a key/value pair in<br>
# self.type_translation, mapping an abstract type name to a C<br>
# type.<br>
@@ -311,13 +317,29 @@ class Api(object):<br>
# ('Foo', ['bar', 'baz'],<br>
# {'x': ['value1'], 'y': ['value2 other_info', 'value3 more_info']})<br>
@staticmethod<br>
- def group_gl_spec_functions(f):<br>
+ def group_gl_spec_functions(self, f):<br></blockquote><div><br>If we're going to pass self to this function, we might as well just remove the "@staticmethod" annotation so that we can call it like a normal method.<br>
</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
function_name = None<br>
param_names = None<br>
attributes = None<br>
+ version = None<br>
for line in filter_comments(f):<br>
+ m = GLSPEC_EXT_VERSION_REGEXP.match(line)<br>
+ if m:<br>
+ version = m.group(1)<br>
+ continue<br>
+ if version != None:<br>
+ m = GLSPEC_EXT_REGEXP.match(line)<br>
+ if m:<br>
+ ext = m.group(1)<br>
+ ext = 'GL_' + ext<br>
+ if ext in self.core_exts:<br>
+ self.core_exts[ext].append(version)<br>
+ else:<br>
+ self.core_exts[ext] = [version]<br>
+ continue<br>
m = GLSPEC_HEADER_REGEXP.match(line)<br>
if m:<br>
+ version = None<br>
if function_name:<br>
yield function_name, param_names, attributes<br>
function_name = m.group(1)<br></blockquote><div><br>With this change, group_gl_spec_functions() now has two outputs which it returns in completely different ways: one which it outputs via "yield" statements, and one which it pokes into self.core_exts. I would prefer to just change it from a generator function to an ordinary function (that builds up a result in a list and then returns it), that way we can have it return both outputs in the normal way.<br>
</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
@@ -339,7 +361,7 @@ class Api(object):<br>
# Process the data in gl.spec, and populate self.functions,<br>
# self.synonyms, and self.categories based on it.<br>
def read_gl_spec(self, f):<br>
- for name, param_names, attributes in self.group_gl_spec_functions(f):<br>
+ for name, param_names, attributes in self.group_gl_spec_functions(self, f):<br></blockquote><div><br>With "@staticmethod" removed this change shouldn't be needed.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
if name in self.functions:<br>
raise Exception(<br>
'Function {0!r} appears more than once'.format(name))<br>
@@ -415,6 +437,14 @@ class Api(object):<br>
'param_types': param_types,<br>
'category': [category],<br>
}<br>
+ if category in self.core_exts:<br>
+ for ver in self.core_exts[category]:<br>
+ self.functions[name]['category'].append(ver)<br>
+ if ver not in self.categories:<br>
+ self.categories[ver] = {<br>
+ 'kind': 'GL',<br>
+ 'gl_10x_version': int(ver.replace('.',''))<br>
+ }<br></blockquote><div><br>If possible, I would prefer to keep the amount of data munging in parse_glspec.py to a minimum, so that its output is simply a transliteration of the source spec file into a more machine readable form, and have gen_dispatch.py do the interpretation. Would it suit your needs to store the information you want in self.functions[name]['version'] so that it's more similar to the organization of gl.spec?<br>
</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
self.synonyms.add_singleton(name)<br>
for alias in attributes['alias']:<br>
self.synonyms.add_alias(name, alias)<br>
<span><font color="#888888">--<br>
1.7.5.4<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org" target="_blank">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br>