I need to read out the depth buffer’s contents in response to a mouse click.
I’m using Sascha Willem’s example for reading a swap chain image to take a screenshot.
I recall there’s a transfer and or visible bit that must be set.
My code is checking that (VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) are set.
I thought I was setting everything correctly.
VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
_swapChain._depthImage.create(depthFormat, usage, _swapChain._extent.width, _swapChain._extent.height, _msaaSamples);
which then passes down to
_imageInfo.usage = usage;
if (vkCreateImage(dc.device_, &_imageInfo, nullptr, &_image) != VK_SUCCESS) {
throw runtime_error("failed to create image!");
}
When I create the temporary buffer for the copy, the visible and coherent bits aren’t set. I’ve also tried
_imageInfo.usage = usage |
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
When creating the temporary image - no luck so far.
The project and branch are located at
Any input would be appreciated.