Replace the OpenGL rendering backend with Vulkan across the engine: - Graphics: add VulkanContext (instance/device/swapchain/renderpass with depth-stencil), port Canvas to nanovg-on-Vulkan and DebugGUI to the imgui Vulkan backend, drop GLEW. Wait for the Wayland configure handshake before the first present and rebuild the swapchain to the confirmed size so the window maps reliably on fractional-scale outputs. - RasterRender: reimplement RenderBuffer, shaders and object pipeline on Vulkan (offscreen VkImage target with MSAA resolve, SPIR-V pipelines, push-constant MVP, depth remap for Vulkan clip space). - Sketch3D: port the stroke renderer (geometry-shader line expansion) and stroke GPU buffers to Vulkan. - 3DEditor: port the path-tracer texture upload to a Vulkan staging upload and keep raster/path-tracer viewports oriented consistently. - Add a nanovg external-VkImage bridge plus a render-target registry so 3D render targets can be shown inside the 2D canvas. - Prefer the Wayland platform in GLFW regardless of DISPLAY. - Widgets: make BasicLayout size distribution converge with a sub-pixel epsilon instead of an exact-zero comparison, which could otherwise spin forever on fractional-scale displays and block the first frame. Vendor nanovg_vulkan and add a standalone VulkanGraphics module.
95 lines
2.1 KiB
C++
95 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include "VulkanUtils.hpp"
|
|
|
|
#include "VulkanTime.hpp"
|
|
|
|
#include <GLFW/glfw3.h>
|
|
|
|
class SwapChain;
|
|
|
|
class VulkanWindow {
|
|
public:
|
|
VulkanWindow();
|
|
~VulkanWindow();
|
|
|
|
GLFWwindow* getWindow();
|
|
VkDevice getDevice();
|
|
RenderCreateInfo getRenderInfo();
|
|
void setRenderPass(VkRenderPass renderPass);
|
|
|
|
struct FrameData {
|
|
VkSemaphore imageAvailableSemaphore;
|
|
VkSemaphore renderFinishedSemaphore;
|
|
VkFence inFlightFence;
|
|
|
|
VkCommandBuffer commandBuffer;
|
|
VkFramebuffer frameBuffer;
|
|
VkExtent2D extent2D;
|
|
uint32_t swapChainImageIndex;
|
|
};
|
|
|
|
void pollEvents();
|
|
void waitDevice();
|
|
|
|
FrameData startDrawFrame();
|
|
void endDrawFrame(const FrameData& frame);
|
|
|
|
void scheduleWindowResize(int sizeX, int sizeY);
|
|
|
|
private:
|
|
void initWindow();
|
|
|
|
void initVulkan();
|
|
|
|
void createLogicalDevice(const std::vector<const char *> &deviceExtensions);
|
|
|
|
void getQueues();
|
|
|
|
void createWindowSurface();
|
|
|
|
void recreateSwapChain(int sizeX, int sizeY);
|
|
|
|
void createSynchronizationObjects();
|
|
|
|
void destroySynchronizationObjects();
|
|
|
|
void cleanup();
|
|
|
|
void createCommandPool();
|
|
|
|
void createCommandBuffer();
|
|
|
|
void destroyCommandPool();
|
|
|
|
public:
|
|
GLFWwindow *mWindow = nullptr;
|
|
|
|
bool mWindowSizeDirtyFlag = true;
|
|
TimePoint mWindowSizeDirtyFlagTime = std::chrono::system_clock::now();
|
|
TimeMs mWindowSizeApplyMinDelay = 200;
|
|
std::pair<int, int> mWindowFramebufferSize = {0, 0};
|
|
|
|
int mGraphicsQueueFamilyIndex = -1;
|
|
int mPresentationQueueFamilyIndex = -1;
|
|
|
|
VkCommandPool mCommandPool = VK_NULL_HANDLE;
|
|
VkCommandBuffer mCommandBuffer = VK_NULL_HANDLE;
|
|
|
|
VkInstance mInstance = VK_NULL_HANDLE;
|
|
VkPhysicalDevice mPhysicalDevice = VK_NULL_HANDLE;
|
|
VkDevice mDevice = VK_NULL_HANDLE;
|
|
|
|
VkQueue mGraphicsQueue = VK_NULL_HANDLE;
|
|
VkQueue mPresentQueue = VK_NULL_HANDLE;
|
|
|
|
VkSurfaceKHR mSurface = VK_NULL_HANDLE;
|
|
SwapChain* mSwapChain = nullptr;
|
|
|
|
VkRenderPass mRenderPass = VK_NULL_HANDLE;
|
|
// Renderer* mRenderer = nullptr;
|
|
|
|
VkSemaphore mSemaphoreImageAcquired = VK_NULL_HANDLE;
|
|
VkSemaphore mSemaphoreFramebufferDrawn = VK_NULL_HANDLE;
|
|
VkFence mFenceCanStartNewFrame = VK_NULL_HANDLE;
|
|
};
|