| 5151 | } |
| 5152 | |
| 5153 | static void TestPool_SameSize() |
| 5154 | { |
| 5155 | const VkDeviceSize BUF_SIZE = 1024 * 1024; |
| 5156 | const size_t BUF_COUNT = 100; |
| 5157 | VkResult res; |
| 5158 | |
| 5159 | RandomNumberGenerator rand{123}; |
| 5160 | |
| 5161 | VkBufferCreateInfo bufferInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO }; |
| 5162 | bufferInfo.size = BUF_SIZE; |
| 5163 | bufferInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; |
| 5164 | |
| 5165 | uint32_t memoryTypeBits = UINT32_MAX; |
| 5166 | { |
| 5167 | VkBuffer dummyBuffer; |
| 5168 | res = vkCreateBuffer(g_hDevice, &bufferInfo, g_Allocs, &dummyBuffer); |
| 5169 | TEST(res == VK_SUCCESS); |
| 5170 | |
| 5171 | VkMemoryRequirements memReq; |
| 5172 | vkGetBufferMemoryRequirements(g_hDevice, dummyBuffer, &memReq); |
| 5173 | memoryTypeBits = memReq.memoryTypeBits; |
| 5174 | |
| 5175 | vkDestroyBuffer(g_hDevice, dummyBuffer, g_Allocs); |
| 5176 | } |
| 5177 | |
| 5178 | VmaAllocationCreateInfo poolAllocInfo = {}; |
| 5179 | poolAllocInfo.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT; |
| 5180 | uint32_t memTypeIndex; |
| 5181 | res = vmaFindMemoryTypeIndex( |
| 5182 | g_hAllocator, |
| 5183 | memoryTypeBits, |
| 5184 | &poolAllocInfo, |
| 5185 | &memTypeIndex); |
| 5186 | |
| 5187 | VmaPoolCreateInfo poolCreateInfo = {}; |
| 5188 | poolCreateInfo.memoryTypeIndex = memTypeIndex; |
| 5189 | poolCreateInfo.blockSize = BUF_SIZE * BUF_COUNT / 4; |
| 5190 | poolCreateInfo.minBlockCount = 1; |
| 5191 | poolCreateInfo.maxBlockCount = 4; |
| 5192 | |
| 5193 | VmaPool pool; |
| 5194 | res = vmaCreatePool(g_hAllocator, &poolCreateInfo, &pool); |
| 5195 | TEST(res == VK_SUCCESS); |
| 5196 | |
| 5197 | // Test pool name |
| 5198 | { |
| 5199 | static const char* const POOL_NAME = "Pool name"; |
| 5200 | vmaSetPoolName(g_hAllocator, pool, POOL_NAME); |
| 5201 | |
| 5202 | const char* fetchedPoolName = nullptr; |
| 5203 | vmaGetPoolName(g_hAllocator, pool, &fetchedPoolName); |
| 5204 | TEST(strcmp(fetchedPoolName, POOL_NAME) == 0); |
| 5205 | |
| 5206 | // Generate JSON dump. There was a bug with this... |
| 5207 | char* json = nullptr; |
| 5208 | vmaBuildStatsString(g_hAllocator, &json, VK_TRUE); |
| 5209 | vmaFreeStatsString(g_hAllocator, json); |
| 5210 |
no test coverage detected