diff --git a/engine/include/nova/platform/system_driver.h b/engine/include/nova/platform/system_driver.h index 2f97790..0f89aab 100644 --- a/engine/include/nova/platform/system_driver.h +++ b/engine/include/nova/platform/system_driver.h @@ -12,5 +12,7 @@ namespace Nova { class NOVA_API SystemDriver { public: virtual ~SystemDriver() = default; + + [[nodiscard]] virtual const char* get_surface_extension() const = 0; }; } // namespace Nova diff --git a/engine/src/drivers/linux/system_driver.cpp b/engine/src/drivers/linux/system_driver.cpp index 8b48f1b..be9ffa8 100644 --- a/engine/src/drivers/linux/system_driver.cpp +++ b/engine/src/drivers/linux/system_driver.cpp @@ -4,6 +4,8 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "drivers/linux/system_driver.h" + #ifdef NOVA_WAYLAND #include "drivers/linux/wayland/system_driver.h" #endif @@ -13,8 +15,6 @@ #include -#include "drivers/linux/system_driver.h" - using namespace Nova; LinuxSystemDriver::LinuxSystemDriver() { @@ -25,6 +25,11 @@ LinuxSystemDriver::~LinuxSystemDriver() { NOVA_AUTO_TRACE(); } +const char* LinuxSystemDriver::get_surface_extension() const { + NOVA_WARN("System driver does not support surfaces"); + return nullptr; +} + std::unique_ptr LinuxSystemDriver::get_default_driver() { NOVA_AUTO_TRACE(); diff --git a/engine/src/drivers/linux/system_driver.h b/engine/src/drivers/linux/system_driver.h index f9faa9c..206b595 100644 --- a/engine/src/drivers/linux/system_driver.h +++ b/engine/src/drivers/linux/system_driver.h @@ -16,6 +16,8 @@ namespace Nova { LinuxSystemDriver(); ~LinuxSystemDriver() override; + [[nodiscard]] const char* get_surface_extension() const override; + static std::unique_ptr get_default_driver(); }; } // namespace Nova diff --git a/engine/src/drivers/linux/x11/system_driver.cpp b/engine/src/drivers/linux/x11/system_driver.cpp index f5eff67..803377f 100644 --- a/engine/src/drivers/linux/x11/system_driver.cpp +++ b/engine/src/drivers/linux/x11/system_driver.cpp @@ -6,6 +6,11 @@ #include "drivers/linux/x11/system_driver.h" +#ifdef NOVA_VULKAN + #include + #include +#endif + #include using namespace Nova; @@ -17,3 +22,11 @@ X11SystemDriver::X11SystemDriver() { X11SystemDriver::~X11SystemDriver() { NOVA_AUTO_TRACE(); } + +const char* X11SystemDriver::get_surface_extension() const { +#ifdef NOVA_VULKAN + return VK_KHR_XLIB_SURFACE_EXTENSION_NAME; +#else + return nullptr; +#endif +} diff --git a/engine/src/drivers/linux/x11/system_driver.h b/engine/src/drivers/linux/x11/system_driver.h index 2070ff1..7457857 100644 --- a/engine/src/drivers/linux/x11/system_driver.h +++ b/engine/src/drivers/linux/x11/system_driver.h @@ -8,10 +8,14 @@ #include "drivers/linux/system_driver.h" +#include + namespace Nova { class X11SystemDriver final : public LinuxSystemDriver { public: X11SystemDriver(); ~X11SystemDriver() override; + + [[nodiscard]] const char* get_surface_extension() const override; }; } // namespace Nova diff --git a/engine/src/drivers/vulkan/render_driver.cpp b/engine/src/drivers/vulkan/render_driver.cpp index 81590f5..b05d36f 100644 --- a/engine/src/drivers/vulkan/render_driver.cpp +++ b/engine/src/drivers/vulkan/render_driver.cpp @@ -6,9 +6,8 @@ #include "drivers/vulkan/render_driver.h" -#include -#include #include +#include #include #include @@ -117,12 +116,8 @@ void VulkanRenderDriver::_check_extensions() { u32 count; std::unordered_map requested; // - // Find required extensions - SDL_Init(SDL_INIT_VIDEO); // TODO: Move to SDL driver - const auto required = SDL_Vulkan_GetInstanceExtensions(&count); - for (u32 i = 0; i < count; ++i) { - requested[required[i]] = true; - } + requested[VK_KHR_SURFACE_EXTENSION_NAME] = true; + requested[System::get_driver()->get_surface_extension()] = true; // Add optional extensions requested[VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME] = false;