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>
This commit is contained in:
Chia-I Wu 2021-04-30 10:33:32 -07:00 committed by Marge Bot
parent 14ce47e04a
commit c44225c20b

View file

@ -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