The performance of FBO glReadPixels is quite poor especially on ATI HD 4000 cards. However using OpenCL for read-back on the 4000 series achieves numbers close to the 5000 series. The different formats in the results correspond to the glReadPixels format parameter. I also tried using GL_TEXTURE_RECTANGLE and got similar numbers. I did not try GL_TEXTURE_2D, but that format is not applicable to my specific problem.
- Linux 32-bit
- Xorg 7.5
- fglrx 10.5
- OpenGL 3.2 compat context
- ATI HD 4870, 5670
CODE
#define BUF_SIZE (1280 * 720 * 4)
int width = 1280;
int height = 720;
GLuint fboId, rboIds[2];
unsigned char outData[BUF_SIZE];
glGenRenderbuffers(2, rboIds);
glBindRenderbuffer(GL_RENDERBUFFER, rboIds[0]);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA, width, height);
glBindRenderbuffer(GL_RENDERBUFFER, rboIds[1]);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, width, height);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glGenFramebuffers(1, &fboId);
glBindFramebuffer(GL_FRAMEBUFFER, fboId);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rboIds[0]);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rboIds[1]);
glBindFramebuffer(GL_FRAMEBUFFER, fboId);
glReadBuffer(GL_COLOR_ATTACHMENT0);
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, outData);
NVIDIA 260 @ 1920x1080
----------------------
GL_RED: 3.804882 ms
GL_GREEN: 3.806893 ms
GL_BLUE: 3.812911 ms
GL_ALPHA: 3.863015 ms
GL_RGB: 6.806097 ms
GL_BGR: 4.792902 ms
GL_RGBA: 6.148106 ms
GL_BGRA: 2.173992 ms
NVIDIA 260 @ 1280x720
----------------------
GL_RED: 1.772031 ms
GL_GREEN: 1.774084 ms
GL_BLUE: 1.800905 ms
GL_ALPHA: 1.770023 ms
GL_RGB: 3.090897 ms
GL_BGR: 2.223933 ms
GL_RGBA: 2.790050 ms
GL_BGRA: 1.066923 ms
ATI 5670 @ 1920x1080
----------------------
GL_RED: 42.376039 ms
GL_GREEN: 42.690963 ms
GL_BLUE: 42.681898 ms
GL_ALPHA: 42.675084 ms
GL_RGB: 9.894946 ms
GL_BGR: 59.478978 ms
GL_RGBA: 7.479098 ms
GL_BGRA: 6.731079 ms
ATI 5670 @ 1280x720
----------------------
GL_RED: 19.468948 ms
GL_GREEN: 19.431084 ms
GL_BLUE: 19.049949 ms
GL_ALPHA: 19.216000 ms
GL_RGB: 4.638965 ms
GL_BGR: 26.787034 ms
GL_RGBA: 3.631971 ms
GL_BGRA: 3.249028 ms
ATI 4870 @ 1920x1080
----------------------
GL_RED: 51.179038 ms
GL_GREEN: 52.905026 ms
GL_BLUE: 52.559062 ms
GL_ALPHA: 50.855996 ms
GL_RGB: 18.033955 ms
GL_BGR: 67.671093 ms
GL_RGBA: 21.254912 ms
GL_BGRA: 20.467922 ms
ATI 4870 @ 1280x720
----------------------
GL_RED: 23.001010 ms
GL_GREEN: 23.231882 ms
GL_BLUE: 23.524070 ms
GL_ALPHA: 23.424958 ms
GL_RGB: 8.305027 ms
GL_BGR: 30.466888 ms
GL_RGBA: 9.727973 ms
GL_BGRA: 9.393951 ms