Forward required/desired API versions to PhysicalDeviceBuilder

Desired version is called max_api_version, since valid Vulkan
program is not allowed to use features from any higher version.
This commit is contained in:
Danderaion 2022-02-22 20:33:57 +02:00 committed by Charles Giessen
parent 0fa1dd8e20
commit b7c2ddd8e5
2 changed files with 10 additions and 3 deletions

View File

@ -601,7 +601,10 @@ detail::Result<Instance> InstanceBuilder::build() const {
if (info.required_api_version > VKB_VK_API_VERSION_1_0) {
api_version = info.required_api_version;
}
if (info.desired_api_version > api_version && instance_version >= VKB_VK_API_VERSION_1_1){
if (instance_version > info.desired_api_version) {
instance_version = info.desired_api_version;
}
if (info.desired_api_version > api_version && instance_version >= VKB_VK_API_VERSION_1_1){
api_version = info.desired_api_version;
}
}
@ -745,6 +748,8 @@ detail::Result<Instance> InstanceBuilder::build() const {
instance.supports_properties2_ext = supports_properties2_ext;
instance.allocation_callbacks = info.allocation_callbacks;
instance.instance_version = instance_version;
instance.required_version = info.required_api_version;
instance.max_api_version = api_version;
instance.fp_vkGetInstanceProcAddr = detail::vulkan_functions().ptr_vkGetInstanceProcAddr;
instance.fp_vkGetDeviceProcAddr = detail::vulkan_functions().fp_vkGetDeviceProcAddr;
return instance;
@ -1168,8 +1173,8 @@ PhysicalDeviceSelector::PhysicalDeviceSelector(Instance const& instance) {
instance_info.version = instance.instance_version;
instance_info.supports_properties2_ext = instance.supports_properties2_ext;
criteria.require_present = !instance.headless;
criteria.required_version = instance.instance_version;
criteria.desired_version = instance.instance_version;
criteria.required_version = instance.required_version;
criteria.desired_version = instance.max_api_version;
}
detail::Result<PhysicalDevice> PhysicalDeviceSelector::select() const {

View File

@ -282,6 +282,8 @@ struct Instance {
bool headless = false;
bool supports_properties2_ext = false;
uint32_t instance_version = VKB_VK_API_VERSION_1_0;
uint32_t required_version = VKB_VK_API_VERSION_1_0;
uint32_t max_api_version = VKB_VK_API_VERSION_1_0;
friend class InstanceBuilder;
friend class PhysicalDeviceSelector;