Mesa (main): venus: use vk_default_allocator

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 3 09:11:35 UTC 2021


Module: Mesa
Branch: main
Commit: 736e24bdce3ddcdcd29ee1346645ef03e765e5f8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=736e24bdce3ddcdcd29ee1346645ef03e765e5f8

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Tue Jun  1 09:32:57 2021 -0700

venus: use vk_default_allocator

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4870
Signed-off-by: Chia-I Wu <olvaffe at gmail.com>
Acked-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11117>

---

 src/virtio/vulkan/vn_common.c | 44 -------------------------------------------
 src/virtio/vulkan/vn_common.h |  3 ---
 src/virtio/vulkan/vn_device.c |  2 +-
 3 files changed, 1 insertion(+), 48 deletions(-)

diff --git a/src/virtio/vulkan/vn_common.c b/src/virtio/vulkan/vn_common.c
index 9d6be361b57..91ba2f6e9c2 100644
--- a/src/virtio/vulkan/vn_common.c
+++ b/src/virtio/vulkan/vn_common.c
@@ -17,12 +17,6 @@
 #include "util/os_misc.h"
 #include "vk_enum_to_str.h"
 
-#if __STDC_VERSION__ >= 201112L
-#define VN_MAX_ALIGN _Alignof(max_align_t)
-#else
-#define VN_MAX_ALIGN VN_DEFAULT_ALIGN
-#endif
-
 static const struct debug_control vn_debug_options[] = {
    { "init", VN_DEBUG_INIT },
    { "result", VN_DEBUG_RESULT },
@@ -67,44 +61,6 @@ vn_log_result(struct vn_instance *instance,
    return result;
 }
 
-static void *
-vn_default_alloc(void *pUserData,
-                 size_t size,
-                 size_t alignment,
-                 VkSystemAllocationScope allocationScope)
-{
-   assert(VN_MAX_ALIGN % alignment == 0);
-   return malloc(size);
-}
-
-static void *
-vn_default_realloc(void *pUserData,
-                   void *pOriginal,
-                   size_t size,
-                   size_t alignment,
-                   VkSystemAllocationScope allocationScope)
-{
-   assert(VN_MAX_ALIGN % alignment == 0);
-   return realloc(pOriginal, size);
-}
-
-static void
-vn_default_free(void *pUserData, void *pMemory)
-{
-   free(pMemory);
-}
-
-const VkAllocationCallbacks *
-vn_default_allocator(void)
-{
-   static const VkAllocationCallbacks allocator = {
-      .pfnAllocation = vn_default_alloc,
-      .pfnReallocation = vn_default_realloc,
-      .pfnFree = vn_default_free,
-   };
-   return &allocator;
-}
-
 void
 vn_relax(uint32_t *iter)
 {
diff --git a/src/virtio/vulkan/vn_common.h b/src/virtio/vulkan/vn_common.h
index b0a33f1a7ba..80780efccc2 100644
--- a/src/virtio/vulkan/vn_common.h
+++ b/src/virtio/vulkan/vn_common.h
@@ -132,9 +132,6 @@ vn_log_result(struct vn_instance *instance,
               VkResult result,
               const char *where);
 
-const VkAllocationCallbacks *
-vn_default_allocator(void);
-
 void
 vn_relax(uint32_t *iter);
 
diff --git a/src/virtio/vulkan/vn_device.c b/src/virtio/vulkan/vn_device.c
index 804e88a1f86..e1a9c053773 100644
--- a/src/virtio/vulkan/vn_device.c
+++ b/src/virtio/vulkan/vn_device.c
@@ -1853,7 +1853,7 @@ vn_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
                   VkInstance *pInstance)
 {
    const VkAllocationCallbacks *alloc =
-      pAllocator ? pAllocator : vn_default_allocator();
+      pAllocator ? pAllocator : vk_default_allocator();
    struct vn_instance *instance;
    VkResult result;
 



More information about the mesa-commit mailing list