2

I've started learning how to use OpenGL ES, and am trying to do some general purpose computing using the Pi's GPU. I've got it mostly working, but I'm hung up on the last step: getting a framebuffer object (FBO) back to the CPU memory so I can manipulate it.

I see that one method is to use the glReadPixels() function. Would this be a bottleneck if I'm transferring large framebuffers back to the CPU in real-time? Is there a proper way of doing it? I found a few instances of people mentioning using the KHR_image EGL extension, but haven't found any solid examples.

Thanks!

  • AFAIK that depends on the pixel format, specifically, whenever you want to read GL_DEPTH_COMPONENT along with the regular GL_RGBA. But I'm not an expert on this. – Dmitry Grigoryev Aug 28 at 8:13
3

glReadPixels() is the correct function to use, and it's exactly what you asked for: Move data from the GPU's framebuffer to the CPU.

On Raspbian, I believe they disabled the NEON code in the GL driver due to their compiler not liking compiling NEON code (for pi0/1 compatibility), even though Mesa has conditional dispatch to the NEON code based on availability on your CPU. That means that you'll probably get lower readback performance on Raspbian than you would on a Debian or Fedora-derived system.

Regardless, expect readback to be your performance bottleneck. Reads from GPU memory are uncached, and so you just can't move the data very fast, even with NEON helping you get more data moved per bus transaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.