diff options
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp index 555b12ed7..5d5329abf 100644 --- a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp +++ b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp | |||
| @@ -61,11 +61,15 @@ std::optional<u32> FindMemoryTypeIndex(const VkPhysicalDeviceMemoryProperties& p | |||
| 61 | return std::nullopt; | 61 | return std::nullopt; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | u32 FindMemoryTypeIndex(const VkPhysicalDeviceMemoryProperties& props, u32 type_mask) { | 64 | u32 FindMemoryTypeIndex(const VkPhysicalDeviceMemoryProperties& props, u32 type_mask, |
| 65 | // Try to find a DEVICE_LOCAL_BIT type, Nvidia and AMD have a dedicated heap for this | 65 | bool try_device_local) { |
| 66 | std::optional<u32> type = FindMemoryTypeIndex(props, type_mask, STREAM_FLAGS); | 66 | std::optional<u32> type; |
| 67 | if (type) { | 67 | if (try_device_local) { |
| 68 | return *type; | 68 | // Try to find a DEVICE_LOCAL_BIT type, Nvidia and AMD have a dedicated heap for this |
| 69 | type = FindMemoryTypeIndex(props, type_mask, STREAM_FLAGS); | ||
| 70 | if (type) { | ||
| 71 | return *type; | ||
| 72 | } | ||
| 69 | } | 73 | } |
| 70 | // Otherwise try without the DEVICE_LOCAL_BIT | 74 | // Otherwise try without the DEVICE_LOCAL_BIT |
| 71 | type = FindMemoryTypeIndex(props, type_mask, HOST_FLAGS); | 75 | type = FindMemoryTypeIndex(props, type_mask, HOST_FLAGS); |
| @@ -115,12 +119,21 @@ StagingBufferPool::StagingBufferPool(const Device& device_, MemoryAllocator& mem | |||
| 115 | .buffer = *stream_buffer, | 119 | .buffer = *stream_buffer, |
| 116 | }; | 120 | }; |
| 117 | const auto memory_properties = device.GetPhysical().GetMemoryProperties(); | 121 | const auto memory_properties = device.GetPhysical().GetMemoryProperties(); |
| 118 | stream_memory = dev.AllocateMemory(VkMemoryAllocateInfo{ | 122 | VkMemoryAllocateInfo stream_memory_info{ |
| 119 | .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, | 123 | .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, |
| 120 | .pNext = make_dedicated ? &dedicated_info : nullptr, | 124 | .pNext = make_dedicated ? &dedicated_info : nullptr, |
| 121 | .allocationSize = requirements.size, | 125 | .allocationSize = requirements.size, |
| 122 | .memoryTypeIndex = FindMemoryTypeIndex(memory_properties, requirements.memoryTypeBits), | 126 | .memoryTypeIndex = |
| 123 | }); | 127 | FindMemoryTypeIndex(memory_properties, requirements.memoryTypeBits, true), |
| 128 | }; | ||
| 129 | stream_memory = dev.TryAllocateMemory(stream_memory_info); | ||
| 130 | if (!stream_memory) { | ||
| 131 | LOG_INFO(Render_Vulkan, "Dynamic memory allocation failed, trying with system memory"); | ||
| 132 | stream_memory_info.memoryTypeIndex = | ||
| 133 | FindMemoryTypeIndex(memory_properties, requirements.memoryTypeBits, false); | ||
| 134 | stream_memory = dev.AllocateMemory(stream_memory_info); | ||
| 135 | } | ||
| 136 | |||
| 124 | if (device.HasDebuggingToolAttached()) { | 137 | if (device.HasDebuggingToolAttached()) { |
| 125 | stream_memory.SetObjectNameEXT("Stream Buffer Memory"); | 138 | stream_memory.SetObjectNameEXT("Stream Buffer Memory"); |
| 126 | } | 139 | } |