45 lines
1.2 KiB
Text
45 lines
1.2 KiB
Text
|
|
module;
|
||
|
|
|
||
|
|
#include <cstdint>
|
||
|
|
#include <string>
|
||
|
|
#include <vulkan/vulkan.h>
|
||
|
|
#include <vulkan/vulkan_wayland.h>
|
||
|
|
#include <vector>
|
||
|
|
#include <thread>
|
||
|
|
|
||
|
|
export module Crafter.Graphics:WindowWaylandVulkan;
|
||
|
|
import Crafter.Event;
|
||
|
|
import :WindowWayland;
|
||
|
|
import Crafter.Component;
|
||
|
|
|
||
|
|
namespace Crafter {
|
||
|
|
struct SwapchainElement
|
||
|
|
{
|
||
|
|
VkCommandBuffer commandBuffer;
|
||
|
|
VkImage image;
|
||
|
|
VkImageView imageView;
|
||
|
|
VkFramebuffer framebuffer;
|
||
|
|
VkSemaphore startSemaphore;
|
||
|
|
VkSemaphore endSemaphore;
|
||
|
|
VkFence fence;
|
||
|
|
VkFence lastFence;
|
||
|
|
};
|
||
|
|
|
||
|
|
export class WindowWaylandVulkan : public WindowWayland {
|
||
|
|
public:
|
||
|
|
WindowWaylandVulkan(std::string name, std::uint32_t width, std::uint32_t height);
|
||
|
|
void Start();
|
||
|
|
inline static VkRenderPass renderPass = VK_NULL_HANDLE;
|
||
|
|
private:
|
||
|
|
void CreateSwapchain();
|
||
|
|
void DestroySwapchain();
|
||
|
|
VkSurfaceKHR vulkanSurface = VK_NULL_HANDLE;
|
||
|
|
VkSwapchainKHR swapchain = VK_NULL_HANDLE;
|
||
|
|
std::vector<SwapchainElement> swapchainElements;
|
||
|
|
std::uint32_t imageCount;
|
||
|
|
std::uint32_t currentFrame = 0;
|
||
|
|
std::uint32_t imageIndex = 0;
|
||
|
|
VkFormat format = VK_FORMAT_UNDEFINED;
|
||
|
|
std::thread thread;
|
||
|
|
};
|
||
|
|
}
|