Skip to content

Commit 1296e2d

Browse files
VmaReplay: Switch to Vulkan 1.1
Recording file format version bumped to 1.8 to support "VulkanApiVersion". VmaReplay now uses Vulkan 1.1 by default and so it removes parameter --VK_KHR_dedicated_allocation.
1 parent 10f68cb commit 1296e2d

File tree

4 files changed

+37
-69
lines changed

4 files changed

+37
-69
lines changed

docs/Recording file format.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Formats with only minor version incremented are backward compatible.
2323
VmaReplay application supports all older versions.
2424
Current version is:
2525

26-
1,7
26+
1,8
2727

2828
# Configuration
2929

@@ -37,6 +37,8 @@ And ends with line:
3737

3838
Between them there can be zero or more lines with configuration options. They store values of various variables from the current environment from the time of recording, like properties and limits of Vulkan physical device, available memory heaps and types, enabled Vulkan extensions, as well macros that configure VMA internals. Supported configuration options are:
3939

40+
VulkanApiVersion,<uint32>,<uint32>
41+
4042
PhysicalDevice,apiVersion,<uint32>
4143
PhysicalDevice,driverVersion,<uint32>
4244
PhysicalDevice,vendorID,<uint32>
@@ -56,6 +58,8 @@ Between them there can be zero or more lines with configuration options. They st
5658
PhysicalDeviceMemory,Type,<index:uint32>,propertyFlags,<uint32>
5759

5860
Extension,VK_KHR_dedicated_allocation,<bool>
61+
Extension,VK_KHR_bind_memory2,<bool>
62+
Extension,VK_EXT_memory_budget,<bool>
5963

6064
Macro,VMA_DEBUG_ALWAYS_DEDICATED_MEMORY,<bool>
6165
Macro,VMA_DEBUG_ALIGNMENT,<uint64>
@@ -276,8 +280,9 @@ An ordered sequence of values of some type, separated by single space.
276280
# Example file
277281

278282
Vulkan Memory Allocator,Calls recording
279-
1,7
283+
1,8
280284
Config,Begin
285+
VulkanApiVersion,1,1
281286
PhysicalDevice,apiVersion,4198477
282287
PhysicalDevice,driverVersion,8388653
283288
PhysicalDevice,vendorID,4098

src/VmaReplay/VmaReplay.cpp

Lines changed: 22 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
static VERBOSITY g_Verbosity = VERBOSITY::DEFAULT;
3131

32+
static const uint32_t VULKAN_API_VERSION = VK_API_VERSION_1_1;
33+
3234
namespace DetailedStats
3335
{
3436

@@ -668,7 +670,6 @@ static uint32_t g_PhysicalDeviceIndex = 0;
668670
static RangeSequence<size_t> g_LineRanges;
669671
static bool g_UserDataEnabled = true;
670672
static bool g_MemStatsEnabled = false;
671-
VULKAN_EXTENSION_REQUEST g_VK_KHR_dedicated_allocation_request = VULKAN_EXTENSION_REQUEST::DEFAULT;
672673
VULKAN_EXTENSION_REQUEST g_VK_LAYER_LUNARG_standard_validation = VULKAN_EXTENSION_REQUEST::DEFAULT;
673674
VULKAN_EXTENSION_REQUEST g_VK_EXT_memory_budget_request = VULKAN_EXTENSION_REQUEST::DEFAULT;
674675

@@ -689,7 +690,7 @@ static size_t g_DefragmentAfterLineNextIndex = 0;
689690
static bool ValidateFileVersion()
690691
{
691692
if(GetVersionMajor(g_FileVersion) == 1 &&
692-
GetVersionMinor(g_FileVersion) <= 7)
693+
GetVersionMinor(g_FileVersion) <= 8)
693694
{
694695
return true;
695696
}
@@ -1064,12 +1065,13 @@ class ConfigurationParser
10641065
void Compare(
10651066
const VkPhysicalDeviceProperties& currDevProps,
10661067
const VkPhysicalDeviceMemoryProperties& currMemProps,
1067-
bool currDedicatedAllocationExtensionEnabled,
1068+
uint32_t vulkanApiVersion,
10681069
bool currMemoryBudgetEnabled);
10691070

10701071
private:
10711072
enum class OPTION
10721073
{
1074+
VulkanApiVersion,
10731075
PhysicalDevice_apiVersion,
10741076
PhysicalDevice_driverVersion,
10751077
PhysicalDevice_vendorID,
@@ -1159,7 +1161,11 @@ bool ConfigurationParser::Parse(LineSplit& lineSplit)
11591161
}
11601162

11611163
const StrRange optionName = csvSplit.GetRange(0);
1162-
if(StrRangeEq(optionName, "PhysicalDevice"))
1164+
if(StrRangeEq(optionName, "VulkanApiVersion"))
1165+
{
1166+
SetOption(currLineNumber, OPTION::VulkanApiVersion, StrRange{csvSplit.GetRange(1).beg, csvSplit.GetRange(2).end});
1167+
}
1168+
else if(StrRangeEq(optionName, "PhysicalDevice"))
11631169
{
11641170
if(csvSplit.GetCount() >= 3)
11651171
{
@@ -1205,7 +1211,9 @@ bool ConfigurationParser::Parse(LineSplit& lineSplit)
12051211
{
12061212
const StrRange subOptionName = csvSplit.GetRange(1);
12071213
if(StrRangeEq(subOptionName, "VK_KHR_dedicated_allocation"))
1208-
SetOption(currLineNumber, OPTION::Extension_VK_KHR_dedicated_allocation, csvSplit.GetRange(2));
1214+
{
1215+
// Ignore because this extension is promoted to Vulkan 1.1.
1216+
}
12091217
else if(StrRangeEq(subOptionName, "VK_KHR_bind_memory2"))
12101218
SetOption(currLineNumber, OPTION::Extension_VK_KHR_bind_memory2, csvSplit.GetRange(2));
12111219
else if(StrRangeEq(subOptionName, "VK_EXT_memory_budget"))
@@ -1305,9 +1313,14 @@ bool ConfigurationParser::Parse(LineSplit& lineSplit)
13051313
void ConfigurationParser::Compare(
13061314
const VkPhysicalDeviceProperties& currDevProps,
13071315
const VkPhysicalDeviceMemoryProperties& currMemProps,
1308-
bool currDedicatedAllocationExtensionEnabled,
1316+
uint32_t vulkanApiVersion,
13091317
bool currMemoryBudgetEnabled)
13101318
{
1319+
char vulkanApiVersionStr[32];
1320+
sprintf_s(vulkanApiVersionStr, "%u,%u", VK_VERSION_MAJOR(vulkanApiVersion), VK_VERSION_MINOR(vulkanApiVersion));
1321+
CompareOption(VERBOSITY::DEFAULT, "VulkanApiVersion",
1322+
OPTION::VulkanApiVersion, vulkanApiVersionStr);
1323+
13111324
CompareOption(VERBOSITY::MAXIMUM, "PhysicalDevice apiVersion",
13121325
OPTION::PhysicalDevice_apiVersion, currDevProps.apiVersion);
13131326
CompareOption(VERBOSITY::MAXIMUM, "PhysicalDevice driverVersion",
@@ -1327,8 +1340,6 @@ void ConfigurationParser::Compare(
13271340
OPTION::PhysicalDeviceLimits_bufferImageGranularity, currDevProps.limits.bufferImageGranularity);
13281341
CompareOption(VERBOSITY::DEFAULT, "PhysicalDeviceLimits nonCoherentAtomSize",
13291342
OPTION::PhysicalDeviceLimits_nonCoherentAtomSize, currDevProps.limits.nonCoherentAtomSize);
1330-
CompareOption(VERBOSITY::DEFAULT, "Extension VK_KHR_dedicated_allocation",
1331-
OPTION::Extension_VK_EXT_memory_budget, currMemoryBudgetEnabled);
13321343

13331344
CompareMemProps(currMemProps);
13341345
}
@@ -1588,7 +1599,6 @@ class Player
15881599
VmaAllocator m_Allocator = VK_NULL_HANDLE;
15891600
VkCommandPool m_CommandPool = VK_NULL_HANDLE;
15901601
VkCommandBuffer m_CommandBuffer = VK_NULL_HANDLE;
1591-
bool m_DedicatedAllocationEnabled = false;
15921602
bool m_MemoryBudgetEnabled = false;
15931603
const VkPhysicalDeviceProperties* m_DevProps = nullptr;
15941604
const VkPhysicalDeviceMemoryProperties* m_MemProps = nullptr;
@@ -1711,7 +1721,7 @@ Player::~Player()
17111721
void Player::ApplyConfig(ConfigurationParser& configParser)
17121722
{
17131723
configParser.Compare(*m_DevProps, *m_MemProps,
1714-
m_DedicatedAllocationEnabled,
1724+
VULKAN_API_VERSION,
17151725
m_MemoryBudgetEnabled);
17161726
}
17171727

@@ -2055,7 +2065,7 @@ int Player::InitVulkan()
20552065
appInfo.applicationVersion = VK_MAKE_VERSION(2, 2, 0);
20562066
appInfo.pEngineName = "Vulkan Memory Allocator";
20572067
appInfo.engineVersion = VK_MAKE_VERSION(2, 2, 0);
2058-
appInfo.apiVersion = VK_API_VERSION_1_0;
2068+
appInfo.apiVersion = VULKAN_API_VERSION;
20592069

20602070
VkInstanceCreateInfo instInfo = { VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO };
20612071
instInfo.pApplicationInfo = &appInfo;
@@ -2163,7 +2173,6 @@ int Player::InitVulkan()
21632173
InitVulkanFeatures(enabledFeatures, supportedFeatures);
21642174

21652175
bool VK_KHR_get_memory_requirements2_available = false;
2166-
bool VK_KHR_dedicated_allocation_available = false;
21672176

21682177
// Determine list of device extensions to enable.
21692178
std::vector<const char*> enabledDeviceExtensions;
@@ -2186,10 +2195,6 @@ int Player::InitVulkan()
21862195
{
21872196
VK_KHR_get_memory_requirements2_available = true;
21882197
}
2189-
else if(strcmp(properties[i].extensionName, VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME) == 0)
2190-
{
2191-
VK_KHR_dedicated_allocation_available = true;
2192-
}
21932198
else if(strcmp(properties[i].extensionName, VK_EXT_MEMORY_BUDGET_EXTENSION_NAME) == 0)
21942199
{
21952200
if(VK_KHR_get_physical_device_properties2_enabled)
@@ -2201,26 +2206,6 @@ int Player::InitVulkan()
22012206
}
22022207
}
22032208

2204-
const bool dedicatedAllocationAvailable =
2205-
VK_KHR_get_memory_requirements2_available && VK_KHR_dedicated_allocation_available;
2206-
2207-
switch(g_VK_KHR_dedicated_allocation_request)
2208-
{
2209-
case VULKAN_EXTENSION_REQUEST::DISABLED:
2210-
break;
2211-
case VULKAN_EXTENSION_REQUEST::DEFAULT:
2212-
m_DedicatedAllocationEnabled = dedicatedAllocationAvailable;
2213-
break;
2214-
case VULKAN_EXTENSION_REQUEST::ENABLED:
2215-
m_DedicatedAllocationEnabled = dedicatedAllocationAvailable;
2216-
if(!dedicatedAllocationAvailable)
2217-
{
2218-
printf("WARNING: VK_KHR_dedicated_allocation extension cannot be enabled.\n");
2219-
}
2220-
break;
2221-
default: assert(0);
2222-
}
2223-
22242209
switch(g_VK_EXT_memory_budget_request)
22252210
{
22262211
case VULKAN_EXTENSION_REQUEST::DISABLED:
@@ -2238,11 +2223,6 @@ int Player::InitVulkan()
22382223
default: assert(0);
22392224
}
22402225

2241-
if(m_DedicatedAllocationEnabled)
2242-
{
2243-
enabledDeviceExtensions.push_back(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME);
2244-
enabledDeviceExtensions.push_back(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME);
2245-
}
22462226
if(m_MemoryBudgetEnabled)
22472227
{
22482228
enabledDeviceExtensions.push_back(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME);
@@ -2278,11 +2258,8 @@ int Player::InitVulkan()
22782258
allocatorInfo.device = m_Device;
22792259
allocatorInfo.flags = VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT;
22802260
allocatorInfo.pDeviceMemoryCallbacks = &deviceMemoryCallbacks;
2261+
allocatorInfo.vulkanApiVersion = VULKAN_API_VERSION;
22812262

2282-
if(m_DedicatedAllocationEnabled)
2283-
{
2284-
allocatorInfo.flags |= VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT;
2285-
}
22862263
if(m_MemoryBudgetEnabled)
22872264
{
22882265
allocatorInfo.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT;
@@ -4005,8 +3982,6 @@ static void PrintCommandLineSyntax()
40053982
" Default is 1. Affects both creation of buffers and images, as well as calls to vmaSetAllocationUserData.\n"
40063983
" --VK_LAYER_LUNARG_standard_validation <Value> - 0 to disable or 1 to enable validation layers.\n"
40073984
" By default the layers are silently enabled if available.\n"
4008-
" --VK_KHR_dedicated_allocation <Value> - 0 to disable or 1 to enable this extension.\n"
4009-
" By default the extension is silently enabled if available.\n"
40103985
" --VK_EXT_memory_budget <Value> - 0 to disable or 1 to enable this extension.\n"
40113986
" By default the extension is silently enabled if available.\n"
40123987
);
@@ -4227,7 +4202,6 @@ static int main2(int argc, char** argv)
42274202
cmdLineParser.RegisterOpt(CMD_LINE_OPT_LINES, "Lines", true);
42284203
cmdLineParser.RegisterOpt(CMD_LINE_OPT_PHYSICAL_DEVICE, "PhysicalDevice", true);
42294204
cmdLineParser.RegisterOpt(CMD_LINE_OPT_USER_DATA, "UserData", true);
4230-
cmdLineParser.RegisterOpt(CMD_LINE_OPT_VK_KHR_DEDICATED_ALLOCATION, "VK_KHR_dedicated_allocation", true);
42314205
cmdLineParser.RegisterOpt(CMD_LINE_OPT_VK_EXT_MEMORY_BUDGET, "VK_EXT_memory_budget", true);
42324206
cmdLineParser.RegisterOpt(CMD_LINE_OPT_VK_LAYER_LUNARG_STANDARD_VALIDATION, VALIDATION_LAYER_NAME, true);
42334207
cmdLineParser.RegisterOpt(CMD_LINE_OPT_MEM_STATS, "MemStats", true);
@@ -4287,22 +4261,6 @@ static int main2(int argc, char** argv)
42874261
return RESULT_ERROR_COMMAND_LINE;
42884262
}
42894263
break;
4290-
case CMD_LINE_OPT_VK_KHR_DEDICATED_ALLOCATION:
4291-
{
4292-
bool newValue;
4293-
if(StrRangeToBool(StrRange(cmdLineParser.GetParameter()), newValue))
4294-
{
4295-
g_VK_KHR_dedicated_allocation_request = newValue ?
4296-
VULKAN_EXTENSION_REQUEST::ENABLED :
4297-
VULKAN_EXTENSION_REQUEST::DISABLED;
4298-
}
4299-
else
4300-
{
4301-
PrintCommandLineSyntax();
4302-
return RESULT_ERROR_COMMAND_LINE;
4303-
}
4304-
}
4305-
break;
43064264
case CMD_LINE_OPT_VK_EXT_MEMORY_BUDGET:
43074265
{
43084266
bool newValue;

src/VmaUsage.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ include all public interface declarations. Example:
5959
//#define VMA_DEBUG_GLOBAL_MUTEX 1
6060
//#define VMA_MEMORY_BUDGET 0
6161

62-
//#define VMA_VULKAN_VERSION 1001000 // Vulkan 1.1
63-
#define VMA_VULKAN_VERSION 1000000 // Vulkan 1.0
62+
#define VMA_VULKAN_VERSION 1001000 // Vulkan 1.1
63+
//#define VMA_VULKAN_VERSION 1000000 // Vulkan 1.0
6464

6565
/*
6666
#define VMA_DEBUG_LOG(format, ...) do { \

src/vk_mem_alloc.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6846,6 +6846,7 @@ class VmaRecorder
68466846
void WriteConfiguration(
68476847
const VkPhysicalDeviceProperties& devProps,
68486848
const VkPhysicalDeviceMemoryProperties& memProps,
6849+
uint32_t vulkanApiVersion,
68496850
bool dedicatedAllocationExtensionEnabled,
68506851
bool bindMemory2ExtensionEnabled,
68516852
bool memoryBudgetExtensionEnabled);
@@ -13951,7 +13952,7 @@ VkResult VmaRecorder::Init(const VmaRecordSettings& settings, bool useMutex)
1395113952

1395213953
// Write header.
1395313954
fprintf(m_File, "%s\n", "Vulkan Memory Allocator,Calls recording");
13954-
fprintf(m_File, "%s\n", "1,7");
13955+
fprintf(m_File, "%s\n", "1,8");
1395513956

1395613957
return VK_SUCCESS;
1395713958
}
@@ -14420,12 +14421,15 @@ VmaRecorder::UserDataString::UserDataString(VmaAllocationCreateFlags allocFlags,
1442014421
void VmaRecorder::WriteConfiguration(
1442114422
const VkPhysicalDeviceProperties& devProps,
1442214423
const VkPhysicalDeviceMemoryProperties& memProps,
14424+
uint32_t vulkanApiVersion,
1442314425
bool dedicatedAllocationExtensionEnabled,
1442414426
bool bindMemory2ExtensionEnabled,
1442514427
bool memoryBudgetExtensionEnabled)
1442614428
{
1442714429
fprintf(m_File, "Config,Begin\n");
1442814430

14431+
fprintf(m_File, "VulkanApiVersion,%u,%u\n", VK_VERSION_MAJOR(vulkanApiVersion), VK_VERSION_MINOR(vulkanApiVersion));
14432+
1442914433
fprintf(m_File, "PhysicalDevice,apiVersion,%u\n", devProps.apiVersion);
1443014434
fprintf(m_File, "PhysicalDevice,driverVersion,%u\n", devProps.driverVersion);
1443114435
fprintf(m_File, "PhysicalDevice,vendorID,%u\n", devProps.vendorID);
@@ -14668,6 +14672,7 @@ VkResult VmaAllocator_T::Init(const VmaAllocatorCreateInfo* pCreateInfo)
1466814672
m_pRecorder->WriteConfiguration(
1466914673
m_PhysicalDeviceProperties,
1467014674
m_MemProps,
14675+
m_VulkanApiVersion,
1467114676
m_UseKhrDedicatedAllocation,
1467214677
m_UseKhrBindMemory2,
1467314678
m_UseExtMemoryBudget);

0 commit comments

Comments
 (0)