summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2021-04-30 10:33:32 -0700
committerMarge Bot <eric+marge@anholt.net>2021-05-03 20:51:46 +0000
commitc44225c20b35759cf1266741531407b7fe0618de (patch)
treeeb5f17b8a35b5fc70f7e719d8b42f128923087a0
parent14ce47e04a9ede42bf25e4b8c6d96f5af663c59a (diff)
venus: avoid strcmp for spec version override
Add VN_EXTENSION_TABLE_INDEX for use with VK_ANDROID_native_buffer spec version override. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10556>
-rw-r--r--src/virtio/vulkan/vn_device.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/virtio/vulkan/vn_device.c b/src/virtio/vulkan/vn_device.c
index 94a23182557..ab2311c18d8 100644
--- a/src/virtio/vulkan/vn_device.c
+++ b/src/virtio/vulkan/vn_device.c
@@ -37,6 +37,11 @@
#define VN_MAX_API_VERSION VK_MAKE_VERSION(1, 2, VK_HEADER_VERSION)
#endif
+#define VN_EXTENSION_TABLE_INDEX(tbl, ext) \
+ ((const bool *)((const void *)(&(tbl)) + \
+ offsetof(__typeof__(tbl), ext)) - \
+ (tbl).extensions)
+
/*
* Instance extensions add instance-level or physical-device-level
* functionalities. It seems renderer support is either unnecessary or
@@ -1523,13 +1528,6 @@ vn_physical_device_init_supported_extensions(
if (supported.extensions[i]) {
physical_dev->base.base.supported_extensions.extensions[i] = true;
physical_dev->extension_spec_versions[i] = props->specVersion;
-#ifdef ANDROID
- /* override VK_ANDROID_native_buffer spec version */
- if (!strcmp(props->extensionName,
- VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME))
- physical_dev->extension_spec_versions[i] =
- VN_ANDROID_NATIVE_BUFFER_SPEC_VERSION;
-#endif
continue;
}
@@ -1545,6 +1543,14 @@ vn_physical_device_init_supported_extensions(
physical_dev->extension_spec_versions[i] =
MIN2(physical_dev->extension_spec_versions[i], props->specVersion);
}
+
+ /* override VK_ANDROID_native_buffer spec version */
+ if (supported.ANDROID_native_buffer) {
+ const uint32_t index =
+ VN_EXTENSION_TABLE_INDEX(supported, ANDROID_native_buffer);
+ physical_dev->extension_spec_versions[index] =
+ VN_ANDROID_NATIVE_BUFFER_SPEC_VERSION;
+ }
}
static VkResult