Hello, In my Vulkan journey I made a home made memory allocator. My question is about performances when we use VK_BUFFER_USAGE_TRANSFER_SRC to buffer. I explain:
I create a buffer with memory let say of size 100 (for test purpose) then I upload 3 vertex buffers A = 40, B = 15, C = 15. then I freed buffer B. At that moment the memory looks like this :
[0-39 Used] - [40 - 54 Free] - [55 - 69 used] - [70 -99 free].
when I add D = 40 it can’t fill in the first free block [40-55] and neither in the last one [70 - 99] . 40 > 15 && 40 > 30
So I wanted to move the data to get:
[0-39 Used] - [40 - 54 used] - [55 - 99 free].
The problem is that I created the buffer with usage : VK_BUFFER_USAGE_TRANSFER_DST_BITS | VK_BUFFER_USAGE_VERTEX_BITS | VK_BUFFER_USAGE_INDEX_BIT meaning I cant use vkCopy as it require that the source should be create with VK_BUFFER_USAGE_TRANSFER_SRC_BIT.
I think of 2 solutions:
1 - add VK_BUFFER_USAGE_TRANSFER_SRC_BIT when creating the buffer.
2 - create another buffer with VK_BUFFER_USAGE_TRANSFER_SRC_BIT and bind it to the same memory (I didn’t try yet)
The memory was created in LOCAL_DEVICE in case this is important to know.
Questions:
if I use (1) is there any performance penalties if I create all my buffer with transfer_src_bit?
is even the (2) possible I may try myself before somebody answers but if it works is that a correct used of buffer/memory ?
Thanks
ps: Sometimes in the forums there are some people who don’t answer the question and tell us USE VMA or this or that don’t recreate the whell. I know VMA exists and the goal here is not to write better but to understand more, what’s best to understand vulkan memory than writing something just to learn?