glapi: replace dispatch.h inline functions with macros for faster compilation
authorMarek Olšák <marek.olsak@amd.com>
Mon, 29 Nov 2021 12:14:31 +0000 (07:14 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 14 Dec 2021 17:00:11 +0000 (12:00 -0500)
A change in dispatch.h now takes 11.7% less user+sys time to compile.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14000>

src/mapi/glapi/gen/gl_table.py

index 659e177..d1a0675 100644 (file)
@@ -164,16 +164,13 @@ class PrintRemapTable(gl_XML.gl_print_base):
             arg_string = gl_XML.create_parameter_string(f.parameters, 0)
 
             print('typedef %s (GLAPIENTRYP _glptr_%s)(%s);' % (f.return_type, f.name, arg_string))
-            print('#define CALL_%s(disp, parameters) \\' % (f.name))
-            print('    (* GET_%s(disp)) parameters' % (f.name))
-            print('static inline _glptr_%s GET_%s(struct _glapi_table *disp) {' % (f.name, f.name))
-            print('   return (_glptr_%s) (GET_by_offset(disp, _gloffset_%s));' % (f.name, f.name))
-            print('}')
-            print()
-            print('static inline void SET_%s(struct _glapi_table *disp, %s (GLAPIENTRYP fn)(%s)) {' % (f.name, f.return_type, arg_string))
-            print('   SET_by_offset(disp, _gloffset_%s, fn);' % (f.name))
-            print('}')
-            print()
+            print('#define CALL_{0}(disp, parameters) (* GET_{0}(disp)) parameters'.format(f.name))
+            print('#define GET_{0}(disp) ((_glptr_{0})(GET_by_offset((disp), _gloffset_{0})))'.format(f.name))
+            print("""#define SET_{0}(disp, func) do {{ \\
+   {1} (GLAPIENTRYP fn)({2}) = func; \\
+   SET_by_offset(disp, _gloffset_{0}, fn); \\
+}} while (0)
+""".format(f.name, f.return_type, arg_string))
 
         return