Win32 vulkan window
This commit is contained in:
parent
415e523a45
commit
b5e69c90fa
12 changed files with 950 additions and 85 deletions
|
|
@ -40,6 +40,7 @@ module;
|
|||
#include <wayland-client-protocol.h>
|
||||
#endif
|
||||
#ifdef CRAFTER_GRAPHICS_VULKAN
|
||||
#ifndef CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -61,6 +62,9 @@ module;
|
|||
#include <wayland-client-protocol.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <vulkan/vulkan_wayland.h>
|
||||
#else
|
||||
#include <vulkan/vulkan.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
export module Crafter.Graphics:Window;
|
||||
|
|
@ -278,7 +282,7 @@ export namespace Crafter {
|
|||
// Command buffer submission and execution
|
||||
VkSemaphore renderComplete;
|
||||
};
|
||||
|
||||
#ifndef CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32
|
||||
class WindowVulkan final : public Window, public WindowKeyboard, public WindowMouse, public WindowTitle {
|
||||
public:
|
||||
WindowVulkan(std::uint32_t width, std::uint32_t height);
|
||||
|
|
@ -412,5 +416,63 @@ export namespace Crafter {
|
|||
VkStridedDeviceAddressRegionKHR hitRegion;
|
||||
VkStridedDeviceAddressRegionKHR callableRegion;
|
||||
};
|
||||
#else
|
||||
class WindowVulkan final : public Window, public WindowKeyboard, public WindowMouse, public WindowTitle {
|
||||
public:
|
||||
WindowVulkan(std::uint32_t width, std::uint32_t height);
|
||||
WindowVulkan(std::uint32_t width, std::uint32_t height, const std::string_view title);
|
||||
~WindowVulkan();
|
||||
Event<void> onRender;
|
||||
std::vector<VkDescriptorSet> descriptorsRt;
|
||||
void Render();
|
||||
void QueueRender();
|
||||
void Resize(std::uint32_t width, std::uint32_t height);
|
||||
void StartSync() override;
|
||||
void StartUpdate() override;
|
||||
void StopUpdate() override;
|
||||
void SetTitle(const std::string_view title) override;
|
||||
VkCommandBuffer StartInit();
|
||||
void FinishInit();
|
||||
|
||||
template <typename Pipeline>
|
||||
void SetPipelineRT() {
|
||||
rtPipeline = Pipeline::pipeline;
|
||||
rtPipelineLayout = Pipeline::pipelineLayout;
|
||||
raygenRegion = Pipeline::raygenRegion;
|
||||
missRegion = Pipeline::missRegion;
|
||||
hitRegion = Pipeline::hitRegion;
|
||||
callableRegion = Pipeline::callableRegion;
|
||||
}
|
||||
|
||||
void SetPipelineRT(PipelineRTVulkan& pipeline) {
|
||||
rtPipeline = pipeline.pipeline;
|
||||
rtPipelineLayout = pipeline.pipelineLayout;
|
||||
raygenRegion = pipeline.raygenRegion;
|
||||
missRegion = pipeline.missRegion;
|
||||
hitRegion = pipeline.hitRegion;
|
||||
callableRegion = pipeline.callableRegion;
|
||||
}
|
||||
void CreateSwapchain();
|
||||
static constexpr std::uint32_t numFrames = 3;
|
||||
VkSurfaceKHR vulkanSurface = VK_NULL_HANDLE;
|
||||
VkSwapchainKHR swapChain = VK_NULL_HANDLE;
|
||||
VkFormat colorFormat;
|
||||
VkColorSpaceKHR colorSpace;
|
||||
VkImage images[numFrames];
|
||||
VkImageView imageViews[numFrames];
|
||||
std::thread thread;
|
||||
VkCommandBuffer drawCmdBuffers[numFrames];
|
||||
VkSubmitInfo submitInfo;
|
||||
Semaphores semaphores;
|
||||
uint32_t currentBuffer = 0;
|
||||
VkPipelineStageFlags submitPipelineStages = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
VkPipeline rtPipeline;
|
||||
VkPipelineLayout rtPipelineLayout;
|
||||
VkStridedDeviceAddressRegionKHR raygenRegion;
|
||||
VkStridedDeviceAddressRegionKHR missRegion;
|
||||
VkStridedDeviceAddressRegionKHR hitRegion;
|
||||
VkStridedDeviceAddressRegionKHR callableRegion;
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue