Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to share textures between processes without texture's data copy?

I tought that it might work using the Vulkan's external memory extension by allocating the memory in process A, create a HANDLE to that memory and pass that HANDLE via shared memory to process B.

But this seems is not possible as HANDLE is actually just a void* and for different processes exist different memory mapping, so the pointer/HANDLE is actually not transferable between processes.

Is there some way how to get the handle somehow and recreate the GL texture/ VK image in different process without copying all images's pixel data (like when PBO is used)?

like image 479
CJ_Notned Avatar asked Oct 20 '25 03:10

CJ_Notned


1 Answers

To transfer a HANDLE to a different process use the function DuplicateHandle, which will create a duplicate handle referencing the same object, but in the other process. Then you'll have to pass the value of that new HANDLE (which isn't usable in the original process) to the other process by some means of IPC. You could use shared memory, or send a message, or… well whatever that allows you to send the other process an integer of sizeof(void*), i.e. in terms of C a uintptr_t. You then just cast the HANDLE to a uintptr_t send that numeric value to the other process, where you cast it back to a HANDLE.

You have to do this manually, since there's no mechanism in place, that tells a process that suddenly and out of the blue an entirely new HANDLE was magicked into their task context.

like image 158
datenwolf Avatar answered Oct 24 '25 21:10

datenwolf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!