real-time graphics architecturegraphics.stanford.edu/.../lectures/opengl/opengl.pdf ·...
TRANSCRIPT
7/9/2007
1
Real-Time Graphics Architecture
Lecture 16: The Design of OpenGL
p
Kurt Akeley
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Kurt Akeley
Pat Hanrahanhttp://graphics.stanford.edu/cs448-07-spring/
Early SGI history (dates are approximate)
1975 1980 1985 1990
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
7/9/2007
2
Historical context (circa 1990)
SGI is the dominant workstation 3-D graphics player
High-end multiprocessor: PowerSeries GTX, VGXDesktop: Personal Iris, Indigo
Workstation 3-D APIs are proprietary, not interoperable
IRIS GL (SGI)Starbase (HP)
…IRIS GL is a mess
Evolved (accreted) by SGI from 1982 onPoorly specified with inconsistent implementations
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Poorly specified with inconsistent implementationsIBM licensing deal
GTX/Personal IRIS development
PC is becoming an interesting platform
Intel 486 included on-board FPU and cache memoryMicrosoft exploring 3-D collaboration with SGI
PHIGS/PEX history* (dates are approximate)
1975 1980 1985 1990
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
* Summarized from http://www.jch.com/~jch/vrml/PEXTimes.html
** Programmers Hierarchical Interactive Graphics System
*** Convex, DEC, E&S, HP, IBM, Kubota, ShoGraphics, Stardent, Sun, Tek
7/9/2007
3
PEX (unofficially the PHIGS Extension to X)
PEX
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
The PEX threat (circa 1990)
PEX considered sub-optimal by SGI
Retained scene graph* (immediate mode desired)
X protocol extension (API desired)
Differed from IRIS GL
Designed by committee
NIH (maybe, we had ignored it)
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
But PEX will soon be very real …
* Actually, while PHIGS had no immediate mode, PEX had been extended by this time to include one
7/9/2007
4
The (controversial) choice
Remain proprietary
Evolve IRIS GL
Drive standards
PEX
Our own initiativeInternally called GL5
Became OpenGL
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Talk outline
Goals
Design decisions
Successes and failures
Moving forward
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
7/9/2007
5
Goals
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Goals for OpenGL
Industry-wide acceptance (beat PEX!)
Consistent implementations
Innovative implementations
Innovative and differentiated applications
Long life
High quality
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
7/9/2007
6
Non-goals
Make graphics programming easy
OpenGL is a power tool
You might lose a finger (i.e., see a black screen)
Integrate digital media and 3D graphics
This is a much larger task
See discussion of Khronos later in the talk
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Goal: Industry-wide acceptance
Avoid compromising performance
Allow explicit application trade-offs (modes)
Get it right the first time
Make conservative changes from IRIS GL
Collect lots of input during design
Do implementation during design
Create an open standard
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Create an open standard
Licensing program
Architecture Review Board (OpenGL ARB) to control future evolution of specification
7/9/2007
7
Goal: Industry-wide acceptance (cont.)
Achieve compatibility with multiple …
Operating systems (Windows, IRIX, HPUX, AIX, …)Ultimately Linux, Mac OS, OS/2, Be, …)Ultimately Linux, Mac OS, OS/2, Be, …)
Window systems (Windows UI, X Window System, …)Frame buffer is not part of OpenGL state
Programming languages (C, FORTRAN, Java, …)No pointers, structures, function overloading
No 2-D arrays at interface (row-major / column-major)
T t Mi ft t
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Target Microsoft acceptance
Omit 2D-only functions, window interface, font supportAllow full application compliance with Windows standards
Issue: no driver interface specified
Goal: Industry-wide acceptance (cont.)
Marginalize PEX
API, not protocol, is the right interface
But client-server mattered tooDefined GLX protocol
Included server-side display list storage
Carefully specified client-side state
Match current hardware capabilities
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Get input from other IHVs
Meet current application needs
Get input from ISVs
7/9/2007
8
Goal: Consistent implementations
Tightly written specification
Conformance tests and required verification
Complete implementationsComplete implementations
No sub-setting of 1.n specification
Minimum resource requirements specified
Required runtime error semantics (small performance cost)
Check and report
No other side effects
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Incentives to share extensions
Balance desires for consistency and for innovation
Result: portable applications
Goal: Innovative implementations
Specification not too tight
Not pixel-exact
Smooth antialiasing loosely definedSmooth antialiasing loosely defined
Abstraction sometimes tilted in implementor’s favor
Texture images and filters are paired
Evaluated attributes do not become “current”
Extensibility
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Key to IHV innovation
Requires IHV control of entire driverObvious for hardware systems companies
Not at all obvious for Microsoft
7/9/2007
9
Extensibility
Registry is maintained on www.opengl.org
Over 340 extensions so far
Names, token values, GLX protocol, …
Careful extension documentation
Suffix/prefix rulesClearly identify all non-core commands and tokens
Extension numbers
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Must account for all lower-numbered extensions
OpenGL is more than the sum of its parts
Extension specification template
Extension template
Name
Name strings
Version
Dependencies (details)
Errors
New state (table format)Version
Number
Dependencies (list)
Issues
Overview
New procedures and functions
New state (table format)
Get Value
Get Command
Type
Initial Value
Attribute Set
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
New tokens
Additions to chapter [2,3,4,5,6]
Additions to GLX specification
GLX protocol
New implementation-dependent state (table format)
Usage examples
7/9/2007
10
Extension syntax rules
Abbreviations (required, specifically not allowed)
Compound words (required)
Naming rules
General (e.g., “depth” rather than “z”)
Procedures (e.g., verb-noun or adjective-noun)
Defined constants (all caps, underbars)
Parameters ([0],1,2, <target>, <params>)
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Parameters ([0],1,2, <target>, <params>)
Extensions (prefixes, suffixes)
Parameter order and typing rules
Suffix codes
Extension categories
Proprietary
Use corporate prefix/suffix (e.g. NV)
EXTEXT
Use EXT prefix/suffix
Must be implemented by at least two licensees
ARB
Use ARB prefix/suffix
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Specification controlled by the ARB
1.n
No prefix/suffix
Specification controlled by the ARB
7/9/2007
11
Goal: Innovative applications
Design qualities that encourage innovative useImperative (procedural) interface
In X-speak, “mechanism, not policy”
Orthogonal mechanismsData recirculation
Similarity of pixels and texelsMachine shop analogy
Sufficiency of capability (e.g., stencil, blending)Intuitive usability (not ease of use)Invariant operation
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Invariant operationTaken together, these design qualities allow
“programmable” operation, in the multi-pass senseUsages that were not anticipated by the designers
But application developers will not innovate if implementations are not consistent!
Goal: Long life
Extensibility
Enabled
Directed (process in place)
Strong foundation
Precise specificationAnd culture that values it
Anticipation of important trends
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
p pTexture mapping
Integration of image processing and 3-D graphics
7/9/2007
12
Goal: High quality
Aim for beauty, not just sufficiency or correctness
SGI culture supportive of this
Avoid design-by-committeeAvoid design by committee
Build a horse, not a camel
Correct well known IRIS GL deficiencies
No command prefixes
Can’t be used by libraries (incomplete save/restore)
Error reporting via printf() !
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Provide documentation
Specification
Man pages
Programming guide
Design Decisions
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
7/9/2007
13
Unit-square pixels and (matching) texels
Square
Exact tiling of window area
Matches window system ownership
(1,1)
y pmodel
No window compositingWIDS (later: CIDs and DIDs)
Correct frustum arithmeticConsider single-pixel frustum
Correct texture wrapping
N d i l i
(0,0)
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Not centered at integral units
Non-negative in window
Obvious viewport arithmetic
Matching pixels and texels
Obviously important (in retrospect!)
(0.5,0.5)
No direct render to texture
Pixel and texel coordinates are equivalent
But pixels and texels are still distinguished
Allows implementation with separate memories
Supports OpenGL state modelTextures are OpenGL state
Frame buffer contents are not
– Allows mutiple renderers to share frame buffer
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
An unnecessary orthogonality?
7/9/2007
14
No return values (except from queries)
Status return values are a common library feature
But they have horrible performance implications
Expose pipeline latency
Expose client-server latency
OpenGL error system carefully engineered to be
Asynchronous
Distributed
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Distributed
void glBegin(GL_POLYGON);
GLstatus glBegin(GL_POLYGON);
Evaluated attributes do not become current
“Correct” semantics
Force separate hardware for evaluation and vertex Evaluationfor evaluation and vertex ops
Defeat “unified” implementation
Compromise allows practical implementation
Evaluation
“Smear” currentvalues
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Vertex
Operations
7/9/2007
15
More design decisions
Object IDs (not handles)
No return value ☺
Scriptable
Sifdv interface
For application convenience and efficiency
Discourage incremental matrix arithmetic
No pre-multiply
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
No pre multiply
Stack provided for undo
Application-specified clipping done in eye coordinates
Allows use of singular projection matrixes
Successes and Failures
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
7/9/2007
16
Success with respect to goals
Industry-wide acceptance
Great for Unix, Linux, Apple, embedded systems
Good as can be expected with Microsoft ☺
Poor for game consoles
Consistent implementations
Good for core features
Marginal for new features
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Marginal for new features
Innovative implementations
Industry and academic standard
Interesting work-arounds for constraints
Success with respect to goals (cont.)
Innovative and differentiated applications
Very successful
Long life
Fifteen years and counting
High quality
Generally respected
But implementations on Windows suffer as Direct
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
But implementations on Windows suffer as Direct 3D becomes more important
7/9/2007
17
Technical successes
Imperative interface
“Every graphics systems aspires to have an imperative interface”p
Generalized texture capability
All primitives (with pixel texture extension)
Various dimensions of texture
Texel and pixel conformance
Incremental in-place modification
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Incremental in place modification
Explicit format, filter specification, MIP level, …
Texture matrix
Formalization of fragment
Mistakes
Business
Taking our eye off Microsoft
TechnicalTechnical
Display lists as encapsulation for “objects”Forced to introduce texture objects in version 1.1
Overly-abstract storage managementProxy-priority middle ground is not tenable
Few “fast path” clues in API
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Too much faith in pure mechanism
E.g., DL objects, window position, 2-D transform, in-place frame buffer to texture memory transfer, …
Persistent parameter state between Begin/EndBut would have broken IRIS GL programs badly
7/9/2007
18
Mistakes (cont.)
Probably should have been omitted
Texture borders! (but not texture-border color)
Edge flagsEdge flags
Smooth polygon antialiasing
Color index features (lighting, antialiasing, …)
Needlessly complex or wrong
ColorMaterial()
Normal transformation
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Texture wrap semantics
Bit fields (cannot support extensions)
Viewport should accept doubles, not ints
Presumption of “view direction” (lighting, fog)
“While the quality of tangible goods has increased dramatically over the last 30 years the quality of software artifacts
Did OpenGL help SGI?
years the quality of software artifacts has been steadily declining.”
— Alex StepanovIn Industrializing Software Development,Zhejiang University 2004
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007 36
Zhejiang University, 2004
Software quality and corporate success may be inversely correlated
7/9/2007
19
Lessons
It is worthwhile to specify carefully
Don’t complete the implementation before starting on the specification!starting on the specification!
It is critical to guide system implementers and application developers to a common understanding of how to support and achieve high performance.
People make and evolve standards
Invest in developing a culture
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
p g
Keep competitive issues out of a specification’s controlling body.
Moving Forward
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
7/9/2007
20
Future of OpenGL (from 2001 talk)
On the rebound
Low period in the late 90s
Provides alternative to DirectX/Microsoft API control
Apple commitment is a positive sign
Programmability is an exciting development
Fits well in OpenGL structure
OpenGL may truly be a “library” some day
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
OpenGL may truly be a library some day
Lots of 2.0 activity, ARB still functioning
Tenth birthday this summer (at SIGGRAPH)
Khronos - Open Media Standards
Open International MembershipAny company is welcome
Funded by membership dues - $6K / year
Open StandardsPublicly available on web-site
To be used by any company in any productsu ded by e be s p dues $6 / yea y y p y y p
Open Standards for Media Authoring and Acceleration
Creating Market OpportunitiesBringing together industry’s leading media technology experts
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Bringing together industry s leading media technology expertsInvesting hundreds of man years to create state-of-the-art media API standards
Making those standards available to the industry – ROYALTY-FREE
7/9/2007
21
Over 100 companies creating media authoring and
acceleration standards
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Khronos Standards Ecosystem
Cross platform desktop 3D
Cross-platform graphics authoring/acceleration ecosystemSafety Critical 2D/3D
All open standards for native 3D graphics acceleration and authoring are now being
developed in Khronos. Tremendous opportunity for collaboration and synergy
Dynamic Media Authoring
Dynamic Media Authoring Standards
Cross platform desktop 3D
glFX3D Authoring Effects
Framework
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
“DirectX-like” set of native APIsIncludes mixed media acceleration and OS portability APIs
Embedded Media Acceleration APIsVector 2D Streaming Media Enhanced Audio
Composition Working GroupHardware acceleration for window systems
2D/3D
7/9/2007
22
Khronos Participation Model
PromotersBoard decides strategy – approves working groups, controls budget,
ratifies specifications Contributors
Any company can join Khronos to participate in any number of working
groups to produce specifications.$6,000 annual membership dues
Conformance Tests
RatifiedSpecifications
Conformance Tests and Conformance Test Process.Typically $10K per API fee
Openly and publicly distributed – free of charge,
royalty free
ratifies specifications. $20,000 annual membership dues
SDKs
A Working Group for each API standard –
one company one vote
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
AdoptersImplementers
Anyone can download specifications and SDKs and implement royalty-free products
Conforming products can use API
trademark and logo
Free libraries, utilities, examples
Khronos Conformance Process
Non-MembersKhronos
Contributor or Promoter
Become Adopter Member ($2,500
annual fee)
Sign Adopters Agreement to access Test Source and
Process(typically $10K
per API)
Port Test Source to
product and generate test
results
Upload test results to
Khronos private web-site for peer review by other
Adopters
Successful Review means
products can use Khronostrademarks
Members
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
2D/3D
Vector 2D
Streaming MediaAlready released
COLLADA, OpenKODE coming soon
7/9/2007
23
SGI / Pixar collaboration
“It seems to me that we are trying to merge troff and Scribe into a single hodge-podge. I don't think that we'll get a good result if we continue.”
“It seems that a key to a high-performance interface is choosing the right boundary between what and how. … Even the Pixar language has this boundary in it. It still does not support a description like 'lighted like a Sunday afternoon in September'.”
“I am in touch with Pat Hanrahan. He will send me an
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
updated copy of a document outline today. I am to be working on what I discuss in this note. What next?”
— Kurt Akeley (to Forest Baskett)
Fahrenheit
SGI promoting and supporting PC OpenGL
Microsoft asserting control of their own platform
Fahrenheit is the negotiated settlement
Results:
Broad reach of agreement failedNo new low-level standard, little at scene graph level
OpenGL still exists on all Windows platforms
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
p p
SGI learned a lot about Microsoft’s business
Microsoft learned a lot about graphicsSeamus’s presentation at Graphics Hardware 2001
7/9/2007
24
Direct3D
For years Direct3D has patterned itself after OpenGL
Immediate mode
Features such as stencil buffer
There are surprising examples in Direct3D 10
Geometry shaders (anticipated by evaluators)
Unified shaders (anticipated by evaluators)
Stream out (anticipated by feedback)
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Stream out (anticipated by feedback)
Even GPU programmability is not really new
Recall earlier lecture
But also …
From the Wikipedia article on PHIGS:
The rise of OpenGL and the decline of PHIGSOpenGL, unlike PHIGS, is an immediate-mode rendering system with no "state";
once an object is sent to a view to be rendered it essentially disappears. Changes to the model have to be re-sent into the system and re-rendered Changes to the model have to be re-sent into the system and re-rendered, dramatically increasing programmer workload. For simple projects, PHIGS was considerably easier to use and work with.
However, OpenGL's "low-level" API allowed the programmer to make dramatic improvements in rendering performance by first examining the data on the CPU-side before trying to send it over the bus to the graphics engine. For instance, the programmer could "cull" the objects by examining which objects were actually visible in the scene, and sending only those objects that would actually end up on the screen. This was kept private in PHIGS, making it much more difficult to tune performance.
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Given the low performance systems of the era and the need for high-performance rendering, OpenGL was generally considered to be much more "powerful" for 3D programming. PHIGS fell into disuse. Version 6.0 of the PEX protocol was designed to support other 3D programming models as well, but did not regain popularity. PEX was mostly removed from XFree86 4.2.x (2002) and finally removed from the X Window System altogether in X11R6.7.0 (April 2004).
7/9/2007
25
OpenGL specifies an architecture
OpenGL is an API-based architecture specification
Low-level imperative interface (like an ISA)
Tight specification (like an ISA)
Orthogonal operation (like an ISA)
This is what mattered most
Allowed hardware innovation
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Allowed hardware innovation
Allowed application innovation
Allowed programmability
Deferred need for “shaders”, then allowed them
“In terms of stifling innovation, good ideas are far more dangerous than badideas are far more dangerous than bad ones. They take hold, assume momentum, and therefore result in inertia. Consequently, they are hard to displace, even when they are well past their prime.”
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007 50
— Bill BuxtonIn Sketching User Experience,Morgan Kaufmann, 2007
7/9/2007
26
To learn more
www.opengl.org
www.khronos.org
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Real-Time Graphics Architecture
Lecture 16: The Design of OpenGL
p
Kurt Akeley
CS448 Lecture 16 Kurt Akeley, Pat Hanrahan, Spring 2007
Kurt Akeley
Pat Hanrahanhttp://graphics.stanford.edu/cs448-07-spring/