fix attachment layout for partial clear (#4097)

This commit is contained in:
Yun Hsiao Wu
2021-12-09 18:32:55 +08:00
committed by GitHub
parent 0c835d487d
commit bf97459a92
2 changed files with 6 additions and 7 deletions
@@ -388,7 +388,7 @@ void cmdFuncCCVKCreateRenderPass(CCVKDevice *device, CCVKGPURenderPass *gpuRende
attachmentDescriptions[i].storeOp = mapVkStoreOp(attachment.storeOp);
attachmentDescriptions[i].stencilLoadOp = hasStencil ? attachmentDescriptions[i].loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachmentDescriptions[i].stencilStoreOp = hasStencil ? attachmentDescriptions[i].storeOp : VK_ATTACHMENT_STORE_OP_DONT_CARE;
attachmentDescriptions[i].initialLayout = attachment.loadOp == gfx::LoadOp::LOAD ? beginAccessInfo.imageLayout : VK_IMAGE_LAYOUT_UNDEFINED;
attachmentDescriptions[i].initialLayout = attachment.loadOp == gfx::LoadOp::DISCARD ? VK_IMAGE_LAYOUT_UNDEFINED : beginAccessInfo.imageLayout;
attachmentDescriptions[i].finalLayout = endAccessInfo.imageLayout;
}
if (hasDepth) {
@@ -420,7 +420,7 @@ void cmdFuncCCVKCreateRenderPass(CCVKDevice *device, CCVKGPURenderPass *gpuRende
attachmentDescriptions[colorAttachmentCount].storeOp = mapVkStoreOp(depthStencilAttachment.depthStoreOp);
attachmentDescriptions[colorAttachmentCount].stencilLoadOp = hasStencil ? mapVkLoadOp(depthStencilAttachment.stencilLoadOp) : VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachmentDescriptions[colorAttachmentCount].stencilStoreOp = hasStencil ? mapVkStoreOp(depthStencilAttachment.stencilStoreOp) : VK_ATTACHMENT_STORE_OP_DONT_CARE;
attachmentDescriptions[colorAttachmentCount].initialLayout = depthStencilAttachment.depthLoadOp == gfx::LoadOp::LOAD ? beginAccessInfo.imageLayout : VK_IMAGE_LAYOUT_UNDEFINED;
attachmentDescriptions[colorAttachmentCount].initialLayout = depthStencilAttachment.depthLoadOp == gfx::LoadOp::DISCARD ? VK_IMAGE_LAYOUT_UNDEFINED : beginAccessInfo.imageLayout;
attachmentDescriptions[colorAttachmentCount].finalLayout = endAccessInfo.imageLayout;
}
@@ -37,7 +37,6 @@
#include "gfx-base/GFXFramebuffer.h"
#include "pipeline/UIPhase.h"
namespace cc {
namespace pipeline {
@@ -168,7 +167,7 @@ void ForwardStage::render(scene::Camera *camera) {
if (shadingScale != 1.F) {
colorTexInfo.usage |= gfx::TextureUsageBit::TRANSFER_SRC;
}
data.outputTex = builder.create(RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo);
data.outputTex = builder.create(RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo);
framegraph::RenderTargetAttachment::Descriptor colorAttachmentInfo;
colorAttachmentInfo.usage = framegraph::RenderTargetAttachment::Usage::COLOR;
colorAttachmentInfo.clearColor = _clearColors[0];
@@ -179,11 +178,11 @@ void ForwardStage::render(scene::Camera *camera) {
colorAttachmentInfo.loadOp = gfx::LoadOp::DISCARD;
} else {
colorAttachmentInfo.loadOp = gfx::LoadOp::LOAD;
colorAttachmentInfo.beginAccesses = {gfx::AccessType::COLOR_ATTACHMENT_WRITE};
}
}
colorAttachmentInfo.endAccesses = {gfx::AccessType::COLOR_ATTACHMENT_WRITE};
data.outputTex = builder.write(data.outputTex, colorAttachmentInfo);
colorAttachmentInfo.beginAccesses = colorAttachmentInfo.endAccesses = {gfx::AccessType::COLOR_ATTACHMENT_WRITE};
data.outputTex = builder.write(data.outputTex, colorAttachmentInfo);
builder.writeToBlackboard(RenderPipeline::fgStrHandleOutColorTexture, data.outputTex);
// depth
gfx::TextureInfo depthTexInfo{