Skip to content

Commit d8d4f86

Browse files
Fix in TestDefragmentationAlgorithms for Nvidia cards
Fixes #422
1 parent a77a76c commit d8d4f86

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/Tests.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,11 +2267,13 @@ void TestDefragmentationAlgorithms()
22672267

22682268
VkImageCreateInfo imageCreateInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO };
22692269
imageCreateInfo.imageType = VK_IMAGE_TYPE_2D;
2270+
imageCreateInfo.extent.width = 128; // Example one.
2271+
imageCreateInfo.extent.height = 128; // Example one.
22702272
imageCreateInfo.extent.depth = 1;
22712273
imageCreateInfo.mipLevels = 1;
22722274
imageCreateInfo.arrayLayers = 1;
22732275
imageCreateInfo.format = VK_FORMAT_R8_UNORM;
2274-
imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
2276+
imageCreateInfo.tiling = VK_IMAGE_TILING_LINEAR;
22752277
imageCreateInfo.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
22762278
imageCreateInfo.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
22772279
imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT;
@@ -2280,12 +2282,18 @@ void TestDefragmentationAlgorithms()
22802282
allocCreateInfo.usage = VMA_MEMORY_USAGE_AUTO;
22812283
allocCreateInfo.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT;
22822284

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);
22852293

22862294
VmaPoolCreateInfo poolCreateInfo = {};
22872295
poolCreateInfo.blockSize = BLOCK_SIZE;
2288-
poolCreateInfo.memoryTypeIndex = memTypeIndex;
2296+
poolCreateInfo.memoryTypeIndex = commonMemTypeIndex;
22892297

22902298
VmaPool pool;
22912299
TEST(vmaCreatePool(g_hAllocator, &poolCreateInfo, &pool) == VK_SUCCESS);

0 commit comments

Comments
 (0)