Vulkan: Enable VK_EXT_memory_priority for Pageable Memory to work properly

This commit is contained in:
KeatonTheBot
2026-04-01 09:10:46 -05:00
parent b7ffcb3be8
commit 0d8bd2653b
2 changed files with 48 additions and 9 deletions
@@ -108,12 +108,19 @@ namespace Ryujinx.Graphics.Vulkan
PHostPointer = (void*)pageAlignedPointer,
};
MemoryPriorityAllocateInfoEXT priorityInfo = new()
{
SType = StructureType.MemoryPriorityAllocateInfoExt,
Priority = 0.0f,
PNext = &importInfo,
};
var memoryAllocateInfo = new MemoryAllocateInfo
{
SType = StructureType.MemoryAllocateInfo,
AllocationSize = pageAlignedSize,
MemoryTypeIndex = (uint)memoryTypeIndex,
PNext = &importInfo,
PNext = &priorityInfo,
};
Result result = _api.AllocateMemory(_device, in memoryAllocateInfo, null, out var deviceMemory);
@@ -46,7 +46,8 @@ namespace Ryujinx.Graphics.Vulkan
"VK_KHR_8bit_storage",
"VK_KHR_maintenance2",
"VK_EXT_attachment_feedback_loop_layout",
"VK_EXT_attachment_feedback_loop_dynamic_state"
"VK_EXT_attachment_feedback_loop_dynamic_state",
"VK_EXT_memory_priority"
];
private static readonly string[] _requiredExtensions =
@@ -466,7 +467,21 @@ namespace Ryujinx.Graphics.Vulkan
PNext = features2.PNext,
};
features2.PNext = &supportedPageableDeviceLocalMemoryFeatures;
if (physicalDevice.IsDeviceExtensionPresent(ExtPageableDeviceLocalMemory.ExtensionName))
{
features2.PNext = &supportedPageableDeviceLocalMemoryFeatures;
}
PhysicalDeviceMemoryPriorityFeaturesEXT supportedDeviceMemoryPriorityFeatures = new()
{
SType = StructureType.PhysicalDeviceMemoryPriorityFeaturesExt,
PNext = features2.PNext,
};
if (physicalDevice.IsDeviceExtensionPresent("VK_EXT_memory_priority"))
{
features2.PNext = &supportedDeviceMemoryPriorityFeatures;
}
PhysicalDeviceVulkan12Features supportedPhysicalDeviceVulkan12Features = new()
{
@@ -640,14 +655,31 @@ namespace Ryujinx.Graphics.Vulkan
pExtendedFeatures = &featuresDynamicAttachmentFeedbackLoop;
}
PhysicalDevicePageableDeviceLocalMemoryFeaturesEXT featuresPageableDeviceLocalMemory = new()
if (physicalDevice.IsDeviceExtensionPresent(ExtPageableDeviceLocalMemory.ExtensionName) &&
supportedPageableDeviceLocalMemoryFeatures.PageableDeviceLocalMemory)
{
SType = StructureType.PhysicalDevicePageableDeviceLocalMemoryFeaturesExt,
PNext = pExtendedFeatures,
PageableDeviceLocalMemory = supportedPageableDeviceLocalMemoryFeatures.PageableDeviceLocalMemory,
};
PhysicalDevicePageableDeviceLocalMemoryFeaturesEXT featuresPageableDeviceLocalMemory = new()
{
SType = StructureType.PhysicalDevicePageableDeviceLocalMemoryFeaturesExt,
PNext = pExtendedFeatures,
PageableDeviceLocalMemory = true,
};
pExtendedFeatures = &featuresPageableDeviceLocalMemory;
pExtendedFeatures = &featuresPageableDeviceLocalMemory;
}
if (physicalDevice.IsDeviceExtensionPresent("VK_EXT_memory_priority") &&
supportedDeviceMemoryPriorityFeatures.MemoryPriority)
{
PhysicalDeviceMemoryPriorityFeaturesEXT featuresDeviceMemoryPriority = new()
{
SType = StructureType.PhysicalDeviceMemoryPriorityFeaturesExt,
PNext = pExtendedFeatures,
MemoryPriority = true,
};
pExtendedFeatures = &featuresDeviceMemoryPriority;
}
var enabledExtensions = _requiredExtensions.Union(_desirableExtensions.Intersect(physicalDevice.DeviceExtensions)).ToArray();