vulkan/util: Add a helper to get a version override

Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
This commit is contained in:
Jason Ekstrand 2017-11-09 19:17:17 -08:00
parent d6b65222df
commit a1ee51309e
3 changed files with 32 additions and 0 deletions

View File

@ -135,6 +135,16 @@ home directory.
<li>MESA_NO_MINMAX_CACHE - when set, the minmax index cache is globally disabled.
<li>MESA_SHADER_CAPTURE_PATH - see <a href="shading.html#capture">Capturing Shaders</a></li>
<li>MESA_SHADER_DUMP_PATH and MESA_SHADER_READ_PATH - see <a href="shading.html#replacement">Experimenting with Shader Replacements</a></li>
<li>MESA_VK_VERSION_OVERRIDE - changes the Vulkan physical device version
as returned in VkPhysicalDeviceProperties::apiVersion.
<ul>
<li>The format should be MAJOR.MINOR[.PATCH]</li>
<li>This will not let you force a version higher than the driver's
instance versionas advertised by vkEnumerateInstanceVersion</li>
<li>This can be very useful for debugging but some features may not be
implemented correctly. (For developers only)</li>
</ul>
</li>
</ul>

View File

@ -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);
}

View File

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