Add get_surface_extension to X11SystenDriver

This commit is contained in:
2025-03-28 22:21:57 +10:00
parent d64b283319
commit a6962bfba8
6 changed files with 31 additions and 10 deletions

View File

@@ -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

View File

@@ -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 <nova/core/debug.h>
#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<SystemDriver> LinuxSystemDriver::get_default_driver() {
NOVA_AUTO_TRACE();

View File

@@ -16,6 +16,8 @@ namespace Nova {
LinuxSystemDriver();
~LinuxSystemDriver() override;
[[nodiscard]] const char* get_surface_extension() const override;
static std::unique_ptr<SystemDriver> get_default_driver();
};
} // namespace Nova

View File

@@ -6,6 +6,11 @@
#include "drivers/linux/x11/system_driver.h"
#ifdef NOVA_VULKAN
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_xlib.h>
#endif
#include <nova/core/debug.h>
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
}

View File

@@ -8,10 +8,14 @@
#include "drivers/linux/system_driver.h"
#include <X11/Xlib.h>
namespace Nova {
class X11SystemDriver final : public LinuxSystemDriver {
public:
X11SystemDriver();
~X11SystemDriver() override;
[[nodiscard]] const char* get_surface_extension() const override;
};
} // namespace Nova

View File

@@ -6,9 +6,8 @@
#include "drivers/vulkan/render_driver.h"
#include <SDL3/SDL.h>
#include <SDL3/SDL_vulkan.h>
#include <nova/core/debug.h>
#include <nova/platform/system.h>
#include <nova/version.h>
#include <vulkan/vulkan.h>
@@ -117,12 +116,8 @@ void VulkanRenderDriver::_check_extensions() {
u32 count;
std::unordered_map<std::string_view, bool> requested; // <extension, required>
// 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;