Vulkan: Swap to system memory for device local memory

This PR will swap device local memory to system ram. It relies on
VK_EXT_external_memory and VK_EXT_pageable_device_local_memory
extensions to be supported by the system.

Most platforms support these extensions.

Pull Request: https://projects.blender.org/blender/blender/pulls/144422
This commit is contained in:
Jeroen Bakker
2025-08-12 11:51:40 +02:00
parent d278e7d424
commit 42c3f35780
14 changed files with 75 additions and 12 deletions

View File

@@ -393,6 +393,22 @@ class GHOST_DeviceVK {
feature_struct_ptr.push_back(&fragment_shader_barycentric);
}
/* VK_EXT_memory_priority */
VkPhysicalDeviceMemoryPriorityFeaturesEXT memory_priority = {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT, nullptr, VK_TRUE};
if (extension_enabled(VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME)) {
feature_struct_ptr.push_back(&memory_priority);
}
/* VK_EXT_pageable_device_local_memory */
VkPhysicalDevicePageableDeviceLocalMemoryFeaturesEXT pageable_device_local_memory = {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PAGEABLE_DEVICE_LOCAL_MEMORY_FEATURES_EXT,
nullptr,
VK_TRUE};
if (extension_enabled(VK_EXT_PAGEABLE_DEVICE_LOCAL_MEMORY_EXTENSION_NAME)) {
feature_struct_ptr.push_back(&pageable_device_local_memory);
}
/* Link all registered feature structs. */
for (int i = 1; i < feature_struct_ptr.size(); i++) {
((VkBaseInStructure *)(feature_struct_ptr[i - 1]))->pNext =
@@ -1291,6 +1307,8 @@ GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext()
optional_device_extensions.push_back(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME);
optional_device_extensions.push_back(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME);
optional_device_extensions.push_back(VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME);
optional_device_extensions.push_back(VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME);
optional_device_extensions.push_back(VK_EXT_PAGEABLE_DEVICE_LOCAL_MEMORY_EXTENSION_NAME);
VkInstance instance = VK_NULL_HANDLE;
if (!vulkan_device.has_value()) {