diff --git a/native/cocos/renderer/gfx-vulkan/VKCommands.cpp b/native/cocos/renderer/gfx-vulkan/VKCommands.cpp index 710dc1ec56..bf17f1ba6e 100644 --- a/native/cocos/renderer/gfx-vulkan/VKCommands.cpp +++ b/native/cocos/renderer/gfx-vulkan/VKCommands.cpp @@ -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; } diff --git a/native/cocos/renderer/pipeline/forward/ForwardStage.cpp b/native/cocos/renderer/pipeline/forward/ForwardStage.cpp index dfb3460c2a..f65e990332 100644 --- a/native/cocos/renderer/pipeline/forward/ForwardStage.cpp +++ b/native/cocos/renderer/pipeline/forward/ForwardStage.cpp @@ -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{