AnatH
AnatH

Reputation: 76

Using glReadPixels with PBO does not improve performance (GLES3)

I'm trying to implement the PBO logic with glReadPixels (on an Android app), in order to read the data asynchronously.

The motivation for this is that the app renders a video on screen, and I want to take screenshots of that video, without delaying the on-screen renders.

I thought glReadPixels with PBO should return immediately, but it takes up to 250ms to return (much like regular glReadPixels without the pbo).

Any idea why? (This happens even without actually reading the data using glMapBufferRange, which is actually pretty fast)

This is my code:

GLuint pbo_size = mScreenWidth*mScreenHeight*4;
GLGenBuffers(1, &mPboId);
GLBindBuffer(GL_PIXEL_PACK_BUFFER, mPboId);
GLBufferData(GL_PIXEL_PACK_BUFFER, pbo_size, 0, GL_DYNAMIC_READ);
GLBindBuffer(GL_PIXEL_PACK_BUFFER, 0);

GLReadBuffer(GL_BACK);
GLBindBuffer(GL_PIXEL_PACK_BUFFER, mPboId);
// This next line of code takes ~250ms
GLReadPixels(0, 0, mScreenWidth, mScreenHeight, GL_RGBA, GL_UNSIGNED_BYTE, 0);
GLBindBuffer(GL_PIXEL_PACK_BUFFER, 0);

Upvotes: 4

Views: 294

Answers (0)

Related Questions