From 27f084f19e7b3a430e6d1ebfa9e2daf118687fd2 Mon Sep 17 00:00:00 2001 From: Jon Ashburn Date: Fri, 28 Aug 2015 13:48:40 -0600 Subject: demos: Add allocation callback to tri test CreateInstance --- demos/tri.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/demos/tri.c b/demos/tri.c index 1a53d0ea..feb187d9 100644 --- a/demos/tri.c +++ b/demos/tri.c @@ -1705,6 +1705,20 @@ static VkBool32 demo_check_layers(uint32_t check_count, char **check_names, return 1; } +void* VKAPI myalloc( + void* pUserData, + size_t size, + size_t alignment, + VkSystemAllocType allocType) +{ + return malloc(size); +} +void VKAPI myfree( + void* pUserData, + void* pMem) +{ + return free(pMem); +} static void demo_init_vk(struct demo *demo) { VkResult err; @@ -1785,11 +1799,16 @@ static void demo_init_vk(struct demo *demo) .engineVersion = 0, .apiVersion = VK_API_VERSION, }; + VkAllocCallbacks cb = { + .pUserData = NULL, + .pfnAlloc = myalloc, + .pfnFree = myfree, + }; VkInstanceCreateInfo inst_info = { .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, .pNext = NULL, .pAppInfo = &app, - .pAllocCb = NULL, + .pAllocCb = &cb, .layerCount = enabled_layer_count, .ppEnabledLayerNames = (const char *const*) layer_names, .extensionCount = enabled_extension_count, -- cgit v1.2.3