Commit 84d22197 by Mohan Maiya Committed by Commit Bot

Vulkan: Add device local fallback in findCompatibleMemoryIndex(...)

When finding a compatible memory index for an external buffer, we need to have a fallback path that requires just the VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT property. Bug: angleproject:5909 Change-Id: Id3faffb3e357be2e5e6f5fce9e64f0f2889d199a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2862561Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
parent 417d912a
......@@ -3492,8 +3492,6 @@ angle::Result BufferHelper::initExternal(ContextVk *contextVk,
ANGLE_TRY(mMemory.initExternal(clientBuffer));
// Set local variables
mMemoryPropertyFlags = memoryProperties;
mCurrentQueueFamilyIndex = renderer->getQueueFamilyIndex();
return angle::Result::Continue;
......
......@@ -89,9 +89,9 @@ angle::Result FindAndAllocateCompatibleMemory(vk::Context *context,
VkDevice device = context->getDevice();
uint32_t memoryTypeIndex = 0;
ANGLE_TRY(memoryProperties.findCompatibleMemoryIndex(context, memoryRequirements,
requestedMemoryPropertyFlags,
memoryPropertyFlagsOut, &memoryTypeIndex));
ANGLE_TRY(memoryProperties.findCompatibleMemoryIndex(
context, memoryRequirements, requestedMemoryPropertyFlags, (extraAllocationInfo != nullptr),
memoryPropertyFlagsOut, &memoryTypeIndex));
VkMemoryAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
......@@ -373,6 +373,7 @@ angle::Result MemoryProperties::findCompatibleMemoryIndex(
Context *context,
const VkMemoryRequirements &memoryRequirements,
VkMemoryPropertyFlags requestedMemoryPropertyFlags,
bool isExternalMemory,
VkMemoryPropertyFlags *memoryPropertyFlagsOut,
uint32_t *typeIndexOut) const
{
......@@ -406,6 +407,21 @@ angle::Result MemoryProperties::findCompatibleMemoryIndex(
}
}
// We did not find a compatible memory type. When importing external memory, there may be
// additional restrictions on memoryType. Fallback to requesting device local memory.
if (isExternalMemory)
{
// The Vulkan spec says the following -
// There must be at least one memory type with the VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
// bit set in its propertyFlags
if (FindCompatibleMemory(mMemoryProperties, memoryRequirements,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, memoryPropertyFlagsOut,
typeIndexOut))
{
return angle::Result::Continue;
}
}
// TODO(jmadill): Add error message to error.
context->handleError(VK_ERROR_INCOMPATIBLE_DRIVER, __FILE__, ANGLE_FUNCTION, __LINE__);
return angle::Result::Stop;
......
......@@ -341,6 +341,7 @@ class MemoryProperties final : angle::NonCopyable
angle::Result findCompatibleMemoryIndex(Context *context,
const VkMemoryRequirements &memoryRequirements,
VkMemoryPropertyFlags requestedMemoryPropertyFlags,
bool isExternalMemory,
VkMemoryPropertyFlags *memoryPropertyFlagsOut,
uint32_t *indexOut) const;
void destroy();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment