From 3afb43090f34e80bc8b17a14d4f4ea3d37923440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Tue, 2 Apr 2024 07:50:19 -0700 Subject: [PATCH] Fixed #3274. --- src/renderer_vk.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index 2b6fa09a3..4a9ba72f0 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -555,24 +555,32 @@ VK_IMPORT_DEVICE static void* VKAPI_PTR allocationFunction(void* _userData, size_t _size, size_t _alignment, VkSystemAllocationScope _allocationScope) { bx::AllocatorI* allocator = (bx::AllocatorI*)_userData; - return allocator->realloc(NULL, _size, bx::max(kMinAlignment, _alignment), s_allocScopeName[_allocationScope], 0); + return bx::alignedAlloc(allocator, _size, bx::max(kMinAlignment, _alignment), bx::Location(s_allocScopeName[_allocationScope], 0) ); } - static void* VKAPI_PTR reallocationFunction(void* _userData, void* _original, size_t _size, size_t _alignment, VkSystemAllocationScope _allocationScope) + static void* VKAPI_PTR reallocationFunction(void* _userData, void* _ptr, size_t _size, size_t _alignment, VkSystemAllocationScope _allocationScope) { bx::AllocatorI* allocator = (bx::AllocatorI*)_userData; - return allocator->realloc(_original, _size, bx::max(kMinAlignment, _alignment), s_allocScopeName[_allocationScope], 0); + + BX_UNUSED(_userData); + if (0 == _size) + { + bx::alignedFree(allocator, _ptr, 0); + return NULL; + } + + return bx::alignedRealloc(allocator, _ptr, _size, bx::max(kMinAlignment, _alignment), bx::Location(s_allocScopeName[_allocationScope], 0) ); } - static void VKAPI_PTR freeFunction(void* _userData, void* _memory) + static void VKAPI_PTR freeFunction(void* _userData, void* _ptr) { - if (NULL == _memory) + if (NULL == _ptr) { return; } bx::AllocatorI* allocator = (bx::AllocatorI*)_userData; - allocator->realloc(_memory, 0, kMinAlignment, "vkFree", 0); + bx::alignedFree(allocator, _ptr, kMinAlignment); } static void VKAPI_PTR internalAllocationNotification(void* _userData, size_t _size, VkInternalAllocationType _allocationType, VkSystemAllocationScope _allocationScope)