Need help with poor framerate

Started by tomster, July 30, 2007, 21:40:24

Previous topic - Next topic

tomster

Hi,

I am new to lwjgl and openGL in general and I have a question.
I wrote a test program to see if java/opengl have the capabilities i need for an app i am writing.
I am using AWTGLCanvas to draw 6000 8 cornered polygons and some text using textures and quads.
I have optimized each polygon to use a display list and so do the fonts of course.
I am getting a frame rate of about 45 - 55. is this what I should expect?
It is not a whole lot better then what I got using java's Graphics2D.

(This is being run on AMD 64x2 with Nvidia 7900gtx and java 6)

Matzon

Try running org.lwjgl.test.opengl.Gears and the org.lwjgl.test.opengl.awt.AWTGears tests.
Confirm that vsync is off.
Make sure you're not starving the event thread when using AWT - so you need to sleep once in a while to let the event mechanism do a paint event.

That said, 6000 polygons is a fair bunch I think - but others might have a saying about that.

tomster

Thanks for you reply,

I ran both tests (vsync was indeed turned off) and I got about the same results from the AWTGears (~50fps) however the Gears tests gave me around 6000fps (which is cool). Does this make sense? should AWT be that much slower?

Also I tired adding sleep in the main loop. Didn't help.

Matzon

to be honest, I am clueless. I usually get 10-15% drop when using AWT compared to native display. Has anyone else experienced such massive slowdowns ?

SHAFT

Hey Guys,
     I'm actually having the same problem. I'm using the AWTGLCanvas to run an applet and I get the same junky performance (30-40fps vs. 700+fps). Like Tomster, I'm using java6 and I also have an NVidia card (6800GT 256MB). Here's what I get when running both ways:


C:\BATMG\lwjgl\jar>java -cp ./lwjgl_applet.jar;./lwjgl_util_applet.jar;./lwjgl.jar;res.jar./lwjgl_util.jar;./lwjgl_fmod3.jar;./lwjgl_devil.jar;./natives.ja
r;./jinput.jar;./lwjgl_test.jar -Djava.library.path=../native/win32 org.lwjgl.test.opengl.Gears
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce 6800 GT/AGP/SSE2
GL_VERSION: 2.0.1

glLoadTransposeMatrixfARB() supported: true
23598 frames in 5.0 seconds = 4719.6
23704 frames in 5.0 seconds = 4740.8
24664 frames in 5.0 seconds = 4932.8
24356 frames in 5.0 seconds = 4871.2

C:\BATMG\lwjgl\jar>java -cp ./lwjgl_applet.jar;./lwjgl_util_applet.jar;./lwjgl.jar;res.jar./lwjgl_util.jar;./lwjgl_fmod3.jar;./lwjgl_devil.jar;./natives.ja
r;./jinput.jar;./lwjgl_test.jar -Djava.library.path=../native/win32 org.lwjgl.test.opengl.awt.AWTGears
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce 6800 GT/AGP/SSE2
GL_VERSION: 2.0.1

glLoadTransposeMatrixfARB() supported: true
425 frames in 5.0 seconds = 85.0
424 frames in 5.0 seconds = 84.8
425 frames in 5.0 seconds = 85.0
424 frames in 5.0 seconds = 84.8


Any pointers would be much appreciated. I love what you guys are doing; it's great to be able to use GL in an Applet!

-SHAFT

SHAFT

Hey again,
     One thing I noticed in my code (per Matzon's suggestion) was that adding a sleep for even just 1 nano to the painting Thread doubled my framerate (went from 30-40 to 60-80). It doesn't seem to matter how long I sleep either; I get the same benefit all the way up to 10ms where it obviously starts to slip. I've tried running on java 1.4.2_14, 1.5.0_12 and 1.6.0 and I actually get worse framerate on the previous versions. The previous versions all ran relatively better with the sleep added, so that is at least part of the problem. Still, 70-80 is pretty bad considering I can get 400+ using AWT on my work computer with integrated graphics.

Please let me know if you come across something.

-SHAFT

Matzon

Quote from: SHAFT on August 08, 2007, 02:03:48
...
425 frames in 5.0 seconds = 85.0
424 frames in 5.0 seconds = 84.8
425 frames in 5.0 seconds = 85.0
424 frames in 5.0 seconds = 84.8

Any pointers would be much appreciated. I love what you guys are doing; it's great to be able to use GL in an Applet!


Values around 60, 75, 85, fps are always suspicious, and tend to have to do with vsync. Please double check that vsync is forced off in the drivers.

SHAFT

Hey Matzon,
     Well, you were correct about that. Even though I have it set to no Vsync, I have to force it off for it to really work. Your wisdom is greatly appreciated:


C:\BATMG\lwjgl\jar>java -cp ./lwjgl_applet.jar;./lwjgl_util_applet.jar;./lwjgl.jar;res.jar./lwjgl_util.jar;./lwjgl_fmod3.jar;./lwjgl_devil.jar;./natives.ja
r;./jinput.jar;./lwjgl_test.jar -Djava.library.path=../native/win32 org.lwjgl.test.opengl.awt.AWTGears
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce 6800 GT/AGP/SSE2
GL_VERSION: 2.0.1

glLoadTransposeMatrixfARB() supported: true
12524 frames in 5.0 seconds = 2504.8
12399 frames in 5.0 seconds = 2479.8
12839 frames in 5.0 seconds = 2567.8
12914 frames in 5.0 seconds = 2582.8


     I think I can better deal with a %40 reduction in performance when running in an applet. Do you know if that AWTGears test has any sleeps in place while rendering? That could be where the difference is coming now; I noticed a %40 increase when I added sleeps to my code. Anyway, thanks for the update!

-SHAFT

Matzon

You will take a hit when using AWT. This is because of the way AWT works with the event thread and all.
However, the 40% drop is only when you have empty scenes. When you actually have a scene that renders at 60 fps in native window, you should se somewhat similar performance in awt (maybe 5% slower).

What you are benchmarking right now, is the speed at which you can do the swap buffer part - not actually opengl performance as such.