Mesa (master): venus: add VN_MAX_API_VERSION

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 3 21:07:42 UTC 2021


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

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Mon May  3 09:46:32 2021 -0700

venus: add VN_MAX_API_VERSION

Use VN_MAX_API_VERSION for the instance version such that we don't
suddenly advertise 1.3 when the header is updated to 1.3 for example.

Use it to cap the device version as well.

Signed-off-by: Chia-I Wu <olvaffe at gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10556>

---

 src/virtio/vulkan/vn_device.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/virtio/vulkan/vn_device.c b/src/virtio/vulkan/vn_device.c
index ef7af79501e..a3acf12b331 100644
--- a/src/virtio/vulkan/vn_device.c
+++ b/src/virtio/vulkan/vn_device.c
@@ -30,6 +30,13 @@
  */
 #define VN_MIN_RENDERER_VERSION VK_API_VERSION_1_1
 
+/* max advertised version at both instance and device levels */
+#ifdef ANDROID
+#define VN_MAX_API_VERSION VK_MAKE_VERSION(1, 1, VK_HEADER_VERSION)
+#else
+#define VN_MAX_API_VERSION VK_MAKE_VERSION(1, 2, VK_HEADER_VERSION)
+#endif
+
 /*
  * Instance extensions add instance-level or physical-device-level
  * functionalities.  It seems renderer support is either unnecessary or
@@ -1239,15 +1246,14 @@ vn_physical_device_init_properties(struct vn_physical_device *physical_dev)
    if (version_override) {
       props->apiVersion = version_override;
    } else {
-      if (props->apiVersion > VK_HEADER_VERSION_COMPLETE)
-         props->apiVersion = VK_HEADER_VERSION_COMPLETE;
-      if (props->apiVersion > vn_info_vk_xml_version())
-         props->apiVersion = vn_info_vk_xml_version();
-#ifdef ANDROID
-      if (props->apiVersion >= VK_API_VERSION_1_2)
-         props->apiVersion =
-            VK_MAKE_VERSION(1, 1, VK_VERSION_PATCH(props->apiVersion));
-#endif
+      /* cap the advertised api version */
+      uint32_t version = MIN3(props->apiVersion, VN_MAX_API_VERSION,
+                              instance->renderer_info.vk_xml_version);
+      if (VK_VERSION_PATCH(version) > VK_VERSION_PATCH(props->apiVersion)) {
+         version = version - VK_VERSION_PATCH(version) +
+                   VK_VERSION_PATCH(props->apiVersion);
+      }
+      props->apiVersion = version;
    }
 
    props->driverVersion = vk_get_driver_version();
@@ -1770,7 +1776,7 @@ out:
 VkResult
 vn_EnumerateInstanceVersion(uint32_t *pApiVersion)
 {
-   *pApiVersion = VK_HEADER_VERSION_COMPLETE;
+   *pApiVersion = VN_MAX_API_VERSION;
    return VK_SUCCESS;
 }
 



More information about the mesa-commit mailing list