diff options
author | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2023-09-19 22:39:22 +0200 |
---|---|---|
committer | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2023-10-06 08:52:06 +0200 |
commit | f585dec48db1e5af069551d2d132093882c27a93 (patch) | |
tree | aec9e8d07a9e9e8b1b46b4a0327a8f3f5cdd6a61 /src/video_core/vulkan_common/vulkan_memory_allocator.h | |
parent | Merge pull request #11542 from t895/touch-offset-fix (diff) | |
download | yuzu-f585dec48db1e5af069551d2d132093882c27a93.tar yuzu-f585dec48db1e5af069551d2d132093882c27a93.tar.gz yuzu-f585dec48db1e5af069551d2d132093882c27a93.tar.bz2 yuzu-f585dec48db1e5af069551d2d132093882c27a93.tar.lz yuzu-f585dec48db1e5af069551d2d132093882c27a93.tar.xz yuzu-f585dec48db1e5af069551d2d132093882c27a93.tar.zst yuzu-f585dec48db1e5af069551d2d132093882c27a93.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/vulkan_common/vulkan_memory_allocator.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/video_core/vulkan_common/vulkan_memory_allocator.h b/src/video_core/vulkan_common/vulkan_memory_allocator.h index f449bc8d0..38a182bcb 100644 --- a/src/video_core/vulkan_common/vulkan_memory_allocator.h +++ b/src/video_core/vulkan_common/vulkan_memory_allocator.h @@ -7,6 +7,7 @@ #include <span> #include <vector> #include "common/common_types.h" +#include "video_core/vulkan_common/vulkan_device.h" #include "video_core/vulkan_common/vulkan_wrapper.h" VK_DEFINE_HANDLE(VmaAllocator) @@ -26,6 +27,18 @@ enum class MemoryUsage { Stream, ///< Requests device local host visible buffer, falling back host memory. }; +template <typename F> +void ForEachDeviceLocalHostVisibleHeap(const Device& device, F&& f) { + auto memory_props = device.GetPhysical().GetMemoryProperties().memoryProperties; + for (size_t i = 0; i < memory_props.memoryTypeCount; i++) { + auto& memory_type = memory_props.memoryTypes[i]; + if ((memory_type.propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) && + (memory_type.propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) { + f(memory_type.heapIndex, memory_props.memoryHeaps[memory_type.heapIndex]); + } + } +} + /// Ownership handle of a memory commitment. /// Points to a subregion of a memory allocation. class MemoryCommit { @@ -124,6 +137,7 @@ private: std::vector<std::unique_ptr<MemoryAllocation>> allocations; ///< Current allocations. VkDeviceSize buffer_image_granularity; // The granularity for adjacent offsets between buffers // and optimal images + u32 valid_memory_types{~0u}; }; } // namespace Vulkan |