I am trying to figure out how to create a Vulkan 2D image shared with D3D11 texture.
My Windows 10 development system is equipped with Radeon RX 570 Series card which is a primary GPU device with monitors connected to it. I have 19.7.2 driver installed along with Vulkan RT and SDK 1.1.108.
For the record, there is a related topic here, which however does not help me enough.
I have a derivative of Vulkan SDK vcubecpp application which code as described below. This is a branch with code, and this is, separately, a diff which highlights my code edit.
It is worth mentioning that vkGetPhysicalDeviceImageFormatProperties2 gets me VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT | VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT external memory features with VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT compatible handle for VK_FORMAT_R8G8B8A8_UNORM image. And this is what I am trying to do: to "import" an existing D3D11 texture for allocation of Vulkan image, if I understand the concept of import right.
Things are not going well at already vkGetImageMemoryRequirements2 step here.
If validation layer is not enabled, I get a memory access violation inside the call.
If however, the layer is enabled, the call passes through, but output VkMemoryRequirements remain uninitialized.
If I attempt to "fix" this by regular vkGetImageMemoryRequirements and use the data for allocation, I seem to be able to complete allocation and binding and the rest of the calls succeed (with still no confirmation whether the copied data got into the texture).
In a more complicated application where I do seemingly the same thing, but the source of the data is coming from image receiving render results, I have a consistent BSOD inside vkQueueSubmit call. Even though the properties of the images look the same, submission of work causes a kernel bugcheck (also attached bugcheck.txt😞
VIDEO_SCHEDULER_INTERNAL_ERROR (119)
The video scheduler has detected that fatal violation has occurred. This resulted
in a condition that video scheduler can no longer progress. Any other values after
parameter 1 must be individually examined according to the subtype.
Arguments:
Arg1: 0000000000000001, The driver has reported an invalid fence ID.
Arg2: 00000000ffb93b0a
Arg3: 00000000000002ea
Arg4: ffffad0f724e7000...
nt!KeBugCheckEx
watchdog!WdLogEvent5_WdCriticalError+0xe0
dxgmms2!VidSchiVerifyDriverReportedFenceId+0xe803
dxgmms2!VidSchDdiNotifyInterruptWorker+0x291
dxgmms2!VidSchDdiNotifyInterrupt+0xd1
dxgkrnl!DxgNotifyInterruptCB+0x94
atikmpag+0x52960
atikmdag+0x4e0ba8
atikmdag+0x9607d
0x1
0xffffad0f`6a7ac000
In all cases, I don't see any reasonable hints from validation layer and debug output to help with vkGetImageMemoryRequirements2 and BSOD. That is, it brings me into situation where I am not sure what I should do to troubleshoot this further.
I would appreciate help in setting the interop up correctly or possibly an example of image/texture sharing.
roman380, Thanks for your report ! Is there a minimal code that can reproduce your problem?
Thak you for the followup, dorisyan.
Hi roman380, Thanks for that, I will try to reproduce it.
dorisyan, I extracted relevant code into single .cpp file.
It has all the properties mentioned above:
I thought that cube project behavior could be different because maybe the same code there is executed in the scope of begun command buffer. I assume it could make a difference.
dorisyan, I wonder if you have anything to update?
This looked like a tech in active development, so I expected the question to draw some attention.
Hi roman380, Thanks for the provided info, I will give you feed back soon! (I'm so sorry that I didn't investigate this issue last week)
Hi roman380, I can reproduce your problem on AMD card, but I run your app on NV, there are also some bugs like 'access violation', maybe there is something wrong in your app, could you please have a check again?
Thanks for looking, I thought my question is dead...
AFAIR I took a working app from Vulkan SDK just to have baseline initialization done. then on top of that I attached an attempt to use BindImageMemory2 and initialize D3D11 interop. Yes it does not work and in a strange way. I am guessing there is nothing wrong with the app itself, just my edit is not functional, and my edit is basically a single block of code ~200 lines in cube.cpp lines 2126-2303 as highlighted here by github in the bottom file: Comparing master...d3d11-image-interop · roman380/VulkanSdkDemos · GitHub
I will re-check later but I assume the question remains where it was, how to use D3D11 texture interop.