Mesa (master): radv: add device->instance extension dependencies

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jan 27 12:53:46 UTC 2019


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

Author: Niklas Haas <git at haasn.xyz>
Date:   Fri Nov 23 00:32:28 2018 +0100

radv: add device->instance extension dependencies

>From the vulkan spec 33.3 "Extension Dependencies":

"Any device extension that has an instance extension dependency that is
not enabled by vkCreateInstance is considered to be unsupported, hence
it must not be returned by vkEnumerateDeviceExtensionProperties for any
VkPhysicalDevice child of the instance."

Therefore we need to check whether the instance-level extensions are
actually enabled when deciding to support a device-level extension or
not.

Furthermore, we need to do this for all instance-level extensions of any
(transitive) device-level extension dependency, due to the following
paragraph:

"If an extension is supported (as queried by
vkEnumerateInstanceExtensionProperties or
vkEnumerateDeviceExtensionProperties), then required extensions of that
extension must also be supported for the same instance or physical
device."

Finally, because some of these vulkan extensions may be implicitly
promoted to future vulkan core API versions, we can also satisfy the
dependency if the vulkan API version is high enough.

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

---

 src/amd/vulkan/radv_extensions.py | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/amd/vulkan/radv_extensions.py b/src/amd/vulkan/radv_extensions.py
index 491ed9d94c..eb3743e960 100644
--- a/src/amd/vulkan/radv_extensions.py
+++ b/src/amd/vulkan/radv_extensions.py
@@ -184,6 +184,32 @@ def _init_exts_from_xml(xml):
 
         ext = ext_name_map[ext_name]
         ext.type = ext_elem.attrib['type']
+        ext.promotedto = ext_elem.attrib.get('promotedto', None)
+        try:
+            ext.requires = ext_elem.attrib['requires'].split(',')
+        except KeyError:
+            ext.requires = []
+
+    def extra_deps(ext):
+        if ext.type == 'instance':
+            check = 'instance->enabled_extensions.{}'.format(ext.name[3:])
+            if ext.promotedto is not None:
+                # the xml contains values like VK_VERSION_1_1, but we need to
+                # translate them to VK_API_VERSION_1_1 for the apiVersion check
+                api_ver = ext.promotedto.replace('VK_VER', 'VK_API_VER')
+                check = '({} || instance->apiVersion >= {})'.format(check, api_ver)
+            return set([check])
+
+        deps = set()
+        for dep in ext.requires:
+            deps |= extra_deps(ext_name_map[dep])
+
+        return deps
+
+    for ext in EXTENSIONS:
+        if ext.type == 'device':
+            for dep in extra_deps(ext):
+                ext.enable += ' && ' + dep
 
 _TEMPLATE_H = Template(COPYRIGHT + """
 #ifndef RADV_EXTENSIONS_H
@@ -278,6 +304,7 @@ const struct radv_instance_extension_table radv_supported_instance_extensions =
 void radv_fill_device_extension_table(const struct radv_physical_device *device,
                                       struct radv_device_extension_table* table)
 {
+   const struct radv_instance *instance = device->instance;
 %for ext in device_extensions:
    table->${ext.name[3:]} = ${ext.enable};
 %endfor




More information about the mesa-commit mailing list