aboutsummaryrefslogtreecommitdiff
path: root/app/source/Cplt/ImGuiBackend/Backend_Vulkan.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'app/source/Cplt/ImGuiBackend/Backend_Vulkan.cpp')
-rw-r--r--app/source/Cplt/ImGuiBackend/Backend_Vulkan.cpp42
1 files changed, 14 insertions, 28 deletions
diff --git a/app/source/Cplt/ImGuiBackend/Backend_Vulkan.cpp b/app/source/Cplt/ImGuiBackend/Backend_Vulkan.cpp
index 3694f05..6532b37 100644
--- a/app/source/Cplt/ImGuiBackend/Backend_Vulkan.cpp
+++ b/app/source/Cplt/ImGuiBackend/Backend_Vulkan.cpp
@@ -12,8 +12,7 @@
# include <backend/imgui_impl_vulkan.h>
# include <backend/imgui_impl_vulkan.cpp>
-class VulkanBackend : public RenderingBackend
-{
+class VulkanBackend : public RenderingBackend {
private:
GLFWwindow* mWindow;
@@ -32,8 +31,7 @@ private:
bool mSwapChainRebuild = false;
public:
- VulkanBackend()
- {
+ VulkanBackend() {
glfwSetErrorCallback(&GlfwErrorCallback);
if (!glfwInit()) {
throw std::runtime_error("Failed to initialize GLFW.");
@@ -82,8 +80,7 @@ public:
ImGui_ImplVulkan_Init(&init_info, mMainWindowData.RenderPass);
}
- virtual ~VulkanBackend()
- {
+ virtual ~VulkanBackend() {
auto err = vkDeviceWaitIdle(mDevice);
CheckVkResults(err);
ImGui_ImplVulkan_Shutdown();
@@ -97,8 +94,7 @@ public:
glfwTerminate();
}
- virtual void RunUntilWindowClose(void (*windowContent)()) override
- {
+ virtual void RunUntilWindowClose(void (*windowContent)()) override {
// Upload Fonts
{
// Use any command queue
@@ -162,8 +158,7 @@ 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
@@ -272,8 +267,7 @@ 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
@@ -297,8 +291,7 @@ 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;
@@ -363,8 +356,7 @@ private:
}
}
- void FramePresent(ImGui_ImplVulkanH_Window* wd)
- {
+ void FramePresent(ImGui_ImplVulkanH_Window* wd) {
if (mSwapChainRebuild) {
return;
}
@@ -386,21 +378,18 @@ 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;
@@ -413,14 +402,12 @@ 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) {
@@ -430,8 +417,7 @@ 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;
}