aboutsummaryrefslogtreecommitdiff
path: root/core/src/Entrypoint/Backend_Vulkan.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/Entrypoint/Backend_Vulkan.cpp')
-rw-r--r--core/src/Entrypoint/Backend_Vulkan.cpp42
1 files changed, 28 insertions, 14 deletions
diff --git a/core/src/Entrypoint/Backend_Vulkan.cpp b/core/src/Entrypoint/Backend_Vulkan.cpp
index 9d79acf..de3b5ca 100644
--- a/core/src/Entrypoint/Backend_Vulkan.cpp
+++ b/core/src/Entrypoint/Backend_Vulkan.cpp
@@ -12,7 +12,8 @@
# include <backend/imgui_impl_vulkan.h>
# include <backend/imgui_impl_vulkan.cpp>
-class VulkanBackend : public RenderingBackend {
+class VulkanBackend : public RenderingBackend
+{
private:
GLFWwindow* mWindow;
@@ -31,7 +32,8 @@ private:
bool mSwapChainRebuild = false;
public:
- VulkanBackend() {
+ VulkanBackend()
+ {
glfwSetErrorCallback(&GlfwErrorCallback);
if (!glfwInit()) {
throw std::runtime_error("Failed to initialize GLFW.");
@@ -80,7 +82,8 @@ public:
ImGui_ImplVulkan_Init(&init_info, mMainWindowData.RenderPass);
}
- virtual ~VulkanBackend() {
+ virtual ~VulkanBackend()
+ {
auto err = vkDeviceWaitIdle(mDevice);
CheckVkResults(err);
ImGui_ImplVulkan_Shutdown();
@@ -94,7 +97,8 @@ public:
glfwTerminate();
}
- virtual void RunUntilWindowClose(void (*windowContent)()) override {
+ virtual void RunUntilWindowClose(void (*windowContent)()) override
+ {
// Upload Fonts
{
// Use any command queue
@@ -158,7 +162,8 @@ public:
}
private:
- void SetupVulkan(const char** extensions, uint32_t extensions_count) {
+ void SetupVulkan(const char** extensions, uint32_t extensions_count)
+ {
VkResult err;
// Create Vulkan Instance
@@ -267,7 +272,8 @@ private:
}
}
- void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface, int width, int height) {
+ void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface, int width, int height)
+ {
wd->Surface = surface;
// Check for WSI support
@@ -291,7 +297,8 @@ private:
ImGui_ImplVulkanH_CreateOrResizeWindow(mInstance, mPhysicalDevice, mDevice, wd, mQueueFamily, mAllocator, width, height, mMinImageCount);
}
- void FrameRender(ImGui_ImplVulkanH_Window* wd, ImDrawData* drawData) {
+ void FrameRender(ImGui_ImplVulkanH_Window* wd, ImDrawData* drawData)
+ {
VkResult err;
VkSemaphore imageAcquiredSemaphore = wd->FrameSemaphores[wd->SemaphoreIndex].ImageAcquiredSemaphore;
@@ -356,7 +363,8 @@ private:
}
}
- void FramePresent(ImGui_ImplVulkanH_Window* wd) {
+ void FramePresent(ImGui_ImplVulkanH_Window* wd)
+ {
if (mSwapChainRebuild) {
return;
}
@@ -378,18 +386,21 @@ private:
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores
}
- void CleanupVulkan() {
+ void CleanupVulkan()
+ {
vkDestroyDescriptorPool(mDevice, mDescriptorPool, mAllocator);
vkDestroyDevice(mDevice, mAllocator);
vkDestroyInstance(mInstance, mAllocator);
}
- void CleanupVulkanWindow() {
+ void CleanupVulkanWindow()
+ {
ImGui_ImplVulkanH_DestroyWindow(mInstance, mDevice, &mMainWindowData, mAllocator);
}
- static void CheckVkResults(VkResult err) {
+ static void CheckVkResults(VkResult err)
+ {
if (err == 0) return;
std::string message;
@@ -402,12 +413,14 @@ private:
std::cerr << message << '\n';
}
}
- static void GlfwErrorCallback(int errorCode, const char* message) {
+ static void GlfwErrorCallback(int errorCode, const char* message)
+ {
std::cerr << "GLFW Error " << errorCode << ": " << message << "\n";
}
};
-std::unique_ptr<RenderingBackend> RenderingBackend::CreateVulkanBackend() {
+std::unique_ptr<RenderingBackend> RenderingBackend::CreateVulkanBackend()
+{
try {
return std::make_unique<VulkanBackend>();
} catch (std::exception& e) {
@@ -417,7 +430,8 @@ std::unique_ptr<RenderingBackend> RenderingBackend::CreateVulkanBackend() {
#else // ^^ BUILD_CORE_WITH_VULKAN_BACKEND | ~BUILD_CORE_WITH_VULKAN_BACKEND vv
-std::unique_ptr<RenderingBackend> RenderingBackend::CreateVulkanBackend() {
+std::unique_ptr<RenderingBackend> RenderingBackend::CreateVulkanBackend()
+{
return nullptr;
}