glapi: add KHR_no_error support to dispatch table generation
authorTimothy Arceri <tarceri@itsqueeze.com>
Thu, 27 Apr 2017 03:32:43 +0000 (13:32 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Thu, 4 May 2017 01:35:36 +0000 (11:35 +1000)
This will allows us to create no error versions of functions
noted by a _no_error suffix. We also need to set a no_error
attribute equal to "true" in the xml.

V3: stop the no_error attribute being overwritten when functions
    alias another.
V2: tidy up suggested by Nicolai.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/mapi/glapi/gen/gl_XML.py
src/mapi/glapi/gen/gl_genexec.py

index c688906e8845314c84c6831b064302dc09ef1744..a5320e90a1ded5e6ec1540b9a7277f041b3a9923 100644 (file)
@@ -606,6 +606,7 @@ class gl_function( gl_item ):
         self.exec_flavor = 'mesa'
         self.desktop = True
         self.deprecated = None
+        self.has_no_error_variant = False
 
         # self.entry_point_api_map[name][api] is a decimal value
         # indicating the earliest version of the given API in which
@@ -676,6 +677,11 @@ class gl_function( gl_item ):
         if not is_attr_true(element, 'desktop', 'true'):
             self.desktop = False
 
+        if self.has_no_error_variant or is_attr_true(element, 'no_error'):
+            self.has_no_error_variant = True
+        else:
+            self.has_no_error_variant = False
+
         if alias:
             true_name = alias
         else:
index 3a75419a75285e1bee5839158b483cbb0c1ec136..37b1cc6be0d60f4fdd94d553504bb300824a33c1 100644 (file)
@@ -232,8 +232,16 @@ class PrintCode(gl_XML.gl_print_base):
                 # This function is not implemented, or is dispatched
                 # dynamically.
                 continue
-            settings_by_condition[condition].append(
-                'SET_{0}(exec, {1}{0});'.format(f.name, prefix, f.name))
+            if f.has_no_error_variant:
+                no_error_condition = '_mesa_is_no_error_enabled(ctx) && ({0})'.format(condition)
+                error_condition = '!_mesa_is_no_error_enabled(ctx) && ({0})'.format(condition)
+                settings_by_condition[no_error_condition].append(
+                    'SET_{0}(exec, {1}{0}_no_error);'.format(f.name, prefix, f.name))
+                settings_by_condition[error_condition].append(
+                    'SET_{0}(exec, {1}{0});'.format(f.name, prefix, f.name))
+            else:
+                settings_by_condition[condition].append(
+                    'SET_{0}(exec, {1}{0});'.format(f.name, prefix, f.name))
         # Print out an if statement for each unique condition, with
         # the SET_* calls nested inside it.
         for condition in sorted(settings_by_condition.keys()):