mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-13 07:33:34 +00:00
removing unecessary SDL window creation in Vulkan Instance creation
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/08 19:04:21 by maldavid #+# #+# */
|
/* Created: 2022/10/08 19:04:21 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/10 21:54:06 by maldavid ### ########.fr */
|
/* Updated: 2024/02/24 04:31:00 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -58,25 +58,34 @@ namespace mlx
|
|||||||
|
|
||||||
std::vector<const char*> Instance::getRequiredExtensions()
|
std::vector<const char*> Instance::getRequiredExtensions()
|
||||||
{
|
{
|
||||||
unsigned int count = 0;
|
std::vector<const char*> extensions;
|
||||||
SDL_Window* window = SDL_CreateWindow("", 0, 0, 1, 1, SDL_WINDOW_VULKAN | SDL_WINDOW_HIDDEN);
|
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
||||||
if(!window)
|
|
||||||
core::error::report(e_kind::fatal_error, "Vulkan : cannot get instance extentions from window : %s", SDL_GetError());
|
#ifdef VK_USE_PLATFORM_XCB_KHR
|
||||||
|
extensions.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(!SDL_Vulkan_GetInstanceExtensions(window, &count, nullptr))
|
#ifdef VK_USE_PLATFORM_XLIB_KHR
|
||||||
core::error::report(e_kind::fatal_error, "Vulkan : cannot get instance extentions from window : %s", SDL_GetError());
|
extensions.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
|
||||||
|
#endif
|
||||||
|
|
||||||
std::vector<const char*> extensions = { VK_EXT_DEBUG_REPORT_EXTENSION_NAME };
|
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
||||||
size_t additional_extension_count = extensions.size();
|
extensions.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME);
|
||||||
extensions.resize(additional_extension_count + count);
|
#endif
|
||||||
|
|
||||||
if(!SDL_Vulkan_GetInstanceExtensions(window, &count, extensions.data() + additional_extension_count))
|
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||||
core::error::report(e_kind::error, "Vulkan : cannot get instance extentions from window : %s", SDL_GetError());
|
extensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef VK_USE_PLATFORM_METAL_EXT
|
||||||
|
extensions.push_back(VK_EXT_METAL_SURFACE_EXTENSION_NAME);
|
||||||
|
#endif
|
||||||
|
|
||||||
if constexpr(enableValidationLayers)
|
if constexpr(enableValidationLayers)
|
||||||
|
{
|
||||||
|
extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
|
||||||
extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||||
|
}
|
||||||
SDL_DestroyWindow(window);
|
|
||||||
return extensions;
|
return extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user