Changing render attachment sharing
This commit is contained in:
@@ -71,7 +71,7 @@ void BasePass::render()
|
||||
tLightGrid->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
depthAttachment->getTexture()->pipelineBarrier(
|
||||
depthAttachment.getTexture()->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
|
||||
|
||||
@@ -190,7 +190,7 @@ void BasePass::endFrame()
|
||||
|
||||
void BasePass::publishOutputs()
|
||||
{
|
||||
colorAttachment = new Gfx::SwapchainAttachment(viewport,
|
||||
colorAttachment = Gfx::RenderTargetAttachment(viewport,
|
||||
Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||
resources->registerRenderPassOutput("BASEPASS_COLOR", colorAttachment);
|
||||
@@ -199,9 +199,9 @@ void BasePass::publishOutputs()
|
||||
void BasePass::createRenderPass()
|
||||
{
|
||||
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
|
||||
depthAttachment->setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
|
||||
depthAttachment->setInitialLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL);
|
||||
depthAttachment->setFinalLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
depthAttachment.setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
|
||||
depthAttachment.setInitialLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL);
|
||||
depthAttachment.setFinalLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
|
||||
.colorAttachments = { colorAttachment },
|
||||
.depthAttachment = depthAttachment,
|
||||
|
||||
@@ -19,8 +19,8 @@ public:
|
||||
virtual void createRenderPass() override;
|
||||
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
|
||||
private:
|
||||
Gfx::ORenderTargetAttachment colorAttachment;
|
||||
Gfx::PRenderTargetAttachment depthAttachment;
|
||||
Gfx::RenderTargetAttachment colorAttachment;
|
||||
Gfx::RenderTargetAttachment depthAttachment;
|
||||
Gfx::PShaderBuffer oLightIndexList;
|
||||
Gfx::PShaderBuffer tLightIndexList;
|
||||
Gfx::PTexture2D oLightGrid;
|
||||
|
||||
@@ -69,12 +69,12 @@ void DebugPass::publishOutputs()
|
||||
|
||||
void DebugPass::createRenderPass()
|
||||
{
|
||||
Gfx::PRenderTargetAttachment baseColorAttachment = resources->requestRenderTarget("BASEPASS_COLOR");
|
||||
baseColorAttachment->setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
|
||||
baseColorAttachment->setInitialLayout(Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
Gfx::PRenderTargetAttachment depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
|
||||
depthAttachment->setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
|
||||
depthAttachment->setInitialLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
Gfx::RenderTargetAttachment baseColorAttachment = resources->requestRenderTarget("BASEPASS_COLOR");
|
||||
baseColorAttachment.setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
|
||||
baseColorAttachment.setInitialLayout(Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
Gfx::RenderTargetAttachment depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
|
||||
depthAttachment.setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
|
||||
depthAttachment.setInitialLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
|
||||
.colorAttachments = {baseColorAttachment},
|
||||
.depthAttachment = depthAttachment,
|
||||
|
||||
@@ -152,10 +152,10 @@ void DepthPrepass::publishOutputs()
|
||||
};
|
||||
depthBuffer = graphics->createTexture2D(depthBufferInfo);
|
||||
depthAttachment =
|
||||
new Gfx::RenderTargetAttachment(depthBuffer,
|
||||
Gfx::RenderTargetAttachment(depthBuffer,
|
||||
Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_GENERAL,
|
||||
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||
depthAttachment->clear.depthStencil.depth = 1.0f;
|
||||
depthAttachment.clear.depthStencil.depth = 1.0f;
|
||||
resources->registerRenderPassOutput("DEPTHPREPASS_DEPTH", depthAttachment);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
virtual void createRenderPass() override;
|
||||
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
|
||||
private:
|
||||
Gfx::ORenderTargetAttachment depthAttachment;
|
||||
Gfx::RenderTargetAttachment depthAttachment;
|
||||
Gfx::OTexture2D depthBuffer;
|
||||
|
||||
Array<Gfx::PDescriptorSet> descriptorSets;
|
||||
|
||||
@@ -184,7 +184,7 @@ void LightCullingPass::publishOutputs()
|
||||
|
||||
void LightCullingPass::createRenderPass()
|
||||
{
|
||||
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH")->getTexture();
|
||||
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH").getTexture();
|
||||
}
|
||||
|
||||
void LightCullingPass::modifyRenderPassMacros(Map<const char*, const char*>&)
|
||||
|
||||
@@ -13,47 +13,27 @@ RenderGraphResources::~RenderGraphResources()
|
||||
|
||||
}
|
||||
|
||||
Gfx::PRenderTargetAttachment RenderGraphResources::requestRenderTarget(const std::string& outputName)
|
||||
Gfx::RenderTargetAttachment RenderGraphResources::requestRenderTarget(const std::string& outputName)
|
||||
{
|
||||
if(registeredAttachments.find(outputName) == registeredAttachments.end())
|
||||
{
|
||||
std::cout << "Attachment " << outputName << " not found" << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
return registeredAttachments[outputName];
|
||||
return registeredAttachments.at(outputName);
|
||||
}
|
||||
|
||||
Gfx::PTexture RenderGraphResources::requestTexture(const std::string& outputName)
|
||||
{
|
||||
if(registeredTextures.find(outputName) == registeredTextures.end())
|
||||
{
|
||||
std::cout << "Attachment " << outputName << " not found" << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
return registeredTextures[outputName];
|
||||
return registeredTextures.at(outputName);
|
||||
}
|
||||
|
||||
Gfx::PShaderBuffer RenderGraphResources::requestBuffer(const std::string& outputName)
|
||||
{
|
||||
if(registeredBuffers.find(outputName) == registeredBuffers.end())
|
||||
{
|
||||
std::cout << "Attachment " << outputName << " not found" << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
return registeredBuffers[outputName];
|
||||
return registeredBuffers.at(outputName);
|
||||
}
|
||||
|
||||
Gfx::PUniformBuffer RenderGraphResources::requestUniform(const std::string& outputName)
|
||||
{
|
||||
if(registeredUniforms.find(outputName) == registeredUniforms.end())
|
||||
{
|
||||
std::cout << "Attachment " << outputName << " not found" << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
return registeredUniforms[outputName];
|
||||
return registeredUniforms.at(outputName);
|
||||
}
|
||||
|
||||
void RenderGraphResources::registerRenderPassOutput(const std::string& outputName, Gfx::PRenderTargetAttachment attachment)
|
||||
void RenderGraphResources::registerRenderPassOutput(const std::string& outputName, Gfx::RenderTargetAttachment attachment)
|
||||
{
|
||||
registeredAttachments[outputName] = attachment;
|
||||
}
|
||||
|
||||
@@ -13,16 +13,16 @@ class RenderGraphResources
|
||||
public:
|
||||
RenderGraphResources();
|
||||
~RenderGraphResources();
|
||||
Gfx::PRenderTargetAttachment requestRenderTarget(const std::string& outputName);
|
||||
Gfx::RenderTargetAttachment requestRenderTarget(const std::string& outputName);
|
||||
Gfx::PTexture requestTexture(const std::string& outputName);
|
||||
Gfx::PShaderBuffer requestBuffer(const std::string& outputName);
|
||||
Gfx::PUniformBuffer requestUniform(const std::string& outputName);
|
||||
void registerRenderPassOutput(const std::string& outputName, Gfx::PRenderTargetAttachment attachment);
|
||||
void registerRenderPassOutput(const std::string& outputName, Gfx::RenderTargetAttachment attachment);
|
||||
void registerTextureOutput(const std::string& outputName, Gfx::PTexture buffer);
|
||||
void registerBufferOutput(const std::string& outputName, Gfx::PShaderBuffer buffer);
|
||||
void registerUniformOutput(const std::string& outputName, Gfx::PUniformBuffer buffer);
|
||||
protected:
|
||||
Map<std::string, Gfx::PRenderTargetAttachment> registeredAttachments;
|
||||
Map<std::string, Gfx::RenderTargetAttachment> registeredAttachments;
|
||||
Map<std::string, Gfx::PTexture> registeredTextures;
|
||||
Map<std::string, Gfx::PShaderBuffer> registeredBuffers;
|
||||
Map<std::string, Gfx::PUniformBuffer> registeredUniforms;
|
||||
|
||||
@@ -47,11 +47,11 @@ void SkyboxRenderPass::beginFrame(const Component::Camera& cam)
|
||||
|
||||
void SkyboxRenderPass::render()
|
||||
{
|
||||
colorAttachment->getTexture()->pipelineBarrier(
|
||||
colorAttachment.getTexture()->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||
Gfx::SE_ACCESS_COLOR_ATTACHMENT_READ_BIT, Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
|
||||
);
|
||||
depthAttachment->getTexture()->pipelineBarrier(
|
||||
depthAttachment.getTexture()->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
|
||||
);
|
||||
|
||||
@@ -18,8 +18,8 @@ public:
|
||||
virtual void publishOutputs() override;
|
||||
virtual void createRenderPass() override;
|
||||
private:
|
||||
Gfx::PRenderTargetAttachment colorAttachment;
|
||||
Gfx::PRenderTargetAttachment depthAttachment;
|
||||
Gfx::RenderTargetAttachment colorAttachment;
|
||||
Gfx::RenderTargetAttachment depthAttachment;
|
||||
Gfx::ODescriptorLayout skyboxDataLayout;
|
||||
Gfx::PDescriptorSet skyboxDataSet;
|
||||
Gfx::ODescriptorLayout textureLayout;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
namespace Seele
|
||||
{
|
||||
DECLARE_NAME_REF(Gfx, Texture2D)
|
||||
DECLARE_NAME_REF(Gfx, RenderTargetAttachment)
|
||||
DECLARE_NAME_REF(Gfx, ShaderBuffer)
|
||||
struct TextRender
|
||||
{
|
||||
@@ -64,8 +63,8 @@ private:
|
||||
};
|
||||
Map<PFontAsset, Array<TextResources>> textResources;
|
||||
|
||||
Gfx::PRenderTargetAttachment renderTarget;
|
||||
Gfx::PRenderTargetAttachment depthAttachment;
|
||||
Gfx::RenderTargetAttachment renderTarget;
|
||||
Gfx::RenderTargetAttachment depthAttachment;
|
||||
|
||||
Gfx::ODescriptorLayout generalLayout;
|
||||
Gfx::ODescriptorLayout textureArrayLayout;
|
||||
|
||||
@@ -70,10 +70,10 @@ void UIPass::publishOutputs()
|
||||
|
||||
depthBuffer = graphics->createTexture2D(depthBufferInfo);
|
||||
depthAttachment =
|
||||
new Gfx::RenderTargetAttachment(depthBuffer,
|
||||
Gfx::RenderTargetAttachment(depthBuffer,
|
||||
Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||
depthAttachment->clear.depthStencil.depth = 1.0f;
|
||||
depthAttachment.clear.depthStencil.depth = 1.0f;
|
||||
resources->registerRenderPassOutput("UIPASS_DEPTH", depthAttachment);
|
||||
|
||||
TextureCreateInfo colorBufferInfo = {
|
||||
@@ -84,10 +84,10 @@ void UIPass::publishOutputs()
|
||||
};
|
||||
colorBuffer = graphics->createTexture2D(colorBufferInfo);
|
||||
renderTarget =
|
||||
new Gfx::RenderTargetAttachment(colorBuffer,
|
||||
Gfx::RenderTargetAttachment(colorBuffer,
|
||||
Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||
renderTarget->clear.color = { {0.0f, 0.0f, 0.0f, 1.0f} };
|
||||
renderTarget.clear.color = { {0.0f, 0.0f, 0.0f, 1.0f} };
|
||||
resources->registerRenderPassOutput("UIPASS_COLOR", renderTarget);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ public:
|
||||
virtual void publishOutputs() override;
|
||||
virtual void createRenderPass() override;
|
||||
private:
|
||||
Gfx::ORenderTargetAttachment renderTarget;
|
||||
Gfx::RenderTargetAttachment renderTarget;
|
||||
Gfx::OTexture2D colorBuffer;
|
||||
Gfx::ORenderTargetAttachment depthAttachment;
|
||||
Gfx::RenderTargetAttachment depthAttachment;
|
||||
Gfx::OTexture2D depthBuffer;
|
||||
|
||||
Gfx::ODescriptorLayout descriptorLayout;
|
||||
|
||||
@@ -22,6 +22,25 @@ RenderTargetAttachment::RenderTargetAttachment(PTexture2D texture,
|
||||
{
|
||||
}
|
||||
|
||||
RenderTargetAttachment::RenderTargetAttachment(PViewport viewport,
|
||||
SeImageLayout initialLayout,
|
||||
SeImageLayout finalLayout,
|
||||
SeAttachmentLoadOp loadOp,
|
||||
SeAttachmentStoreOp storeOp,
|
||||
SeAttachmentLoadOp stencilLoadOp,
|
||||
SeAttachmentStoreOp stencilStoreOp)
|
||||
: clear()
|
||||
, componentFlags(0)
|
||||
, viewport(viewport)
|
||||
, initialLayout(initialLayout)
|
||||
, finalLayout(finalLayout)
|
||||
, loadOp(loadOp)
|
||||
, storeOp(storeOp)
|
||||
, stencilLoadOp(stencilLoadOp)
|
||||
, stencilStoreOp(stencilStoreOp)
|
||||
{
|
||||
}
|
||||
|
||||
RenderTargetAttachment::~RenderTargetAttachment()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace Gfx
|
||||
class RenderTargetAttachment
|
||||
{
|
||||
public:
|
||||
RenderTargetAttachment()
|
||||
{}
|
||||
RenderTargetAttachment(PTexture2D texture,
|
||||
SeImageLayout initialLayout,
|
||||
SeImageLayout finalLayout,
|
||||
@@ -17,25 +19,53 @@ public:
|
||||
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
|
||||
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
|
||||
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE);
|
||||
virtual ~RenderTargetAttachment();
|
||||
virtual PTexture2D getTexture()
|
||||
|
||||
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);
|
||||
~RenderTargetAttachment();
|
||||
PTexture2D getTexture()
|
||||
{
|
||||
if(viewport != nullptr)
|
||||
{
|
||||
return viewport->getOwner()->getBackBuffer();
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
virtual SeFormat getFormat() const
|
||||
SeFormat getFormat() const
|
||||
{
|
||||
if(viewport != nullptr)
|
||||
{
|
||||
return viewport->getOwner()->getSwapchainFormat();
|
||||
}
|
||||
return texture->getFormat();
|
||||
}
|
||||
virtual SeSampleCountFlags getNumSamples() const
|
||||
SeSampleCountFlags getNumSamples() const
|
||||
{
|
||||
if(viewport != nullptr)
|
||||
{
|
||||
return viewport->getSamples();
|
||||
}
|
||||
return texture->getNumSamples();
|
||||
}
|
||||
virtual uint32 getWidth() const
|
||||
uint32 getWidth() const
|
||||
{
|
||||
if(viewport != nullptr)
|
||||
{
|
||||
return viewport->getWidth();
|
||||
}
|
||||
return texture->getWidth();
|
||||
}
|
||||
virtual uint32 getHeight() const
|
||||
uint32 getHeight() const
|
||||
{
|
||||
if(viewport != nullptr)
|
||||
{
|
||||
return viewport->getHeight();
|
||||
}
|
||||
return texture->getHeight();
|
||||
}
|
||||
constexpr SeAttachmentLoadOp getLoadOp() const { return loadOp; }
|
||||
@@ -53,7 +83,8 @@ public:
|
||||
SeClearValue clear;
|
||||
SeColorComponentFlags componentFlags;
|
||||
protected:
|
||||
PTexture2D texture;
|
||||
PTexture2D texture = nullptr;
|
||||
PViewport viewport = nullptr;
|
||||
SeImageLayout initialLayout;
|
||||
SeImageLayout finalLayout;
|
||||
SeAttachmentLoadOp loadOp;
|
||||
@@ -61,55 +92,14 @@ protected:
|
||||
SeAttachmentLoadOp stencilLoadOp;
|
||||
SeAttachmentStoreOp stencilStoreOp;
|
||||
};
|
||||
DEFINE_REF(RenderTargetAttachment)
|
||||
|
||||
class SwapchainAttachment : public RenderTargetAttachment
|
||||
{
|
||||
public:
|
||||
SwapchainAttachment(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)
|
||||
: RenderTargetAttachment(nullptr, initialLayout, finalLayout, 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;
|
||||
};
|
||||
|
||||
struct RenderTargetLayout
|
||||
{
|
||||
Array<PRenderTargetAttachment> inputAttachments;
|
||||
Array<PRenderTargetAttachment> colorAttachments;
|
||||
Array<PRenderTargetAttachment> resolveAttachments;
|
||||
PRenderTargetAttachment depthAttachment;
|
||||
PRenderTargetAttachment depthResolveAttachment;
|
||||
Array<RenderTargetAttachment> inputAttachments;
|
||||
Array<RenderTargetAttachment> colorAttachments;
|
||||
Array<RenderTargetAttachment> resolveAttachments;
|
||||
RenderTargetAttachment depthAttachment;
|
||||
RenderTargetAttachment depthResolveAttachment;
|
||||
};
|
||||
|
||||
struct SubPassDependency
|
||||
|
||||
@@ -19,7 +19,7 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::Render
|
||||
uint32 height = 0;
|
||||
for (auto inputAttachment : layout.inputAttachments)
|
||||
{
|
||||
PTexture2D vkInputAttachment = inputAttachment->getTexture().cast<Texture2D>();
|
||||
PTexture2D vkInputAttachment = inputAttachment.getTexture().cast<Texture2D>();
|
||||
attachments.add(vkInputAttachment->getView());
|
||||
description.inputAttachments[description.numInputAttachments++] = vkInputAttachment->getView();
|
||||
width = std::max(width, vkInputAttachment->getWidth());
|
||||
@@ -27,7 +27,7 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::Render
|
||||
}
|
||||
for (auto colorAttachment : layout.colorAttachments)
|
||||
{
|
||||
PTexture2D vkColorAttachment = colorAttachment->getTexture().cast<Texture2D>();
|
||||
PTexture2D vkColorAttachment = colorAttachment.getTexture().cast<Texture2D>();
|
||||
attachments.add(vkColorAttachment->getView());
|
||||
description.colorAttachments[description.numColorAttachments++] = vkColorAttachment->getView();
|
||||
width = std::max(width, vkColorAttachment->getWidth());
|
||||
@@ -35,23 +35,23 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::Render
|
||||
}
|
||||
for (auto resolveAttachment : layout.resolveAttachments)
|
||||
{
|
||||
PTexture2D vkResolveAttachment = resolveAttachment->getTexture().cast<Texture2D>();
|
||||
PTexture2D vkResolveAttachment = resolveAttachment.getTexture().cast<Texture2D>();
|
||||
attachments.add(vkResolveAttachment->getView());
|
||||
description.resolveAttachments[description.numResolveAttachments++] = vkResolveAttachment->getView();
|
||||
width = std::max(width, vkResolveAttachment->getWidth());
|
||||
height = std::max(height, vkResolveAttachment->getHeight());
|
||||
}
|
||||
if (layout.depthAttachment != nullptr)
|
||||
if (layout.depthAttachment.getTexture() != nullptr)
|
||||
{
|
||||
PTexture2D vkDepthAttachment = layout.depthAttachment->getTexture().cast<Texture2D>();
|
||||
PTexture2D vkDepthAttachment = layout.depthAttachment.getTexture().cast<Texture2D>();
|
||||
attachments.add(vkDepthAttachment->getView());
|
||||
description.depthAttachment = vkDepthAttachment->getView();
|
||||
width = std::max(width, vkDepthAttachment->getWidth());
|
||||
height = std::max(height, vkDepthAttachment->getHeight());
|
||||
}
|
||||
if (layout.depthResolveAttachment != nullptr)
|
||||
if (layout.depthResolveAttachment.getTexture() != nullptr)
|
||||
{
|
||||
PTexture2D vkDepthAttachment = layout.depthResolveAttachment->getTexture().cast<Texture2D>();
|
||||
PTexture2D vkDepthAttachment = layout.depthResolveAttachment.getTexture().cast<Texture2D>();
|
||||
attachments.add(vkDepthAttachment->getView());
|
||||
description.depthResolveAttachment = vkDepthAttachment->getView();
|
||||
width = std::max(width, vkDepthAttachment->getWidth());
|
||||
|
||||
@@ -27,18 +27,18 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
||||
uint32 attachmentCounter = 0;
|
||||
for (auto& inputAttachment : layout.inputAttachments)
|
||||
{
|
||||
PTexture2D image = inputAttachment->getTexture().cast<Texture2D>();
|
||||
PTexture2D image = inputAttachment.getTexture().cast<Texture2D>();
|
||||
VkAttachmentDescription2& desc = attachments.add() = {
|
||||
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
.format = cast(image->getFormat()),
|
||||
.loadOp = cast(inputAttachment->getLoadOp()),
|
||||
.storeOp = cast(inputAttachment->getStoreOp()),
|
||||
.stencilLoadOp = cast(inputAttachment->getStencilLoadOp()),
|
||||
.stencilStoreOp = cast(inputAttachment->getStencilStoreOp()),
|
||||
.initialLayout = cast(inputAttachment->getInitialLayout()),
|
||||
.finalLayout = cast(inputAttachment->getFinalLayout()),
|
||||
.loadOp = cast(inputAttachment.getLoadOp()),
|
||||
.storeOp = cast(inputAttachment.getStoreOp()),
|
||||
.stencilLoadOp = cast(inputAttachment.getStencilLoadOp()),
|
||||
.stencilStoreOp = cast(inputAttachment.getStencilStoreOp()),
|
||||
.initialLayout = cast(inputAttachment.getInitialLayout()),
|
||||
.finalLayout = cast(inputAttachment.getFinalLayout()),
|
||||
};
|
||||
|
||||
inputRefs.add() = {
|
||||
@@ -52,20 +52,20 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
||||
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
.format = cast(colorAttachment->getFormat()),
|
||||
.samples = (VkSampleCountFlagBits)colorAttachment->getNumSamples(),
|
||||
.loadOp = cast(colorAttachment->getLoadOp()),
|
||||
.storeOp = cast(colorAttachment->getStoreOp()),
|
||||
.stencilLoadOp = cast(colorAttachment->getStencilLoadOp()),
|
||||
.stencilStoreOp = cast(colorAttachment->getStencilStoreOp()),
|
||||
.initialLayout = cast(colorAttachment->getInitialLayout()),
|
||||
.finalLayout = cast(colorAttachment->getFinalLayout()),
|
||||
.format = cast(colorAttachment.getFormat()),
|
||||
.samples = (VkSampleCountFlagBits)colorAttachment.getNumSamples(),
|
||||
.loadOp = cast(colorAttachment.getLoadOp()),
|
||||
.storeOp = cast(colorAttachment.getStoreOp()),
|
||||
.stencilLoadOp = cast(colorAttachment.getStencilLoadOp()),
|
||||
.stencilStoreOp = cast(colorAttachment.getStencilStoreOp()),
|
||||
.initialLayout = cast(colorAttachment.getInitialLayout()),
|
||||
.finalLayout = cast(colorAttachment.getFinalLayout()),
|
||||
};
|
||||
|
||||
VkClearValue& clearValue = clearValues.add();
|
||||
if(attachments.back().loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
|
||||
{
|
||||
clearValue = cast(colorAttachment->clear);
|
||||
clearValue = cast(colorAttachment.clear);
|
||||
}
|
||||
|
||||
colorRefs.add() = {
|
||||
@@ -81,20 +81,20 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
||||
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
.format = cast(resolveAttachment->getFormat()),
|
||||
.samples = (VkSampleCountFlagBits)resolveAttachment->getNumSamples(),
|
||||
.loadOp = cast(resolveAttachment->getLoadOp()),
|
||||
.storeOp = cast(resolveAttachment->getStoreOp()),
|
||||
.stencilLoadOp = cast(resolveAttachment->getStencilLoadOp()),
|
||||
.stencilStoreOp = cast(resolveAttachment->getStencilStoreOp()),
|
||||
.initialLayout = cast(resolveAttachment->getInitialLayout()),
|
||||
.finalLayout = cast(resolveAttachment->getFinalLayout()),
|
||||
.format = cast(resolveAttachment.getFormat()),
|
||||
.samples = (VkSampleCountFlagBits)resolveAttachment.getNumSamples(),
|
||||
.loadOp = cast(resolveAttachment.getLoadOp()),
|
||||
.storeOp = cast(resolveAttachment.getStoreOp()),
|
||||
.stencilLoadOp = cast(resolveAttachment.getStencilLoadOp()),
|
||||
.stencilStoreOp = cast(resolveAttachment.getStencilStoreOp()),
|
||||
.initialLayout = cast(resolveAttachment.getInitialLayout()),
|
||||
.finalLayout = cast(resolveAttachment.getFinalLayout()),
|
||||
};
|
||||
|
||||
VkClearValue& clearValue = clearValues.add();
|
||||
if (attachments.back().loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
|
||||
{
|
||||
clearValue = cast(resolveAttachment->clear);
|
||||
clearValue = cast(resolveAttachment.clear);
|
||||
}
|
||||
|
||||
resolveRefs.add() = {
|
||||
@@ -104,27 +104,27 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
||||
.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||
};
|
||||
}
|
||||
if (layout.depthAttachment != nullptr)
|
||||
if (layout.depthAttachment.getTexture() != nullptr)
|
||||
{
|
||||
PTexture2D image = layout.depthAttachment->getTexture().cast<Texture2D>();
|
||||
PTexture2D image = layout.depthAttachment.getTexture().cast<Texture2D>();
|
||||
attachments.add() = {
|
||||
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
.format = cast(image->getFormat()),
|
||||
.samples = (VkSampleCountFlagBits)image->getNumSamples(),
|
||||
.loadOp = cast(layout.depthAttachment->getLoadOp()),
|
||||
.storeOp = cast(layout.depthAttachment->getStoreOp()),
|
||||
.stencilLoadOp = cast(layout.depthAttachment->getStencilLoadOp()),
|
||||
.stencilStoreOp = cast(layout.depthAttachment->getStencilStoreOp()),
|
||||
.initialLayout = cast(layout.depthAttachment->getInitialLayout()),
|
||||
.finalLayout = cast(layout.depthAttachment->getFinalLayout()),
|
||||
.loadOp = cast(layout.depthAttachment.getLoadOp()),
|
||||
.storeOp = cast(layout.depthAttachment.getStoreOp()),
|
||||
.stencilLoadOp = cast(layout.depthAttachment.getStencilLoadOp()),
|
||||
.stencilStoreOp = cast(layout.depthAttachment.getStencilStoreOp()),
|
||||
.initialLayout = cast(layout.depthAttachment.getInitialLayout()),
|
||||
.finalLayout = cast(layout.depthAttachment.getFinalLayout()),
|
||||
};
|
||||
|
||||
VkClearValue& clearValue = clearValues.add();
|
||||
if (attachments.back().loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
|
||||
{
|
||||
clearValue = cast(layout.depthAttachment->clear);
|
||||
clearValue = cast(layout.depthAttachment.clear);
|
||||
}
|
||||
|
||||
depthRef = {
|
||||
@@ -134,21 +134,21 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
||||
.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||
};
|
||||
}
|
||||
if (layout.depthResolveAttachment != nullptr)
|
||||
if (layout.depthResolveAttachment.getTexture() != nullptr)
|
||||
{
|
||||
PTexture2D image = layout.depthResolveAttachment->getTexture().cast<Texture2D>();
|
||||
PTexture2D image = layout.depthResolveAttachment.getTexture().cast<Texture2D>();
|
||||
attachments.add() = {
|
||||
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
.format = cast(image->getFormat()),
|
||||
.samples = (VkSampleCountFlagBits)image->getNumSamples(),
|
||||
.loadOp = cast(layout.depthResolveAttachment->getLoadOp()),
|
||||
.storeOp = cast(layout.depthResolveAttachment->getStoreOp()),
|
||||
.stencilLoadOp = cast(layout.depthResolveAttachment->getStencilLoadOp()),
|
||||
.stencilStoreOp = cast(layout.depthResolveAttachment->getStencilStoreOp()),
|
||||
.initialLayout = cast(layout.depthResolveAttachment->getInitialLayout()),
|
||||
.finalLayout = cast(layout.depthResolveAttachment->getFinalLayout()),
|
||||
.loadOp = cast(layout.depthResolveAttachment.getLoadOp()),
|
||||
.storeOp = cast(layout.depthResolveAttachment.getStoreOp()),
|
||||
.stencilLoadOp = cast(layout.depthResolveAttachment.getStencilLoadOp()),
|
||||
.stencilStoreOp = cast(layout.depthResolveAttachment.getStencilStoreOp()),
|
||||
.initialLayout = cast(layout.depthResolveAttachment.getInitialLayout()),
|
||||
.finalLayout = cast(layout.depthResolveAttachment.getFinalLayout()),
|
||||
};
|
||||
depthResolveRef = {
|
||||
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2,
|
||||
@@ -167,7 +167,7 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
||||
};
|
||||
VkSubpassDescription2 subPassDesc = {
|
||||
.sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2,
|
||||
.pNext = layout.depthResolveAttachment != nullptr ? &depthResolve : nullptr,
|
||||
.pNext = layout.depthResolveAttachment.getTexture() != nullptr ? &depthResolve : nullptr,
|
||||
.flags = 0,
|
||||
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
.inputAttachmentCount = (uint32)inputRefs.size(),
|
||||
@@ -216,17 +216,17 @@ uint32 RenderPass::getFramebufferHash()
|
||||
std::memset(&description, 0, sizeof(FramebufferDescription));
|
||||
for (auto& inputAttachment : layout.inputAttachments)
|
||||
{
|
||||
PTexture2D tex = inputAttachment->getTexture().cast<Texture2D>();
|
||||
PTexture2D tex = inputAttachment.getTexture().cast<Texture2D>();
|
||||
description.inputAttachments[description.numInputAttachments++] = tex->getView();
|
||||
}
|
||||
for (auto& colorAttachment : layout.colorAttachments)
|
||||
{
|
||||
PTexture2D tex = colorAttachment->getTexture().cast<Texture2D>();
|
||||
PTexture2D tex = colorAttachment.getTexture().cast<Texture2D>();
|
||||
description.colorAttachments[description.numColorAttachments++] = tex->getView();
|
||||
}
|
||||
if (layout.depthAttachment != nullptr)
|
||||
if (layout.depthAttachment.getTexture() != nullptr)
|
||||
{
|
||||
PTexture2D tex = layout.depthAttachment->getTexture().cast<Texture2D>();
|
||||
PTexture2D tex = layout.depthAttachment.getTexture().cast<Texture2D>();
|
||||
description.depthAttachment = tex->getView();
|
||||
}
|
||||
return CRC::Calculate(&description, sizeof(FramebufferDescription), CRC::CRC_32());
|
||||
@@ -236,17 +236,17 @@ void Vulkan::RenderPass::endRenderPass()
|
||||
{
|
||||
for (auto& inputAttachment : layout.inputAttachments)
|
||||
{
|
||||
PTexture2D tex = inputAttachment->getTexture().cast<Texture2D>();
|
||||
tex->setLayout(inputAttachment->getFinalLayout());
|
||||
PTexture2D tex = inputAttachment.getTexture().cast<Texture2D>();
|
||||
tex->setLayout(inputAttachment.getFinalLayout());
|
||||
}
|
||||
for (auto& colorAttachment : layout.colorAttachments)
|
||||
{
|
||||
PTexture2D tex = colorAttachment->getTexture().cast<Texture2D>();
|
||||
tex->setLayout(colorAttachment->getFinalLayout());
|
||||
PTexture2D tex = colorAttachment.getTexture().cast<Texture2D>();
|
||||
tex->setLayout(colorAttachment.getFinalLayout());
|
||||
}
|
||||
if (layout.depthAttachment != nullptr)
|
||||
if (layout.depthAttachment.getTexture() != nullptr)
|
||||
{
|
||||
PTexture2D tex = layout.depthAttachment->getTexture().cast<Texture2D>();
|
||||
tex->setLayout(layout.depthAttachment->getFinalLayout());
|
||||
PTexture2D tex = layout.depthAttachment.getTexture().cast<Texture2D>();
|
||||
tex->setLayout(layout.depthAttachment.getFinalLayout());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user