-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add VK_EXT_external_memory_metal #2414
base: main
Are you sure you want to change the base?
Add VK_EXT_external_memory_metal #2414
Conversation
a1ac4fa
to
9d16d7e
Compare
@aitor-lunarg process-wise, we require that extension number and flag bits be reserved by a commit to main prior to the extension development branch actually being able to use them. I don't know where this extension stands deployment / release-wise, but we need to separate out the reservations and accept those first, to avoid a race condition (see extension 597 for a guide to what that PR would look like). |
Before moving forward with this extension, there's one concern that we need to address. Metal does not provide all Vulkan formats, so there are times where an implementation will emulate some of them. Why is this an issue: Implementations may decide to emulate those formats with an internal representation such that those formats are backed by multiple textures. Taking MoltenVK as an example implementation with There are 3 potential solutions that come to mind to fix this issue as we stand:
@linyaa-kiwi would it be possible to bring this up for discussion this coming SI meeting? I would like to understand if other similar extensions have run into similar issues and how they've tackled them if so. Or just get general feedback/ideas about this issue. cc/ @kocdemir |
@aitor-lunarg Would you like to discuss in today's SI meeting? If not, what week works best for you? |
c3095fa
to
44958d2
Compare
|
bf0a84a
to
5eabdbb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found some more points for improvement today.
=== Description | ||
|
||
An application may wish to reference device memory in multiple Vulkan device instances, in multiple processes, and/or in Metal API. | ||
This extension enables an application to export non-Vulkan handles from Vulkan memory objects such that the underlying resources can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/non-Vulkan handles/Metal handles/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text says "export", but the extension supports import too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if the new wording works!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So close! "Import" is misspelled as "impor". Other than the typo, the text looks good.
implementations will be required to report `VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT` for | ||
`VK_EXTERNAL_MEMORY_HANDLE_TYPE_MTLTEXTURE_BIT_EXT`. When importing a MTLTexture through the creation of a | ||
link:{refpage}VkDeviceMemory.html[VkDeviceMemory], the link:{refpage}VkImage.html[VkImage] it will be bound to | ||
must have the same creation parameters as the MTLTexture used at import. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"must have same creation parameters as the MTLTexture used at import"
This needs a VU. A good example is VUID-VkMemoryAllocateInfo-pNext-02388, which is about AHardwareBuffer. There are more VUs in that neighborhood that are worth considering too. The new VU (new VUs) should enumerate which fields of VkImageCreateInfo must match the MTLTexture's creation params.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a new VU to handle this case. I am thinking that maybe we could add a few more to force the users to provide the right size at allocation when importing buffers or heaps, but it kind of seems slightly pointless. Right now, we just say we don't really care about the size for buffers and heaps since we will use Metal to know the size of said resources. Any way, let me know your thoughts!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion on whether the spec should (a) require size
to be correct or (b) ignore size
. That's a decision is yours. In my opinion, the only practical difference is that choice (b) inhibits some VVL checks.
Regardless of the choice of (a) or (b) though for MTLBuffer and MTLHeap, more spec text is needed. If (a), then a VU is needed (similar to VUID-VkMemoryAllocateInfo-allocationSize-00647 or VUID-VkMemoryAllocateInfo-allocationSize-02383). If (b), then text similar to the MTLTexture "ignore" text is needed.
However, if you do choose (b), I prefer that the value not be actually ignored. In the past two years, several members of the Vulkan WG have become frustrated with the unintended consequences caused by ignored values in the spec. Superficially, it seems that an ignored allocationSize
would cause no problems. But sometimes it can cause surprising difficulties for tools and layers. Instead of saying that allocationSize
is ignored, I think it's better to add a VU that requires it to be 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went (b), added a VUID to enforce allocationSize
to be 0
when importing MTLTextures so there's no issue in the future. Let me know what you think!
* pname:handleType must: have been included in | ||
slink:VkExportMemoryAllocateInfo::pname:handleTypes when pname:memory | ||
was created | ||
* pname:handleType it must: be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/pname:handleType it must: be/pname:handleType must: be/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
**** | ||
* pname:handle must: point to a valid id<MTLBuffer>, id<MTLTexture> or | ||
id<MTLDevice> | ||
* pname:handleType it must: be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/pname:handleType it must: be/pname:handleType must: be/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
chapters/memory.adoc
Outdated
ifdef::VK_EXT_external_memory_metal[] | ||
* If the parameters define an import operation and the external handle is | ||
a ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_MTLTEXTURE_BIT_EXT, then | ||
pname:pNext must: include a slink:VkMemoryDedicatedAllocateInfo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This VU needs a little more text.
[...] must: include a slink:VkMemoryDedicatedAllocateInfo structure with pname:image not equal to dlink:VK_NULL_HANDLE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some more context. Let me know if that is clear enough or if a different wording is needed!
implementations will be required to report `VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT` for | ||
`VK_EXTERNAL_MEMORY_HANDLE_TYPE_MTLTEXTURE_BIT_EXT`. When importing a MTLTexture through the creation of a | ||
link:{refpage}VkDeviceMemory.html[VkDeviceMemory], the link:{refpage}VkImage.html[VkImage] it will be bound to | ||
must have the same creation parameters as the MTLTexture used at import. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion on whether the spec should (a) require size
to be correct or (b) ignore size
. That's a decision is yours. In my opinion, the only practical difference is that choice (b) inhibits some VVL checks.
Regardless of the choice of (a) or (b) though for MTLBuffer and MTLHeap, more spec text is needed. If (a), then a VU is needed (similar to VUID-VkMemoryAllocateInfo-allocationSize-00647 or VUID-VkMemoryAllocateInfo-allocationSize-02383). If (b), then text similar to the MTLTexture "ignore" text is needed.
However, if you do choose (b), I prefer that the value not be actually ignored. In the past two years, several members of the Vulkan WG have become frustrated with the unintended consequences caused by ignored values in the spec. Superficially, it seems that an ignored allocationSize
would cause no problems. But sometimes it can cause surprising difficulties for tools and layers. Instead of saying that allocationSize
is ignored, I think it's better to add a VU that requires it to be 0.
Thanks. I'll give it another review today. |
No description provided.