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;
|
||||
|
||||
Reference in New Issue
Block a user