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

Function TestInvalidAllocations

src/Tests.cpp:3073–3120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3071}
3072
3073static void TestInvalidAllocations()
3074{
3075 VkResult res;
3076
3077 VmaAllocationCreateInfo allocCreateInfo = {};
3078
3079 // Try to allocate 0 bytes.
3080 {
3081 VkMemoryRequirements memReq = {};
3082 memReq.size = 0; // !!!
3083 memReq.alignment = 4;
3084 memReq.memoryTypeBits = UINT32_MAX;
3085 VmaAllocation alloc = VK_NULL_HANDLE;
3086 res = vmaAllocateMemory(g_hAllocator, &memReq, &allocCreateInfo, &alloc, nullptr);
3087 TEST(res == VK_ERROR_INITIALIZATION_FAILED && alloc == VK_NULL_HANDLE);
3088 }
3089
3090 // Try to create buffer with size = 0.
3091 {
3092 VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
3093 bufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
3094 bufCreateInfo.size = 0; // !!!
3095 VkBuffer buf = VK_NULL_HANDLE;
3096 VmaAllocation alloc = VK_NULL_HANDLE;
3097 res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, nullptr);
3098 TEST(res == VK_ERROR_INITIALIZATION_FAILED && buf == VK_NULL_HANDLE && alloc == VK_NULL_HANDLE);
3099 }
3100
3101 // Try to create image with one dimension = 0.
3102 {
3103 VkImageCreateInfo imageCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
3104 imageCreateInfo.imageType = VK_IMAGE_TYPE_2D;
3105 imageCreateInfo.format = VK_FORMAT_B8G8R8A8_UNORM;
3106 imageCreateInfo.extent.width = 128;
3107 imageCreateInfo.extent.height = 0; // !!!
3108 imageCreateInfo.extent.depth = 1;
3109 imageCreateInfo.mipLevels = 1;
3110 imageCreateInfo.arrayLayers = 1;
3111 imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT;
3112 imageCreateInfo.tiling = VK_IMAGE_TILING_LINEAR;
3113 imageCreateInfo.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
3114 imageCreateInfo.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
3115 VkImage image = VK_NULL_HANDLE;
3116 VmaAllocation alloc = VK_NULL_HANDLE;
3117 res = vmaCreateImage(g_hAllocator, &imageCreateInfo, &allocCreateInfo, &image, &alloc, nullptr);
3118 TEST(res == VK_ERROR_INITIALIZATION_FAILED && image == VK_NULL_HANDLE && alloc == VK_NULL_HANDLE);
3119 }
3120}
3121
3122static void TestMemoryRequirements()
3123{

Callers 1

TestBasicsFunction · 0.85

Calls 4

vmaAllocateMemoryFunction · 0.85
TESTEnum · 0.85
vmaCreateBufferFunction · 0.85
vmaCreateImageFunction · 0.85

Tested by

no test coverage detected