High-Performance
Graphics
Goals
To educate on improvements to the internal architecture of graphics for the Java platform and new API that enables access to platform-dependent graphics acceleration
Learning Objectives
After this presentation, you should be able
to understand:
- Key improvements in the software architecture of the Java 2D API that enable higher performance graphics in the JDK 1.4 release
- Full-Screen Mode usage and capabilities
- VolatileImage API usage and capabilities
Agenda
Java 2D API-based Software Performance
Full-Screen Mode
Accelerated Offscreen Images
Java Technology on Apple
Java 2D API-based Software Performance
Jim Graham
Staff Engineer
Sun Microsystems, Inc.
Speakers Qualifications
Technical lead of Java 2D API team
Responsible for internal rendering architecture and overall software rendering performance
Working on imaging for the Java platform
since the JDK 1.0 release
Software Performance Overview
Less validation overhead
Faster blit dispatching
Support for accelerated images
Better code sharing
More reliable rendering
Java Foundation Classes (JFC/Swing) API Benefits
Less overhead for common operations
- Graphics.setColor()
- Scrolling
- Graphics.create() / dispose()
Using accelerated back buffer
Remote X11 Benefits
Server side offscreen images
Better logic to choose X11 pipelines
JFC/Swing API now usable in the remote case
TBD: Improve advanced rendering
- Antialiasing
- Alpha blending
More Reliable Rendering
Glyph cache used more consistently
Fixed hangs when using large scale factors
Overlapping copyareas
More Efficient Implementation
Better graphics primitive management
- Better sharing of setup/cleanup code
- Modular inheritance of pixel formats
Added new alpha blending modes w/ no code(!)
More intelligent caches
- Pipeline configurations
- Graphics loops
Demos
CopyArea
FadeText
ImageRotation
Full-Screen Mode
Michael Martak
Software Engineer
Sun Microsystems, Inc.
Speakers Qualifications
Member of AWT team
Responsible for implementing Full-Screen and related APIs
Background in gaming technologies prior
to work on AWT
Full-Screen Mode Overview
Games
Slide shows
Exclusive rendering
Double buffering
Changing display mode
Full-Screen and Exclusive Mode
Exclusive means:
- Suspend windowing system
- Direct rendering to hardware
Knowing whether exclusive mode supported
- GraphicsDevices.isFullScreenSupported()
Entering full-screen mode
- GraphicsDevice.setFullScreenWindow()
Setting Display Modes
Control over application presentation
- Resolution could be governed by frame rate
- Media sizes (images) may work best in some display modes
A display mode is:
- Width, height, bit depth, refresh rate
- Set on GraphicsDevice
May not be supported on device
Must be in Fullscreen/Exclusive mode
Passive vs. Active Rendering
Important for Fullscreen/exclusive mode
- Dont want erroneous window events
Passive: typical windowed GUI application
- Rendering code in paint() method
Active: high-frame-rate animation application
- Rendering usually on own thread
Double-Buffering
Bit-blit
- Copy bits between buffers
Flip
Blt
Double Buffering
Flip
Page Flipping
Buffering
BufferStrategy
- Number of buffers
- Buffering technique (Blt vs. Flip)
- Common rendering loop
BufferCapabilities
- Blt vs. Flip
- Fullscreen requirements
- Multibuffer (> 2) availability
- Back buffer contents post-flip
Demos
DisplayModeTest
- Setting display modes
- Using the JFC/Swing API for full-screen GUI
Accelerated
Offscreen Images
Chet Haase
President
Warewolf Technologies
Speakers Qualifications
Member of Java 2D API team for the
JDK 1.4 implementation
Responsible for implementation of hardware acceleration for offscreen images, especially
for win32
Experience implementing 2D and 3D graphics systems at the driver, API, and application
level for over 10 years
History Lesson
JDK 1.1 release would sometimes put images in VRAM for you
- Driver- and situation-dependent, unpredictable
- When in VRAM, rendering was accelerated
JDK 1.21.3 releases put images in
system memory
- New API needed pixel access; 1.1-style
storage not possible
JDK 1.4 release puts images in accelerated memory whenever possible
- Upon user request (new API)
- For user (existing API)
Problem: Win32 Surface Loss
(VRAM + HW Accel + pixel-access) == Ddraw
BUT: DirectDraw surfaces can be lost
- Screen saver
- Task manager (NT)
- Other app running fullscreen
Cant just insert feature under existing API
Answer: VolatileImage API
New subclass of Image
API to handle content loss
- int validate(GraphicsConfiguration)
- boolean contentsLost()
Acceleration and control
- ImageCapabilities getCapabilities()
- Image lives in accelerated memory when possible (VRAM on win32, pixmap on the Solaris platform)
But Wait, Theres More!
Component.createImage(), Toolkit.getImage(), etc.
Created BufferedImage in jdk1.2/1.3
Now also creates accelerated image copy
Great for images rendered to infrequently, copied from often
We handle surface loss for you
The Java 2D API
vs. Native API Performance
VolatileDuke demo: Basic fill/sprite-copy/buffer-copy operations
Demos
VolatileDuke
- Advantages of acceleration for fills and copies
DukeRoids
Blastian2
- Better gaming technology demo. From FriendlyGiants, ported from the JDK 1.1 to JDK 1.4 release
Demos (Cont.)
Blastian2 Porting Case Study
Basic port to JDK 1.4 API and features
took about one full day
Minor tweaks to take advantage of new acceleration (image types, rendering primitives)
- Example: fillOval(2,2) changed to 2 drawLine() commands
Performance hint: Render as image copies and rectangular fills as much as possible
Conclusions
Graphics performance overall much better
in the JDK 1.4 release
Use VolatileImage API for hardware- accelerated back buffers
Use Full-Screen and BufferStrategy APIs for fullscreen display and hardware-accelerated buffer flipping
Java Technology
on Apple
John Burkey
Software Engineer
Apple Computer
Speakers Qualifications
Technical lead of UI classes team at Apple
Responsible for porting Java 2D technology onto Apples internal APIs
Java Technology Ships
With Mac OS X
JDK 1.3 release with first Mac OS X Release
JDK 1.3.1 release ships this summer
Apple and Sun working together to provide
high-performance platform
High-Performance Java Technology on Mac OS X
Way faster than Mac OS 7/8/9
Hardware acceleration for the
JDK 1.3.1 release
- BufferedImage, JFC/Swing API
(accelerated double-buffering), alpha blending, affine transforms, text
Results
Demos
More Information
Java 2D API website:
- http://java.sun.com/products/java-media/2D/index.html
Full-Screen tutorial
- http://java.sun.com/docs/books/tutorial/extra/fullscreen
Game Developers
- http://www.javagaming.org
Apple site, for Java technology
- http://developer.apple.com/java
FriendlyGiants
- http://www.friendlygiants.com