Hi, after the previous discussion, I did some experiments, trying to understand more about the synchronization of Vulkan. Now I have some following questions:
What I did is this: still 3 processes, S, A, and B
1. In S, I allocate a VkDeviceMemory and export the win32 handle to A and B.
2. Then in A, I create a VkImage, import the memory handle, and bind it to the image.
3. Then in A, I initialize the VkImage by a compute shader or a copy operation. The remote memory should be initialized after this.
4. In A, I use the image to render something in every frame.
For now, everything works fine, the process A is rendered correctly, at 30FPS.
Now, After a significant amount of time, like 1min, I start B and do the following:
5. In B, create a VkImage, import the memory handle, and bind it to the image.
6. In B, I use the image to render something in every frame.
In several AMD cards I tested, at this point, the A's rendering stays correct all the time, while the B's rendering is not right, here are the snapshots:
Note the blue background images, which are sharing external memory. Here are my questions:
1. In the steps above, I did not use a semaphore to sync between A and B, because I had waited for a long time so B will not be reading until A's writing is done,
so no semaphore is needed in this scenario, am I right?
2. It seems the process B is using the memory A writes, but with different interpretation. The image in A seems to be cut into blocks and be re-arranged in B,
why is that? I don't think this is a cache problem ( in which case the content should be blank or undefined, right?)
3. Is this because of no semaphore synchronization between A and B, or does it related to the image layout transition? or queue ownership transfer?
What can I do to make it right.
I know that many operations may be missing here, but I just want to understand the exact cause of the issue before making it right.
I found the vulkan spec about inter-instance synchronization is a bit vague and hard to follow.
Also, I tested it in several Nvidia cards, none have the issue. It only appears on AMD pc cards. so is there any chance that this is a driver issue? (although unlikely)
Thanks!