Hi,
I’m writing a graphic application in Vulkan.
The idea is to render a 3D scene, and a head-up display on top of it.
That visualization requires 2 render passes to be executed:
- Render pass 1: it clears the color and depth buffers of the framebuffer, and then renders the 3D scene;
- Render pass 2: it clears the depth buffer (in order to render the head-up display on top of the scene), but keeps the content of the color buffer.
In the first render pass I had to set, as explained in the Vulkan-tutorial that I followed to write my application, an implicit dependency subpass, to wait for color and depth buffers to be ready for writing. So basically I defined this:
VkSubpassDependency dependency_1 = {};
dependency_1.srcSubpass = VK_SUBPASS_EXTERNAL;
dependency_1.dstSubpass = 0;
dependency_1.srcStageMask =
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT |
VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
dependency_1.srcAccessMask = 0;
dependency_1.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT |
VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
dependency_1.dstAccessMask =
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
And in the render pass 1 I set the dependency from this implicit sub-pass in this way:
VkRenderPass renderPass_1;
...
VkRenderPassCreateInfo renderPassInfo_1;
renderPassInfo_1.dependencyCount = 1;
renderPassInfo_1.pDependencies = &dependency_1;
In the other render pass (2), that clears the depth buffer, but not the color buffer, apparently I don’t need any additional dependency. So, in that case I do this:
VkRenderPass renderPass_2;
VkRenderPassCreateInfo renderPassInfo_2;
renderPassInfo_2.dependencyCount = 0;
renderPassInfo_2.pDependencies = nullptr;
Finally, when I create the frame buffer, I have to specify a render pass compatible with the frame buffer:
VkFramebufferCreateInfo framebufferInfo = {};
framebufferInfo.renderPass = renderPass_1;
This approach has worked fine for years, with no validation layer error, and the result on the screen was the one expected: the 3D scene on the background, with some other graphic objects (mainly texts) on top of it.
I had installed many years ago the Vulkan SDK (version 1.2.80), and enabled validation layer errors in my debug build. No error message printed in the console, and my application worked fine.
Then yesterday I updated the Vulkan SDK to the latest version (1.4.313.0), and my application started to trigger this error at startup:
Validation layer: vkCmdBeginRenderPass(): dependencyCount is incompatible between VkRenderPass 0x1f000000001f (from VkRenderPass 0x1f000000001f) and VkRenderPass 0x1d000000001d (from VkFramebuffer 0x200000000020), 0 != 1.
The Vulkan spec states: renderPass must be compatible with the renderPass member of the VkFramebufferCreateInfo structure specified when creating framebuffer
Basically, in the moment it tries to begin the render pass for the head-up display (the 2), it finds it not compatible with the render pass passed in the creation of the frame buffer (the render pass 1).
and the application soon crashes.
If instead I built the application in Release, it simply works fine.
I tried to fix it by setting the same implicit dependency sub-pass also in the render pass 2:
renderPassInfo_2.dependencyCount = 1;
renderPassInfo_2.pDependencies = &dependency_1;
But now when I run the application, it crashes directly without printing any validation error.
Anyway, in Release it keeps working fine.
Any idea about how to fix the issue in debug? I cannot either understand why my approach appeared to be fine with old Vulkan SDK, and started showing the issue only with new version.
Any help is really appreciated.
Luco.