Renderpass clearing issue

Hello guys, i have a strange bug which i couldnt solve on my own:

[ATTACH=CONFIG]124[/ATTACH]

This is how i am rendering:
1.) Render scene into an offscreen framebuffer (in the image the clear-value if BLUE)
2.) Use the previous framebuffer as a input for post-processing and render it on a fullscreen quad (in this case the shader do nothing)
3.) Copy the image from the last post-processed framebuffer into the right swapchain-image

Here comes the weird thing:

  • If i am rendering a skybox (overwrite the whole render-target) then everything works fine
  • If i display just the rendered-scene (without the post-process stage) it works fine again. That means that the scene framebuffer gets definitely cleared with the mentioned blue color.

The “Clear-Value” pixels are the problem but i dont know why, nor i couldn’t find any solution. Blending is disabled.
Why the post-processing shader cant render those “cleared-pixels”?

Thanks in Advance

Are you using the correct storeOp for your attachment? If so, do you have proper barriers for resource transitioning between rendering to the offscreen framebuffer and using it in the second pass? (In case you’re using separate render passes instead of subpasses, where you’d use dependencies for implicit layout transitions).

I am using separate renderpasses. Both have VK_ATTACHMENT_STORE_OP_STORE for the color-attachment.
Beside that both renderpasses have these subpass-dependencies:

        VkSubpassDependency subpassDependencys[2];
        subpassDependencys[0].srcSubpass        = VK_SUBPASS_EXTERNAL;
        subpassDependencys[0].dstSubpass        = 0;
        subpassDependencys[0].srcStageMask      = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
        subpassDependencys[0].dstStageMask      = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
        subpassDependencys[0].srcAccessMask     = VK_ACCESS_MEMORY_READ_BIT;
        subpassDependencys[0].dstAccessMask     = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
        subpassDependencys[0].dependencyFlags   = VK_DEPENDENCY_BY_REGION_BIT;

        subpassDependencys[1].srcSubpass        = 0;
        subpassDependencys[1].dstSubpass        = VK_SUBPASS_EXTERNAL;
        subpassDependencys[1].srcStageMask      = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
        subpassDependencys[1].dstStageMask      = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
        subpassDependencys[1].srcAccessMask     = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
        subpassDependencys[1].dstAccessMask     = VK_ACCESS_MEMORY_READ_BIT;
        subpassDependencys[1].dependencyFlags   = VK_DEPENDENCY_BY_REGION_BIT;

EDIT: Tested it on my laptop (using a NVIDIA instead of a AMD card) and it works fine there. Could it be a driver bug?

I don’t think it’s a driver bug. It reminds me of this screenshot from my presentation: http://www.saschawillems.de/vulkan/khronosmeetup/#/21

This was on AMD too and didn’t happen on NVIDIA as AMD relies on proper image layout transitions. In my case the example was missing a post present barrier. I have folded those into renderpasses. But on AMD you must ensure that resources are always in the required layout for the next operation.

Can you also post the attachment descriptions showing the layouts and usage types of the attachment?

So i finally figured it out, thanks to your answer Sascha!!
I had for the color-attachment

        colorAttachment.initialLayout   = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
        colorAttachment.finalLayout     = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;

but of course i am sampling from it after rendering so i set the layouts to

        colorAttachment.initialLayout   = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
        colorAttachment.finalLayout     = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;

and now it works!
:slight_smile:

Do the VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL increase FPS ?

Depends on the implementation, but yes, using the best fit image layout is always advised and may result in better performance. So try to stay away from VK_IMAGE_LAYOUT_GENERAL if possible.