diff options
author | Mary <mary@mary.zone> | 2023-04-05 19:48:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-05 14:48:38 -0300 |
commit | c95be55091eaee446e1ad51ad215b82be5866bb3 (patch) | |
tree | 874f6119c183e3fa94bc329285b6d17ddb04d6e7 /Ryujinx.Graphics.Vulkan/MemoryAllocator.cs | |
parent | 63dedbda862533342fd8fac148f0c1d6427c9d84 (diff) |
vulkan: Cleanup PhysicalDevice and Instance querying (#4632)1.1.698
* vulkan: Move most of the properties enumeration to VulkanPhysicalDevice
That clean up a bit of duplicate logic.
Also move to use an hashset for device extensions.
* vulkan: Move instance querying to VulkanInstance
Also cleanup code to use span when possible instead of unsafe pointers.
* Address gdkchan's comments
Diffstat (limited to 'Ryujinx.Graphics.Vulkan/MemoryAllocator.cs')
-rw-r--r-- | Ryujinx.Graphics.Vulkan/MemoryAllocator.cs | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/Ryujinx.Graphics.Vulkan/MemoryAllocator.cs b/Ryujinx.Graphics.Vulkan/MemoryAllocator.cs index 6a786a96..3139e209 100644 --- a/Ryujinx.Graphics.Vulkan/MemoryAllocator.cs +++ b/Ryujinx.Graphics.Vulkan/MemoryAllocator.cs @@ -9,21 +9,18 @@ namespace Ryujinx.Graphics.Vulkan private ulong MaxDeviceMemoryUsageEstimate = 16UL * 1024 * 1024 * 1024; private readonly Vk _api; - private readonly PhysicalDevice _physicalDevice; + private readonly VulkanPhysicalDevice _physicalDevice; private readonly Device _device; private readonly List<MemoryAllocatorBlockList> _blockLists; private readonly int _blockAlignment; - private readonly PhysicalDeviceMemoryProperties _physicalDeviceMemoryProperties; - public MemoryAllocator(Vk api, PhysicalDevice physicalDevice, Device device, uint maxMemoryAllocationCount) + public MemoryAllocator(Vk api, VulkanPhysicalDevice physicalDevice, Device device) { _api = api; _physicalDevice = physicalDevice; _device = device; _blockLists = new List<MemoryAllocatorBlockList>(); - _blockAlignment = (int)Math.Min(int.MaxValue, MaxDeviceMemoryUsageEstimate / (ulong)maxMemoryAllocationCount); - - _api.GetPhysicalDeviceMemoryProperties(_physicalDevice, out _physicalDeviceMemoryProperties); + _blockAlignment = (int)Math.Min(int.MaxValue, MaxDeviceMemoryUsageEstimate / (ulong)_physicalDevice.PhysicalDeviceProperties.Limits.MaxMemoryAllocationCount); } public MemoryAllocation AllocateDeviceMemory( @@ -64,9 +61,9 @@ namespace Ryujinx.Graphics.Vulkan uint memoryTypeBits, MemoryPropertyFlags flags) { - for (int i = 0; i < _physicalDeviceMemoryProperties.MemoryTypeCount; i++) + for (int i = 0; i < _physicalDevice.PhysicalDeviceMemoryProperties.MemoryTypeCount; i++) { - var type = _physicalDeviceMemoryProperties.MemoryTypes[i]; + var type = _physicalDevice.PhysicalDeviceMemoryProperties.MemoryTypes[i]; if ((memoryTypeBits & (1 << i)) != 0) { @@ -80,15 +77,11 @@ namespace Ryujinx.Graphics.Vulkan return -1; } - public static bool IsDeviceMemoryShared(Vk api, PhysicalDevice physicalDevice) + public static bool IsDeviceMemoryShared(VulkanPhysicalDevice physicalDevice) { - // The device is regarded as having shared memory if all heaps have the device local bit. - - api.GetPhysicalDeviceMemoryProperties(physicalDevice, out var properties); - - for (int i = 0; i < properties.MemoryHeapCount; i++) + for (int i = 0; i < physicalDevice.PhysicalDeviceMemoryProperties.MemoryHeapCount; i++) { - if (!properties.MemoryHeaps[i].Flags.HasFlag(MemoryHeapFlags.DeviceLocalBit)) + if (!physicalDevice.PhysicalDeviceMemoryProperties.MemoryHeaps[i].Flags.HasFlag(MemoryHeapFlags.DeviceLocalBit)) { return false; } |