vkQueuePresentKHR() error


while trying to run my Vulkan code am getting this error :

vkQueuePresentKHR(): Cannot read invalid swapchain image 0x13, please fill the memory before using.

I would like to know why this error occurs and how to go about it.

Thanks in advance

This one in particular looks uncharacteristically self-explanatory to me. It warns that you are trying to read memory that has its contents undefined (e.g. not initialized).

It is an ongoing discussion if and to what degree this should be an “error”. Nevetheless it is a useful warning. Reading such memory is often unintentional by user.

It will be triggered if you supply such image as src to copy, blit or resolve operation. Or to present operation. Or to beginRenderPass, where its first use is read or it has LOAD_OP_LOAD.

okay … does this mean that i am trying to present image to the surface without any draw call or memory write being made . If not what does contents undefined mean?

I had the error a couple times during developing and it just tells you what you think: You did not any draw-call or anything other which fills the swapchain-image with data.

Yes, you simply haven’t written anything into it in any way before attempting to read it.

All images are created with undefined content (which BTW means it may contain anything – same as in C/C++ for uninitialized variable). Unlike C/C++ the contents of an Image can become undefined even during its lifetime after some operations.