52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <sophia/types.hpp>
|
|
#include <vulkan/vulkan.hpp>
|
|
|
|
#include "vulkan/device.hpp"
|
|
#include "vulkan/image.hpp"
|
|
|
|
namespace sophia {
|
|
|
|
/**
|
|
* A place rendering can go. Currently always backed by an offscreen color
|
|
* image.
|
|
*
|
|
* Owned by the ResourceRegistry and addressed through a RenderTargetHandle.
|
|
*/
|
|
class RenderTarget {
|
|
public:
|
|
RenderTarget(Device& device, vk::Format format, u32 width, u32 height);
|
|
~RenderTarget();
|
|
|
|
RenderTarget(const RenderTarget&) = delete;
|
|
RenderTarget& operator=(const RenderTarget&) = delete;
|
|
|
|
Image& getImage() const { return *this->image; }
|
|
|
|
vk::Extent2D getExtent() const;
|
|
|
|
void requestResize(u32 width, u32 height);
|
|
|
|
/**
|
|
* Applies a pending resize. Waits for the GPU, so it must run before any of
|
|
* the frame's work (or any UI reference to the image) is recorded.
|
|
*/
|
|
void applyPendingResize();
|
|
|
|
private:
|
|
void create(u32 width, u32 height);
|
|
void destroy();
|
|
|
|
Device& device;
|
|
vk::Format format;
|
|
|
|
std::unique_ptr<Image> image;
|
|
|
|
std::optional<vk::Extent2D> pendingExtent;
|
|
};
|
|
|
|
} // namespace sophia
|