There's a bit of a chicken and the egg issue I'm dealing with. I create a buffer, and if that buffer is going to be allocated to device-local memory then there's the possibility that the memory type I can use for that buffer will NOT be host-visible, and so I need to set the VK_BUFFER_USAGE_TRANSFER_DST_BIT flag on the buffer, and use a host-visible staging buffer. The problem goes like this:
auto bufferUsageBits = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT /* | VK_BUFFER_USAGE_TRANSFER_DST_BIT*/;
// The second flag should be set only if the memory requirements queries later
// tell me there's no device-local AND host-visible memory types
VkBuffer vkBufferHandle;
VK::createBuffer(size, bufferUsageBits, VK_SHARING_MODE_EXCLUSIVE, &vkBufferHandle);
vkGetBufferMemoryRequirements();
// Only know do I now if I need a staging buffer and the buffer I'm creating needs to be transfered to.
I could do two things as far as I can see:
- If the device is integrated or CPU type then assume that the buffer won't need the transfer flag set.
- Set the flag anyway whether it's integrated/CPU or discrete.
How am I supposed to deal with this?