Apple provides different implementations of OpenGL ES for different hardware platforms. Each of these implementations has different limitations, from the maximum size allowed for textures to the list of OpenGL ES extensions that implementation supports. This chapter spells out the details on each platform to assist you in tailoring your applications to get the highest performance and quality.
The information in this chapter is current as of iPhone OS 3.0 but is subject to change in future hardware or software. For best results, your application must test for these capabilities at runtime, as described in “Determining OpenGL ES Capabilities.”
The PowerVR SGX is the graphics processor in the iPhone 3GS and is designed for OpenGL ES 2.0. The graphics driver for the PowerVR SGX also implements OpenGL ES 1.1 by efficiently implementing the fixed-function pipeline using shaders. More information about PowerVR technologies can be found in the PowerVR Technology Overview. Detailed information about the PowerVR SGX can be found in the POWERVR SGX OpenGL ES 2.0 Application Development Recommendations.
The PowerVR SGX uses a technique known as tile based deferred rendering (TBDR). When you submit OpenGL ES commands for rendering, the PowerVR SGX defers rendering until it accumulates a large list of rendering commands and then operates on this list as a single action. The framebuffer is then divided into tiles, and the scene is drawn once for each tile, with each tile drawing only the content that is visible within it. The key advantage to a deferred renderer is that it accesses memory more efficiently. Partitioning rendering into tiles allows the GPU to more effectively cache the pixel values from the framebuffer, making depth testing and blending more efficient.
Another advantage of deferred rendering is that it allows the GPU to perform hidden surface removal before fragments are processed. Pixels that are not visible are discarded without sampling textures or performing fragment processing, significantly reducing the calculations that the GPU must perform to render the scene. To gain the most benefit from this feature, you should try to draw as much of the scene with opaque content as possible and minimize use of blending, alpha testing, and the discard instruction in GLSL shaders. Because the hardware performs hidden surface removal, it is not necessary for your application to sort its geometry from front to back.
Some operations under a deferred renderer are more expensive than they would be under a traditional stream renderer. The memory bandwidth and computational savings described above perform best when processing large scenes. When the hardware receives OpenGL ES commands that require it to render smaller scenes (or duplicate resources to avoid flushing the scene), the renderer loses much of its efficiency.
For example, if your application updates a texture in the middle of a frame by calling glTexSubImage, the renderer may need to keep both the modified and previous versions of the texture at the same time, increasing memory usage in your application. Similarly, any attempt to read pixel data from the framebuffer requires that preceding commands be processed if they would alter that framebuffer.
These practices apply to both OpenGL ES 1.1 and OpenGL ES 2.0 applications.
Avoid operations that depend on previous commands. If you need to execute these commands, schedule these operations at the beginning or end of a frame. These commands include glTexSubImage, glCopyTexImage, glCopyTexSubImage, glReadPixels, glBindFramebufferOES, glFlush, and glFinish.
To take advantage of the processor’s hidden surface removal, follow the drawing guidelines found in “Drawing Order.”
Vertex buffer objects (VBOs) provide a performance improvement on the PowerVR SGX. See “Use Vertex Buffers” for information on how to use these in your application.
Starting in iPhone OS 3.1, setting texture filter settings (glTexParameter) before loading texture images (glTexImage2D) allows OpenGL ES to optimize its memory usage and texture load times.
The maximum 2D or cube map texture size is 2048 x 2048. This is also the maximum renderbuffer size and viewport size.
You can use up to 8 textures in your fragment shaders. You cannot use texture lookups in your vertex shaders.
You can use up to 16 vertex attributes.
You can use up to 8 varying vectors.
You can use up to 128 uniform vectors in your vertex shaders and up to 64 in your fragment shaders.
Points can range in size from 1.0 to 511.0 pixels.
Lines can range in width from 1.0 to 16.0 pixels.
The following extensions are supported:
GL_IMG_texture_format_BGRA8888
iPhone OS 3.1 also supports rendering to cube map textures. Previous versions of iPhone OS return FRAMEBUFFER_UNSUPPORTED for cube maps.
The following are known limitations as of iPhone OS 3.0:
The PowerVR SGX does not support non–power of two cube mapped or mipmapped textures
The PowerVR SGX processes high-precision floating-point calculations using a scalar processor, even when those values are declared in a vector. Proper use of write masks and careful definitions of your calculations can improve the performance of your shaders. See “Be Cautious of Vector Operations” for more information.
Medium- and low-precision floating-point values are processed in parallel. However, low-precision variables have a few specific performance limitations:
Swizzling components of vectors declared with low precision is expensive and should be avoided.
Many built-in functions use medium-precision inputs and outputs. Using a low-precision float as a parameter or assigning the result to a low-precision float adds conversion overhead.
For best results, limit your use of low-precision variables to color values.
OpenGL ES 1.1 is efficiently implemented using shaders that are customized as your application changes OpenGL ES state. Because of this, OpenGL ES state changes may be more expensive than they would be on a traditional hardware implementation. You can improve the performnce of your application by reducing the number of state changes it performs. For more information, see “Avoid Changing OpenGL ES State Unnecessarily.”
The maximum 2D texture size is 2048 x 2048. This is also the maximum renderbuffer size and viewport size.
There are 8 texture units available.
Points can range in size from 1.0 to 511.0 pixels.
Lines can range in width from 1.0 to 16.0 pixels.
The maximum texture LOD bias is 4.0.
For GL_OES_matrix_palette, the maximum number of palette matrices is 11 and the maximum vertex units is 4.
The maximum number of user clip planes is 6.
GL_IMG_texture_format_BGRA8888
The PowerVR MBX implements the OpenGL ES 1.1 fixed-function pipeline. More information about PowerVR technologies can be found in the PowerVR Technology Overview. Detailed information about the PowerVR MBX can be found in the PowerVR MBX 3D Application Development Recommendations.
The PowerVR MBX is a tile-based deferred renderer. Although it does not support custom fragment shaders, as on OpenGL ES 2.0, the traditional pipeline is still accelerated by avoiding unnecessary fragment processing. See “Tile-Based Deferred Rendering” for more information on how to tailor your application to perform well on a deferred renderer.
OpenGL ES applications targeting the PowerVR MBX must limit themselves to no more than 24 MB of memory for textures and renderbuffers. Overall, the PowerVR MBX is more sensitive to memory usage, and your application should minimize the size of textures and renderbuffers.
For best performance, you should interleave the standard vertex attributes in the following order: Position, Normal, Color, TexCoord0, TexCoord1, PointSize, Weight, MatrixIndex.
The maximum 2D texture size is 1024 x 1024. This is also the maximum renderbuffer size and viewport size.
There are 2 texture units available.
Points can range in size from 1.0 to 64 pixels.
Lines can range in width from 1.0 to 64 pixels.
The maximum texture LOD bias is 2.0.
For GL_OES_matrix_palette, the maximum number of palette matrices is 9 and the maximum vertex units is 3.
The maximum number of user clip planes is 1.
The extensions supported by the OpenGL ES 1.1 implementation for iPhone and iPod touch are:
GL_IMG_texture_format_BGRA8888
The PowerVR MBX implementation of OpenGL ES 1.1 has a number of limitations that are not shared by iPhone Simulator or the PowerVR SGX. :
The texture magnification and minification filters (within a texture level) must match. For example:
Supported:
GL_TEXTURE_MAG_FILTER = GL_LINEAR, GL_TEXTURE_MIN_FILTER = GL_LINEAR_MIPMAP_LINEAR |
Supported:
GL_TEXTURE_MAG_FILTER = GL_NEAREST, GL_TEXTURE_MIN_FILTER = GL_NEAREST_MIPMAP_LINEAR |
Not Supported:
GL_TEXTURE_MAG_FILTER = GL_NEAREST, GL_TEXTURE_MIN_FILTER = GL_LINEAR_MIPMAP_LINEAR |
There are a few, rarely used texture environment operations that aren’t available:
If the value of GL_COMBINE_RGB is GL_MODULATE, only one of the two operands may read from a GL_ALPHA source.
If the value of GL_COMBINE_RGB is GL_INTERPOLATE, GL_DOT3_RGB, or GL_DOT3_RGBA, then several combinations of GL_CONSTANT and GL_PRIMARY_COLOR sources and GL_ALPHA operands do not work properly.
If the value of GL_COMBINE_RGB or GL_COMBINE_ALPHA is GL_SUBTRACT, then GL_SCALE_RGB or GL_SCALE_ALPHA must be 1.0.
If the value of GL_COMBINE_ALPHA is GL_INTERPOLATE or GL_MODULATE, only one of the two sources can be GL_CONSTANT.
The value of GL_TEXTURE_ENV_COLOR must be the same for all texture units.
Two-sided lighting (GL_LIGHT_MODEL_TWO_SIDE) is ignored.
The factor argument to glPolygonOffset is ignored. Only the slope-independent units parameter is honored.
Perspective-correct texturing is supported only for the S and T texture coordinates. The Q coordinate is not interpolated with perspective correction.
iPhone Simulator includes complete and conformant implementations of both OpenGL ES 1.1 and OpenGL ES 2.0 that you can use for your application development. Simulator differs from the PowerVR MBX and PowerVR SGX in a number of ways:
Simulator does not use a tile-based deferred renderer.
Simulator does not enforce the memory limitations of the PowerVR MBX.
Simulator does not support the same extensions on either the PowerVR MBX or the PowerVR SGX.
Simulator does not attempt to simulate either the PowerVR MBX or the PowerVR SGX. Images generated by the simulator are not a pixel-for-pixel match with those generated on the device.
Important: It is important to understand that rendering performance of OpenGL ES in Simulator has no relation to the performance of OpenGL ES on an actual device. Simulator provides an optimized software rasterizer that takes advantage of the vector processing capabilities of your Macintosh computer. As a result, your OpenGL ES code may run faster or slower in OS simulator (depending on your computer and what you are drawing) than on an actual device. You should always profile and optimize your drawing code on a real device and never assume that Simulator reflects real-world performance.
Simulator supports the following extensions to OpenGL ES 2.0:
GL_IMG_texture_format_BGRA8888
GL_IMG_texture_format_BGRA8888
Last updated: 2009-11-17