renaming dir
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <sophia/types.hpp>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
#include "vulkan/device.hpp"
|
||||
#include "vulkan/swapchain.hpp"
|
||||
#include "window.hpp"
|
||||
|
||||
namespace sophia {
|
||||
|
||||
struct FrameData {
|
||||
vk::CommandBuffer commandBuffer;
|
||||
vk::UniqueSemaphore imageAvailable;
|
||||
vk::UniqueFence inFlight;
|
||||
};
|
||||
|
||||
class RenderContext {
|
||||
public:
|
||||
static constexpr u32 MAX_FRAMES_IN_FLIGHT = 2;
|
||||
|
||||
RenderContext(const RenderContext&) = delete;
|
||||
RenderContext& operator=(const RenderContext&) = delete;
|
||||
|
||||
RenderContext(Window& window, Device& device);
|
||||
~RenderContext();
|
||||
|
||||
vk::CommandBuffer beginFrame();
|
||||
void endFrame();
|
||||
|
||||
Image& getCurrentImage() const {
|
||||
return this->swapchain->getImage(static_cast<int>(this->currentImageIndex));
|
||||
}
|
||||
|
||||
vk::Extent2D getExtent() const { return this->swapchain->getExtent(); }
|
||||
vk::Format getImageFormat() const {
|
||||
return this->swapchain->getImageFormat();
|
||||
}
|
||||
u32 getFrameIndex() const { return this->currentFrameIndex; }
|
||||
u32 getImageCount() const {
|
||||
return static_cast<u32>(this->swapchain->imageCount());
|
||||
}
|
||||
|
||||
private:
|
||||
void recreateSwapchain();
|
||||
void createFrames();
|
||||
|
||||
Window& window;
|
||||
Device& device;
|
||||
|
||||
std::unique_ptr<Swapchain> swapchain;
|
||||
|
||||
std::array<FrameData, MAX_FRAMES_IN_FLIGHT> frames;
|
||||
|
||||
std::vector<vk::UniqueSemaphore> renderFinishedSemaphores;
|
||||
std::vector<vk::Fence> imagesInFlight;
|
||||
|
||||
u32 currentFrameIndex = 0;
|
||||
u32 currentImageIndex = 0;
|
||||
bool isFrameStarted = false;
|
||||
};
|
||||
|
||||
} // namespace sophia
|
||||
Reference in New Issue
Block a user