111 lines
2.9 KiB
C++
111 lines
2.9 KiB
C++
//
|
|
// Created by kj16609 on 11/28/23.
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#pragma GCC diagnostic push
|
|
#pragma GCC diagnostic ignored "-Weffc++"
|
|
#pragma GCC diagnostic ignored "-Wduplicated-branches"
|
|
#define GLM_ENABLE_EXPERIMENTAL
|
|
#include <glm/glm.hpp>
|
|
#include <glm/gtx/string_cast.hpp>
|
|
#pragma GCC diagnostic pop
|
|
|
|
#include "CameraViewpoint.hpp"
|
|
#include "CompositeSwapchain.hpp"
|
|
#include "GBufferSwapchain.hpp"
|
|
#include "debug/Track.hpp"
|
|
#include "engine/descriptors/DescriptorSet.hpp"
|
|
#include "engine/memory/buffers/HostSingleT.hpp"
|
|
#include "engine/memory/buffers/UniqueFrameSuballocation.hpp"
|
|
#include "engine/primitives/Frustum.hpp"
|
|
#include "engine/rendering/types.hpp"
|
|
|
|
namespace vk::raii
|
|
{
|
|
class CommandBuffer;
|
|
class RenderPass;
|
|
} // namespace vk::raii
|
|
|
|
namespace fgl::engine
|
|
{
|
|
namespace descriptors
|
|
{
|
|
class DescriptorSetLayout;
|
|
}
|
|
class Image;
|
|
struct FrameInfo;
|
|
class GBufferRenderer;
|
|
|
|
struct CameraInfo;
|
|
class RenderCamera;
|
|
|
|
FrustumBase createFrustum( float aspect, float fovy, float near, float far );
|
|
|
|
using CameraIDX = std::uint8_t;
|
|
|
|
class RenderCamera final : public CameraViewpoint
|
|
{
|
|
inline static CameraIDX m_camera_counter { 0 };
|
|
|
|
debug::Track< "CPU", "Camera" > m_camera {};
|
|
|
|
vk::Extent2D m_target_extent;
|
|
|
|
std::unique_ptr< CompositeSwapchain > m_composite_swapchain;
|
|
std::unique_ptr< GBufferSwapchain > m_gbuffer_swapchain;
|
|
|
|
//TODO: Move to deffered deleter
|
|
std::queue< std::unique_ptr< CompositeSwapchain > > m_old_composite_swapchain {};
|
|
std::queue< std::unique_ptr< GBufferSwapchain > > m_old_gbuffer_swapchain {};
|
|
|
|
std::shared_ptr< GBufferRenderer > m_camera_renderer;
|
|
|
|
//! True if the camera is active and to be rendered
|
|
bool m_active { true };
|
|
|
|
//! If true, The camera's swapchain is to be destroyed to preserve memory.
|
|
//! This is here to allow us to set a camera cold when it's not likely to be used soon
|
|
bool m_cold { false };
|
|
|
|
// Const is acceptable, Since this value should never change. EVER
|
|
const CameraIDX m_camera_idx { m_camera_counter++ };
|
|
|
|
std::string m_name { "Unnamed Camera" };
|
|
|
|
RenderCamera( vk::Extent2D extent, memory::Buffer& buffer, const std::shared_ptr< GBufferRenderer >& renderer );
|
|
|
|
friend class CameraManager;
|
|
|
|
public:
|
|
|
|
FGL_DELETE_ALL_RO5( RenderCamera );
|
|
|
|
~RenderCamera();
|
|
|
|
[[nodiscard]] CameraIDX getIDX() const;
|
|
|
|
[[nodiscard]] const std::string& getName() const;
|
|
|
|
descriptors::DescriptorSet& getDescriptor( FrameIndex index );
|
|
|
|
void setExtent( vk::Extent2D extent );
|
|
|
|
//! Performs the render pass for this camera
|
|
void pass( FrameInfo& frame_info );
|
|
|
|
[[nodiscard]] GBufferSwapchain& getSwapchain() const;
|
|
[[nodiscard]] CompositeSwapchain& getCompositeSwapchain() const;
|
|
|
|
void remakeSwapchain( vk::Extent2D extent );
|
|
|
|
void setName( std::string_view str );
|
|
|
|
[[nodiscard]] float aspectRatio() const;
|
|
|
|
void copyOutput( const vk::raii::CommandBuffer& command_buffer, FrameIndex frame_index, Image& target ) const;
|
|
};
|
|
|
|
} // namespace fgl::engine
|