2025-04-19 15:46:26 +02:00
|
|
|
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 {
|
2025-04-19 23:59:27 +02:00
|
|
|
struct DepthStencil {
|
2025-04-19 15:46:26 +02:00
|
|
|
VkImage image;
|
2025-04-19 23:59:27 +02:00
|
|
|
VkDeviceMemory memory;
|
|
|
|
|
VkImageView view;
|
2025-04-19 15:46:26 +02:00
|
|
|
};
|
|
|
|
|
|
2025-04-19 23:59:27 +02:00
|
|
|
struct Semaphores {
|
|
|
|
|
// Swap chain image presentation
|
|
|
|
|
VkSemaphore presentComplete;
|
|
|
|
|
// Command buffer submission and execution
|
|
|
|
|
VkSemaphore renderComplete;
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-19 15:46:26 +02:00
|
|
|
export class WindowWaylandVulkan : public WindowWayland {
|
|
|
|
|
public:
|
|
|
|
|
WindowWaylandVulkan(std::string name, std::uint32_t width, std::uint32_t height);
|
2025-04-19 23:59:27 +02:00
|
|
|
~WindowWaylandVulkan();
|
2025-04-19 15:46:26 +02:00
|
|
|
void Start();
|
|
|
|
|
private:
|
|
|
|
|
void CreateSwapchain();
|
|
|
|
|
VkSurfaceKHR vulkanSurface = VK_NULL_HANDLE;
|
2025-04-19 23:59:27 +02:00
|
|
|
VkSwapchainKHR swapChain = VK_NULL_HANDLE;
|
|
|
|
|
VkFormat colorFormat;
|
|
|
|
|
VkColorSpaceKHR colorSpace;
|
|
|
|
|
std::vector<VkImage> images;
|
|
|
|
|
std::vector<VkImageView> imageViews;
|
2025-04-19 15:46:26 +02:00
|
|
|
std::thread thread;
|
2025-04-19 23:59:27 +02:00
|
|
|
std::vector<VkCommandBuffer> drawCmdBuffers;
|
|
|
|
|
std::vector<VkFramebuffer> frameBuffers;
|
|
|
|
|
VkSubmitInfo submitInfo;
|
|
|
|
|
DepthStencil depthStencil;
|
|
|
|
|
Semaphores semaphores;
|
|
|
|
|
uint32_t currentBuffer = 0;
|
|
|
|
|
VkPipelineStageFlags submitPipelineStages = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
|
|
|
|
VkRenderPass renderPass = VK_NULL_HANDLE;
|
2025-04-19 15:46:26 +02:00
|
|
|
};
|
|
|
|
|
}
|