#pragma once #include #include #include #include #include "device.hpp" #include "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; std::optional pendingExtent; }; } // namespace sophia