improving descriptor sets and pools management

This commit is contained in:
Kbz-8
2024-01-20 08:46:50 +01:00
parent 6866f2240e
commit 05362905f7
17 changed files with 186 additions and 60 deletions

View File

@@ -6,12 +6,13 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 19:14:29 by maldavid #+# #+# */
/* Updated: 2024/01/10 21:54:17 by maldavid ### ########.fr */
/* Updated: 2024/01/20 05:34:15 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#include "render_core.h"
#include <iterator>
#include <map>
#include <vector>
#include <set>
#include <SDL2/SDL.h>
@@ -84,24 +85,19 @@ namespace mlx
if(SDL_Vulkan_CreateSurface(window, Render_Core::get().getInstance().get(), &surface) != SDL_TRUE)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create a surface to pick physical device");
std::vector<std::pair<int, VkPhysicalDevice>> devices_score;
std::multimap<int, VkPhysicalDevice> devices_score;
std::transform(devices.cbegin(), devices.cend(), std::back_inserter(devices_score), [&](VkPhysicalDevice device)
for(const auto& device : devices)
{
return std::make_pair(deviceScore(device, surface), device);
});
int score = deviceScore(device, surface);
devices_score.insert(std::make_pair(score, device));
}
using device_pair = std::pair<int, VkPhysicalDevice>;
std::sort(devices_score.begin(), devices_score.end(), [](const device_pair& a, const device_pair& b)
{
return a.first > b.first;
});
if(devices_score.front().first > 0)
_physicalDevice = devices_score.front().second;
if(_physicalDevice == VK_NULL_HANDLE)
if(devices_score.rbegin()->first > 0)
_physicalDevice = devices_score.rbegin()->second;
else
core::error::report(e_kind::fatal_error, "Vulkan : failed to find a suitable GPU");
#ifdef DEBUG
VkPhysicalDeviceProperties props;
vkGetPhysicalDeviceProperties(_physicalDevice, &props);
@@ -126,6 +122,9 @@ namespace mlx
if(!indices.isComplete() || !extensionsSupported || formatCount == 0)
return -1;
VkPhysicalDeviceFeatures features;
vkGetPhysicalDeviceFeatures(device, &features);
int score = 0;
#ifndef FORCE_INTEGRATED_GPU
if(props.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
@@ -134,6 +133,10 @@ namespace mlx
if(props.deviceType != VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU)
return -1;
#endif
if(!features.geometryShader)
return -1;
score += props.limits.maxImageDimension2D;
score += props.limits.maxBoundDescriptorSets;
return score;