From a1ee51309ef7a36aef177ef523260e7b574ce4ab Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 9 Nov 2017 19:17:17 -0800 Subject: vulkan/util: Add a helper to get a version override MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Samuel Iglesias Gonsálvez --- src/vulkan/util/vk_util.c | 20 ++++++++++++++++++++ src/vulkan/util/vk_util.h | 2 ++ 2 files changed, 22 insertions(+) (limited to 'src') diff --git a/src/vulkan/util/vk_util.c b/src/vulkan/util/vk_util.c index 769e69062ad..ec95a89078a 100644 --- a/src/vulkan/util/vk_util.c +++ b/src/vulkan/util/vk_util.c @@ -47,3 +47,23 @@ uint32_t vk_get_driver_version(void) } return VK_MAKE_VERSION(major, minor, patch); } + +uint32_t vk_get_version_override(void) +{ + const char *str = getenv("MESA_VK_VERSION_OVERRIDE"); + if (str == NULL) + return 0; + + const char *minor_str = strchr(str, '.'); + const char *patch_str = minor_str ? strchr(minor_str + 1, '.') : NULL; + + int major = atoi(str); + int minor = minor_str ? atoi(minor_str + 1) : 0; + int patch = patch_str ? atoi(patch_str + 1) : 0; + + /* Do some basic version sanity checking */ + if (major < 1 || minor < 0 || patch < 0 || minor > 1023 || patch > 4095) + return 0; + + return VK_MAKE_VERSION(major, minor, patch); +} diff --git a/src/vulkan/util/vk_util.h b/src/vulkan/util/vk_util.h index 4c18a196b71..cc6a36e5acc 100644 --- a/src/vulkan/util/vk_util.h +++ b/src/vulkan/util/vk_util.h @@ -199,6 +199,8 @@ __vk_find_struct(void *start, VkStructureType sType) uint32_t vk_get_driver_version(void); +uint32_t vk_get_version_override(void); + #define VK_EXT_OFFSET (1000000000UL) #define VK_ENUM_EXTENSION(__enum) \ ((__enum) >= VK_EXT_OFFSET ? ((((__enum) - VK_EXT_OFFSET) / 1000UL) + 1) : 0) -- cgit v1.2.3