KhronosGroup / KhronosGroup/Vulkan-ValidationLayers
Make sure Cross Device layout transition are handled
- Dominant language
- C++
- Stars
- 1k
- Forks
- 504
- Avg merge
- 11h 35m
- Merged PRs (30d)
- 224
Description
The following was observed in `./angle_end2end_tests --gtest_filter=VulkanExternalImageTest.ShouldClearOpaqueFdWithSemaphores/ES2_Vulkan_SwiftShader` (change causing issue [still in flight](https://chromium-review.googlesource.com/c/angle/angle/+/4116450))
The following only showed issues when using Vulkan 1.3, not Vulkan 1.2, assuming this has something to do with `VK_KHR_synchronization2` adding the clause
> Image memory barriers that do not perform an image layout transition can be specified by setting oldLayout equal to newLayout.
-----
The following is a breaking down of the test API calls causing the issue
- `VkImage` **image_A** (created with `VkDevice` **A**)
- `VkImage` **image_B** (created with `VkDevice` **B**)
everything using `VK_EXTERNAL_*_HANDLE_TYPE_OPAQUE_FD_BIT` as the `handleType`
```c++
vkCreateImage(image_A); // VkExternalMemoryImageCreateInfo
vkAllocateMemory(image_A); // dedicated and VkExportMemoryAllocateInfo
vkBindImageMemory(image_A);
vkGetMemoryFdKHR(image_A, &memory_fd);
vkCreateImage(image_B); // VkExternalMemoryImageCreateInfo
vkAllocateMemory(image_B, import == memory_fd); // dedicated and VkImportMemoryFdInfoKHR
vkBindImageMemory(image_B);
vkCreateSemaphore(semaphore_A); // VkExportSemaphoreCreateInfo
vkGetSemaphoreFdKHR(semaphore_A, &semaphore_fd);
vkCreateSemaphore(semaphore_B);
vkImportSemaphoreFdKHR(semaphore_B, semaphore_fd);
// Command Buffer from Device A == cb_A
vkCmdPipelineBarrier(cb_A, image_A, /*from*/ VK_IMAGE_LAYOUT_UNDEFINED, /*to*/ VK_IMAGE_LAYOUT_GENERAL);
vkQueueSubmit(cb_A, pSignalSemaphores = semaphore_fd);
// Command Buffer from Device B == cb_b
vkCmdPipelineBarrier(cb_B, image_B, /*from*/ VK_IMAGE_LAYOUT_GENERAL, /*to*/ VK_IMAGE_LAYOUT_GENERAL);
vkCmdPipelineBarrier(cb_B, image_B, /*from*/ VK_IMAGE_LAYOUT_GENERAL, /*to*/ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
// Throwing error that it can't go from `UNDEFINED`, but should be in `GENERAL` from Device A
vkQueueSubmit(cb_B, pWaitSemaphores = semaphore_B);
```
Contributor guide
Research direction
Reproduce the issue with ./angle_end2end_tests --gtest_filter=VulkanExternalImageTest.ShouldClearOpaqueFdWithSemaphores/ES2_Vulkan_SwiftShader, comparing Vulkan 1.2 and 1.3 behavior. Trace validation of the cross-device image layout transitions and synchronization2 barriers described in the report; done means the imported image is recognized as GENERAL after Device A signals, without the erroneous UNDEFINED validation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100