Open Gergilcan opened 8 years ago
If you need this to implement on screen rendering in WPF I suggest a different approach:
I am successfully rendering to the window handle of a Windows forms control. To use this control inside a WPF application I am using a WindowsFormsHost. Performance of this approach is quite good.
I know that the performance is a little better (2-3 fps with my tests) but the problem with that are the AirSpace problems, the WindowsHostControl it is always on top and my application is a docked one with tabs and many WPF elements must be placed over it, so that is not a option.
That's why i have developed that approach in OpenGL and it's working fine, but I want to upgrade it to Vulkan.
Ok, I understand that this is a problem:-)
I do not have any experience with this approach, but here are some thoughts that could help you:
1) Render to a framebuffer the usual way 2) Copy the data from the image connected to that framebuffer to an image with VK_IMAGE_TILING_LINEAR 3) Copy from that image to a buffer (vkCmdCopyImageToBuffer) 4) Perhaps at this point some synchronization is necessary...(For testing device.WaitIdle could be enough) 5) Map the buffer 6) Copy from the resulting pointer to your bitmap(what about image formats? RGBA? BGRA?) 7) Unmap the buffer again
Perhaps this approach can be simplified by directly rendering to an image with VK_IMAGE_TILING_LINEAR
Please let us know if you are successful and how it worked in the end:-)
Hi, I'm trying to obtain the image data from vulkan as I do right now using the ReadPixels function, do anyone know how to do this, I need this in order to use it as I want in WPF in order to store the data in a WriteableBitmap.
Thanks a lot.