JavaFX effects and hardware acceleration…
Note, this entry has been superceeded by Take 3, you can read it for historical context/further explanation. The comments of this blog are also of value as they lead to what I’ve restated in ‘Take 3′
This post was sparked today by Jonathan Giles and his optimization of Josh Marinacci’s particle accelerator demo.
One of the questions I asked after he posted his blog entry was “Do you know if hardware acceleration being used for your effects?”
He didn’t know, and to be honest, I wasn’t entirely sure how to check myself.
So, I whipped up this test called Leadfoot (because it’s all about Acceleration
It’s a JavaFX 1.2 app, and you can run it using webstart by clicking here.
Here are some of the answers so far:
- MacBook with GMA850
- WinXP nVidia 9800GT
- MacBook Pro (Interestingly this machine, when booted under Windows 7 reports CPU/SIMD)
What does it all mean? Well, “CPU/SIMD” apparently is hardware acceleration. I’m still not entirely sure! I believe CPU/SIMD relates to the fact it is using the SSE instructions on the CPU. Which is NOT by my definition, the GPU on your video card. So the question remains, under what circumstances does GPU aceleration actually occur?
More news: Other users have reported OpenGL (On a MacBook Pro, see gallery) and CPU/Java (On Ubuntu and on Windows with an older Toshiba laptop)
Below is the source code, feedback welcome!
/*
* Main.fx
*
* Created on Jul 20, 2009, 8:38:21 PM
*/
package leadfoot;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.scene.effect.Blend;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javafx.scene.effect.Bloom;
import javafx.scene.effect.ColorAdjust;
import javafx.scene.effect.DisplacementMap;
import javafx.scene.effect.DropShadow;
import javafx.scene.effect.Flood;
import javafx.scene.effect.GaussianBlur;
import javafx.scene.effect.Glow;
import javafx.scene.effect.Identity;
import javafx.scene.effect.InnerShadow;
import javafx.scene.effect.InvertMask;
import javafx.scene.effect.Lighting;
import javafx.scene.effect.MotionBlur;
import javafx.scene.effect.PerspectiveTransform;
import javafx.scene.effect.Reflection;
import javafx.scene.effect.SepiaTone;
import javafx.scene.effect.Shadow;
import javafx.scene.effect.BoxBlur;
/**
* @author steven
*/
function getAccelerationFaults():Object[] {
def gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
var returnVal:Object[];
var blend:Blend = new Blend();
insert “blend: {blend.getAccelType(gc)}” into returnVal;
var bloom:Bloom = new Bloom();
insert “bloom: {bloom.getAccelType(gc)}” into returnVal;
var boxBlur:BoxBlur = new BoxBlur();
insert “boxBlur: {boxBlur.getAccelType(gc)}” into returnVal;
var colorAdjust:ColorAdjust = new ColorAdjust();
insert “colorAdjust: {colorAdjust.getAccelType(gc)}” into returnVal;
var displacmentMap:DisplacementMap = new DisplacementMap();
insert “displacmentMap: {displacmentMap.getAccelType(gc)}” into returnVal;
var dropShadow:DropShadow = new DropShadow();
insert “dropShadow: {dropShadow.getAccelType(gc)}” into returnVal;
var flood:Flood = new Flood();
insert “flood: {flood.getAccelType(gc)}” into returnVal;
var gaussianBlur:GaussianBlur = new GaussianBlur();
insert “gaussianBlur: {gaussianBlur.getAccelType(gc)}” into returnVal;
var glow:Glow = new Glow();
insert “glow: {glow.getAccelType(gc)}” into returnVal;
var identity:Identity = new Identity();
insert “identity: {identity.getAccelType(gc)}” into returnVal;
var innerShadow:InnerShadow = new InnerShadow();
insert “innerShadow: {innerShadow.getAccelType(gc)}” into returnVal;
var invertMask:InvertMask = new InvertMask();
insert “invertMask: {invertMask.getAccelType(gc)}” into returnVal;
var lighting:Lighting = new Lighting();
insert “lighting: {lighting.getAccelType(gc)}” into returnVal;
var motionBlur:MotionBlur = new MotionBlur();
insert “motionBlur: {motionBlur.getAccelType(gc)}” into returnVal;
var perspectiveTransform:PerspectiveTransform = new PerspectiveTransform();
insert “perspectiveTransform: {perspectiveTransform.getAccelType(gc)}” into returnVal;
var reflection:Reflection = new Reflection();
insert “reflection: {reflection.getAccelType(gc)}” into returnVal;
var sepiaTone:SepiaTone = new SepiaTone();
insert “sepiaTone: {sepiaTone.getAccelType(gc)}” into returnVal;
var shadow:Shadow = new Shadow();
insert “shadow: {shadow.getAccelType(gc)}” into returnVal;
return returnVal;
}
Stage {
title: “Leadfoot”
width: 250
height: 400
scene: Scene {
content: [
ListView {
width: 250
items: getAccelerationFaults()
}
]
}
}


