From 8c8694f441576c2b0bdf634a1dff698e91eb39b8 Mon Sep 17 00:00:00 2001 From: sean <43609023+spnda@users.noreply.github.com> Date: Sun, 17 Oct 2021 01:09:42 +0200 Subject: [PATCH] Add InstanceBuilder functions for setting the different versions directly --- src/VkBootstrap.cpp | 16 ++++++++++++++++ src/VkBootstrap.h | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/VkBootstrap.cpp b/src/VkBootstrap.cpp index ccfbedb..4c7336a 100644 --- a/src/VkBootstrap.cpp +++ b/src/VkBootstrap.cpp @@ -749,18 +749,34 @@ InstanceBuilder& InstanceBuilder::set_engine_name(const char* engine_name) { info.engine_name = engine_name; return *this; } +InstanceBuilder& InstanceBuilder::set_app_version(uint32_t app_version) { + info.application_version = app_version; + return *this; +} InstanceBuilder& InstanceBuilder::set_app_version(uint32_t major, uint32_t minor, uint32_t patch) { info.application_version = VK_MAKE_VERSION(major, minor, patch); return *this; } +InstanceBuilder& InstanceBuilder::set_engine_version(uint32_t engine_version) { + info.engine_version = engine_version; + return *this; +} InstanceBuilder& InstanceBuilder::set_engine_version(uint32_t major, uint32_t minor, uint32_t patch) { info.engine_version = VK_MAKE_VERSION(major, minor, patch); return *this; } +InstanceBuilder& InstanceBuilder::require_api_version(uint32_t required_api_version) { + info.required_api_version = required_api_version; + return *this; +} InstanceBuilder& InstanceBuilder::require_api_version(uint32_t major, uint32_t minor, uint32_t patch) { info.required_api_version = VK_MAKE_VERSION(major, minor, patch); return *this; } +InstanceBuilder& InstanceBuilder::desire_api_version(uint32_t preferred_vulkan_version) { + info.desired_api_version = preferred_vulkan_version; + return *this; +} InstanceBuilder& InstanceBuilder::desire_api_version(uint32_t major, uint32_t minor, uint32_t patch) { info.desired_api_version = VK_MAKE_VERSION(major, minor, patch); return *this; diff --git a/src/VkBootstrap.h b/src/VkBootstrap.h index 654ba9c..490a4ef 100644 --- a/src/VkBootstrap.h +++ b/src/VkBootstrap.h @@ -290,12 +290,28 @@ class InstanceBuilder { InstanceBuilder& set_app_name(const char* app_name); // Sets the name of the engine. Defaults to "" if none is provided. InstanceBuilder& set_engine_name(const char* engine_name); + + // Sets the version of the application. + // Should be constructed with VK_MAKE_VERSION or VK_MAKE_API_VERSION. + InstanceBuilder& set_app_version(uint32_t app_version); // Sets the (major, minor, patch) version of the application. InstanceBuilder& set_app_version(uint32_t major, uint32_t minor, uint32_t patch = 0); + + // Sets the version of the engine. + // Should be constructed with VK_MAKE_VERSION or VK_MAKE_API_VERSION. + InstanceBuilder& set_engine_version(uint32_t engine_version); // Sets the (major, minor, patch) version of the engine. InstanceBuilder& set_engine_version(uint32_t major, uint32_t minor, uint32_t patch = 0); + + // Require a vulkan instance API version. Will fail to create if this version isn't available. + // Should be constructed with VK_MAKE_VERSION or VK_MAKE_API_VERSION. + InstanceBuilder& require_api_version(uint32_t required_api_version); // Require a vulkan instance API version. Will fail to create if this version isn't available. InstanceBuilder& require_api_version(uint32_t major, uint32_t minor, uint32_t patch = 0); + + // Prefer a vulkan instance API version. If the desired version isn't available, it will use the highest version available. + // Should be constructed with VK_MAKE_VERSION or VK_MAKE_API_VERSION. + InstanceBuilder& desire_api_version(uint32_t preferred_vulkan_version); // Prefer a vulkan instance API version. If the desired version isn't available, it will use the highest version available. InstanceBuilder& desire_api_version(uint32_t major, uint32_t minor, uint32_t patch = 0);