2023-10-26 18:37:29 +02:00
|
|
|
#pragma once
|
2024-04-13 23:51:38 +02:00
|
|
|
#include "Graphics/Enums.h"
|
2023-10-26 18:37:29 +02:00
|
|
|
#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
|
|
|
|
2024-06-09 12:20:04 +02:00
|
|
|
namespace Seele {
|
|
|
|
|
namespace Gfx {
|
|
|
|
|
class RenderTargetAttachment {
|
|
|
|
|
public:
|
|
|
|
|
RenderTargetAttachment() {}
|
|
|
|
|
RenderTargetAttachment(PTexture2D texture, SeImageLayout initialLayout, SeImageLayout finalLayout,
|
|
|
|
|
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-02-01 10:21:36 +01:00
|
|
|
|
2024-06-09 12:20:04 +02:00
|
|
|
RenderTargetAttachment(PViewport viewport, SeImageLayout initialLayout, SeImageLayout finalLayout,
|
|
|
|
|
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-02-01 10:21:36 +01:00
|
|
|
~RenderTargetAttachment();
|
2024-06-09 12:20:04 +02:00
|
|
|
PTexture2D getTexture() const {
|
|
|
|
|
if (viewport != nullptr) {
|
2024-02-01 10:21:36 +01:00
|
|
|
return viewport->getOwner()->getBackBuffer();
|
|
|
|
|
}
|
2023-10-26 18:37:29 +02:00
|
|
|
return texture;
|
|
|
|
|
}
|
2024-06-09 12:20:04 +02:00
|
|
|
SeFormat getFormat() const {
|
|
|
|
|
if (viewport != nullptr) {
|
2024-02-01 10:21:36 +01:00
|
|
|
return viewport->getOwner()->getSwapchainFormat();
|
|
|
|
|
}
|
2023-10-26 18:37:29 +02:00
|
|
|
return texture->getFormat();
|
|
|
|
|
}
|
2024-06-09 12:20:04 +02:00
|
|
|
SeSampleCountFlags getNumSamples() const {
|
|
|
|
|
if (viewport != nullptr) {
|
2025-03-10 18:35:35 +01:00
|
|
|
// viewport backbuffers are not multisampled themselves
|
|
|
|
|
return Gfx::SE_SAMPLE_COUNT_1_BIT;
|
2024-02-01 10:21:36 +01:00
|
|
|
}
|
2023-10-26 18:37:29 +02:00
|
|
|
return texture->getNumSamples();
|
|
|
|
|
}
|
2024-06-09 12:20:04 +02:00
|
|
|
uint32 getWidth() const {
|
|
|
|
|
if (viewport != nullptr) {
|
2024-02-01 10:21:36 +01:00
|
|
|
return viewport->getWidth();
|
|
|
|
|
}
|
2024-06-09 12:20:04 +02:00
|
|
|
return texture->getWidth();
|
2023-10-26 18:37:29 +02:00
|
|
|
}
|
2024-06-09 12:20:04 +02:00
|
|
|
uint32 getHeight() const {
|
|
|
|
|
if (viewport != nullptr) {
|
2024-02-01 10:21:36 +01:00
|
|
|
return viewport->getHeight();
|
|
|
|
|
}
|
2024-06-09 12:20:04 +02: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; }
|
2024-01-31 09:49:53 +01:00
|
|
|
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; }
|
2024-06-09 12:20:04 +02:00
|
|
|
SeClearValue clear = {{{0}}};
|
2024-04-05 10:41:59 +02:00
|
|
|
SeColorComponentFlags componentFlags = 0;
|
2024-06-09 12:20:04 +02:00
|
|
|
|
|
|
|
|
protected:
|
2024-02-01 10:21:36 +01:00
|
|
|
PTexture2D texture = nullptr;
|
|
|
|
|
PViewport viewport = nullptr;
|
2024-04-13 23:51:38 +02:00
|
|
|
SeImageLayout initialLayout = SE_IMAGE_LAYOUT_UNDEFINED;
|
|
|
|
|
SeImageLayout finalLayout = SE_IMAGE_LAYOUT_UNDEFINED;
|
|
|
|
|
SeAttachmentLoadOp loadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE;
|
|
|
|
|
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_DONT_CARE;
|
|
|
|
|
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE;
|
|
|
|
|
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE;
|
2023-10-26 18:37:29 +02:00
|
|
|
};
|
2024-01-24 23:10:33 +01:00
|
|
|
|
2024-06-09 12:20:04 +02:00
|
|
|
struct RenderTargetLayout {
|
2024-02-01 10:21:36 +01:00
|
|
|
Array<RenderTargetAttachment> inputAttachments;
|
|
|
|
|
Array<RenderTargetAttachment> colorAttachments;
|
|
|
|
|
Array<RenderTargetAttachment> resolveAttachments;
|
|
|
|
|
RenderTargetAttachment depthAttachment;
|
|
|
|
|
RenderTargetAttachment depthResolveAttachment;
|
2023-10-26 18:37:29 +02:00
|
|
|
};
|
2024-01-31 09:49:53 +01:00
|
|
|
|
2024-06-09 12:20:04 +02:00
|
|
|
struct SubPassDependency {
|
2024-01-31 09:49:53 +01:00
|
|
|
uint32 srcSubpass;
|
|
|
|
|
uint32 dstSubpass;
|
|
|
|
|
SePipelineStageFlags srcStage;
|
|
|
|
|
SePipelineStageFlags dstStage;
|
|
|
|
|
SeAccessFlags srcAccess;
|
|
|
|
|
SeAccessFlags dstAccess;
|
|
|
|
|
};
|
2023-10-26 18:37:29 +02:00
|
|
|
|
2024-06-09 12:20:04 +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;
|
2024-01-31 09:49:53 +01:00
|
|
|
const RenderTargetLayout& getLayout() const { return layout; }
|
2023-10-26 18:37:29 +02:00
|
|
|
|
2024-06-09 12:20:04 +02:00
|
|
|
protected:
|
2024-01-31 09:49:53 +01:00
|
|
|
RenderTargetLayout layout;
|
|
|
|
|
Array<SubPassDependency> dependencies;
|
2023-10-26 18:37:29 +02:00
|
|
|
};
|
|
|
|
|
DEFINE_REF(RenderPass)
|
2024-06-09 12:20:04 +02:00
|
|
|
} // namespace Gfx
|
|
|
|
|
} // namespace Seele
|