aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Vulkan/MemoryAllocator.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2023-01-26 18:34:35 -0300
committerGitHub <noreply@github.com>2023-01-26 18:34:35 -0300
commit296c4a3d012b1203b1b7e58cdc34c334159e1599 (patch)
tree837659e6401356fac77a93681e3c678724074acf /Ryujinx.Graphics.Vulkan/MemoryAllocator.cs
parente7cf4e6eaf528aa72e27f6ba86259c00813bc776 (diff)
Relax Vulkan requirements (#4282)1.1.596
* Relax Vulkan requirements * Fix MaxColorAttachmentIndex * Fix ColorBlendAttachmentStateCount value mismatch for background pipelines * Change query capability check to check for pipeline statistics query rather than geometry shader support
Diffstat (limited to 'Ryujinx.Graphics.Vulkan/MemoryAllocator.cs')
-rw-r--r--Ryujinx.Graphics.Vulkan/MemoryAllocator.cs33
1 files changed, 28 insertions, 5 deletions
diff --git a/Ryujinx.Graphics.Vulkan/MemoryAllocator.cs b/Ryujinx.Graphics.Vulkan/MemoryAllocator.cs
index eea4e60b..83c0a324 100644
--- a/Ryujinx.Graphics.Vulkan/MemoryAllocator.cs
+++ b/Ryujinx.Graphics.Vulkan/MemoryAllocator.cs
@@ -27,7 +27,16 @@ namespace Ryujinx.Graphics.Vulkan
MemoryRequirements requirements,
MemoryPropertyFlags flags = 0)
{
- int memoryTypeIndex = FindSuitableMemoryTypeIndex(_api, physicalDevice, requirements.MemoryTypeBits, flags);
+ return AllocateDeviceMemory(physicalDevice, requirements, flags, flags);
+ }
+
+ public MemoryAllocation AllocateDeviceMemory(
+ PhysicalDevice physicalDevice,
+ MemoryRequirements requirements,
+ MemoryPropertyFlags flags,
+ MemoryPropertyFlags alternativeFlags)
+ {
+ int memoryTypeIndex = FindSuitableMemoryTypeIndex(_api, physicalDevice, requirements.MemoryTypeBits, flags, alternativeFlags);
if (memoryTypeIndex < 0)
{
return default;
@@ -56,21 +65,35 @@ namespace Ryujinx.Graphics.Vulkan
return newBl.Allocate(size, alignment, map);
}
- private static int FindSuitableMemoryTypeIndex(Vk api, PhysicalDevice physicalDevice, uint memoryTypeBits, MemoryPropertyFlags flags)
+ private static int FindSuitableMemoryTypeIndex(
+ Vk api,
+ PhysicalDevice physicalDevice,
+ uint memoryTypeBits,
+ MemoryPropertyFlags flags,
+ MemoryPropertyFlags alternativeFlags)
{
+ int bestCandidateIndex = -1;
+
api.GetPhysicalDeviceMemoryProperties(physicalDevice, out var properties);
for (int i = 0; i < properties.MemoryTypeCount; i++)
{
var type = properties.MemoryTypes[i];
- if ((memoryTypeBits & (1 << i)) != 0 && type.PropertyFlags.HasFlag(flags))
+ if ((memoryTypeBits & (1 << i)) != 0)
{
- return i;
+ if (type.PropertyFlags.HasFlag(flags))
+ {
+ return i;
+ }
+ else if (type.PropertyFlags.HasFlag(alternativeFlags))
+ {
+ bestCandidateIndex = i;
+ }
}
}
- return -1;
+ return bestCandidateIndex;
}
public void Dispose()