mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-22 15:24:34 +00:00
implemented enable_extensions_if_present and tests
This commit is contained in:
parent
382259e32b
commit
0af4cb5055
@ -1399,6 +1399,17 @@ bool PhysicalDevice::enable_extension_if_present(const char* extension) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
bool PhysicalDevice::enable_extensions_if_present(const std::vector<const char*>& extensions) {
|
||||||
|
for (const auto extension : extensions) {
|
||||||
|
auto it = std::find_if(std::begin(available_extensions),
|
||||||
|
std::end(available_extensions),
|
||||||
|
[extension](std::string const& ext_name) { return ext_name == extension; });
|
||||||
|
if (it == std::end(available_extensions)) return false;
|
||||||
|
}
|
||||||
|
for (const auto extension : extensions)
|
||||||
|
extensions_to_enable.push_back(extension);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
PhysicalDevice::operator VkPhysicalDevice() const { return this->physical_device; }
|
PhysicalDevice::operator VkPhysicalDevice() const { return this->physical_device; }
|
||||||
|
|
||||||
|
@ -509,6 +509,10 @@ struct PhysicalDevice {
|
|||||||
// Returns true the extension is present.
|
// Returns true the extension is present.
|
||||||
bool enable_extension_if_present(const char* extension);
|
bool enable_extension_if_present(const char* extension);
|
||||||
|
|
||||||
|
// If all the given extensions are present, make all the extensions be enabled on the device.
|
||||||
|
// Returns true if all the extensions are present.
|
||||||
|
bool enable_extensions_if_present(const std::vector<const char*>& extensions);
|
||||||
|
|
||||||
// A conversion function which allows this PhysicalDevice to be used
|
// A conversion function which allows this PhysicalDevice to be used
|
||||||
// in places where VkPhysicalDevice would have been used.
|
// in places where VkPhysicalDevice would have been used.
|
||||||
operator VkPhysicalDevice() const;
|
operator VkPhysicalDevice() const;
|
||||||
|
@ -121,6 +121,14 @@ TEST_CASE("Instance with surface", "[VkBootstrap.bootstrap]") {
|
|||||||
REQUIRE(phys_dev_ret->enable_extension_if_present(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME));
|
REQUIRE(phys_dev_ret->enable_extension_if_present(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME));
|
||||||
REQUIRE(!phys_dev_ret->enable_extension_if_present(VK_KHR_16BIT_STORAGE_EXTENSION_NAME));
|
REQUIRE(!phys_dev_ret->enable_extension_if_present(VK_KHR_16BIT_STORAGE_EXTENSION_NAME));
|
||||||
|
|
||||||
|
const std::vector<const char*> extension_set_1 = { VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME,
|
||||||
|
VK_EXT_ROBUSTNESS_2_EXTENSION_NAME };
|
||||||
|
const std::vector<const char*> extension_set_2 = { VK_KHR_16BIT_STORAGE_EXTENSION_NAME,
|
||||||
|
VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME };
|
||||||
|
|
||||||
|
REQUIRE(phys_dev_ret->enable_extensions_if_present(extension_set_1));
|
||||||
|
REQUIRE(!phys_dev_ret->enable_extensions_if_present(extension_set_2));
|
||||||
|
|
||||||
auto device_ret = vkb::DeviceBuilder(phys_dev_ret.value()).build();
|
auto device_ret = vkb::DeviceBuilder(phys_dev_ret.value()).build();
|
||||||
REQUIRE(device_ret.has_value());
|
REQUIRE(device_ret.has_value());
|
||||||
vkb::destroy_device(device_ret.value());
|
vkb::destroy_device(device_ret.value());
|
||||||
|
Loading…
Reference in New Issue
Block a user