Commit 3ff24d6f by Michael Spang Committed by Commit Bot

Vulkan: Add dedicated allocation support to MemoryObjectVk

Add a VkMemoryDedicatedAllocateInfo to the vkAllocateMemory pNext chain if the client specifies the memory object was a dedicated allocation. We don't yet support suballocation of external memory objects, so all allocations are already effectively dedicated allocations regardless of whether vulkan requires it. The spec requires that memory passed to vkBindImageMemory be created with a VkMemoryDedicatedAllocateInfo if the driver requires dedicated allocations for that VkImage. If the driver does not require a dedicated allocation, there actually seems to be no explicit requirement to use this structure even if it was passed in at allocation time. Bug: angleproject:4627 Change-Id: I8a660e871bdf72815815f0c0b3000f3b0570bd2d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2192501Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Michael Spang <spang@chromium.org>
parent 823b1bff
......@@ -97,7 +97,7 @@ void MemoryObjectVk::onDestroy(const gl::Context *context)
angle::Result MemoryObjectVk::setDedicatedMemory(const gl::Context *context, bool dedicatedMemory)
{
UNIMPLEMENTED();
mDedicatedMemory = dedicatedMemory;
return angle::Result::Continue;
}
......@@ -204,7 +204,15 @@ angle::Result MemoryObjectVk::createImage(ContextVk *contextVk,
VkMemoryRequirements externalMemoryRequirements;
image->getImage().getMemoryRequirements(renderer->getDevice(), &externalMemoryRequirements);
void *importMemoryInfo = nullptr;
void *importMemoryInfo = nullptr;
VkMemoryDedicatedAllocateInfo memoryDedicatedAllocateInfo = {};
if (mDedicatedMemory)
{
memoryDedicatedAllocateInfo.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR;
memoryDedicatedAllocateInfo.image = image->getImage().getHandle();
importMemoryInfo = &memoryDedicatedAllocateInfo;
}
VkImportMemoryFdInfoKHR importMemoryFdInfo = {};
VkImportMemoryZirconHandleInfoFUCHSIA importMemoryZirconHandleInfo = {};
switch (mHandleType)
......@@ -212,6 +220,7 @@ angle::Result MemoryObjectVk::createImage(ContextVk *contextVk,
case gl::HandleType::OpaqueFd:
ASSERT(mFd != kInvalidFd);
importMemoryFdInfo.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR;
importMemoryFdInfo.pNext = importMemoryInfo;
importMemoryFdInfo.handleType = ToVulkanHandleType(mHandleType);
importMemoryFdInfo.fd = dup(mFd);
importMemoryInfo = &importMemoryFdInfo;
......@@ -220,6 +229,7 @@ angle::Result MemoryObjectVk::createImage(ContextVk *contextVk,
ASSERT(mZirconHandle != ZX_HANDLE_INVALID);
importMemoryZirconHandleInfo.sType =
VK_STRUCTURE_TYPE_TEMP_IMPORT_MEMORY_ZIRCON_HANDLE_INFO_FUCHSIA;
importMemoryZirconHandleInfo.pNext = importMemoryInfo;
importMemoryZirconHandleInfo.handleType = ToVulkanHandleType(mHandleType);
ANGLE_TRY(
DuplicateZirconVmo(contextVk, mZirconHandle, &importMemoryZirconHandleInfo.handle));
......
......@@ -48,6 +48,9 @@ class MemoryObjectVk : public MemoryObjectImpl
angle::Result importOpaqueFd(ContextVk *contextVk, GLuint64 size, GLint fd);
angle::Result importZirconVmo(ContextVk *contextVk, GLuint64 size, GLuint handle);
// Imported memory object was a dedicated allocation.
bool mDedicatedMemory = false;
GLuint64 mSize = 0;
gl::HandleType mHandleType = gl::HandleType::InvalidEnum;
int mFd = kInvalidFd;
......
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