[Mesa-dev] [PATCH] radv: add back ability to gen some entrypoints from optional headers

Dave Airlie airlied at gmail.com
Tue Jan 24 00:51:12 UTC 2017


From: Dave Airlie <airlied at redhat.com>

bf8e1f9e7 radv: generate entrypoints from vk.xml
ripped out the ability to add extra header files (and writing
extra xml files is a bit messier). For some non-public
development or even developing future EXT/MESA extensions,
it would be nice to allow this option before things land in
the registry.

This reintroduces this functionality on top of the registry.

I think anv might also be interested in having this work.

Cc: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/amd/vulkan/Makefile.am             | 15 ++++++-------
 src/amd/vulkan/radv_entrypoints_gen.py | 39 ++++++++++++++++++++++++++++++++--
 2 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/src/amd/vulkan/Makefile.am b/src/amd/vulkan/Makefile.am
index b47109b..28b9f6a 100644
--- a/src/amd/vulkan/Makefile.am
+++ b/src/amd/vulkan/Makefile.am
@@ -21,11 +21,10 @@
 
 include Makefile.sources
 
-vulkan_includedir = $(includedir)/vulkan
+vulkan_extra_includedir = $(includedir)/vulkan
 
-vulkan_include_HEADERS = \
-	$(top_srcdir)/include/vulkan/vk_platform.h \
-	$(top_srcdir)/include/vulkan/vulkan.h
+# Unused in-tree but used for out of tree development (KHR internal or otherwise)
+vulkan_extra_include_HEADERS =
 
 lib_LTLIBRARIES = libvulkan_radeon.la
 
@@ -113,13 +112,13 @@ libvulkan_radeon_la_SOURCES = $(VULKAN_GEM_FILES)
 
 vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 
-radv_entrypoints.h : radv_entrypoints_gen.py $(vulkan_api_xml)
+radv_entrypoints.h : radv_entrypoints_gen.py $(vulkan_api_xml) $(vulkan_extra_include_HEADERS)
 	$(AM_V_GEN) cat $(vulkan_api_xml) |\
-	$(PYTHON2) $(srcdir)/radv_entrypoints_gen.py header > $@
+	$(PYTHON2) $(srcdir)/radv_entrypoints_gen.py header $(vulkan_extra_include_HEADERS) > $@
 
-radv_entrypoints.c : radv_entrypoints_gen.py $(vulkan_api_xml)
+radv_entrypoints.c : radv_entrypoints_gen.py $(vulkan_api_xml) $(vulkan_extra_include_HEADERS)
 	$(AM_V_GEN) cat $(vulkan_api_xml) |\
-	$(PYTHON2) $(srcdir)/radv_entrypoints_gen.py code > $@
+	$(PYTHON2) $(srcdir)/radv_entrypoints_gen.py code $(vulkan_extra_include_HEADERS) > $@
 
 vk_format_table.c: vk_format_table.py \
 		   vk_format_parse.py \
diff --git a/src/amd/vulkan/radv_entrypoints_gen.py b/src/amd/vulkan/radv_entrypoints_gen.py
index adab91a..a4e72a7 100644
--- a/src/amd/vulkan/radv_entrypoints_gen.py
+++ b/src/amd/vulkan/radv_entrypoints_gen.py
@@ -24,6 +24,13 @@
 
 import sys
 import xml.etree.ElementTree as ET
+import fileinput
+import re
+
+# Each function typedef in the vulkan.h header is all on one line and matches
+# this regepx. We hope that won't change.
+
+p = re.compile('typedef ([^ ]*) *\((?:VKAPI_PTR)? *\*PFN_vk([^(]*)\)(.*);')
 
 # We generate a static hash table for entry point lookup
 # (vkGetProcAddress). We use a linear congruential generator for our hash
@@ -58,10 +65,10 @@ opt_code = False
 
 if (sys.argv[1] == "header"):
     opt_header = True
-    sys.argv.pop()
+    sys.argv.pop(1)
 elif (sys.argv[1] == "code"):
     opt_code = True
-    sys.argv.pop()
+    sys.argv.pop(1)
 
 # Extract the entry points from the registry
 def get_entrypoints(doc, entrypoints_to_defines):
@@ -92,9 +99,37 @@ def get_entrypoints_defines(doc):
             entrypoints_to_defines[fullname] = define
     return entrypoints_to_defines
 
+def get_platform_guard_macro(name):
+    if "Xlib" in name:
+        return "VK_USE_PLATFORM_XLIB_KHR"
+    elif "Xcb" in name:
+        return "VK_USE_PLATFORM_XCB_KHR"
+    elif "Wayland" in name:
+        return "VK_USE_PLATFORM_WAYLAND_KHR"
+    elif "Mir" in name:
+        return "VK_USE_PLATFORM_MIR_KHR"
+    elif "Android" in name:
+        return "VK_USE_PLATFORM_ANDROID_KHR"
+    elif "Win32" in name:
+        return "VK_USE_PLATFORM_WIN32_KHR"
+    else:
+        return None
+
 doc = ET.parse(sys.stdin)
 entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
 
+# See if we got any other files
+if (len(sys.argv) > 1):
+    i = 0
+    for line in fileinput.input(sys.argv[1:]):
+        m = p.match(line)
+        if (m):
+            if m.group(2) == 'VoidFunction':
+                continue
+            fullname = "vk" + m.group(2)
+            entrypoints.append((m.group(1), m.group(2), m.group(3).strip("()"), i, hash(fullname), get_platform_guard_macro(fullname)))
+            i = i + 1
+
 # For outputting entrypoints.h we generate a radv_EntryPoint() prototype
 # per entry point.
 
-- 
2.9.3



More information about the mesa-dev mailing list