2

I've been coding a Vulkan rendering engine for the past few weeks. My code still continues to execute and I get the desired output, but I am getting an error.

I'm fairly certain that my error is a mistake in my code somewhere. My code is 1000+ lines, so I'm not going to ask anyone to debug it. I guess my question is what typically causes the error I'm getting, and how can I fix it?

I've been pretty closely following this (if this helps anyone): https://software.intel.com/en-us/articles/api-without-secrets-introduction-to-vulkan-part-3#_Toc445674490

My code draws the desired triangle from the tutorial, but I get an error for the first 3 frames:

VKDBG: ERROR: @[DS]: Cannot submit cmd buffer using image (0x6) [sub-resource: aspectMask 0x1 array layer 0, mip level 0], with layout VK_IMAGE_LAYOUT_UNDEFINED when first use is VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.
VKDBG: ERROR: @[DS]: Cannot submit cmd buffer using image (0x7) [sub-resource: aspectMask 0x1 array layer 0, mip level 0], with layout VK_IMAGE_LAYOUT_UNDEFINED when first use is VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.
VKDBG: ERROR: @[DS]: Cannot submit cmd buffer using image (0x8) [sub-resource: aspectMask 0x1 array layer 0, mip level 0], with layout VK_IMAGE_LAYOUT_UNDEFINED when first use is VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.

I suppose I could just ignore this, because I get a desired output and the error doesn't seem to break anything, but I would guess that it's bad practice to leave this unfixed.

Thank you for anyone helping!

user2129189
  • 387
  • 3
  • 8

3 Answers3

3

From Dustin Graves of LunarG about this exact issue:

This message appears to be generated for a swapchain image that is not being tranitioned from UNDEFINED to PRESENT_SRC_KHR. Initializing texture->imageLayout as VK_IMAGE_LAYOUT_UNDEFINED instead of VK_IMAGE_LAYOUT_PRESENT_SRC_KHR in GpuTexture_CreateFromSwapChain should take care of it.

  • Thank you! I had found that before, and looked through it, but I assumed the issue was different because it seemed to deal with loading textures. – user2129189 Aug 01 '16 at 00:57
  • If you look below at the end of the comments thread there is someone who has the identical issue you had, not the primary issue I had linked to, they're all part of a common group of validation layer behaviors. –  Aug 01 '16 at 00:59
2

Swapchain images, when acquired from the presentation engine, are in a PRESENT_SRC layout. Before we can use an image in a command buffer, we need to transition away from this layout, but using the UNDEFINED as an old layout during transition is also a proper behaviour. Nevertheless, it should also be a proper behaviour to transition away from the PRESENT_SRC layout and the reported error is (probably) a bug in validation layers.

Ekzuzy
  • 36
  • 1
0

Right, I thought images acquired from the presentation engine are always in PRESENT_SRC layout, not after the first time they were acquired:

"After a successful return, the image indicated by pImageIndex will still be in the VK_IMAGE_LAYOUT_PRESENT_SRC_KHR layout if it was previously presented, or in the VK_IMAGE_LAYOUT_UNDEFINED layout if this is the first time it has been acquired."

So it is safer to always transition away from the UNDEFINED layout.

Ekzuzy
  • 141
  • 3