From 1160b19a5c1301a1e2cefd4b3a0e733552a7abc6 Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Sun, 8 Mar 2020 00:59:58 -0700 Subject: [PATCH] Rename set_api_version to required_api_version and make the PhysicalDeviceSelector use the provided value as the required minimum for devices --- src/VkBootstrap.cpp | 4 +++- src/VkBootstrap.h | 5 +++-- tests/run_tests.cpp | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/VkBootstrap.cpp b/src/VkBootstrap.cpp index 7c9f247..6bd5b67 100644 --- a/src/VkBootstrap.cpp +++ b/src/VkBootstrap.cpp @@ -406,6 +406,7 @@ detail::Expected> InstanceBuilder::build instance.headless = true; } instance.allocation_callbacks = info.allocation_callbacks; + instance.instance_version = info.api_version; return instance; } @@ -427,7 +428,7 @@ InstanceBuilder& InstanceBuilder::set_engine_version (uint32_t major, uint32_t m info.engine_version = VK_MAKE_VERSION (major, minor, patch); return *this; } -InstanceBuilder& InstanceBuilder::set_api_version (uint32_t major, uint32_t minor, uint32_t patch) { +InstanceBuilder& InstanceBuilder::require_api_version (uint32_t major, uint32_t minor, uint32_t patch) { info.api_version = VK_MAKE_VERSION (major, minor, patch); return *this; } @@ -750,6 +751,7 @@ PhysicalDeviceSelector::PhysicalDeviceSelector (Instance const& instance) { system_info.instance = instance.instance; system_info.headless = instance.headless; criteria.require_present = !instance.headless; + criteria.required_version = instance.instance_version; } detail::Expected> PhysicalDeviceSelector::select () const { diff --git a/src/VkBootstrap.h b/src/VkBootstrap.h index d08ee06..e131975 100644 --- a/src/VkBootstrap.h +++ b/src/VkBootstrap.h @@ -159,6 +159,7 @@ struct Instance { private: bool headless = false; + uint32_t instance_version = VK_MAKE_VERSION (1, 0, 0); friend class InstanceBuilder; friend class PhysicalDeviceSelector; @@ -182,8 +183,8 @@ class InstanceBuilder { InstanceBuilder& set_app_version (uint32_t major, uint32_t minor, uint32_t patch); // Sets the (major, minor, patch) version of the engine. InstanceBuilder& set_engine_version (uint32_t major, uint32_t minor, uint32_t patch); - // Sets the vulkan API version to use. - InstanceBuilder& set_api_version (uint32_t major, uint32_t minor, uint32_t patch); + // Require a minimum vulkan instance API version. + InstanceBuilder& require_api_version (uint32_t major, uint32_t minor, uint32_t patch); // Adds a layer to be enabled. Will fail to create an instance if the layer isn't available. InstanceBuilder& enable_layer (const char* layer_name); diff --git a/tests/run_tests.cpp b/tests/run_tests.cpp index cff5ba8..fb76b63 100644 --- a/tests/run_tests.cpp +++ b/tests/run_tests.cpp @@ -55,7 +55,7 @@ int test_instance_basic () { printf ("[%s: %s](user defined)\n%s\n", ms, mt, pCallbackData->pMessage); return VK_FALSE; }) - .set_api_version (1, 2, 111) + .require_api_version (1, 2, 111) .build (); if (!instance_ret.has_value ()) { return 1; @@ -76,7 +76,7 @@ int test_instance_headless () { .set_app_version (4, 5, 6) .set_app_name ("headless") .set_engine_name ("nick") - .set_api_version (1, 0, 34) + .require_api_version (1, 0, 34) .use_default_debug_messenger () .add_validation_feature_enable (VkValidationFeatureEnableEXT::VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT) .add_validation_feature_disable (VkValidationFeatureDisableEXT::VK_VALIDATION_FEATURE_DISABLE_OBJECT_LIFETIMES_EXT)