Files
Seele/src/Engine/Graphics/RenderTarget.h
T

143 lines
4.4 KiB
C++
Raw Normal View History

2023-10-26 18:37:29 +02:00
#pragma once
#include "Resources.h"
#include "Texture.h"
2023-11-16 22:58:47 +01:00
#include "Window.h"
2023-10-26 18:37:29 +02:00
namespace Seele
{
namespace Gfx
{
class RenderTargetAttachment
{
public:
RenderTargetAttachment(PTexture2D texture,
SeImageLayout initialLayout,
SeImageLayout finalLayout,
2023-11-15 00:06:00 +01:00
SeAttachmentLoadOp loadOp = SE_ATTACHMENT_LOAD_OP_LOAD,
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE);
2024-01-24 23:10:33 +01:00
virtual ~RenderTargetAttachment();
virtual PTexture2D getTexture()
2023-10-26 18:37:29 +02:00
{
return texture;
}
2024-01-24 23:10:33 +01:00
virtual SeFormat getFormat() const
2023-10-26 18:37:29 +02:00
{
return texture->getFormat();
}
2024-01-24 23:10:33 +01:00
virtual SeSampleCountFlags getNumSamples() const
2023-10-26 18:37:29 +02:00
{
return texture->getNumSamples();
}
2024-01-24 23:10:33 +01:00
virtual uint32 getWidth() const
2023-10-26 18:37:29 +02:00
{
2023-11-15 00:06:00 +01:00
return texture->getWidth();
2023-10-26 18:37:29 +02:00
}
2024-01-24 23:10:33 +01:00
virtual uint32 getHeight() const
2023-10-26 18:37:29 +02:00
{
2023-11-15 00:06:00 +01:00
return texture->getHeight();
2023-10-26 18:37:29 +02:00
}
2023-12-04 16:36:02 +01:00
constexpr SeAttachmentLoadOp getLoadOp() const { return loadOp; }
constexpr SeAttachmentStoreOp getStoreOp() const { return storeOp; }
constexpr SeAttachmentLoadOp getStencilLoadOp() const { return stencilLoadOp; }
constexpr SeAttachmentStoreOp getStencilStoreOp() const { return stencilStoreOp; }
constexpr SeImageLayout getInitialLayout() const { return initialLayout; }
constexpr SeImageLayout getFinalLayout() const { return finalLayout; }
constexpr void setLoadOp(SeAttachmentLoadOp val) { loadOp = val; }
constexpr void setStoreOp(SeAttachmentStoreOp val) { storeOp = val; }
constexpr void setStencilLoadOp(SeAttachmentLoadOp val) { stencilLoadOp = val; }
constexpr void setStencilStoreOp(SeAttachmentStoreOp val) { stencilStoreOp = val; }
constexpr void setInitialLayout(SeImageLayout val) { initialLayout = val; }
constexpr void setFinalLayout(SeImageLayout val) { finalLayout = val; }
2023-10-26 18:37:29 +02:00
SeClearValue clear;
SeColorComponentFlags componentFlags;
protected:
PTexture2D texture;
SeImageLayout initialLayout;
SeImageLayout finalLayout;
2023-10-26 18:37:29 +02:00
SeAttachmentLoadOp loadOp;
SeAttachmentStoreOp storeOp;
SeAttachmentLoadOp stencilLoadOp;
SeAttachmentStoreOp stencilStoreOp;
};
DEFINE_REF(RenderTargetAttachment)
2024-01-24 23:10:33 +01:00
class SwapchainAttachment : public RenderTargetAttachment
{
public:
SwapchainAttachment(PViewport viewport,
SeImageLayout initialLayout,
SeImageLayout finalLayout,
2024-01-24 23:10:33 +01:00
SeAttachmentLoadOp loadOp = SE_ATTACHMENT_LOAD_OP_LOAD,
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE)
: RenderTargetAttachment(nullptr, initialLayout, finalLayout, loadOp, storeOp, stencilLoadOp, stencilStoreOp)
2024-01-24 23:10:33 +01:00
, viewport(viewport)
{}
virtual ~SwapchainAttachment()
{
}
virtual PTexture2D getTexture()
{
return viewport->getOwner()->getBackBuffer();
}
virtual SeFormat getFormat() const
{
return viewport->getOwner()->getSwapchainFormat();
}
virtual SeSampleCountFlags getNumSamples() const
{
return viewport->getSamples();
}
virtual uint32 getWidth() const
{
return viewport->getWidth();
}
virtual uint32 getHeight() const
{
return viewport->getHeight();
}
private:
PViewport viewport;
};
struct RenderTargetLayout
2023-10-26 18:37:29 +02:00
{
2023-11-05 10:36:01 +01:00
Array<PRenderTargetAttachment> inputAttachments;
Array<PRenderTargetAttachment> colorAttachments;
2023-11-18 11:04:30 +01:00
Array<PRenderTargetAttachment> resolveAttachments;
2023-11-05 10:36:01 +01:00
PRenderTargetAttachment depthAttachment;
2023-12-10 22:27:59 +01:00
PRenderTargetAttachment depthResolveAttachment;
2023-10-26 18:37:29 +02:00
};
struct SubPassDependency
{
uint32 srcSubpass;
uint32 dstSubpass;
SePipelineStageFlags srcStage;
SePipelineStageFlags dstStage;
SeAccessFlags srcAccess;
SeAccessFlags dstAccess;
};
2023-10-26 18:37:29 +02:00
class RenderPass
{
public:
RenderPass(RenderTargetLayout layout, Array<SubPassDependency> dependencies)
: layout(std::move(layout))
, dependencies(std::move(dependencies))
{}
2023-10-26 18:37:29 +02:00
virtual ~RenderPass() {}
2023-11-05 10:36:01 +01:00
RenderPass(RenderPass&&) = default;
RenderPass& operator=(RenderPass&&) = default;
const RenderTargetLayout& getLayout() const { return layout; }
2023-10-26 18:37:29 +02:00
protected:
RenderTargetLayout layout;
Array<SubPassDependency> dependencies;
2023-10-26 18:37:29 +02:00
};
DEFINE_REF(RenderPass)
}
}