anyone succeded using it under linux?
Got absolutly no change in framerate (good or bad).
Is it suffisent to say that it is active or not? are there debug flags to indicate if the GL pipeline is used or not?
ok, let’s widen a bit the field of the thread.
Contests seem to be popular, so here is an other one:.
Make a small graphic app that shows an acceleration when using jdk 1.5 beta1.
Runnable jar, or webstartable applications welcome…
if you fail to get an acceleration, post the example, so we can get material for the j2D team to test.
We NEED those accelerations, time for pressure…
What are the flags to enable ogl acceleration?
I’ve yet to find them in the release notes for 1.5 :-/
[quote]anyone succeded using it under linux?
Got absolutly no change in framerate (good or bad).
Is it suffisent to say that it is active or not? are there debug flags to indicate if the GL pipeline is used or not?
[/quote]
It says something like “using OpenGL pipeline” when turned on with -Dsun.java2d.opengl=true. I thing you must have GLX 1.3+ version on your coumputer to be able to start it at all. I’m on fast machine + NVidia, so I see very little changes compared with vanilla 1.5 (actually very fast) pipeline (except it crashes more often, NVidia problem). But I tested only a few mainstream apps (jedit, netbeans, jgoodies looks). I think more optimizations will go in beta2.
and the ogl pipeline is available only on linux atm?
if we belive what is written here, yes.
http://java.sun.com/developer/technicalArticles/releases/j2se15/#dc
BTW, i’ve been nasty. i unzipped the classes and made a search for the flag string. It is effectively used somewhere. does not say if the string is used for something or not, but at least, it’s been typed somewhere…
edit
the class search was on the linux version.
Also, Trembovetski said
[quote] OpenGL pipeline is indeed in beta1 (on solaris/linux), and it’s turned off by default. Check out the ‘new features in java2D’ page for requirements.
[/quote]
which somewhat implies that it is not in windows. I was not able to have a confirmation of the non presence, anyway, but i had no change in windows when setting the flag
[quote]What are the flags to enable ogl acceleration?
I’ve yet to find them in the release notes for 1.5 :-/
[/quote]
The most detailed instructions are here:
http://java.sun.com/j2se/1.5.0/docs/guide/2d/new_features.html#ogl
There’s also a link to the original RFE, which contains some more (possibly outdated) information.
As others have mentioned, there have been a number of quality, stability, and performance fixes integrated into 1.5-beta2, so those of you looking to test the new OGL pipeline on Linux/Nvidia configs should be a bit more happy. There are still of course some strange driver bugs that cause sporadic “issues”, but we’re doing our best to track them down and resolve them (either by working around them or by submitting bugs to the driver teams).
Also in beta2:
- hw accelerated GradientPaint and TexturePaint renderers (only when AA is disabled, but that will change in the future)
- better support for Linux/ATI configs
- many other bug fixes
Right now the pipeline is only available on Linux and Solaris. We’ve got a prototype up and running on Windows, but there are a number of issues (display mode switches, multimon, fullscreen, etc) we must resolve on that platform before the pipeline can be included safely (hopefully in a release that follows Tiger). Also, I know the Apple guys are excited to have a full OGL pipeline again, and they’re planning on having it available in their 1.5 release. So pretty soon you should be able to count on having the pipeline available on all major platforms, but whether it will be enabled by default on any of them will take some time to sort out.
If you have any specific (hopefully small) testcases that demonstrate bugs in the OGL pipeline, please submit them through the normal channels:
http://java.sun.com/webapps/bugreport/
I’ll be sure to look into them right away. We’d like to shake out as many issues as possible before the final 1.5 release.
Thanks,
Chris
P.S. It would be fun to see some folks respond to pepe’s “contest”. Hint: render some managed images with some arbitrary transforms, alpha compositing, and a complex (Shape) clip for good measure. That should all be accelerated in hardware with OGL enabled… (Abuse’s “Rocks” or “Balls” or “FireStarter” or whatever-it’s-called-these-days is a great demo of what I just described.)
sweet… now all i have to do is install Linux
oh yeah, a quick question that just popped into my head.
Which AlphaComposite rules are accelerated atm?
all of them? or only some of them?
I’ll be glad to post some, and there are quite a few (heh). I don’t think that I can attach screenshots on Sun’s site though (when windows are maximised contet becomes disorted). I can however make VM crash easily, and I noticed that jTunes is MUCH slower than with default pipeline (with their brushed metal backgound).
[quote]sweet… now all i have to do is install Linux
oh yeah, a quick question that just popped into my head.
Which AlphaComposite rules are accelerated atm?
all of them? or only some of them?
[/quote]
All AlphaComposite rules are accelerated in most cases. In a couple cases involving antialiased shape rendering, I believe we only accelerate Src and SrcOver. This may improve in the future when we take more advantage of advanced hardware features, like fragment shaders and multisampling.
Chris
Heh, thanks for the infos. it’s nice to have officials around.
If you ever want to drop something runnable about the win32 GL pipeline, please don’t hesitate a second. I’m sure there will be people around (at least me) that will be happy to crash for the cause.
if anyone has examples of thing that don’t get accelerated, while doing it in ‘the state of the art for acceleration’, please post them also.
Should we restrict to only transformed images with shape clipping in order to have the most interesting examples, or should we also add fancy polygons and things like that?
Ok, I made myself a test case and so far have hit a problem. Just to start, I’ll note that this is running on an Alienware Area 51m with an nVidia GeForce FX5600 Go, Mandrake 9.2, and the latest drivers from nVidia.
I wrote a test that blits progressively more images to the screen, and displays the average framerate for each number of images. At this point, it’s a non-accerated image simply read in through ImageIO. What I’ve discovered is that the OpenGL pipeline does not work in conjunction with a BufferedStrategy. All I see is a gray screen (though the output still claims to be getting quite a good framerate).
One more thing before I post the code. I noticed Chris kept mentioning beta 2. When I go to the download site at java.sun.com, I only see beta 1. Is beta 2 available somewhere else?
Ok, here’s the code. My apologies for the length.
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.*;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class OGLTest extends Frame implements KeyListener {
protected boolean mRunning = true;
protected Image mImage = null;
protected BufferStrategy mBufferStrategy = null;
protected Sprite[] mSprites;
protected long mLastSpriteCreation;
protected int mSamplesTotal;
protected int mNumSamples;
protected int mFrameCount = 0;
protected long mLastFrameCount = 0;
protected int mFPS = 0;
private static final int kInitialSprites = 16;
private static final int kSpriteMultiplier = 2;
private static final long kSpriteIncrementInterval = 15000; // in ms
public static void main(String[] args) {
boolean useBufferStrategy = false;
if ((args.length > 0) && (args[0].equalsIgnoreCase("--buffered"))) {
useBufferStrategy = true;
}
OGLTest test = new OGLTest(useBufferStrategy);
test.run();
test.dispose();
}
public OGLTest(boolean useBufferStrategy) {
super("OGLTest");
setSize(640, 480);
addKeyListener(this);
setIgnoreRepaint(true);
setLayout(null);
setVisible(true);
if (useBufferStrategy) {
createBufferStrategy(2);
mBufferStrategy = getBufferStrategy();
}
setFont(new Font("Arial", Font.BOLD, 14));
try {
mImage = ImageIO.read(new File("test.png"));
} catch (IOException ioex) {
ioex.printStackTrace();
}
mNumSamples = 0;
mSamplesTotal = 0;
createSprites(kInitialSprites);
mLastSpriteCreation = System.currentTimeMillis();
}
public void createSprites(int number) {
mSprites = new Sprite[number];
for (int i=0;i<number;i++) {
mSprites[i] = new Sprite();
}
}
public void run() {
while(mRunning) {
render();
updateFPS();
updateSprites();
// This is to allow keyboard input a chance to be parsed.
Thread.yield();
}
}
public void stop() {
mRunning = false;
}
public void render() {
Graphics g = null;
if (mBufferStrategy != null) {
g = mBufferStrategy.getDrawGraphics();
} else {
g = getGraphics();
}
render(g);
g.dispose();
if (mBufferStrategy != null) {
mBufferStrategy.show();
}
}
public void render(Graphics g) {
// Clear the background
g.setColor(Color.BLACK);
g.fillRect(0, 0, getWidth(), getHeight());
// Draw the sprites
for (int i=0;i<mSprites.length;i++) {
mSprites[i].render(g);
}
// Display the framereate
g.setColor(Color.YELLOW);
g.drawString("Sprites: "+mSprites.length, 20, 20);
g.drawString("FPS: "+mFPS, 20, 40);
}
public void updateFPS() {
long now = System.nanoTime();
if ((mLastFrameCount + 1000000000) < now) {
mFPS = mFrameCount;
mFrameCount = 0;
mLastFrameCount = now;
mSamplesTotal += mFPS;
mNumSamples++;
} else {
mFrameCount++;
}
}
public void updateSprites() {
long now = System.currentTimeMillis();
if ((now - mLastSpriteCreation) > kSpriteIncrementInterval) {
if (mNumSamples > 0) {
int average = mSamplesTotal / mNumSamples;
System.out.println("Average framerate for "+mSprites.length+" sprites: "+average);
}
mSamplesTotal = mNumSamples = 0;
int size = mSprites.length * kSpriteMultiplier;
if (mFPS < 2) {
size = kInitialSprites;
}
createSprites(size);
mLastSpriteCreation = System.currentTimeMillis();
}
for (int i=0;i<mSprites.length;i++) {
mSprites[i].update();
}
}
public static int getRandom (int iMin, int iMax) {
return iMin + (int)Math.round(Math.random() * (iMax - iMin));
}
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
stop();
}
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
class Sprite {
protected int mX;
protected int mY;
protected int mDeltaX;
protected int mDeltaY;
public Sprite() {
mX = getRandom(0, getWidth() - mImage.getWidth(null));
mY = getRandom(0, getHeight() - mImage.getHeight(null));
mDeltaX = (getRandom(0, 1) == 0) ? 1 : -1;
mDeltaY = (getRandom(0, 1) == 0) ? 1 : -1;
}
public void update() {
int nextX = mX + mDeltaX;
int nextY = mY + mDeltaY;
if ((nextX < 0) || ((nextX + mImage.getWidth(null)) > getWidth())) {
mDeltaX = -mDeltaX;
}
if ((nextY < 0) || ((nextY + mImage.getHeight(null)) > getHeight())) {
mDeltaY = -mDeltaY;
}
mX += mDeltaX;
mY += mDeltaY;
}
public void render(Graphics g) {
g.drawImage(mImage, mX, mY, null);
}
}
}
1.5 beta2 is not available yet.
I did a search through Sun’s bug database, and it looks like the issue I encountered has already been reported and fixed:
http://developer.java.sun.com/developer/bugParade/bugs/4968820.html
Looking forward to seeing Beta 2. In the meantime, the test code I posted can be used without the BufferStrategy and shows a notable increase in render speed. (On my own machine, at the start of 16 sprites I jump from 33 fps to 2000+ fps).
Paul
[quote]… shows a notable increase in render speed. (On my own machine, at the start of 16 sprites I jump from 33 fps to 2000+ fps).
[/quote]
right… this is … notable… ;D
heh… can’t wait to see that in action on all OS…
(hint hint)
Well, I’ll point out also that using the BufferStrategy without OpenGL support also causes a jump in performance (from 33 fps to around 400 fps). Though clearly the opengl pipeline is a significantly larger increase. I don’t expect an even more radical improvement by combining the two, I merely would like to be able to code a single implementation that would use a BufferStrategy as the baseline, but also allow for further increased performance by using the OpenGL pipeline.
Paul