Add basic surface handling to RenderDriver and WindowDriver

This will likely require significant rework but it will do for now. A
considerations worth thinking about:

- What happends when the WindowDriver destroys a window, what happens to
  the corresponding surface?
This commit is contained in:
2025-04-10 16:59:59 +10:00
parent 536a1e8773
commit 6e1393ce64
6 changed files with 95 additions and 23 deletions

View File

@@ -14,6 +14,11 @@
#include <vector>
namespace Nova {
struct SurfaceData {
VkSurfaceKHR handle = VK_NULL_HANDLE;
// TODO: Add stuff here
};
class VulkanRenderDriver final : public RenderDriver {
public:
explicit VulkanRenderDriver(WindowDriver* window_driver);
@@ -28,6 +33,12 @@ namespace Nova {
[[nodiscard]] const RenderDevice& get_device(u32 index) const override;
void select_device(u32 index) override;
[[nodiscard]] SurfaceID create_surface(WindowID window) override;
void destroy_surface(SurfaceID surface) override;
[[nodiscard]] VkInstance get_instance() const;
[[nodiscard]] VkAllocationCallbacks* get_allocator(VkObjectType type) const;
private:
WindowDriver* m_window_driver = nullptr;
VkInstance m_instance = VK_NULL_HANDLE;
@@ -50,8 +61,6 @@ namespace Nova {
void _check_device_features();
void _init_queues(std::vector<VkDeviceQueueCreateInfo>& queues) const;
void _init_device(const std::vector<VkDeviceQueueCreateInfo>& queues);
static VkAllocationCallbacks* _get_allocator(VkObjectType type);
};
} // namespace Nova