SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
VulkanBackend.h
1#pragma once
2
3#include "spark/render/Backend.h"
4#include "spark/render/Resource.h"
5#include "spark/render/vk/Export.h"
6#include "spark/render/vk/Helpers.h"
7#include "spark/render/vk/VulkanDevice.h"
8#include "spark/render/vk/VulkanGraphicsAdapter.h"
9#include "spark/render/vk/VulkanSurface.h"
10
11#include <functional>
12#include <span>
13
14SPARK_FWD_DECLARE_VK_HANDLE(VkInstance)
15
16namespace spark::render::vk
17{
21 class SPARK_RENDER_VK_EXPORT VulkanBackend final : public RenderBackend<VulkanDevice>, public Resource<VkInstance>
22 {
23 public:
29 explicit VulkanBackend(std::span<std::string> extensions = {}, std::span<std::string> validation_layers = {});
30 ~VulkanBackend() override;
31
32 VulkanBackend(const VulkanBackend& other) = delete;
33 VulkanBackend(VulkanBackend&& other) noexcept = delete;
34 VulkanBackend& operator=(const VulkanBackend& other) = delete;
35 VulkanBackend& operator=(VulkanBackend&& other) noexcept = delete;
36
42 [[nodiscard]] std::unique_ptr<VulkanSurface> createSurface(const std::function<VkSurfaceKHR(const VkInstance&)>& predicate) const;
43
49 static bool ValidateInstanceLayers(std::span<std::string> validation_layers) noexcept;
50
55 static std::vector<std::string> InstanceValidationLayers() noexcept;
56
61 std::span<std::string> enabledValidationLayers() const noexcept;
62
68 static bool ValidateInstanceExtensions(std::span<std::string> extensions) noexcept;
69
74 static std::vector<std::string> AvailableInstanceExtensions() noexcept;
75
77 [[nodiscard]] std::vector<const VulkanGraphicsAdapter*> adapters() const noexcept override;
78
80 [[nodiscard]] const VulkanGraphicsAdapter* findAdapter(const std::optional<lib::Uuid>& id) const override;
81
83 [[nodiscard]] VulkanDevice* device(const std::string& name) noexcept override;
84
86 [[nodiscard]] const VulkanDevice* device(const std::string& name) const noexcept override;
87
89 void registerDevice(std::string name, std::unique_ptr<VulkanDevice>&& device) override;
90
92 void releaseDevice(const std::string& name) override;
93
94 private:
95 struct Impl;
96 std::unique_ptr<Impl> m_impl;
97 };
98}
Defines a back-end, that provides a device instance for a certain surface and graphics adapter.
Definition Backend.h:88
Definition Resource.h:34
Vulkan implementation of IRenderBackend.
Definition VulkanBackend.h:22
Vulkan implementation of IGraphicsDevice.
Definition VulkanDevice.h:25
Implementation of IGraphicsAdapter for Vulkan.
Definition VulkanGraphicsAdapter.h:21
Definition VulkanBackend.cpp:11