Now properly clearing depth textures
This commit is contained in:
@@ -38,21 +38,25 @@ void RenderPass::Execute(PassRenderContext& ctx, PassAttachments& inputs)
|
||||
void RenderPass::ClearAttachments(PassRenderContext& ctx, PassAttachments& inputs)
|
||||
{
|
||||
// Clear all color attachments
|
||||
for (int i = 0; i < std::size(Attachments); i++)
|
||||
int attachmentIndex = 0;
|
||||
for (int i = 0; i < std::size(inputs); i++)
|
||||
{
|
||||
auto& texture = inputs[i];
|
||||
auto& spec = Attachments[i];
|
||||
|
||||
if (spec.ClearOnLoad)
|
||||
Ref<VulkanImage> input = inputs[i];
|
||||
if (input->GetUsage() == ImageUsage::Depth)
|
||||
{
|
||||
if (texture->GetUsage() != ImageUsage::Depth)
|
||||
if (DepthAttachment.ClearOnLoad)
|
||||
{
|
||||
ctx.commandBuffer.ClearColorImage(texture, this->ClearColor);
|
||||
ctx.commandBuffer.ClearDepthImage(input);
|
||||
}
|
||||
else
|
||||
}
|
||||
else if(input->GetUsage() != ImageUsage::Depth)
|
||||
{
|
||||
if (Attachments[attachmentIndex].ClearOnLoad)
|
||||
{
|
||||
ctx.commandBuffer.ClearDepthImage(texture);
|
||||
ctx.commandBuffer.ClearColorImage(input, this->ClearColor);
|
||||
}
|
||||
|
||||
attachmentIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ ShadowRenderPipeline::ShadowRenderPipeline()
|
||||
|
||||
ShadowPipeline = RenderPipeline();
|
||||
auto& shadowPass = ShadowPipeline.AddPass("Shadow");
|
||||
shadowPass.AddAttachment("Depth", ImageFormat::D32F, ImageUsage::Depth);
|
||||
shadowPass.AddAttachment("Depth", ImageFormat::D32F, ImageUsage::Depth, true);
|
||||
shadowPass.SetShaders(shaderMgr.GetShader("shadow_vert"), shaderMgr.GetShader("shadow_frag"));
|
||||
shadowPass.SetPushConstant<GBufferConstant>(gbufferConstant);
|
||||
shadowPass.SetPreRender([&](PassRenderContext& ctx) {
|
||||
|
||||
@@ -119,6 +119,7 @@ VulkanImage::VulkanImage(ImageFormat inFormat, Vector2 inSize, ImageUsage usage)
|
||||
drawImageUsages |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
drawImageUsages |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
drawImageUsages |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||
drawImageUsages |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||
}
|
||||
|
||||
VkImageCreateInfo imgCreateInfo = VulkanInit::ImageCreateInfo(static_cast<VkFormat>(inFormat), drawImageUsages, vkExtent);
|
||||
|
||||
Reference in New Issue
Block a user