Initial commit

This commit is contained in:
2026-01-23 22:15:36 +01:00
commit ca60108606
167 changed files with 5311 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
sources:
"3.3.0":
url: "https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/archive/refs/tags/v3.3.0.tar.gz"
sha256: "c4f6bbe6b5a45c2eb610ca9d231158e313086d5b1a40c9922cb42b597419b14e"

View File

@@ -0,0 +1,58 @@
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get
from conan.tools.layout import basic_layout
from conan.tools.scm import Version
import os
required_conan_version = ">=1.52.0"
class VulkanMemoryAllocatorConan(ConanFile):
name = "vulkan-memory-allocator"
license = "MIT"
homepage = "https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator"
url = "https://github.com/conan-io/conan-center-index"
description = "Easy to integrate Vulkan memory allocation library."
topics = ("vulkan", "memory-allocator", "graphics")
package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
@property
def _min_cppstd(self):
return "11" if Version(self.version) < "3.0.0" else "14"
def export_sources(self):
export_conandata_patches(self)
def layout(self):
basic_layout(self, src_folder="src")
def requirements(self):
self.requires("vulkan-headers/1.4.313.0")
def package_id(self):
self.info.clear()
def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)
def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)
def build(self):
apply_conandata_patches(self)
def package(self):
copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
if Version(self.version) < "3.0.0":
include_dir = os.path.join(self.source_folder, "src")
else:
include_dir = os.path.join(self.source_folder, "include")
copy(self, "vk_mem_alloc.h", src=include_dir, dst=os.path.join(self.package_folder, "include"))
def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []

View File

@@ -0,0 +1,95 @@
--- a/include/vk_mem_alloc.h
+++ b/include/vk_mem_alloc.h
@@ -2569,6 +2569,7 @@ VMA_CALL_PRE void VMA_CALL_POST vmaFreeStatsString(
#include <cstdlib>
#include <cstring>
#include <utility>
+#include <type_traits>
#ifdef _MSC_VER
#include <intrin.h> // For functions like __popcnt, _BitScanForward etc.
@@ -5491,6 +5492,7 @@ public:
// Posts next part of an open string. The number is converted to decimal characters.
void ContinueString(uint32_t n);
void ContinueString(uint64_t n);
+ void ContinueString_Size(size_t n);
// Posts next part of an open string. Pointer value is converted to characters
// using "%p" formatting - shown as hexadecimal number, e.g.: 000000081276Ad00
void ContinueString_Pointer(const void* ptr);
@@ -5500,6 +5502,7 @@ public:
// Writes a number value.
void WriteNumber(uint32_t n);
void WriteNumber(uint64_t n);
+ void WriteSize(size_t n);
// Writes a boolean value - false or true.
void WriteBool(bool b);
// Writes a null value.
@@ -5524,6 +5527,11 @@ private:
VmaVector< StackItem, VmaStlAllocator<StackItem> > m_Stack;
bool m_InsideString;
+ // Write size_t for less than 64bits
+ void WriteSize(size_t n, std::integral_constant<bool, false>) { m_SB.AddNumber(static_cast<uint32_t>(n)); }
+ // Write size_t for 64bits
+ void WriteSize(size_t n, std::integral_constant<bool, true>) { m_SB.AddNumber(static_cast<uint64_t>(n)); }
+
void BeginValue(bool isString);
void WriteIndent(bool oneLess = false);
};
@@ -5666,6 +5674,14 @@ void VmaJsonWriter::ContinueString(uint64_t n)
m_SB.AddNumber(n);
}
+void VmaJsonWriter::ContinueString_Size(size_t n)
+{
+ VMA_ASSERT(m_InsideString);
+ // Fix for AppleClang incorrect type casting
+ // TODO: Change to if constexpr when C++17 used as minimal standard
+ WriteSize(n, std::is_same<size_t, uint64_t>{});
+}
+
void VmaJsonWriter::ContinueString_Pointer(const void* ptr)
{
VMA_ASSERT(m_InsideString);
@@ -5697,6 +5713,15 @@ void VmaJsonWriter::WriteNumber(uint64_t n)
m_SB.AddNumber(n);
}
+void VmaJsonWriter::WriteSize(size_t n)
+{
+ VMA_ASSERT(!m_InsideString);
+ BeginValue(false);
+ // Fix for AppleClang incorrect type casting
+ // TODO: Change to if constexpr when C++17 used as minimal standard
+ WriteSize(n, std::is_same<size_t, uint64_t>{});
+}
+
void VmaJsonWriter::WriteBool(bool b)
{
VMA_ASSERT(!m_InsideString);
@@ -6440,13 +6465,13 @@ void VmaBlockMetadata::PrintDetailedMap_Begin(class VmaJsonWriter& json,
json.WriteNumber(GetSize());
json.WriteString("UnusedBytes");
- json.WriteNumber(unusedBytes);
+ json.WriteSize(unusedBytes);
json.WriteString("Allocations");
- json.WriteNumber(allocationCount);
+ json.WriteSize(allocationCount);
json.WriteString("UnusedRanges");
- json.WriteNumber(unusedRangeCount);
+ json.WriteSize(unusedRangeCount);
json.WriteString("Suballocations");
json.BeginArray();
@@ -15964,7 +15989,7 @@ void VmaAllocator_T::PrintDetailedMap(VmaJsonWriter& json)
{
json.WriteString("Name");
json.BeginString();
- json.ContinueString(index++);
+ json.ContinueString_Size(index++);
if (pool->GetName())
{
json.WriteString(" - ");

View File

@@ -0,0 +1,15 @@
diff --git a/src/vk_mem_alloc.h b/src/vk_mem_alloc.h
index 32258b4..8da6bba 100644
--- a/src/vk_mem_alloc.h
+++ b/src/vk_mem_alloc.h
@@ -3470,6 +3470,10 @@ VMA_CALL_PRE void VMA_CALL_POST vmaDestroyImage(
#include <cstdlib>
#include <cstring>
+#if VMA_STATS_STRING_ENABLED
+ #include <cstdio> // For snprintf
+#endif
+
/*******************************************************************************
CONFIGURATION SECTION

View File

@@ -0,0 +1,15 @@
diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h
index 3b395a7..542191c 100644
--- a/include/vk_mem_alloc.h
+++ b/include/vk_mem_alloc.h
@@ -2575,6 +2575,10 @@ VMA_CALL_PRE void VMA_CALL_POST vmaFreeStatsString(
#include <intrin.h> // For functions like __popcnt, _BitScanForward etc.
#endif
+#if VMA_STATS_STRING_ENABLED
+ #include <cstdio> // For snprintf
+#endif
+
/*******************************************************************************
CONFIGURATION SECTION

View File

@@ -0,0 +1,15 @@
diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h
index 60f5720..31164bc 100644
--- a/include/vk_mem_alloc.h
+++ b/include/vk_mem_alloc.h
@@ -2578,6 +2578,10 @@ VMA_CALL_PRE void VMA_CALL_POST vmaFreeStatsString(
#include <bit> // For std::popcount
#endif
+#if VMA_STATS_STRING_ENABLED
+ #include <cstdio> // For snprintf
+#endif
+
/*******************************************************************************
CONFIGURATION SECTION

View File

@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)
find_package(vulkan-memory-allocator REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE vulkan-memory-allocator::vulkan-memory-allocator)
if(vulkan-memory-allocator_VERSION VERSION_LESS "3.0.0")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
else()
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
endif()

View File

@@ -0,0 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"
def layout(self):
cmake_layout(self)
def requirements(self):
self.requires(self.tested_reference_str)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,20 @@
#define VMA_STATIC_VULKAN_FUNCTIONS 0
#define VMA_IMPLEMENTATION
#include <vk_mem_alloc.h>
int main()
{
// Load function pointers...
// vmaVmaVulkanFunctions vulkanFunctions{};
// vulkavulkanFunctions.vkAllocateMemory = ... ;
// ...
VmaAllocatorCreateInfo allocatorInfo{}; (void)allocatorInfo;
// allocatorInfo.instance = instance;
// allocatorInfo.physicalDevice = physicalDevice;
// allocatorInfo.device = device;
// allocatorInfo.pVulkanFunctions = &vulkanFunctions;
VmaAllocator allocator; (void)allocator;
// vmaCreateAllocator(&allocatorInfo, &allocator);
}

View File

@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)

View File

@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)

View File

@@ -0,0 +1,3 @@
versions:
"3.3.0":
folder: all