简体   繁体   中英

How can I make Java3D start faster?

My application takes several seconds to show the first window with a Canvas3D in it. I've profiled it and found that the bottleneck is in SimpleUniverse.getPreferredConfiguration() ; the first call takes three or four seconds, and it must be called before the scene can be rendered.

I'm using the Direct3D renderer ( -Dj3d.rend=d3d ), because the OpenGL renderer crashes on my graphics card. I have an integrated ATI card running a single monitor.

The reason for the slowdown is that GraphicsDevice.getConfigurations() , which is used by SimpleUniverse.getPreferredConfiguration() , is very slow on some systems. See this java.net forum thread , which links to this Java3D bug , which in turn links to this Sun bug :

The problem is that ::DescribePixelFormat Win32 call is slow - takes up to 60ms to complete. ...
With the suggested workaround (which elminats [sic] the offending win32 calls) the time is significantly improved (to, like, 0ms).

The workaround mentioned is to pass -Dsun.awt.nopixfmt=true to the JVM , which makes the underlying native code not call DescribePixelFormat .

This apparently is not a perfect solution:

... some applications which use OpenGL with Java may not work correctly.

But since I was using Direct3D anyway, it's not a problem. This cut 3.2 seconds off of the startup time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM