Skip to content

Commit 12b48eb

Browse files
2 parents 1ea5f2f + b5f2032 commit 12b48eb

File tree

8 files changed

+245
-9
lines changed

8 files changed

+245
-9
lines changed

.github/workflows/static_code_analysis.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,16 @@ jobs:
4242
4343
- name: Run Clang-Tidy
4444
run: |
45-
find . -name '*.cpp' | xargs clang-tidy-15 -checks='*, -modernize-use-trailing-return-type, -cppcoreguidelines-macro-usage, -modernize-use-auto, -modernize-use-using' -header-filter='.*vk_mem_alloc\.h' -p build || true
45+
find . -name '*.cpp' | xargs clang-tidy-15 -checks='*, \
46+
-modernize-use-trailing-return-type, \
47+
-cppcoreguidelines-macro-usage, \
48+
-modernize-use-auto, \
49+
-modernize-use-using \
50+
-modernize-use-nodiscard \
51+
-altera-unroll-loops \
52+
-misc-definitions-in-headers \
53+
-cppcoreguidelines-pro-bounds-pointer-arithmetic \
54+
-readability-function-cognitive-complexity \
55+
-llvmlibc-restrict-system-libc-headers \
56+
-cppcoreguidelines-pro-type-union-access' \
57+
-header-filter='.*vk_mem_alloc\.h' -p build || true

Doxyfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2469,7 +2469,8 @@ PREDEFINED = VMA_CALL_PRE= \
24692469
VMA_EXTERNAL_MEMORY_WIN32=1 \
24702470
VMA_EXTERNAL_MEMORY=1 \
24712471
VMA_EXTENDS_VK_STRUCT= \
2472-
VMA_STATS_STRING_ENABLED=1
2472+
VMA_STATS_STRING_ENABLED=1 \
2473+
VOLK_HEADER_VERSION=304
24732474

24742475
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
24752476
# tag can be used to specify a list of macro names that should be expanded. The

include/vk_mem_alloc.h

Lines changed: 159 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,62 @@ typedef struct VmaVirtualAllocationInfo
16691669
@{
16701670
*/
16711671

1672+
#ifdef VOLK_HEADER_VERSION
1673+
/** \brief Fully initializes `pDstVulkanFunctions` structure with Vulkan functions needed by VMA
1674+
using [volk library](https://github.com/zeux/volk).
1675+
1676+
This function is defined in VMA header only if "volk.h" was included before it.
1677+
1678+
To use this function properly:
1679+
1680+
-# Initialize volk and Vulkan:
1681+
-# Call `volkInitialize()`
1682+
-# Create `VkInstance` object
1683+
-# Call `volkLoadInstance()`
1684+
-# Create `VkDevice` object
1685+
-# Call `volkLoadDevice()`
1686+
-# Fill in structure #VmaAllocatorCreateInfo, especially members:
1687+
- VmaAllocatorCreateInfo::device
1688+
- VmaAllocatorCreateInfo::vulkanApiVersion
1689+
- VmaAllocatorCreateInfo::flags - set appropriate flags for the Vulkan extensions you enabled
1690+
-# Create an instance of the #VmaVulkanFunctions structure.
1691+
-# Call vmaImportVulkanFunctionsFromVolk().
1692+
Parameter `pAllocatorCreateInfo` is read to find out which functions should be fetched for
1693+
appropriate Vulkan version and extensions.
1694+
Parameter `pDstVulkanFunctions` is filled with those function pointers, or null if not applicable.
1695+
-# Attach the #VmaVulkanFunctions structure to VmaAllocatorCreateInfo::pVulkanFunctions.
1696+
-# Call vmaCreateAllocator() to create the #VmaAllocator object.
1697+
1698+
Example:
1699+
1700+
\code
1701+
VmaAllocatorCreateInfo allocatorCreateInfo = {};
1702+
allocatorCreateInfo.physicalDevice = myPhysicalDevice;
1703+
allocatorCreateInfo.device = myDevice;
1704+
allocatorCreateInfo.instance = myInstance;
1705+
allocatorCreateInfo.vulkanApiVersion = VK_API_VERSION_1_3;
1706+
allocatorCreateInfo.flags = VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT |
1707+
VMA_ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT |
1708+
VMA_ALLOCATOR_CREATE_KHR_EXTERNAL_MEMORY_WIN32_BIT;
1709+
1710+
VmaVulkanFunctions vulkanFunctions;
1711+
VkResult res = vmaImportVulkanFunctionsFromVolk(&allocatorCreateInfo, &vulkanFunctions);
1712+
// Check res...
1713+
allocatorCreateInfo.pVulkanFunctions = &vulkanFunctions;
1714+
1715+
VmaAllocator allocator;
1716+
res = vmaCreateAllocator(&allocatorCreateInfo, &allocator);
1717+
// Check res...
1718+
\endcode
1719+
1720+
Internally in this function, pointers to functions related to the entire Vulkan instance are fetched using global function definitions,
1721+
while pointers to functions related to the Vulkan device are fetched using `volkLoadDeviceTable()` for given `pAllocatorCreateInfo->device`.
1722+
*/
1723+
VMA_CALL_PRE VkResult VMA_CALL_POST vmaImportVulkanFunctionsFromVolk(
1724+
const VmaAllocatorCreateInfo* VMA_NOT_NULL pAllocatorCreateInfo,
1725+
VmaVulkanFunctions* VMA_NOT_NULL pDstVulkanFunctions);
1726+
#endif
1727+
16721728
/// Creates #VmaAllocator object.
16731729
VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateAllocator(
16741730
const VmaAllocatorCreateInfo* VMA_NOT_NULL pCreateInfo,
@@ -15067,6 +15123,103 @@ void VmaAllocator_T::PrintDetailedMap(VmaJsonWriter& json)
1506715123

1506815124

1506915125
#ifndef _VMA_PUBLIC_INTERFACE
15126+
15127+
#ifdef VOLK_HEADER_VERSION
15128+
15129+
VMA_CALL_PRE VkResult VMA_CALL_POST vmaImportVulkanFunctionsFromVolk(
15130+
const VmaAllocatorCreateInfo* VMA_NOT_NULL pAllocatorCreateInfo,
15131+
VmaVulkanFunctions* VMA_NOT_NULL pDstVulkanFunctions)
15132+
{
15133+
VMA_ASSERT(pAllocatorCreateInfo != VMA_NULL);
15134+
VMA_ASSERT(pAllocatorCreateInfo->instance != VK_NULL_HANDLE);
15135+
VMA_ASSERT(pAllocatorCreateInfo->device != VK_NULL_HANDLE);
15136+
15137+
memset(pDstVulkanFunctions, 0, sizeof(*pDstVulkanFunctions));
15138+
15139+
VolkDeviceTable src = {};
15140+
volkLoadDeviceTable(&src, pAllocatorCreateInfo->device);
15141+
15142+
#define COPY_GLOBAL_TO_VMA_FUNC(volkName, vmaName) if(!pDstVulkanFunctions->vmaName) pDstVulkanFunctions->vmaName = volkName;
15143+
#define COPY_DEVICE_TO_VMA_FUNC(volkName, vmaName) if(!pDstVulkanFunctions->vmaName) pDstVulkanFunctions->vmaName = src.volkName;
15144+
15145+
COPY_GLOBAL_TO_VMA_FUNC(vkGetInstanceProcAddr, vkGetInstanceProcAddr)
15146+
COPY_GLOBAL_TO_VMA_FUNC(vkGetDeviceProcAddr, vkGetDeviceProcAddr)
15147+
COPY_GLOBAL_TO_VMA_FUNC(vkGetPhysicalDeviceProperties, vkGetPhysicalDeviceProperties)
15148+
COPY_GLOBAL_TO_VMA_FUNC(vkGetPhysicalDeviceMemoryProperties, vkGetPhysicalDeviceMemoryProperties)
15149+
COPY_DEVICE_TO_VMA_FUNC(vkAllocateMemory, vkAllocateMemory)
15150+
COPY_DEVICE_TO_VMA_FUNC(vkFreeMemory, vkFreeMemory)
15151+
COPY_DEVICE_TO_VMA_FUNC(vkMapMemory, vkMapMemory)
15152+
COPY_DEVICE_TO_VMA_FUNC(vkUnmapMemory, vkUnmapMemory)
15153+
COPY_DEVICE_TO_VMA_FUNC(vkFlushMappedMemoryRanges, vkFlushMappedMemoryRanges)
15154+
COPY_DEVICE_TO_VMA_FUNC(vkInvalidateMappedMemoryRanges, vkInvalidateMappedMemoryRanges)
15155+
COPY_DEVICE_TO_VMA_FUNC(vkBindBufferMemory, vkBindBufferMemory)
15156+
COPY_DEVICE_TO_VMA_FUNC(vkBindImageMemory, vkBindImageMemory)
15157+
COPY_DEVICE_TO_VMA_FUNC(vkGetBufferMemoryRequirements, vkGetBufferMemoryRequirements)
15158+
COPY_DEVICE_TO_VMA_FUNC(vkGetImageMemoryRequirements, vkGetImageMemoryRequirements)
15159+
COPY_DEVICE_TO_VMA_FUNC(vkCreateBuffer, vkCreateBuffer)
15160+
COPY_DEVICE_TO_VMA_FUNC(vkDestroyBuffer, vkDestroyBuffer)
15161+
COPY_DEVICE_TO_VMA_FUNC(vkCreateImage, vkCreateImage)
15162+
COPY_DEVICE_TO_VMA_FUNC(vkDestroyImage, vkDestroyImage)
15163+
COPY_DEVICE_TO_VMA_FUNC(vkCmdCopyBuffer, vkCmdCopyBuffer)
15164+
#if VMA_VULKAN_VERSION >= 1001000
15165+
if (pAllocatorCreateInfo->vulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0))
15166+
{
15167+
COPY_GLOBAL_TO_VMA_FUNC(vkGetPhysicalDeviceMemoryProperties2, vkGetPhysicalDeviceMemoryProperties2KHR)
15168+
COPY_DEVICE_TO_VMA_FUNC(vkGetBufferMemoryRequirements2, vkGetBufferMemoryRequirements2KHR)
15169+
COPY_DEVICE_TO_VMA_FUNC(vkGetImageMemoryRequirements2, vkGetImageMemoryRequirements2KHR)
15170+
COPY_DEVICE_TO_VMA_FUNC(vkBindBufferMemory2, vkBindBufferMemory2KHR)
15171+
COPY_DEVICE_TO_VMA_FUNC(vkBindImageMemory2, vkBindImageMemory2KHR)
15172+
}
15173+
#endif
15174+
#if VMA_VULKAN_VERSION >= 1003000
15175+
if (pAllocatorCreateInfo->vulkanApiVersion >= VK_MAKE_VERSION(1, 3, 0))
15176+
{
15177+
COPY_DEVICE_TO_VMA_FUNC(vkGetDeviceBufferMemoryRequirements, vkGetDeviceBufferMemoryRequirements)
15178+
COPY_DEVICE_TO_VMA_FUNC(vkGetDeviceImageMemoryRequirements, vkGetDeviceImageMemoryRequirements)
15179+
}
15180+
#endif
15181+
#if VMA_KHR_MAINTENANCE4
15182+
if((pAllocatorCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE4_BIT) != 0)
15183+
{
15184+
COPY_DEVICE_TO_VMA_FUNC(vkGetDeviceBufferMemoryRequirementsKHR, vkGetDeviceBufferMemoryRequirements)
15185+
COPY_DEVICE_TO_VMA_FUNC(vkGetDeviceImageMemoryRequirementsKHR, vkGetDeviceImageMemoryRequirements)
15186+
}
15187+
#endif
15188+
#if VMA_DEDICATED_ALLOCATION
15189+
if ((pAllocatorCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT) != 0)
15190+
{
15191+
COPY_DEVICE_TO_VMA_FUNC(vkGetBufferMemoryRequirements2KHR, vkGetBufferMemoryRequirements2KHR)
15192+
COPY_DEVICE_TO_VMA_FUNC(vkGetImageMemoryRequirements2KHR, vkGetImageMemoryRequirements2KHR)
15193+
}
15194+
#endif
15195+
#if VMA_BIND_MEMORY2
15196+
if ((pAllocatorCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT) != 0)
15197+
{
15198+
COPY_DEVICE_TO_VMA_FUNC(vkBindBufferMemory2KHR, vkBindBufferMemory2KHR)
15199+
COPY_DEVICE_TO_VMA_FUNC(vkBindImageMemory2KHR, vkBindImageMemory2KHR)
15200+
}
15201+
#endif
15202+
#if VMA_MEMORY_BUDGET
15203+
if ((pAllocatorCreateInfo->flags & VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT) != 0)
15204+
{
15205+
COPY_GLOBAL_TO_VMA_FUNC(vkGetPhysicalDeviceMemoryProperties2KHR, vkGetPhysicalDeviceMemoryProperties2KHR)
15206+
}
15207+
#endif
15208+
#if VMA_EXTERNAL_MEMORY_WIN32
15209+
if ((pAllocatorCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_EXTERNAL_MEMORY_WIN32_BIT) != 0)
15210+
{
15211+
COPY_DEVICE_TO_VMA_FUNC(vkGetMemoryWin32HandleKHR, vkGetMemoryWin32HandleKHR)
15212+
}
15213+
#endif
15214+
15215+
#undef COPY_DEVICE_TO_VMA_FUNC
15216+
#undef COPY_GLOBAL_TO_VMA_FUNC
15217+
15218+
return VK_SUCCESS;
15219+
}
15220+
15221+
#endif // #ifdef VOLK_HEADER_VERSION
15222+
1507015223
VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateAllocator(
1507115224
const VmaAllocatorCreateInfo* pCreateInfo,
1507215225
VmaAllocator* pAllocator)
@@ -16781,7 +16934,7 @@ See code sample below.
1678116934

1678216935
\subsection quick_start_initialization_importing_vulkan_functions Importing Vulkan functions
1678316936

16784-
You may need to configure importing Vulkan functions. There are 3 ways to do this:
16937+
You may need to configure importing Vulkan functions. There are 4 ways to do this:
1678516938

1678616939
-# **If you link with Vulkan static library** (e.g. "vulkan-1.lib" on Windows):
1678716940
- You don't need to do anything.
@@ -16792,10 +16945,13 @@ You may need to configure importing Vulkan functions. There are 3 ways to do thi
1679216945
- Provide pointers to these two functions via VmaVulkanFunctions::vkGetInstanceProcAddr,
1679316946
VmaVulkanFunctions::vkGetDeviceProcAddr.
1679416947
- The library will fetch pointers to all other functions it needs internally.
16795-
-# **If you fetch pointers to all Vulkan functions in a custom way**, e.g. using some loader like
16796-
[Volk](https://github.com/zeux/volk):
16948+
-# **If you fetch pointers to all Vulkan functions in a custom way**:
1679716949
- Define `VMA_STATIC_VULKAN_FUNCTIONS` and `VMA_DYNAMIC_VULKAN_FUNCTIONS` to 0.
1679816950
- Pass these pointers via structure #VmaVulkanFunctions.
16951+
-# **If you use [volk library](https://github.com/zeux/volk)**:
16952+
- Define `VMA_STATIC_VULKAN_FUNCTIONS` and `VMA_DYNAMIC_VULKAN_FUNCTIONS` to 0.
16953+
- Use function vmaImportVulkanFunctionsFromVolk() to fill in the structure #VmaVulkanFunctions.
16954+
For more information, see the description of this function.
1679916955

1680016956
\subsection quick_start_initialization_enabling_extensions Enabling extensions
1680116957

src/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
option(VMA_STATIC_VULKAN_FUNCTIONS "Link statically with Vulkan API" ON)
2424
option(VMA_DYNAMIC_VULKAN_FUNCTIONS "Fetch pointers to Vulkan functions internally (no static linking)" OFF)
25+
set(VMA_VOLK_HEADER_PATH "" CACHE STRING "Path to volk.h file from the volk library (optional)")
2526
option(VMA_DEBUG_ALWAYS_DEDICATED_MEMORY "Every allocation will have its own memory block" OFF)
2627
option(VMA_DEBUG_INITIALIZE_ALLOCATIONS "Automatically fill new allocations and destroyed allocations with some bit pattern" OFF)
2728
option(VMA_DEBUG_GLOBAL_MUTEX "Enable single mutex protecting all entry calls to the library" OFF)
@@ -34,7 +35,7 @@ message(STATUS "VMA_DEBUG_INITIALIZE_ALLOCATIONS = ${VMA_DEBUG_INITIALIZE_ALLOCA
3435
message(STATUS "VMA_DEBUG_GLOBAL_MUTEX = ${VMA_DEBUG_GLOBAL_MUTEX}")
3536
message(STATUS "VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT = ${VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT}")
3637

37-
set(CMAKE_CXX_STANDARD 17)
38+
set(CMAKE_CXX_STANDARD 14)
3839
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3940
set(CMAKE_CXX_EXTENSIONS OFF)
4041

@@ -50,6 +51,7 @@ target_sources(VmaSample PRIVATE
5051
Tests.h
5152
VmaUsage.cpp
5253
VmaUsage.h
54+
VolkUsage.cpp
5355
VulkanSample.cpp
5456
../include/vk_mem_alloc.h
5557
)
@@ -78,6 +80,15 @@ target_sources(VmaSample PRIVATE vk_mem_alloc.natvis)
7880
add_subdirectory(Shaders)
7981
add_dependencies(VmaSample VmaSampleShaders)
8082

83+
if(NOT "${VMA_VOLK_HEADER_PATH}" STREQUAL "")
84+
if(EXISTS "${VMA_VOLK_HEADER_PATH}")
85+
message(STATUS "File volk.h found and used from path: ${VMA_VOLK_HEADER_PATH}")
86+
target_compile_definitions(VmaSample PRIVATE VMA_VOLK_HEADER_PATH="${VMA_VOLK_HEADER_PATH}")
87+
else()
88+
message(FATAL_ERROR "File volk.h not found in path: ${VMA_VOLK_HEADER_PATH}")
89+
endif()
90+
endif()
91+
8192
# Use Unicode instead of multibyte set
8293
add_compile_definitions(UNICODE _UNICODE)
8394

src/Tests.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3902,6 +3902,11 @@ void TestHeapSizeLimit()
39023902
allocatorCreateInfo.device = g_hDevice;
39033903
allocatorCreateInfo.instance = g_hVulkanInstance;
39043904
allocatorCreateInfo.pHeapSizeLimit = heapSizeLimit;
3905+
#ifdef VOLK_HEADER_VERSION
3906+
VmaVulkanFunctions vulkanFunctions = {};
3907+
vmaImportVulkanFunctionsFromVolk(&allocatorCreateInfo, &vulkanFunctions);
3908+
allocatorCreateInfo.pVulkanFunctions = &vulkanFunctions;
3909+
#endif
39053910
#if VMA_DYNAMIC_VULKAN_FUNCTIONS
39063911
VmaVulkanFunctions vulkanFunctions = {};
39073912
vulkanFunctions.vkGetInstanceProcAddr = vkGetInstanceProcAddr;

src/VmaUsage.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,14 @@ include all public interface declarations. Example:
9696
#pragma clang diagnostic ignored "-Wnullability-completeness"
9797
#endif
9898

99-
#include <vulkan/vulkan.h>
99+
#ifdef VMA_VOLK_HEADER_PATH
100+
#include VMA_VOLK_HEADER_PATH
101+
#else
102+
#include <vulkan/vulkan.h>
103+
#endif
100104

101105
#ifdef _WIN32
102-
#include <vulkan/vulkan_win32.h>
106+
#include <vulkan/vulkan_win32.h>
103107
#endif // #ifdef _WIN32
104108

105109
#include "vk_mem_alloc.h"

src/VolkUsage.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// Copyright (c) 2017-2025 Advanced Micro Devices, Inc. All rights reserved.
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
//
22+
23+
#ifdef VMA_VOLK_HEADER_PATH
24+
25+
#define VOLK_IMPLEMENTATION
26+
#include "VmaUsage.h"
27+
28+
#endif // #ifdef VMA_VOLK_HEADER_PATH

src/VulkanSample.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,10 @@ void VulkanUsage::Init()
426426
g_Allocs = &g_CpuAllocationCallbacks;
427427
}
428428

429+
#ifdef VOLK_HEADER_VERSION
430+
ERR_GUARD_VULKAN(volkInitialize());
431+
#endif
432+
429433
uint32_t instanceLayerPropCount = 0;
430434
ERR_GUARD_VULKAN( vkEnumerateInstanceLayerProperties(&instanceLayerPropCount, nullptr) );
431435
std::vector<VkLayerProperties> instanceLayerProps(instanceLayerPropCount);
@@ -513,6 +517,10 @@ void VulkanUsage::Init()
513517

514518
ERR_GUARD_VULKAN( vkCreateInstance(&instInfo, g_Allocs, &g_hVulkanInstance) );
515519

520+
#ifdef VOLK_HEADER_VERSION
521+
volkLoadInstance(g_hVulkanInstance);
522+
#endif
523+
516524
if(VK_EXT_debug_utils_enabled)
517525
{
518526
RegisterDebugCallbacks();
@@ -1511,12 +1519,18 @@ void SetAllocatorCreateInfo(VmaAllocatorCreateInfo& outInfo)
15111519
outInfo.pAllocationCallbacks = &g_CpuAllocationCallbacks;
15121520
}
15131521

1522+
#ifdef VOLK_HEADER_VERSION
1523+
static VmaVulkanFunctions vulkanFunctions = {};
1524+
vmaImportVulkanFunctionsFromVolk(&outInfo, &vulkanFunctions);
1525+
outInfo.pVulkanFunctions = &vulkanFunctions;
1526+
#endif // #ifdef VOLK_HEADER_VERSION
1527+
15141528
#if VMA_DYNAMIC_VULKAN_FUNCTIONS
15151529
static VmaVulkanFunctions vulkanFunctions = {};
15161530
vulkanFunctions.vkGetInstanceProcAddr = vkGetInstanceProcAddr;
15171531
vulkanFunctions.vkGetDeviceProcAddr = vkGetDeviceProcAddr;
15181532
outInfo.pVulkanFunctions = &vulkanFunctions;
1519-
#endif
1533+
#endif // #if VMA_DYNAMIC_VULKAN_FUNCTIONS
15201534

15211535
// Uncomment to enable HeapSizeLimit.
15221536
/*
@@ -2083,6 +2097,11 @@ static void InitializeApplication()
20832097
deviceCreateInfo.pQueueCreateInfos = queueCreateInfo;
20842098

20852099
ERR_GUARD_VULKAN( vkCreateDevice(g_hPhysicalDevice, &deviceCreateInfo, g_Allocs, &g_hDevice) );
2100+
2101+
#ifdef VOLK_HEADER_VERSION
2102+
volkLoadDevice(g_hDevice);
2103+
#endif
2104+
20862105
SetDebugUtilsObjectName(VK_OBJECT_TYPE_DEVICE, reinterpret_cast<std::uint64_t>(g_hDevice), "g_hDevice");
20872106
// Only now that SetDebugUtilsObjectName is loaded, we can assign a name to g_hVulkanInstance as well
20882107
SetDebugUtilsObjectName(VK_OBJECT_TYPE_INSTANCE, reinterpret_cast<std::uint64_t>(g_hVulkanInstance), "g_hVulkanInstance");

0 commit comments

Comments
 (0)