[Mesa-dev] [PATCH V3] glapi: add KHR_no_error support to dispatch table generation

Timothy Arceri tarceri at itsqueeze.com
Wed May 3 04:25:47 UTC 2017


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.
---
 src/mapi/glapi/gen/gl_XML.py     |  6 ++++++
 src/mapi/glapi/gen/gl_genexec.py | 12 ++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
index c688906..a5320e9 100644
--- a/src/mapi/glapi/gen/gl_XML.py
+++ b/src/mapi/glapi/gen/gl_XML.py
@@ -599,20 +599,21 @@ class gl_function( gl_item ):
 
         self.entry_points = []
         self.return_type = "void"
         self.parameters = []
         self.offset = -1
         self.initialized = 0
         self.images = []
         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
         # each entry point exists.  Every entry point is included in
         # the first level of the map; the second level of the map only
         # lists APIs which contain the entry point in at least one
         # version.  For example,
         # self.entry_point_api_map['ClipPlanex'] == { 'es1':
         # Decimal('1.1') }.
         self.entry_point_api_map = {}
@@ -669,20 +670,25 @@ class gl_function( gl_item ):
         if exec_flavor:
             self.exec_flavor = exec_flavor
 
         deprecated = element.get('deprecated', 'none')
         if deprecated != 'none':
             self.deprecated = Decimal(deprecated)
 
         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:
             true_name = name
 
             # Only try to set the offset when a non-alias entry-point
             # is being processed.
 
             if name in static_data.offsets:
                 self.offset = static_data.offsets[name]
diff --git a/src/mapi/glapi/gen/gl_genexec.py b/src/mapi/glapi/gen/gl_genexec.py
index 3a75419..37b1cc6 100644
--- a/src/mapi/glapi/gen/gl_genexec.py
+++ b/src/mapi/glapi/gen/gl_genexec.py
@@ -225,22 +225,30 @@ class PrintCode(gl_XML.gl_print_base):
 
             if not condition_parts:
                 # This function does not exist in any API.
                 continue
             condition = ' || '.join(condition_parts)
             prefix = exec_flavor_map[f.exec_flavor]
             if prefix is None:
                 # 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()):
             print '   if ({0}) {{'.format(condition)
             for setting in sorted(settings_by_condition[condition]):
                 print '      {0}'.format(setting)
             print '   }'
 
 
 def _parser():
-- 
2.9.3



More information about the mesa-dev mailing list