Slow readback on ATI


I have quite fast readback (8ms for 1920x1200) on a nVidia 8600m GT (MBP 2007). However, the same code, and many versions of it, is six times slower on a brand new ATI Radeon 4870 512MB on PCI-E (Quad Core 2,93GHz). If it was the other way around I’d understand.

I have tried reading from a new frame buffer. I have tried copy the pixels to a PBO and read/map from it. Not better. Everything is lightning fast on the VRAM but as soon as I try to pull it down to System memory it is slow.

Btw, here’s the simplest version of the code. As I said, I have tried many more complicated versions, but they are all as slow or slower.

Any pointer on how to spead this up would be appreciated. Btw, I’m running 10.5 on the fast MacBook Pro and 10.6 on the MAc Pro, but that shouldn’t matter, should it?


extern “C” int capture(int capX, int capY, int capWidth, int capHeight, char *dest)
if (screen == NULL) {
CGLPixelFormatObj pix;
GLint npix;

	CGLPixelFormatAttribute attribs[] = {
		kCGLPFADisplayMask, (CGLPixelFormatAttribute) CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID()),
		(CGLPixelFormatAttribute) 0

	// Create a fullscreen context
	CGLChoosePixelFormat(attribs, &pix, &npix);
	CGLCreateContext(pix, NULL, &screen);
	if (glGetError() != GL_NO_ERROR)
		return -1;


if (glGetError() != GL_NO_ERROR)
	return -2;

glPixelStorei(GL_PACK_ROW_LENGTH, 0);

glReadPixels(0, 0, 1920, 1200, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, dest);

if (glGetError() != GL_NO_ERROR)
	return -3;

return 0;


I have no experience on that GPU but from previous experience with ATI stuff quite a lot of things that you might expect to be hardware implemented are in software… I think this was the case with Geometry shaders for a while, and may still be! And I am sure that was on some of these newer cards.

Your texture formats look like they should be on the fast path.

Profile your app using the OpenGL profiler and see if you can see where the bottleneck is. I suspect it’s falling back to SW somewhere, and it should be fairly clear from it’s profile output.

But that is purely a guess based on things I’ve seen elsewhere.

If it does seem to be that drop an email to the Mac OpenGL lists, the ATI guys usually monitor that and will get back to you fairly quickly.

Thanks Scratt,

The bottleneck is in the glReadPixels call. And if I use some other method to pull the bytes down to system memory it is that method that is the bottleneck. It seems the PCI-E bus is thin as a hair.

Maybe I should physically dive into the machine and pull the bytes out by force? :wink:


Btw, I’m running 10.5 on the fast MacBook Pro and 10.6 on the MAc Pro, but that shouldn’t matter, should it?

There are known OpenGL performance regressions on 10.6 - you might be seeing their effect.

Try searching and/or posting on the [url]mac-opengl mailing list to see if anyone else has encountered this specific issue.

I am aware of some early benchmarks showing slightly lower OpenGL Performance, but not aware of “known performance regressions”, care to post some links about that?

btw I monitor the OpenGL list daily, have not seen any discussions there about 10.6 “regressions”. That is also where I suggested the OP post, and see that he has this morning. :slight_smile:

@Mikael : btw have you tried adding _REV to the end of the GL_UNSIGNED_INT_8_8_8_8

A post in the OpenGL list just reminded me that that did give me a not inconsiderable speed boost (when combined with GL_BGRA) at some point in the transition to new OpenGL drivers early in 10.5’s life. It certainly speeds up glTexSubImage2D, which I use a lot, although from memory that was more to do with GL_BGRA not requiring “swizzling”.


_REV and BGRA_EXT actually increased the performance by 2%. I’ll test it on the MBP as well but unless there’s regressions I’ll leave it in.


Btw, _REV and BGRA_EXT actually made more difference on the MacBook Pro. The difference is now even greater…

I am aware of some early benchmarks showing slightly lower OpenGL Performance, but not aware of “known performance regressions”, care to post some links about that?

A quick google search for “mac os x 10.6 opengl regression” returns results like “Interestingly, with Snow Leopard o…68, […]” and “I’m having major OpenGL issues in …n in 10.5”.

I’m not a Mac OS X user and I don’t know the extent of the issue, but I don’t like its sound.

Stephen… There are also an equal number of articles which talk about speed increases. You get a batch of each with each new OS revision on any platform.
If you’re not even on OS X I’d say your comments are one step away from trolling to be frank.

The OpenGL drivers in 10.6 are very very similar to those in the last version of 10.5.
I remember when 10.5.2 came out my procedural planet code dropped to about 25% of the speed it had been on 10.5.0 & 10.5.1. The reason: Apple had changed some pretty major things to do with texture formats and I was using something that was not on the fast path any more.

Had I read the release / deprecation notes from previous technical docs I would have been in the loop. One re-compile after a bit of reading sorted that out… and I got a speed increase as a bonus. So RTFM springs to mind in my case.

Mikael’s issue is a known issue which has been reported several times to Apple and is being worked on. AFAIK Mikael got a reply almost instantly from people on the OpenGL list there and I suspect will hear from ATI sooner rather than later. I have seen several replies about this in the community since his post on the Mac OpenGL list referring to his issue… Not bad for such a sinister and secretive company as Apple… :wink:

Let’s see… you accuse me of trolling, tell me to RTFM, then do a 180 and confirm what I said. How nice!

Seriously man, take a deep breath and calm down. You are imagining attacks where there are none.


Just as Scratt said I got word from AMD that this is a known bug and that they are working on it with high priority.


I am totally calm. :slight_smile:

Let’s take a look again:

Stephen rushes into thread and breathlessly exclaims that OS X has massive OpenGL performance issues. States he doesn’t like the sound of it…

I ask for some links.

Stephen posts a couple of fairly obscure links based on out of date profiling tools. Then states he’s not even using OS X!

I laugh. :slight_smile: I give an example of how this kind of hysteria can spread, and tell an anecdotal story where I admonish myself and tell myself to RTFM. I also state that when you actually have no personal experience on OS X it’s a little strange to dive into a thread with no actual information but with an assertion that the world of OpenGL in OS X land is exploding!

Stephen rushes in breathlessly again, mis-reads my posts. Accuses me of telling him to RTFM, which I absolutely did not…

Who needs to calm down?

Peace. :slight_smile:

Mikael, glad you got some feedback. :slight_smile:

Check your PMs.

And please stop putting words in my mouth (“massive performance issues”, “no personal experience on Mac OS X”).