Files
fs2open.github.com/code/graphics/vulkan/RenderFrame.h
asarium 4a0a8463ee Add first basic rendering with Vulkan
This is basically the tutorial from vulkan-tutorial.com adapted to using
VulkanHpp and with some refactorings that extract some locigally
self-contained code.

Currently only draws a simple colored triangle.
2020-10-14 22:21:45 +02:00

40 lines
879 B
C++

#pragma once
#include "globalincs/pstypes.h"
#include <vulkan/vulkan.hpp>
namespace graphics {
namespace vulkan {
class RenderFrame {
public:
RenderFrame(vk::Device device, vk::SwapchainKHR swapChain, vk::Queue graphicsQueue, vk::Queue presentQueue);
void waitForFinish();
uint32_t acquireSwapchainImage();
void onFrameFinished(std::function<void()> finishFunc);
void submitAndPresent(const std::vector<vk::CommandBuffer>& cmdBuffers);
private:
vk::Device m_device;
vk::SwapchainKHR m_swapChain;
vk::Queue m_graphicsQueue;
vk::Queue m_presentQueue;
vk::UniqueSemaphore m_imageAvailableSemaphore;
vk::UniqueSemaphore m_renderingFinishedSemaphore;
vk::UniqueFence m_frameInFlightFence;
SCP_vector<std::function<void()>> m_frameFinishedCallbacks;
bool m_inFlight = false;
uint32_t m_swapChainIdx = 0;
};
} // namespace vulkan
} // namespace graphics