mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-22 07:24:34 +00:00
Guard vkGetPhysicalDeviceFeatures2 behind instance version
Also make it so that instance extensions are queried in the instance only.
This commit is contained in:
parent
f422497cca
commit
244a44da51
@ -618,8 +618,9 @@ detail::Result<Instance> InstanceBuilder::build() const {
|
|||||||
if (info.debug_callback != nullptr && system.debug_utils_available) {
|
if (info.debug_callback != nullptr && system.debug_utils_available) {
|
||||||
extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||||
}
|
}
|
||||||
if (detail::check_extension_supported(
|
bool supports_properties2_ext = detail::check_extension_supported(
|
||||||
system.available_extensions, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) {
|
system.available_extensions, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
||||||
|
if (supports_properties2_ext) {
|
||||||
extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -731,9 +732,8 @@ detail::Result<Instance> InstanceBuilder::build() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.headless_context) {
|
instance.headless = info.headless_context;
|
||||||
instance.headless = true;
|
instance.supports_properties2_ext = supports_properties2_ext;
|
||||||
}
|
|
||||||
instance.allocation_callbacks = info.allocation_callbacks;
|
instance.allocation_callbacks = info.allocation_callbacks;
|
||||||
instance.instance_version = api_version;
|
instance.instance_version = api_version;
|
||||||
instance.fp_vkGetInstanceProcAddr = detail::vulkan_functions().ptr_vkGetInstanceProcAddr;
|
instance.fp_vkGetInstanceProcAddr = detail::vulkan_functions().ptr_vkGetInstanceProcAddr;
|
||||||
@ -1020,7 +1020,7 @@ PhysicalDeviceSelector::PhysicalDeviceDesc PhysicalDeviceSelector::populate_devi
|
|||||||
VkPhysicalDeviceFeatures2 local_features{};
|
VkPhysicalDeviceFeatures2 local_features{};
|
||||||
local_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
local_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||||
local_features.pNext = &fill_chain.front();
|
local_features.pNext = &fill_chain.front();
|
||||||
if (desc.device_properties.apiVersion >= VK_API_VERSION_1_1) {
|
if (instance_info.version >= VK_API_VERSION_1_1 && desc.device_properties.apiVersion >= VK_API_VERSION_1_1) {
|
||||||
detail::vulkan_functions().fp_vkGetPhysicalDeviceFeatures2(phys_device, &local_features);
|
detail::vulkan_functions().fp_vkGetPhysicalDeviceFeatures2(phys_device, &local_features);
|
||||||
} else if (instance_info.supports_properties2_ext) {
|
} else if (instance_info.supports_properties2_ext) {
|
||||||
detail::vulkan_functions().fp_vkGetPhysicalDeviceFeatures2KHR(phys_device, &local_features);
|
detail::vulkan_functions().fp_vkGetPhysicalDeviceFeatures2KHR(phys_device, &local_features);
|
||||||
@ -1134,13 +1134,10 @@ PhysicalDeviceSelector::PhysicalDeviceSelector(Instance const& instance) {
|
|||||||
instance_info.instance = instance.instance;
|
instance_info.instance = instance.instance;
|
||||||
instance_info.headless = instance.headless;
|
instance_info.headless = instance.headless;
|
||||||
instance_info.version = instance.instance_version;
|
instance_info.version = instance.instance_version;
|
||||||
|
instance_info.supports_properties2_ext = instance.supports_properties2_ext;
|
||||||
criteria.require_present = !instance.headless;
|
criteria.require_present = !instance.headless;
|
||||||
criteria.required_version = instance.instance_version;
|
criteria.required_version = instance.instance_version;
|
||||||
criteria.desired_version = instance.instance_version;
|
criteria.desired_version = instance.instance_version;
|
||||||
detail::get_vector<VkExtensionProperties>(
|
|
||||||
instance_info.extensions, detail::vulkan_functions().fp_vkEnumerateInstanceExtensionProperties, nullptr);
|
|
||||||
instance_info.supports_properties2_ext = detail::check_extension_supported(
|
|
||||||
instance_info.extensions, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
detail::Result<PhysicalDevice> PhysicalDeviceSelector::select() const {
|
detail::Result<PhysicalDevice> PhysicalDeviceSelector::select() const {
|
||||||
@ -1149,9 +1146,6 @@ detail::Result<PhysicalDevice> PhysicalDeviceSelector::select() const {
|
|||||||
return detail::Result<PhysicalDevice>{ PhysicalDeviceError::no_surface_provided };
|
return detail::Result<PhysicalDevice>{ PhysicalDeviceError::no_surface_provided };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<VkPhysicalDevice> physical_devices;
|
std::vector<VkPhysicalDevice> physical_devices;
|
||||||
|
|
||||||
auto physical_devices_ret = detail::get_vector<VkPhysicalDevice>(
|
auto physical_devices_ret = detail::get_vector<VkPhysicalDevice>(
|
||||||
|
@ -219,6 +219,7 @@ struct Instance {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool headless = false;
|
bool headless = false;
|
||||||
|
bool supports_properties2_ext = false;
|
||||||
uint32_t instance_version = VK_MAKE_VERSION(1, 0, 0);
|
uint32_t instance_version = VK_MAKE_VERSION(1, 0, 0);
|
||||||
|
|
||||||
friend class InstanceBuilder;
|
friend class InstanceBuilder;
|
||||||
@ -474,7 +475,6 @@ class PhysicalDeviceSelector {
|
|||||||
VkInstance instance = VK_NULL_HANDLE;
|
VkInstance instance = VK_NULL_HANDLE;
|
||||||
VkSurfaceKHR surface = VK_NULL_HANDLE;
|
VkSurfaceKHR surface = VK_NULL_HANDLE;
|
||||||
uint32_t version = VK_MAKE_VERSION(1, 0, 0);
|
uint32_t version = VK_MAKE_VERSION(1, 0, 0);
|
||||||
std::vector<VkExtensionProperties> extensions;
|
|
||||||
bool headless = false;
|
bool headless = false;
|
||||||
bool supports_properties2_ext = false;
|
bool supports_properties2_ext = false;
|
||||||
} instance_info;
|
} instance_info;
|
||||||
|
Loading…
Reference in New Issue
Block a user