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