MCPcopy Create free account
hub / github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator / CreateBuffer

Function CreateBuffer

src/Tests.cpp:1200–1233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1198}
1199
1200static void CreateBuffer(
1201 VmaAllocationCreateInfo allocCreateInfo,
1202 const VkBufferCreateInfo& bufCreateInfo,
1203 bool persistentlyMapped,
1204 AllocInfo& outAllocInfo)
1205{
1206 outAllocInfo = {};
1207 outAllocInfo.m_BufferInfo = bufCreateInfo;
1208
1209 if (persistentlyMapped)
1210 allocCreateInfo.flags |= VMA_ALLOCATION_CREATE_MAPPED_BIT;
1211
1212 VmaAllocationInfo vmaAllocInfo = {};
1213 ERR_GUARD_VULKAN( vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo, &outAllocInfo.m_Buffer, &outAllocInfo.m_Allocation, &vmaAllocInfo) );
1214
1215 // Setup StartValue and fill.
1216 {
1217 outAllocInfo.m_StartValue = (uint32_t)rand();
1218 uint32_t* data = (uint32_t*)vmaAllocInfo.pMappedData;
1219 TEST((data != nullptr) == persistentlyMapped);
1220 if(!persistentlyMapped)
1221 {
1222 ERR_GUARD_VULKAN( vmaMapMemory(g_hAllocator, outAllocInfo.m_Allocation, (void**)&data) );
1223 }
1224
1225 uint32_t value = outAllocInfo.m_StartValue;
1226 TEST(bufCreateInfo.size % 4 == 0);
1227 for(size_t i = 0; i < bufCreateInfo.size / sizeof(uint32_t); ++i)
1228 data[i] = value++;
1229
1230 if(!persistentlyMapped)
1231 vmaUnmapMemory(g_hAllocator, outAllocInfo.m_Allocation);
1232 }
1233}
1234
1235void CreateImage(
1236 VmaAllocationCreateInfo allocCreateInfo,

Callers 2

Calls 4

vmaCreateBufferFunction · 0.85
TESTEnum · 0.85
vmaMapMemoryFunction · 0.85
vmaUnmapMemoryFunction · 0.85

Tested by

no test coverage detected