如何让Java3D更快启动?

时间:2022-08-24 20:47:28

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.

我的应用程序需要几秒钟才能显示第一个带有Canvas3D的窗口。我对它进行了分析,发现瓶颈在于SimpleUniverse.getPreferredConfiguration();第一个调用需要三到四秒,并且必须在渲染场景之前调用它。

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.

我正在使用Direct3D渲染器(-Dj3d.rend = d3d),因为OpenGL渲染器在我的显卡上崩溃了。我有一个运行单个显示器的集成ATI卡。

1 个解决方案

#1


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:

减速的原因是SimpleUniverse.getPreferredConfiguration()使用的GraphicsDevice.getConfigurations()在某些系统上非常慢。请参阅此java.net论坛主题,该主题链接到此Java3D错误,该错误又链接到此Sun错误:

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).

问题是:: DescribePixelFormat Win32调用很慢 - 最多需要60ms才能完成。 ...使用建议的解决方法(elminats [sic]违规的win32调用)时间显着改善(比如,0ms)。

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

提到的解决方法是将-Dsun.awt.nopixfmt = true传递给JVM,这使得底层本机代码不会调用DescribePixelFormat。

This apparently is not a perfect solution:

这显然不是一个完美的解决方案:

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

...某些使用OpenGL和Java的应用程序可能无法正常工作。

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

但是因为我还在使用Direct3D,所以这不是问题。这减少了启动时间的3.2秒。

#1


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:

减速的原因是SimpleUniverse.getPreferredConfiguration()使用的GraphicsDevice.getConfigurations()在某些系统上非常慢。请参阅此java.net论坛主题,该主题链接到此Java3D错误,该错误又链接到此Sun错误:

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).

问题是:: DescribePixelFormat Win32调用很慢 - 最多需要60ms才能完成。 ...使用建议的解决方法(elminats [sic]违规的win32调用)时间显着改善(比如,0ms)。

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

提到的解决方法是将-Dsun.awt.nopixfmt = true传递给JVM,这使得底层本机代码不会调用DescribePixelFormat。

This apparently is not a perfect solution:

这显然不是一个完美的解决方案:

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

...某些使用OpenGL和Java的应用程序可能无法正常工作。

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

但是因为我还在使用Direct3D,所以这不是问题。这减少了启动时间的3.2秒。