diff --git a/config/lib/VulkanMemoryAllocator.cmake b/config/lib/VulkanMemoryAllocator.cmake index 6dc0572bffc074b62da01239e995c5d7ce3811b5..cb9e598bfb7ad685e37005b2aa2b0ca5e248317a 100644 --- a/config/lib/VulkanMemoryAllocator.cmake +++ b/config/lib/VulkanMemoryAllocator.cmake @@ -1,9 +1,8 @@ if ((EXISTS "${vkcv_lib_path}/VulkanMemoryAllocator") AND (EXISTS "${vkcv_lib_path}/VulkanMemoryAllocator-Hpp")) - set(VMA_BUILD_SAMPLE OFF CACHE INTERNAL "") - set(VMA_BUILD_SAMPLE_SHADERS OFF CACHE INTERNAL "") - set(VMA_BUILD_REPLAY OFF CACHE INTERNAL "") + set(VMA_PATH "${vkcv_lib_path}/VulkanMemoryAllocator" CACHE INTERNAL "") + set(VMA_HPP_PATH "${vkcv_lib_path}/VulkanMemoryAllocator-Hpp" CACHE INTERNAL "") set(VMA_RECORDING_ENABLED OFF CACHE INTERNAL "") set(VMA_USE_STL_CONTAINERS OFF CACHE INTERNAL "") @@ -14,7 +13,7 @@ if ((EXISTS "${vkcv_lib_path}/VulkanMemoryAllocator") AND set(VMA_DEBUG_GLOBAL_MUTEX OFF CACHE INTERNAL "") set(VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT OFF CACHE INTERNAL "") - add_subdirectory(${vkcv_lib}/VulkanMemoryAllocator) + add_subdirectory(vma) list(APPEND vkcv_libraries VulkanMemoryAllocator) list(APPEND vkcv_includes ${vkcv_lib_path}/VulkanMemoryAllocator-Hpp) diff --git a/vma/CMakeLists.txt b/vma/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..75089d64d307a85153ee02c5532a03bed0efd2b3 --- /dev/null +++ b/vma/CMakeLists.txt @@ -0,0 +1,62 @@ +cmake_minimum_required(VERSION 3.9) + +project(VulkanMemoryAllocator) + +find_package(Vulkan REQUIRED) + +option(VMA_PATH "Location of official API and headers" "") +option(VMA_HPP_PATH "Location of C++ headers" "") + +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_STATIC_VULKAN_FUNCTIONS "Link statically with Vulkan API" OFF) +option(VMA_DYNAMIC_VULKAN_FUNCTIONS "Fetch pointers to Vulkan functions internally (no static linking)" ON) +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}") + +set(VMA_LIBRARY_SOURCE_FILES ${VMA_PATH}/src/VmaUsage.cpp) + +add_library(VulkanMemoryAllocator ${VMA_LIBRARY_SOURCE_FILES}) + +set_target_properties( + VulkanMemoryAllocator PROPERTIES + + CXX_EXTENSIONS OFF + # Use C++14 + CXX_STANDARD 14 + CXX_STANDARD_REQUIRED ON +) + +target_include_directories(VulkanMemoryAllocator PUBLIC ${VMA_HPP_PATH}) + +# Only link to Vulkan if static linking is used +if (NOT ${VMA_DYNAMIC_VULKAN_FUNCTIONS}) + target_link_libraries(VulkanMemoryAllocator PUBLIC Vulkan::Vulkan) +endif() + +target_compile_definitions( + VulkanMemoryAllocator + + PUBLIC + VMA_USE_STL_CONTAINERS=$<BOOL:${VMA_USE_STL_CONTAINERS}> + VMA_DYNAMIC_VULKAN_FUNCTIONS=$<BOOL:${VMA_DYNAMIC_VULKAN_FUNCTIONS}> + VMA_DEBUG_ALWAYS_DEDICATED_MEMORY=$<BOOL:${VMA_DEBUG_ALWAYS_DEDICATED_MEMORY}> + VMA_DEBUG_INITIALIZE_ALLOCATIONS=$<BOOL:${VMA_DEBUG_INITIALIZE_ALLOCATIONS}> + VMA_DEBUG_GLOBAL_MUTEX=$<BOOL:${VMA_DEBUG_GLOBAL_MUTEX}> + VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT=$<BOOL:${VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT}> + VMA_RECORDING_ENABLED=$<BOOL:${VMA_RECORDING_ENABLED}> +)