From 8111c12b36921858d501f5749403afdb792f2ea4 Mon Sep 17 00:00:00 2001 From: Johannes Schneider Date: Wed, 2 Jun 2021 00:22:18 +0200 Subject: [PATCH] Expose important VMA settings macros as CMake options --- CMakeLists.txt | 20 ++++++++++++++++++++ src/CMakeLists.txt | 13 +++++++++++++ 2 files changed, 33 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29e0260..3ddc079 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,4 +9,24 @@ option(VMA_BUILD_SAMPLE "Build VulkanMemoryAllocator sample application" OFF) option(VMA_BUILD_SAMPLE_SHADERS "Build VulkanMemoryAllocator sample application's shaders" OFF) option(VMA_BUILD_REPLAY "Build VulkanMemoryAllocator replay application" OFF) +message(STATUS "VMA_BUILD_SAMPLE = ${VMA_BUILD_SAMPLE}") +message(STATUS "VMA_BUILD_SAMPLE_SHADERS = ${VMA_BUILD_SAMPLE_SHADERS}") +message(STATUS "VMA_BUILD_REPLAY = ${VMA_BUILD_REPLAY}") + +option(VMA_RECORDING_ENABLED "Enable VMA memory recording for debugging" OFF) +option(VMA_USE_STL_CONTAINERS "Use C++ STL containers instead of VMA's containers" OFF) +option(VMA_DYNAMIC_VULKAN_FUNCTIONS "Fetch pointers to Vulkan functions internally (no static linking)" OFF) +option(VMA_DEBUG_ALWAYS_DEDICATED_MEMORY "Every allocation will have its own memory block" OFF) +option(VMA_DEBUG_INITIALIZE_ALLOCATIONS "Automatically fill new allocations and destroyed allocations with some bit pattern" OFF) +option(VMA_DEBUG_GLOBAL_MUTEX "Enable single mutex protecting all entry calls to the library" OFF) +option(VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT "Never exceed VkPhysicalDeviceLimits::maxMemoryAllocationCount and return error" OFF) + +message(STATUS "VMA_RECORDING_ENABLED = ${VMA_RECORDING_ENABLED}") +message(STATUS "VMA_USE_STL_CONTAINERS = ${VMA_USE_STL_CONTAINERS}") +message(STATUS "VMA_DYNAMIC_VULKAN_FUNCTIONS = ${VMA_DYNAMIC_VULKAN_FUNCTIONS}") +message(STATUS "VMA_DEBUG_ALWAYS_DEDICATED_MEMORY = ${VMA_DEBUG_ALWAYS_DEDICATED_MEMORY}") +message(STATUS "VMA_DEBUG_INITIALIZE_ALLOCATIONS = ${VMA_DEBUG_INITIALIZE_ALLOCATIONS}") +message(STATUS "VMA_DEBUG_GLOBAL_MUTEX = ${VMA_DEBUG_GLOBAL_MUTEX}") +message(STATUS "VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT = ${VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT}") + add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ac465b9..338d0c6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,6 +22,19 @@ target_link_libraries( Vulkan::Vulkan ) +target_compile_definitions( + VulkanMemoryAllocator + + PUBLIC + VMA_USE_STL_CONTAINERS=$ + VMA_DYNAMIC_VULKAN_FUNCTIONS=$ + VMA_DEBUG_ALWAYS_DEDICATED_MEMORY=$ + VMA_DEBUG_INITIALIZE_ALLOCATIONS=$ + VMA_DEBUG_GLOBAL_MUTEX=$ + VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT=$ + VMA_RECORDING_ENABLED=$ +) + if (VMA_BUILD_SAMPLE) if(WIN32) set(VMA_SAMPLE_SOURCE_FILES