@@ -2267,11 +2267,13 @@ void TestDefragmentationAlgorithms()
2267
2267
2268
2268
VkImageCreateInfo imageCreateInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO };
2269
2269
imageCreateInfo.imageType = VK_IMAGE_TYPE_2D;
2270
+ imageCreateInfo.extent .width = 128 ; // Example one.
2271
+ imageCreateInfo.extent .height = 128 ; // Example one.
2270
2272
imageCreateInfo.extent .depth = 1 ;
2271
2273
imageCreateInfo.mipLevels = 1 ;
2272
2274
imageCreateInfo.arrayLayers = 1 ;
2273
2275
imageCreateInfo.format = VK_FORMAT_R8_UNORM;
2274
- imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL ;
2276
+ imageCreateInfo.tiling = VK_IMAGE_TILING_LINEAR ;
2275
2277
imageCreateInfo.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
2276
2278
imageCreateInfo.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
2277
2279
imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT;
@@ -2280,12 +2282,18 @@ void TestDefragmentationAlgorithms()
2280
2282
allocCreateInfo.usage = VMA_MEMORY_USAGE_AUTO;
2281
2283
allocCreateInfo.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT;
2282
2284
2283
- uint32_t memTypeIndex = UINT32_MAX;
2284
- vmaFindMemoryTypeIndexForBufferInfo (g_hAllocator, &bufCreateInfo, &allocCreateInfo, &memTypeIndex);
2285
+ uint32_t bufMemTypeIndex = UINT32_MAX;
2286
+ TEST (vmaFindMemoryTypeIndexForBufferInfo (g_hAllocator, &bufCreateInfo, &allocCreateInfo, &bufMemTypeIndex) == VK_SUCCESS);
2287
+ uint32_t imageMemTypeIndex = UINT32_MAX;
2288
+ TEST (vmaFindMemoryTypeIndexForImageInfo (g_hAllocator, &imageCreateInfo, &allocCreateInfo, &imageMemTypeIndex) == VK_SUCCESS);
2289
+
2290
+ const uint32_t commonMemTypeIndex = bufMemTypeIndex & imageMemTypeIndex;
2291
+ // Check if this platform supports buffer and LINEAR R8 2D images in the same HOST_VISIBLE + HOST_CACHED memory.
2292
+ TEST (commonMemTypeIndex != 0 );
2285
2293
2286
2294
VmaPoolCreateInfo poolCreateInfo = {};
2287
2295
poolCreateInfo.blockSize = BLOCK_SIZE;
2288
- poolCreateInfo.memoryTypeIndex = memTypeIndex ;
2296
+ poolCreateInfo.memoryTypeIndex = commonMemTypeIndex ;
2289
2297
2290
2298
VmaPool pool;
2291
2299
TEST (vmaCreatePool (g_hAllocator, &poolCreateInfo, &pool) == VK_SUCCESS);
0 commit comments