diff options
| author | 2020-04-21 21:46:58 -0300 | |
|---|---|---|
| committer | 2020-04-21 22:06:38 -0300 | |
| commit | 6f47bd9641c04a2cdc8f23fafd49069eab00e3fb (patch) | |
| tree | e4cc0546f628fa1706c88d8ee64556c083eb531c /src | |
| parent | Merge pull request #3714 from lioncash/copies (diff) | |
| download | yuzu-6f47bd9641c04a2cdc8f23fafd49069eab00e3fb.tar.gz yuzu-6f47bd9641c04a2cdc8f23fafd49069eab00e3fb.tar.xz yuzu-6f47bd9641c04a2cdc8f23fafd49069eab00e3fb.zip | |
vk_memory_manager: Remove unified memory model flag
All drivers (even Intel) seem to have a device local memory type that is
not host visible. Remove this flag so all devices follow the same path.
This fixes a crash when trying to map to host device local memory on
integrated devices.
Diffstat (limited to 'src')
5 files changed, 6 insertions, 35 deletions
diff --git a/src/video_core/renderer_vulkan/vk_device.h b/src/video_core/renderer_vulkan/vk_device.h index 60d64572a..bac58d385 100644 --- a/src/video_core/renderer_vulkan/vk_device.h +++ b/src/video_core/renderer_vulkan/vk_device.h | |||
| @@ -78,11 +78,6 @@ public: | |||
| 78 | return present_family; | 78 | return present_family; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | /// Returns true if the device is integrated with the host CPU. | ||
| 82 | bool IsIntegrated() const { | ||
| 83 | return properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU; | ||
| 84 | } | ||
| 85 | |||
| 86 | /// Returns the current Vulkan API version provided in Vulkan-formatted version numbers. | 81 | /// Returns the current Vulkan API version provided in Vulkan-formatted version numbers. |
| 87 | u32 GetApiVersion() const { | 82 | u32 GetApiVersion() const { |
| 88 | return properties.apiVersion; | 83 | return properties.apiVersion; |
diff --git a/src/video_core/renderer_vulkan/vk_memory_manager.cpp b/src/video_core/renderer_vulkan/vk_memory_manager.cpp index 6a9e658bf..b4c650a63 100644 --- a/src/video_core/renderer_vulkan/vk_memory_manager.cpp +++ b/src/video_core/renderer_vulkan/vk_memory_manager.cpp | |||
| @@ -118,8 +118,7 @@ private: | |||
| 118 | }; | 118 | }; |
| 119 | 119 | ||
| 120 | VKMemoryManager::VKMemoryManager(const VKDevice& device) | 120 | VKMemoryManager::VKMemoryManager(const VKDevice& device) |
| 121 | : device{device}, properties{device.GetPhysical().GetMemoryProperties()}, | 121 | : device{device}, properties{device.GetPhysical().GetMemoryProperties()} {} |
| 122 | is_memory_unified{GetMemoryUnified(properties)} {} | ||
| 123 | 122 | ||
| 124 | VKMemoryManager::~VKMemoryManager() = default; | 123 | VKMemoryManager::~VKMemoryManager() = default; |
| 125 | 124 | ||
| @@ -209,16 +208,6 @@ VKMemoryCommit VKMemoryManager::TryAllocCommit(const VkMemoryRequirements& requi | |||
| 209 | return {}; | 208 | return {}; |
| 210 | } | 209 | } |
| 211 | 210 | ||
| 212 | bool VKMemoryManager::GetMemoryUnified(const VkPhysicalDeviceMemoryProperties& properties) { | ||
| 213 | for (u32 heap_index = 0; heap_index < properties.memoryHeapCount; ++heap_index) { | ||
| 214 | if (!(properties.memoryHeaps[heap_index].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)) { | ||
| 215 | // Memory is considered unified when heaps are device local only. | ||
| 216 | return false; | ||
| 217 | } | ||
| 218 | } | ||
| 219 | return true; | ||
| 220 | } | ||
| 221 | |||
| 222 | VKMemoryCommitImpl::VKMemoryCommitImpl(const VKDevice& device, VKMemoryAllocation* allocation, | 211 | VKMemoryCommitImpl::VKMemoryCommitImpl(const VKDevice& device, VKMemoryAllocation* allocation, |
| 223 | const vk::DeviceMemory& memory, u64 begin, u64 end) | 212 | const vk::DeviceMemory& memory, u64 begin, u64 end) |
| 224 | : device{device}, memory{memory}, interval{begin, end}, allocation{allocation} {} | 213 | : device{device}, memory{memory}, interval{begin, end}, allocation{allocation} {} |
diff --git a/src/video_core/renderer_vulkan/vk_memory_manager.h b/src/video_core/renderer_vulkan/vk_memory_manager.h index 5b6858e9b..1af88e3d4 100644 --- a/src/video_core/renderer_vulkan/vk_memory_manager.h +++ b/src/video_core/renderer_vulkan/vk_memory_manager.h | |||
| @@ -40,11 +40,6 @@ public: | |||
| 40 | /// Commits memory required by the image and binds it. | 40 | /// Commits memory required by the image and binds it. |
| 41 | VKMemoryCommit Commit(const vk::Image& image, bool host_visible); | 41 | VKMemoryCommit Commit(const vk::Image& image, bool host_visible); |
| 42 | 42 | ||
| 43 | /// Returns true if the memory allocations are done always in host visible and coherent memory. | ||
| 44 | bool IsMemoryUnified() const { | ||
| 45 | return is_memory_unified; | ||
| 46 | } | ||
| 47 | |||
| 48 | private: | 43 | private: |
| 49 | /// Allocates a chunk of memory. | 44 | /// Allocates a chunk of memory. |
| 50 | bool AllocMemory(VkMemoryPropertyFlags wanted_properties, u32 type_mask, u64 size); | 45 | bool AllocMemory(VkMemoryPropertyFlags wanted_properties, u32 type_mask, u64 size); |
| @@ -53,12 +48,8 @@ private: | |||
| 53 | VKMemoryCommit TryAllocCommit(const VkMemoryRequirements& requirements, | 48 | VKMemoryCommit TryAllocCommit(const VkMemoryRequirements& requirements, |
| 54 | VkMemoryPropertyFlags wanted_properties); | 49 | VkMemoryPropertyFlags wanted_properties); |
| 55 | 50 | ||
| 56 | /// Returns true if the device uses an unified memory model. | 51 | const VKDevice& device; ///< Device handler. |
| 57 | static bool GetMemoryUnified(const VkPhysicalDeviceMemoryProperties& properties); | 52 | const VkPhysicalDeviceMemoryProperties properties; ///< Physical device properties. |
| 58 | |||
| 59 | const VKDevice& device; ///< Device handler. | ||
| 60 | const VkPhysicalDeviceMemoryProperties properties; ///< Physical device properties. | ||
| 61 | const bool is_memory_unified; ///< True if memory model is unified. | ||
| 62 | std::vector<std::unique_ptr<VKMemoryAllocation>> allocations; ///< Current allocations. | 53 | std::vector<std::unique_ptr<VKMemoryAllocation>> allocations; ///< Current allocations. |
| 63 | }; | 54 | }; |
| 64 | 55 | ||
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 94d954d7a..abd836efe 100644 --- a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp +++ b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp | |||
| @@ -39,8 +39,7 @@ VKStagingBufferPool::StagingBuffer& VKStagingBufferPool::StagingBuffer::operator | |||
| 39 | 39 | ||
| 40 | VKStagingBufferPool::VKStagingBufferPool(const VKDevice& device, VKMemoryManager& memory_manager, | 40 | VKStagingBufferPool::VKStagingBufferPool(const VKDevice& device, VKMemoryManager& memory_manager, |
| 41 | VKScheduler& scheduler) | 41 | VKScheduler& scheduler) |
| 42 | : device{device}, memory_manager{memory_manager}, scheduler{scheduler}, | 42 | : device{device}, memory_manager{memory_manager}, scheduler{scheduler} {} |
| 43 | is_device_integrated{device.IsIntegrated()} {} | ||
| 44 | 43 | ||
| 45 | VKStagingBufferPool::~VKStagingBufferPool() = default; | 44 | VKStagingBufferPool::~VKStagingBufferPool() = default; |
| 46 | 45 | ||
| @@ -56,9 +55,7 @@ void VKStagingBufferPool::TickFrame() { | |||
| 56 | current_delete_level = (current_delete_level + 1) % NumLevels; | 55 | current_delete_level = (current_delete_level + 1) % NumLevels; |
| 57 | 56 | ||
| 58 | ReleaseCache(true); | 57 | ReleaseCache(true); |
| 59 | if (!is_device_integrated) { | 58 | ReleaseCache(false); |
| 60 | ReleaseCache(false); | ||
| 61 | } | ||
| 62 | } | 59 | } |
| 63 | 60 | ||
| 64 | VKBuffer* VKStagingBufferPool::TryGetReservedBuffer(std::size_t size, bool host_visible) { | 61 | VKBuffer* VKStagingBufferPool::TryGetReservedBuffer(std::size_t size, bool host_visible) { |
| @@ -95,7 +92,7 @@ VKBuffer& VKStagingBufferPool::CreateStagingBuffer(std::size_t size, bool host_v | |||
| 95 | } | 92 | } |
| 96 | 93 | ||
| 97 | VKStagingBufferPool::StagingBuffersCache& VKStagingBufferPool::GetCache(bool host_visible) { | 94 | VKStagingBufferPool::StagingBuffersCache& VKStagingBufferPool::GetCache(bool host_visible) { |
| 98 | return is_device_integrated || host_visible ? host_staging_buffers : device_staging_buffers; | 95 | return host_visible ? host_staging_buffers : device_staging_buffers; |
| 99 | } | 96 | } |
| 100 | 97 | ||
| 101 | void VKStagingBufferPool::ReleaseCache(bool host_visible) { | 98 | void VKStagingBufferPool::ReleaseCache(bool host_visible) { |
diff --git a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.h b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.h index a0840ff8c..faf6418fd 100644 --- a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.h +++ b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.h | |||
| @@ -71,7 +71,6 @@ private: | |||
| 71 | const VKDevice& device; | 71 | const VKDevice& device; |
| 72 | VKMemoryManager& memory_manager; | 72 | VKMemoryManager& memory_manager; |
| 73 | VKScheduler& scheduler; | 73 | VKScheduler& scheduler; |
| 74 | const bool is_device_integrated; | ||
| 75 | 74 | ||
| 76 | StagingBuffersCache host_staging_buffers; | 75 | StagingBuffersCache host_staging_buffers; |
| 77 | StagingBuffersCache device_staging_buffers; | 76 | StagingBuffersCache device_staging_buffers; |