© Copyright Khronos Group, 2006 - Page 1
Shaders Go Mobile: An Introduction to OpenGL ES
2.0
Tom Olson, Texas Instruments Inc.
2TI Proprietary Information
About Texas Instruments
A Strong Supporter of Standards Khronos Promoting Member Active in OpenGL ES, OpenMAX, OpenKODE
The Leader in Semiconductors for Wireless #1 in wireless revenue (Dataquest) #1 in digital basebands (Forward Concepts 2006)
Over 2B handsets shipped
#1 in wireless application processors (FC 2006) Over 90M OMAP processors shipped
© Copyright Khronos Group, 2006 - Page 3
Outline
Introduction to OpenGL ES•What it is•Design principles•Versions and status
OpenGL ES 2.0•What’s different about the API•What’s different about the shading language
Status•…and where to go for more information
© Copyright Khronos Group, 2006 - Page 4
What is OpenGL ES?
The Leading 3D Graphics API for Mobile Devices• Defined by the Khronos Group• Created with blessing and cooperation of the OpenGL ARB• Subset of Desktop OpenGL •…with a few well-chosen mobile-specific extensions
Design Goal• Deliver most of the power of OpenGL•…but in a much smaller package
Design Principles• Eliminate redundancy - one way to do things• Eliminate rarely used, legacy, or expensive features• Eliminate features not used in games
© Copyright Khronos Group, 2006 - Page 5
Overview of OpenGL ES 1.xFeatures removed from desktop OpenGL• Begin/End - vertex arrays & buffers only• Fancy features: imaging subset, evaluators, display lists• Legacy features: color index, DrawPixels• Double precision data types & entry points
Almost everything else is still there!• Vertex Transforms & Lighting (mostly)• Multi-texturing (2D only)• fsAA via Multisampling• Basic blending
Features added• Fixed-point and byte data• Fixed-point only profile available
© Copyright Khronos Group, 2006 - Page 6
OpenGL ES Versions
OpenGL ES 1.1•Spec released at SIGGRAPH 2004•Adopted as standard in many mobile OSes•Hardware accelerated ES 1.1 shipping in volume•The ‘sweet spot’ for high-end mobile phone content today
OpenGL ES 2.0•Final spec to be released in 4Q 2006•The ‘sweet spot’ in 200?
© Copyright Khronos Group, 2006 - Page 7
Why OpenGL ES 2.0?
Doom 3’s Zombies
Far Cry’s Water
Unreal’s Rocks
Halo’s Ice
Cause shaders are so cool…
© Copyright Khronos Group, 2006 - Page 8
OpenGL ES 2.0 Key Changes
Add:•Vertex and Fragment Shaders•ES Shader Language (GLSL ES)•Option for off-line compilation (binary shaders)
Remove•Anything you can do in a shader• Fixed function transform and lighting• Fixed function texturing, fog, etc.
•That’s right - 2.0 is NOT backward compatible with 1.x!• But, ES 2.0 HW can support an ES 1.x driver
© Copyright Khronos Group, 2006 - Page 9
FragmentProcessor
Vertex Processor
xform
xform
xform
Light
Vtx Coords
Normals
Colors
TexCoords
Primitive assembly
CullClip
Viewport
Rasterize
Z-testStencilScissor Blend
VERTICES TRIANGLES FRAGMENTSAPPLICATION
State VectorState cmds
Input
Indices
Attribute 0
…
…
Attribute n-1
tex0
tex1
fog
What Changes From ES 1.1 to ES 2.0?• General-purpose attributes replace fixed input arrays• Vertex shader programs replace transform and lighting• General-purpose uniforms replace fixed lighting & texture state• General-purpose varyings replace fixed fragment attributes• Fragment shader programs replace texture / fog / alpha test
The OpenGL ES 2.0 Pipeline
© Copyright Khronos Group, 2006 - Page 10
Other Features Added to ES 2.0Texture Features• Cube Maps• Minimum of eight texture units
Frame Buffer Objects• Simplified version of EXT_frame_buffer_object• Mandated minimum configuration support
Per-Fragment Ops• Stencil buffer support is required• BlendEquation and BlendEquationSeparate supported (mostly)
Point Sprites• Regular GL points removed
© Copyright Khronos Group, 2006 - Page 11
Optional FeaturesOptional ETC Texture Compression• IP contributed by Ericsson
NPOT Textures
3D Textures
Visibility Queries
Half Float Data
Float / Half Float Textures
© Copyright Khronos Group, 2006 - Page 12
The ES Shader Language
GLSL ES is very similar to GLSL, but…•No fixed function attributes• glVertex, glMultiTexCoord<n>, glColor…
•No fixed function Uniforms• glModelViewMatrix, glLight[i], …
•Predefined varyings are still there• Vertex shader must write glPosition• Fragment shader can read glFragCoord• Fragment shader must write glFragColor
© Copyright Khronos Group, 2006 - Page 13
Precision Qualifiers GLSL ESRange of precisions• Low - range [-2,2] with 8 bits precision•Medium - range [-214,214] with 10 bits precision•High - range [-262,262] with 16 bits precision•Can declare per variable, or declare a default precision
Examples•lowp vec4 color;•highp vec3 LightPosition;
Defaults•Vertex Shader variables default to high precision•Fragment Shader has no default - MUST declare
© Copyright Khronos Group, 2006 - Page 14
Other Changes to GLSL ES
Invariance•Optimization may affect value of expressions•Handled in Desktop GLSL by ftransform()•Handled in GLSL ES by invariant keyword
No Virtualization•Valid programs may fail to compile due to resource limits•Conformance test will enforce reasonable capability•Any OpenGL ES 1.1 state should compile
© Copyright Khronos Group, 2006 - Page 15
Conclusion
OpenGL ES 2.0 is coming•Full vertex and fragment shader support for mobile devices•Small, clean API thanks to elimination of fixed functionality
For more information•Draft specs at http://www.khronos.org/opengles/2_X/•Final specification coming soon!