Question

I'm using OpenGL for some GPGPU processing. So I have different threads giving work to a OpenGL processing thread.

After each "work-item" I need to call glReadPixels and glMapBuffer in order to transfer back data to the host from the PBO. The problem with this however is that glMapBuffer blocks the thread and no useful work can be done until the DMA transfer finished, even though the GPU is idle. The usual way to solve this is to create a pipeline with a time depth of the longest DMA transfer. However, as I'm working on a low latency system this is suboptimal.

Is there a way to maybe wait for glMapBuffer on a separate thread or maybe get some notification as to when the DMA transfer has finished in order to reduce the latency as much as possible?

Was it helpful?

Solution

Do some additional work in other threads than the one glMapBuffer blocks in? You can have multiple OpenGL contexts, each active in its own thread; if they're configured to share objects they can operate simultanously.

However a DMA actually means work for the GPU, at least the bandwidth to it is fully consumed and so you might end up with even worse performance.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top