Mesa (main): zink: avoid generating nonsensical code
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Aug 27 19:04:35 UTC 2021
Module: Mesa
Branch: main
Commit: 4b8f2b99e852986551661f166d16f8eccfe9e560
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4b8f2b99e852986551661f166d16f8eccfe9e560
Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date: Wed Aug 25 21:51:44 2021 +0200
zink: avoid generating nonsensical code
With this code, we end up generating code such as:
if (!strcmp(extensions[i].extensionName, "VK_KHR_maintenance1")) {
if (VK_MAKE_VERSION(1,2,0) >= screen->vk_version) {
info->have_KHR_maintenance1 = true;
} else {
info->have_KHR_maintenance1 = true;
}
}
That's clearly nonsense, as it does the same thing in the true and false
case. So let's instead try to walk the Vulkan versions up to the one
we're using in a separate pass, and add all extensions that were made core
in that version.
CID: 1473289
Reviewed-by: Hoe Hao Cheng <haochengho12907 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12593>
---
src/gallium/drivers/zink/zink_device_info.py | 36 +++++++++++++---------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_device_info.py b/src/gallium/drivers/zink/zink_device_info.py
index ba9d9f760ea..5494b9e103e 100644
--- a/src/gallium/drivers/zink/zink_device_info.py
+++ b/src/gallium/drivers/zink/zink_device_info.py
@@ -329,30 +329,10 @@ zink_get_physical_device_info(struct zink_screen *screen)
%for ext in extensions:
<%helpers:guard ext="${ext}">
if (!strcmp(extensions[i].extensionName, "${ext.name}")) {
- %if ext.core_since:
- %for version in versions:
- %if ext.core_since.struct_version == version.struct_version:
- if (${version.version()} >= screen->vk_version) {
- %if not (ext.has_features or ext.has_properties):
- info->have_${ext.name_with_vendor()} = true;
- %else:
- support_${ext.name_with_vendor()} = true;
- %endif
- } else {
- %if not (ext.has_features or ext.has_properties):
- info->have_${ext.name_with_vendor()} = true;
- %else:
- support_${ext.name_with_vendor()} = true;
- %endif
- }
- %endif
- %endfor
- %else:
%if not (ext.has_features or ext.has_properties):
info->have_${ext.name_with_vendor()} = true;
%else:
support_${ext.name_with_vendor()} = true;
- %endif
%endif
}
</%helpers:guard>
@@ -363,6 +343,22 @@ zink_get_physical_device_info(struct zink_screen *screen)
}
}
+ %for version in versions:
+ if (${version.version()} <= screen->vk_version) {
+ %for ext in extensions:
+ %if ext.core_since and ext.core_since.struct_version == version.struct_version:
+ <%helpers:guard ext="${ext}">
+ %if not (ext.has_features or ext.has_properties):
+ info->have_${ext.name_with_vendor()} = true;
+ %else:
+ support_${ext.name_with_vendor()} = true;
+ %endif
+ </%helpers:guard>
+ %endif
+ %endfor
+ }
+ %endfor
+
// get device features
if (screen->vk.GetPhysicalDeviceFeatures2) {
// check for device extension features
More information about the mesa-commit
mailing list