What's the best way to share a texture/image between two context with out context sharing?

前端 未结 3 1904
鱼传尺愫
鱼传尺愫 2021-01-25 06:15

What I want to do is to get the render result from one context, and do some further rendering in another context which do not shared with the previous one.

The only meth

相关标签:
3条回答
  • 2021-01-25 06:29

    I'm not aware of a way to share them correctly. The closest I could find for GLX is the GLX_NV_copy_image extension. In the introduction, it says:

    The WGL and GLX versions allow copying between images in different contexts, even if those contexts are in different sharelists or even on different physical devices.

    With this extension, you would use the glXCopyImageSubDataNV() function to copy from one context to the other. While this does not allow sharing, it might still be much faster than copying the data yourself.

    As you can already tell from the name, this is a vendor specific extension. I don't know how widely supported it is, but you certainly shouldn't count on it being present on all systems.

    Other window system bindings have mechanisms for sharing images even between processes. E.g. with EGL, which is used with OpenGL ES, EGLImage can be used for this purpose. But from browsing through the GLX spec and list of extensions, I couldn't spot anything similar there.

    0 讨论(0)
  • 2021-01-25 06:33

    If hacks are in order you could use CUDA or OpenCL for this. Works only on GPUs that support either CUDA or OpenCL though.

    0 讨论(0)
  • 2021-01-25 06:44

    There are also AMD extensions which might be of some relevance to this qeustion: WGL_AMD_gpu_association and GLX_AMD_gpu_association:

    While this extension's focus is assigning GL context to specific GPUs and efficiently copying data between GPUs, it might also be useful for two contexts on the same GPU:

    To provide an accelerated path for blitting data from one context to another, the new blit function blitContextFramebufferAMD has been added.

    These extensions and also some synchronization techniques for using them are covered in somewhat more detail in this AMD whitepaper.

    0 讨论(0)
提交回复
热议问题