Read image from GPU on background thread #1254
-
Is it possible to download the rendered image from a secondary camera in a separate thread? To give more details, I am creating a several cameras which render a single frame of the scene, then are removed from the scene graph. The rendered images are then read from the color attachment to be used elsewhere. I would like to read those images without stalling the main thread. Simply adding a final draw callback which reads the data from the color attachment causes hiccups. This may be an OpenGL question in part, but if it's possible to do I'm not sure how it would work into the OSG API either. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
OpenGL has a single threaded model where each graphics context can only deal with a single thread using it's FIFO at any one time. The FIFO is processed by the driver in-order and calls like glReadPixels requires that all commands+data in FIFO before it are fully processed before it can run, then finally there is the transfer from the GPU to main memory which is why you are seeing a hiccup and unfortunately why you can fix it. If you can try to keep the images on GPU memory and process the images there. Or adopt Vulkan/VulkanSceneGraph as it has a multi-threaded model. |
Beta Was this translation helpful? Give feedback.
OpenGL has a single threaded model where each graphics context can only deal with a single thread using it's FIFO at any one time. The FIFO is processed by the driver in-order and calls like glReadPixels requires that all commands+data in FIFO before it are fully processed before it can run, then finally there is the transfer from the GPU to main memory which is why you are seeing a hiccup and unfortunately why you can fix it.
If you can try to keep the images on GPU memory and process the images there.
Or adopt Vulkan/VulkanSceneGraph as it has a multi-threaded model.