Output buffer from a Context as an Input buffer from another Context

I have two Context and the output buffer from the first Context must be an input buffer on the second Context.

How can I do that?

If that is in the same process and on the same device that would probably only work with CUDA interop. (Not tried myself.) In the easiest case you might be able to get the pointer of one buffer and set it for the other. Or you would need to allocate that with CUDA and set it in both. Not sure if that is working for output buffers, definitiely not in a multi-GPU environment (see links below).

Everything else would require a memcpy() operation which should always work, but goes through the PCI-E bus.

Some related posts which contain links to the relevant OptiX Programming Guide chapters which explain CUDA interop:
https://devtalk.nvidia.com/default/topic/1024818/?comment=5214480
https://devtalk.nvidia.com/default/topic/1026444/?comment=5220405

This would be a rather special case. I’m normally not using more than one OptiX context per process because I’ve experienced issues with that in the past. Maybe explain what you’re trying to achieve, to be able to tell if there are other solutions possible.