Skip to content

[Vulkan] Resource binding example requires 32 bits depth on Windows #220

@dolphineye74

Description

@dolphineye74

Description

By default, the resource binding example will show a black screen & Vulkan validation errors on Windows.

System specs

  • CPU: Intel Core i7 13600 KF
  • GPU: AMD RX 6950 XT
  • RAM: 64 GB
  • OS: Windows 11 x64 24H2

Reproduction steps

  1. Generate MSVC2022 project
  2. Set resource binding example as startup project
  3. Specify the following command line arguments: Vulkan --debug
  4. Run app

Expected results

  • Should be able to visualise the 3 spheres

Actual results

Black screen with the following Vulkan validation errors:

Validation Error: [ VUID-VkFramebufferCreateInfo-attachmentCount-00876 ] Object 0: handle = 0xd897d90000000016, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0xd452b83b | vkCreateFramebuffer(): pCreateInfo->attachmentCount 3 does not match attachmentCount of 2 of VkRenderPass 0xd897d90000000016[] being used to create Framebuffer.
The Vulkan spec states: attachmentCount must be equal to the attachment count specified in renderPass (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-VkFramebufferCreateInfo-attachmentCount-00876)
...

Validation Error: [ UNASSIGNED-CoreValidation-DrawState-InvalidRenderpass ] Object 0: handle = 0xd897d90000000016, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0x9638f80000000036, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0xa1662b9 | vkCmdBeginRenderPass(): pRenderPassBegin You cannot start a render pass using a framebuffer with a different number of attachments (2 vs 3).
Validation Error: [ VUID-VkPresentInfoKHR-pImageIndices-01430 ] Object 0: handle = 0x2bd3ded8950, type = VK_OBJECT_TYPE_QUEUE; | MessageID = 0x48ad24c6 | vkQueuePresentKHR(): pPresentInfo->pSwapchains[0] images passed to present must be in layout VK_IMAGE_LAYOUT_PRESENT_SRC_KHR or VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR but is in VK_IMAGE_LAYOUT_UNDEFINED.
The Vulkan spec states: Each element of pImageIndices must be the index of a presentable image acquired from the swapchain specified by the corresponding element of the pSwapchains array, and the presented image subresource must be in the VK_IMAGE_LAYOUT_PRESENT_SRC_KHR or VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR layout at the time the operation is executed on a VkDevice (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-VkPresentInfoKHR-pImageIndices-01430)
...

Workaround

Enforcing a 32 bits depth when creating the swap chain seems to fix the issue, but I'm not sure of exactly what's going on, so I'm sharing my findings here:

index 6901ccca..c45b58d3 100644
--- a/examples/Cpp/ExampleBase/ExampleBase.cpp
+++ b/examples/Cpp/ExampleBase/ExampleBase.cpp
@@ -548,6 +548,8 @@ ExampleBase::ExampleBase(const LLGL::UTF8String& title)
         swapChainDesc.samples       = std::min<std::uint32_t>(g_Config.samples, renderer->GetRenderingCaps().limits.maxColorBufferSamples);
         #endif
         swapChainDesc.resizable     = true;
+        swapChainDesc.depthBits     = 32;
+        swapChainDesc.stencilBits   = 8;
     }
     swapChain = renderer->CreateSwapChain(swapChainDesc);

Note that using zero bits for the stencil buffer also works correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    VKVulkan specific issuebug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions