/*1* Copyright © 2016 Red Hat.2* Copyright © 2016 Bas Nieuwenhuizen3* Copyright © 2017 Intel Corporation4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the "Software"),7* to deal in the Software without restriction, including without limitation8* the rights to use, copy, modify, merge, publish, distribute, sublicense,9* and/or sell copies of the Software, and to permit persons to whom the10* Software is furnished to do so, subject to the following conditions:11*12* The above copyright notice and this permission notice (including the next13* paragraph) shall be included in all copies or substantial portions of the14* Software.15*16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR17* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,18* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL19* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER20* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING21* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS22* IN THE SOFTWARE.23*/2425#include <stdio.h>26#include <stdlib.h>27#include <string.h>28#include "vk_util.h"29#include "util/debug.h"3031uint32_t vk_get_driver_version(void)32{33const char *minor_string = strchr(PACKAGE_VERSION, '.');34const char *patch_string = minor_string ? strchr(minor_string + 1, '.') : NULL;35int major = atoi(PACKAGE_VERSION);36int minor = minor_string ? atoi(minor_string + 1) : 0;37int patch = patch_string ? atoi(patch_string + 1) : 0;38if (strstr(PACKAGE_VERSION, "devel")) {39if (patch == 0) {40patch = 99;41if (minor == 0) {42minor = 99;43--major;44} else45--minor;46} else47--patch;48}49return VK_MAKE_VERSION(major, minor, patch);50}5152uint32_t vk_get_version_override(void)53{54const char *str = getenv("MESA_VK_VERSION_OVERRIDE");55if (str == NULL)56return 0;5758const char *minor_str = strchr(str, '.');59const char *patch_str = minor_str ? strchr(minor_str + 1, '.') : NULL;6061int major = atoi(str);62int minor = minor_str ? atoi(minor_str + 1) : 0;63int patch = patch_str ? atoi(patch_str + 1) : 0;6465/* Do some basic version sanity checking */66if (major < 1 || minor < 0 || patch < 0 || minor > 1023 || patch > 4095)67return 0;6869return VK_MAKE_VERSION(major, minor, patch);70}7172void73vk_warn_non_conformant_implementation(const char *driver_name)74{75if (env_var_as_boolean("MESA_VK_IGNORE_CONFORMANCE_WARNING", false))76return;7778fprintf(stderr, "WARNING: %s is not a conformant Vulkan implementation, "79"testing use only.\n", driver_name);80}818283