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

119 lines
3.3 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,
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; }
2023-10-26 18:37:29 +02:00
SeClearValue clear;
SeColorComponentFlags componentFlags;
SeAttachmentLoadOp loadOp;
SeAttachmentStoreOp storeOp;
SeAttachmentLoadOp stencilLoadOp;
SeAttachmentStoreOp stencilStoreOp;
protected:
PTexture2D texture;
};
DEFINE_REF(RenderTargetAttachment)
2024-01-24 23:10:33 +01:00
class SwapchainAttachment : public RenderTargetAttachment
{
public:
SwapchainAttachment(PViewport viewport,
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, loadOp, storeOp, stencilLoadOp, stencilStoreOp)
, 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;
};
2023-10-26 18:37:29 +02:00
class RenderTargetLayout
{
public:
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
uint32 width;
uint32 height;
};
DEFINE_REF(RenderTargetLayout)
class RenderPass
{
public:
2023-11-01 23:12:30 +01:00
RenderPass(ORenderTargetLayout layout) : layout(std::move(layout)) {}
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;
PRenderTargetLayout getLayout() const { return layout; }
2023-10-26 18:37:29 +02:00
protected:
2023-11-01 23:12:30 +01:00
ORenderTargetLayout layout;
2023-10-26 18:37:29 +02:00
};
DEFINE_REF(RenderPass)
}
}