Confusion about native pixel format

tigakub
Unregistered
 
Post: #1
There's a demo at

http://developer.apple.com/samplecode/Sa...exDemo.htm

that shows how to optimize for Mac's ARBG pixel format. However, in that demo, it makes the following call:

glPixelStorei(GL_UNPACKCLIENT_STORAGE_APPLE, 1);

which is supposed to make OpenGL use the application copy of the texture. The documentation that came with the demo claims that this results in a 70% speed improvement.

How can this be? How can pulling data through the AGP be faster than using resident textures? (Or can I assume that the demo was written with the software renderer in mind?)

Also, does anyone know where I can get my hands on some CGL documentation/reference material? All I can seem to find is AGL stuff.

thanx
-tigakub
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
* the CGL header (<OpenGL/OpenGL.h>) is pretty good documentation. It all works the same way as AGL, anyway, so the documentation for either is pretty much good for both Smile

* When you create a texture in OpenGL, the specification mandates that OpenGL remember the texture image, regardless of how many other textures you might be using. This means that it can't assume they all fit in VRAM, so it must keep a copy of the image in main memory.

OpenGL also can't assume that the pixel buffer you pass to glTexImage2D will last beyond that point. It's fairly common, after all, to do glTexImage2D(..., buffer); free(buffer);. That means that it has to make its copy of the data when you call glTexImage2D.

GL_APPLE_client_storage gets around the necessity of making this extra copy. You guarantee that you will keep your copy of the texture image around for OpenGL to use when it needs. The extension doesn't change any other behavior -- the texture will still be copied to VRAM, for example.

There is a second Apple extension which helps out with texture uploads, and that is the glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 0);. This is a hint to the card that the texture image should be stored in AGP memory (not quite sure how this works). This makes for very fast uploads to the card, and so is very useful if you are using animated textures (a movie, for example Wink

The 70% performance improvement refers to texture upload times only, but in my experience that's a reasonable figure.
Quote this message in a reply
tigakub
Unregistered
 
Post: #3
Thanks OneSadCookie. That clarified it quite nicely. I'm so glad I stumbled on this site. For the longest time I've been frustrated with the level of support out there for aspiring Mac developers.

- tigakub
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
You might also be interested in the MacGameWiki, or in the Apple-run Mac-Games-Dev and Mac-OpenGL mailing lists. They have very manageable volumes, and often contain useful information. You can subscribe at http://lists.apple.com/.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  iPhone native graphics format DaveJ 2 6,192 Dec 26, 2012 12:44 PM
Last Post: mdejong1024
  [CoreGraphics] Image manipulation - pixel by pixel g00se 5 10,342 Jul 28, 2010 08:27 AM
Last Post: ThemsAllTook
  sdl with a native ui on the iphone is easier than you may think michelleC 0 2,573 Mar 17, 2010 12:05 PM
Last Post: michelleC
  OpenGL/C confusion spsweet 7 4,584 Mar 21, 2007 06:54 PM
Last Post: OneSadCookie
  Confusion about -isFlipped in Cocoa ThemsAllTook 7 5,933 Mar 31, 2006 07:55 AM
Last Post: ThemsAllTook