Skip to content

Commit

Permalink
Replaced std::find_if to std::any_of in few places (#68)
Browse files Browse the repository at this point in the history
It looks like this would make code more readable: don't need to use iterators in if few lines below, and variable names `has**` now reflect variable content more.

Co-authored-by: Bogdan Mart <[email protected]>
  • Loading branch information
Mart-Bogdan and Bogdan Mart authored Apr 16, 2023
1 parent 7590c27 commit 9e4b225
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,24 +234,24 @@ namespace

// We want a device that supports the ray tracing extension.
const auto extensions = Vulkan::GetEnumerateVector(device, static_cast<const char*>(nullptr), vkEnumerateDeviceExtensionProperties);
const auto hasRayTracing = std::find_if(extensions.begin(), extensions.end(), [](const VkExtensionProperties& extension)
const auto hasRayTracing = std::any_of(extensions.begin(), extensions.end(), [](const VkExtensionProperties& extension)
{
return strcmp(extension.extensionName, VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME) == 0;
});

if (hasRayTracing == extensions.end())
if (!hasRayTracing)
{
return false;
}

// We want a device with a graphics queue.
const auto queueFamilies = Vulkan::GetEnumerateVector(device, vkGetPhysicalDeviceQueueFamilyProperties);
const auto hasGraphicsQueue = std::find_if(queueFamilies.begin(), queueFamilies.end(), [](const VkQueueFamilyProperties& queueFamily)
const auto hasGraphicsQueue = std::any_of(queueFamilies.begin(), queueFamilies.end(), [](const VkQueueFamilyProperties& queueFamily)
{
return queueFamily.queueCount > 0 && queueFamily.queueFlags & VK_QUEUE_GRAPHICS_BIT;
});

return hasGraphicsQueue != queueFamilies.end();
return hasGraphicsQueue;
});

if (result == physicalDevices.end())
Expand Down

0 comments on commit 9e4b225

Please sign in to comment.