Add InstanceBuilder functions for setting the different versions directly

This commit is contained in:
sean 2021-10-17 01:09:42 +02:00 committed by Charles Giessen
parent fb8a48779d
commit 8c8694f441
2 changed files with 32 additions and 0 deletions

View File

@ -749,18 +749,34 @@ InstanceBuilder& InstanceBuilder::set_engine_name(const char* engine_name) {
info.engine_name = engine_name; info.engine_name = engine_name;
return *this; 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) { InstanceBuilder& InstanceBuilder::set_app_version(uint32_t major, uint32_t minor, uint32_t patch) {
info.application_version = VK_MAKE_VERSION(major, minor, patch); info.application_version = VK_MAKE_VERSION(major, minor, patch);
return *this; 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) { InstanceBuilder& InstanceBuilder::set_engine_version(uint32_t major, uint32_t minor, uint32_t patch) {
info.engine_version = VK_MAKE_VERSION(major, minor, patch); info.engine_version = VK_MAKE_VERSION(major, minor, patch);
return *this; 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) { InstanceBuilder& InstanceBuilder::require_api_version(uint32_t major, uint32_t minor, uint32_t patch) {
info.required_api_version = VK_MAKE_VERSION(major, minor, patch); info.required_api_version = VK_MAKE_VERSION(major, minor, patch);
return *this; 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) { InstanceBuilder& InstanceBuilder::desire_api_version(uint32_t major, uint32_t minor, uint32_t patch) {
info.desired_api_version = VK_MAKE_VERSION(major, minor, patch); info.desired_api_version = VK_MAKE_VERSION(major, minor, patch);
return *this; return *this;

View File

@ -290,12 +290,28 @@ class InstanceBuilder {
InstanceBuilder& set_app_name(const char* app_name); InstanceBuilder& set_app_name(const char* app_name);
// Sets the name of the engine. Defaults to "" if none is provided. // Sets the name of the engine. Defaults to "" if none is provided.
InstanceBuilder& set_engine_name(const char* engine_name); 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. // Sets the (major, minor, patch) version of the application.
InstanceBuilder& set_app_version(uint32_t major, uint32_t minor, uint32_t patch = 0); 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. // Sets the (major, minor, patch) version of the engine.
InstanceBuilder& set_engine_version(uint32_t major, uint32_t minor, uint32_t patch = 0); 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. // 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); 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. // 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); InstanceBuilder& desire_api_version(uint32_t major, uint32_t minor, uint32_t patch = 0);