Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL Vulkan Interoperability

I need some help with OpenGL-Vulkan Memory Exchange. I've already found this topic How to render to OpenGL from Vulkan? But it is not quite what I need. I dont want Vulkan to allocate and export memory. I want to import OpenGL memory to Vulkan, create Vulkan Image and bind it to the imported memory.

My question is, is it actually possible to get 'HANDLE' (in terms of WinOS) that can be used with vk::ImportMemoryWin32HandleInfoKHR.

like image 327
DND Avatar asked Oct 17 '22 06:10

DND


1 Answers

As far as I can tell, there is no OpenGL extension yet, which would allow to do this. It also kind of makes sense, since memory semantics of OpenGL allocated objects are very vague and the data may actually be all over the place. When you create a texture, buffer, etc. in OpenGL it's completely open, when, how and where the thing will get its memory allocated eventually.

This is very different in Vulkan, where memory management is explicit, and once created you have "perfect" knowledge about it. Which is, why it's possible to simply "import" that memory into an OpenGL object; as far as the OpenGL driver goes, it's just another way to get to the memory, only that this way around it doesn't have to concern itself with the dirty details.

In the end it doesn't make a practical difference if you allocate the memory with Vulkan or OpenGL. Just allocate with Vulkan, then import into OpenGL. You can still write to the memory from OpenGL, i.e. also use it as a renderbuffer or texture for framebuffer attachment.

like image 132
datenwolf Avatar answered Oct 27 '22 10:10

datenwolf