-
Notifications
You must be signed in to change notification settings - Fork 410
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
VK_EXT_external_memory_metal validation #8498
base: main
Are you sure you want to change the base?
VK_EXT_external_memory_metal validation #8498
Conversation
CI Vulkan-ValidationLayers build queued with queue ID 249962. |
CI Vulkan-ValidationLayers build # 17383 running. |
CI Vulkan-ValidationLayers build # 17383 failed. |
"VK_EXTERNAL_MEMORY_HANDLE_TYPE_MTLTEXTURE_BIT_EXT requires textures to be imported as a dedicated" | ||
"allocation."); | ||
} | ||
return skip; |
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 if there is any VkExportMemoryAllocateInfo
we just early return?
I would change the logic to
if (const auto export_memory_info = vku::FindStructInPNextChain<VkExportMemoryAllocateInfo>(allocate_info.pNext)) {
// ... code
return skip; // explain
}
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.
There's 2 potential cases when allocating a VkDeviceMemory object:
- Allocate with the intent to export it.
- Allocate via import.
The VUIDs checked below this point apply to point 2. While this small segment applies to point 1. This is the main reason for the early return. Although now that I think about it more, there's nothing preventing the user from a 3rd option which would be: Allocate via import with the intent to export it. Kind of redundant, but I'm not sure if there's anything in Vulkan that forbids this (I don't think so, there may be even CTS tests testing this, need to double check).
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.
ok, I guess my only ask is to put some of this github comment information into a code comment, the external memory is already a black-box enough, any extra info is helpful
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
const ErrorObject& error_obj) const { | ||
bool skip = false; | ||
const Location get_metal_handle_info = error_obj.location.dot(Field::pGetMetalHandleInfo); | ||
auto memory = Get<vvl::DeviceMemory>(pGetMetalHandleInfo->memory); |
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.
auto memory = Get<vvl::DeviceMemory>(pGetMetalHandleInfo->memory); | |
auto memory = Get<vvl::DeviceMemory>(pGetMetalHandleInfo->memory); | |
ASSERT_AND_RETURN_SKIP(memory) |
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
if ((pGetMetalHandleInfo->handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_MTLBUFFER_BIT_EXT) && | ||
(pGetMetalHandleInfo->handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_MTLTEXTURE_BIT_EXT)) { | ||
skip |= LogError("VUID-VK_EXT_external_memory-get-handle-incorrect-handle-type", device, | ||
get_metal_handle_info.dot(Struct::VkImportMemoryMetalHandleInfoEXT, Field::handleType), |
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.
get_metal_handle_info.dot(Struct::VkImportMemoryMetalHandleInfoEXT, Field::handleType), | |
get_metal_handle_info.dot(Field::handleType), |
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
* | ||
* http://www.apache.org/licenses/LICENSE-2.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 think this file needs to wrapped in a #ifdef VK_USE_PLATFORM_METAL_EXT
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
52e8328
to
62812ec
Compare
CI Vulkan-ValidationLayers build queued with queue ID 252306. |
CI Vulkan-ValidationLayers build # 17412 running. |
// Case 1 and partially 3 | ||
if (const auto export_memory_info = vku::FindStructInPNextChain<VkExportMemoryAllocateInfo>(allocate_info.pNext)) { | ||
if ((export_memory_info->handleTypes == VK_EXTERNAL_MEMORY_HANDLE_TYPE_MTLTEXTURE_BIT_EXT) && dedicated_allocation_info == nullptr) { | ||
skip |= LogError("VUID-UNASSIGNED-VK_EXT_external_memory-no-VkMemoryDedicatedAllocateInfo-export", device, |
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.
@spencer-lunarg thoughts on where this VUID should go? Part of VkExportMemoryAllocateInfo
or VkMemoryDedicatedAllocateInfo
? I'm inclined towards the former since it also requires VkExportMemoryAllocateInfo::handleTypes
to be VK_EXTERNAL_MEMORY_HANDLE_TYPE_MTLTEXTURE_BIT_EXT
, but I'm not sure how cases where a struct is required by another struct are handled in the spec.
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 would say VkExportMemoryAllocateInfo
Also not there are things such as VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT
, there are some extra VUs for some handleTypes
that do requires VkMemoryDedicatedAllocateInfo
, but its not for all to my knowledge
// operations on buffers. | ||
if(import_memory_metal_info->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_MTLTEXTURE_BIT_EXT) { | ||
if (dedicated_allocation_info == nullptr) { | ||
skip |= LogError("VUID-UNASSIGNED-VK_EXT_external_memory-no-VkMemoryDedicatedAllocateInfo-import", device, |
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.
@spencer-lunarg similar situation as the previous one
|
||
// Unsure if there should be a VUID that enforces image to not be NULL when importing a MTLTEXTURE type | ||
if (dedicated_allocation_info->image == VK_NULL_HANDLE) { | ||
skip |= LogError("VUID-UNASSIGNED-VK_EXT_external_memory-dedicated-null-image-import", device, |
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.
Same as above 2
DispatchGetPhysicalDeviceFormatProperties2(physical_device, image_format, &format_properties); | ||
|
||
if ((external_image_format_properties.externalMemoryProperties.externalMemoryFeatures & VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) == 0u) { | ||
skip |= LogError("VUID-UNASSIGNED-VK_EXT_external_memory-unsupported-format-import", device, |
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.
Same here
m_errorMonitor->VerifyFound(); | ||
} | ||
|
||
TEST_F(NegativeExternalMemoryMetal, GetResourceHandleWithoutExportStructAtCreation) { |
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.
New tests I forgot to add in the initial PR start here
CI Vulkan-ValidationLayers build # 17412 failed. |
CI Vulkan-ValidationLayers build queued with queue ID 263839. |
CI Vulkan-ValidationLayers build # 17585 running. |
CI Vulkan-ValidationLayers build # 17585 failed. |
There are some UNASSIGNED VUIDs that I thought would be useful for the user but I'm not sure under which struct they should be. Any suggestions are more than welcome!
I believe there could be a best effort check on certain VUIDs that are not implemented like
The memory from which handle was exported must have been created on the same underlying physical device as device
but would require adding support for having Objective-C files in the repository, unsure if there's something like this at the moment (happy to learn if there's any so I can do some testing).I believe there's a few missing tests for some VUIDs. I'll double check everything tomorrow. Just want to start getting some eyes into this so we can move it forward for extension release. Not looking for approval for merge since that can't happen until the extension is released.