Mesa (master): anv/entrypoints: Rework #if guards

Jason Ekstrand jekstrand at kemper.freedesktop.org
Fri Jun 10 20:21:25 UTC 2016


Module: Mesa
Branch: master
Commit: 8d37556ec9d7fbbffc5497388a52998ae4fe75de
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d37556ec9d7fbbffc5497388a52998ae4fe75de

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Fri Jun 10 12:42:52 2016 -0700

anv/entrypoints: Rework #if guards

This reworks the #if guards a bit.  When Emil originally wrote them, he
just guarded everything.  However, part of what anv_entrypoints_gen.py
generates is a hash table for looking up entrypoints based on their name.
This table *cannot* get out of sync between C and python regardless of
preprocessor flags.  In order to prevent this, this commit makes us use
void pointers in the dispatch table for those entrypoints which aren't
available.  This means that the dispatch table size and entry order is
constant and it should never get out-of-sync with the python.

Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
Acked-by: Emil Velikov <emil.velikov at collabora.com>
Cc: "12.0" <mesa-stable at lists.freedesktop.org>

---

 src/intel/vulkan/anv_entrypoints_gen.py | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py b/src/intel/vulkan/anv_entrypoints_gen.py
index 46bc553..2896174 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -112,9 +112,15 @@ if opt_header:
     print "      struct {"
 
     for type, name, args, num, h in entrypoints:
-        print_guard_start(name)
-        print "         PFN_vk{0} {0};".format(name)
-        print_guard_end(name)
+        guard = get_platform_guard_macro(name)
+        if guard is not None:
+            print "#ifdef {0}".format(guard)
+            print "         PFN_vk{0} {0};".format(name)
+            print "#else"
+            print "         void *{0};".format(name)
+            print "#endif"
+        else:
+            print "         PFN_vk{0} {0};".format(name)
     print "      };\n"
     print "   };\n"
     print "};\n"
@@ -176,11 +182,9 @@ static const char strings[] ="""
 offsets = []
 i = 0;
 for type, name, args, num, h in entrypoints:
-    print_guard_start(name)
     print "   \"vk%s\\0\"" % name
     offsets.append(i)
     i += 2 + len(name) + 1
-    print_guard_end(name)
 print """   ;
 
 /* Weak aliases for all potential validate functions. These will resolve to
@@ -194,9 +198,7 @@ print """   ;
 
 print "\nstatic const struct anv_entrypoint entrypoints[] = {"
 for type, name, args, num, h in entrypoints:
-    print_guard_start(name)
     print "   { %5d, 0x%08x }," % (offsets[num], h)
-    print_guard_end(name)
 print "};\n"
 
 for layer in [ "anv", "validate", "gen7", "gen75", "gen8", "gen9" ]:




More information about the mesa-commit mailing list