Skip to main content

beta b-14 draws 4 times as fast as b24 using BufferStrategy on XP?

11 replies [Last post]
knutej
Offline
Joined: 2006-06-12

I wrote a little test program to see how fast I could redraw a simple shape using BufferStrategy. I was stunned at how fast it was on b-14. Today I downloaded b24 and it ran considerably slower. I tried disabling direct draw on b24 and it was about 10 percent faster than with it enabled.

The program below runs at about 800 fps with b14 and about 200 fps with b24 on my computer. Dell 380, 3Ghz Pentium D, Nvidia NVS 285, XP Pro SP3.

Should I post this as a bug? Thanks.

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.*;

public class test2 extends Canvas implements Runnable {
volatile Thread thread;
volatile BufferStrategy bs;
double angle;
long then = System.currentTimeMillis();
int n;
double rate;

public test2() {
setIgnoreRepaint(true);
setPreferredSize(new Dimension(400,300));

addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent ce) {
if (bs == null) {
createBufferStrategy(2);
bs = getBufferStrategy();
System.out.println(bs);
}
}
});
}

public void start() {
then = System.currentTimeMillis();
thread = new Thread(this);
thread.start();
}

public void stop() {
thread.interrupt();
}

public void run() {
while (!thread.interrupted()) {
render();
}
}

public void render() {
do {
do {
int w = getWidth();
int h = getHeight();

Graphics2D g = (Graphics2D)bs.getDrawGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);

g.setColor(Color.WHITE);
g.fillRect(0,0,w,h);

AffineTransform at = g.getTransform();

angle += 0.001;
g.rotate(angle,w/2,h/2);
g.setColor(Color.BLUE);
g.fillRect(w/2 - 100,h/2 - 100,200,200);

if (++n % 100 == 0) {
long now = System.currentTimeMillis();
long time = now - then;
then = now;
rate = 100000.0 / time;
}

g.setTransform(at);
g.setColor(Color.RED);
g.drawString(String.format("%3.1f",rate),10,10);

g.dispose();
} while (bs.contentsRestored()) ;
bs.show();
} while (bs.contentsLost()) ;
}

public static void main(String[] args) {
final test2 t2 = new test2();
final Frame f = new Frame();
f.addWindowListener(new WindowAdapter() {
public void windowOpened(WindowEvent we) {
t2.start();
}
public void windowClosing(WindowEvent we) {
t2.stop();
f.dispose();
}
});

f.add(t2,BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
knutej
Offline
Joined: 2006-06-12

Dmitri:

6u10b24 with the 3D pipeline disabled it is about 50% faster than with it enabled.

knute...

trembovetski
Offline
Joined: 2003-12-31

OK, thanks for the info. It appears we'll have to devise another way to restrict the use of the new AA shader (or rewrite it) instead of relying on indicated PS30 support.

Dmitri

trembovetski
Offline
Joined: 2003-12-31

I've filed:
6709823: D3D: the AA pixel shader is very slow on some PS3.0 hardware [NVidia NVS 285]

Should appear on bugs.sun.com tomorrow.

Unfortunately I can't guarantee that it will be fixed in 6u10 since we're really close to code freeze and only showstoppers will be allowed in.

Thanks,
Dmitri

knutej
Offline
Joined: 2006-06-12

There is an even newer driver 175.51 which shows up as 6.14.11.7551 in the device properties. That doesn't make any difference with the newer, b24, build but it appears to be just slightly faster with the old b14. I tried 6u4 and that is faster than 6u10b24 but about 1/3 as fast as 6u10b14.

I'm happy to try other combinations, please let me know.

Thanks,

knute...

kirillcool
Offline
Joined: 2004-11-17

I wonder what does it mean to have 800fps? Are you actually able to refresh the screen 800 times per second (that's pretty awesome hardware you have)? I think that it would be better to measure how many primitives you can put on the screen to sustain the refresh rate of your monitor (60fps or whichever). These numbers would reflect better on the performance degradation that you're experiencing.

http://graphics-geek.blogspot.com/2008/04/off-bubblemark.html
http://graphics-geek.blogspot.com/2008/04/times-up.html

trembovetski
Offline
Joined: 2003-12-31

While it may not be the best way to measure, just doing straight "how many times per second I can draw this stuff" is still a valid benchmarking technique and may be be useful in measuring relative performance.

But it indeed may not necessarily be indicative of the end user experience.

Dmitri

trembovetski
Offline
Joined: 2003-12-31

Please run your application from the command line with J2D_TRACE_LEVEL=4 env variable set and post the output.

It is likely that the d3d pipeline isn't enabled. Typically happens because of old drivers were detected.

Dmitri
Java2D Team

knutej
Offline
Joined: 2006-06-12

Dmitri:

Trace for b14

C:\Documents and Settings\Knute Johnson>java test2
[I] OS Version = OS_WINXP Pro
[I] CheckAdaptersInfo
[I] ------------------
[I] Adapter Ordinal : 0
[I] Adapter Handle : 0x10001
[I] Description : NVIDIA Quadro NVS 285
[I] GDI Name, Driver : \\.\DISPLAY1, nv4_disp.dll
[I] Vendor Id : 0x10de
[I] Device Id : 0x0165
[I] SubSys Id : 0x29d10de
[I] Driver Version : 6.14.11.7551
[I] GUID : {D7B71E3E-4225-11CF-116E-962200C2CB35}
[I] D3DPPLM::CheckDeviceCaps: adapter 0: Passed
[I] ------------------
[I] D3DGD_getDeviceCapsNative
[I] D3DContext::InitContext device 0
[I] D3DContext::ConfigureContext device 0
[V] dwBehaviorFlags=D3DCREATE_FPU_PRESERVE|D3DCREATE_HARDWARE_VERTEXPROCESSING
[I] D3DContext::ConfigureContext: successfully created device: 0
[I] D3DContext::InitDevice: device 0
[I] D3DContext::InitDefice: successfully initialized device 0
[V] | CAPS_DEVICE_OK
[V] | CAPS_RT_PLAIN_ALPHA
[V] | CAPS_RT_TEXTURE_ALPHA
[V] | CAPS_RT_TEXTURE_OPAQUE
[V] | CAPS_LCD_SHADER | CAPS_BIOP_SHADER | CAPS_PS20
[V] | CAPS_PS30
[V] | CAPS_MULTITEXTURE
[V] | CAPS_TEXNONPOW2
[V] | CAPS_TEXNONSQUARE
java.awt.Component$FlipSubRegionBufferStrategy@16a55fa

Trace for b24

C:\Documents and Settings\Knute Johnson>java test2
[I] OS Version = OS_WINXP Pro
[I] CheckAdaptersInfo
[I] ------------------
[I] Adapter Ordinal : 0
[I] Adapter Handle : 0x10001
[I] Description : NVIDIA Quadro NVS 285
[I] GDI Name, Driver : \\.\DISPLAY1, nv4_disp.dll
[I] Vendor Id : 0x10de
[I] Device Id : 0x0165
[I] SubSys Id : 0x29d10de
[I] Driver Version : 6.14.11.7551
[I] GUID : {D7B71E3E-4225-11CF-116E-962200C2CB35}
[I] D3DPPLM::CheckDeviceCaps: adapter 0: Passed
[I] ------------------
[I] D3DGD_getDeviceCapsNative
[I] D3DContext::InitContext device 0
[I] D3DContext::ConfigureContext device 0
[V] dwBehaviorFlags=D3DCREATE_FPU_PRESERVE|D3DCREATE_HARDWARE_VERTEXPROCESSING
[I] D3DContext::ConfigureContext: successfully created device: 0
[I] D3DContext::InitDevice: device 0
[I] D3DContext::InitDefice: successfully initialized device 0
[V] | CAPS_DEVICE_OK
[V] | CAPS_RT_PLAIN_ALPHA
[V] | CAPS_RT_TEXTURE_ALPHA
[V] | CAPS_RT_TEXTURE_OPAQUE
[V] | CAPS_LCD_SHADER | CAPS_BIOP_SHADER | CAPS_PS20
[V] | CAPS_AA_SHADER
[V] | CAPS_PS30
[V] | CAPS_MULTITEXTURE
[V] | CAPS_TEXNONPOW2
[V] | CAPS_TEXNONSQUARE
java.awt.Component$FlipSubRegionBufferStrategy@157f0dc

The difference is the CAPS_AA_SHADER on b24. What does that do?

Thanks,

trembovetski
Offline
Joined: 2003-12-31

The problem is that in b23 we have introduced a pixel shader for rendering some primitives (in particular, transformed antialiased rectangles) - see bug http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=479f90c1742425fff....

While on most modern hardware this shader showed considerable performance improvement on some boards it is unfortunately slower than the old non-pixel shader code path - see bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6695820 . The fix for this bug limited the use of the new shader to "pixel shader 3.0"-level hardware in hopes that it this criteria would exclude older hw but apparently that's may not be enough.

Note that you have a pretty old driver (141.1). Could you please update it to the latest version (169.47) from nvidia website and see if it improves the performance?
http://www.nvidia.com/object/winxp_169.47.html

Also, how does this test perform versus previous release (6u4 or earlier) on your hardware?

What about 6u10 with Direct3D pipeline disabled (-Dsun.java2d.d3d=false)?

Thanks,
Dmitri

linuxhippy
Offline
Joined: 2004-01-07

Also note that the "Quadro NVS 285" is based on the "NV44" which is exactly the same which which poweres the GeForce-6200.
Although this card is capable of running pixel-shader 3.0, its so slow that its almost useless.

I guess the next-generation low-end card (7300) should be faster than the masked approach.

lg Clemens

trembovetski
Offline
Joined: 2003-12-31

Good point.