Mesa (master): radv: add code that checks if the extension table is sorted correctly

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 22 13:45:37 UTC 2020


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

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Mon Dec 21 22:53:01 2020 +0100

radv: add code that checks if the extension table is sorted correctly

Ported from ANV.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8190>

---

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

diff --git a/src/amd/vulkan/radv_extensions.py b/src/amd/vulkan/radv_extensions.py
index 5705dd5ec15..da077792296 100644
--- a/src/amd/vulkan/radv_extensions.py
+++ b/src/amd/vulkan/radv_extensions.py
@@ -193,6 +193,26 @@ EXTENSIONS = [
     Extension('VK_VALVE_mutable_descriptor_type',         1, True),
 ]
 
+# Sort the extension list the way we expect: KHR, then EXT, then vendors
+# alphabetically. For digits, read them as a whole number sort that.
+# eg.: VK_KHR_8bit_storage < VK_KHR_16bit_storage < VK_EXT_acquire_xlib_display
+def extension_order(ext):
+    order = []
+    for substring in re.split('(KHR|EXT|[0-9]+)', ext.name):
+        if substring == 'KHR':
+            order.append(1)
+        if substring == 'EXT':
+            order.append(2)
+        elif substring.isdigit():
+            order.append(int(substring))
+        else:
+            order.append(substring)
+    return order
+for i in range(len(EXTENSIONS) - 1):
+    if extension_order(EXTENSIONS[i + 1]) < extension_order(EXTENSIONS[i]):
+        print(EXTENSIONS[i + 1].name + ' should come before ' + EXTENSIONS[i].name)
+        exit(1)
+
 MAX_API_VERSION = VkVersion('0.0.0')
 for version in API_VERSIONS:
     version.version = VkVersion(version.version)



More information about the mesa-commit mailing list