简体   繁体   English

如何让Java3D更快启动?

[英]How can I make Java3D start faster?

My application takes several seconds to show the first window with a Canvas3D in it. 我的应用程序需要几秒钟才能显示第一个带有Canvas3D窗口。 I've profiled it and found that the bottleneck is in SimpleUniverse.getPreferredConfiguration() ; 我对它进行了分析,发现瓶颈在于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. 我正在使用Direct3D渲染器( -Dj3d.rend=d3d ),因为OpenGL渲染器在我的显卡上崩溃了。 I have an integrated ATI card running a single monitor. 我有一个运行单个显示器的集成ATI卡。

The reason for the slowdown is that GraphicsDevice.getConfigurations() , which is used by SimpleUniverse.getPreferredConfiguration() , is very slow on some systems. 的原因减速是GraphicsDevice.getConfigurations()它用于通过SimpleUniverse.getPreferredConfiguration()是在某些系统很慢。 See this java.net forum thread , which links to this Java3D bug , which in turn links to this Sun bug : 请参阅此java.net论坛主题 ,该主题链接到此Java3D错误 ,该错误又链接到此Sun错误

The problem is that ::DescribePixelFormat Win32 call is slow - takes up to 60ms to complete. 问题是::DescribePixelFormat Win32调用很慢 - 最多需要60ms才能完成。 ... ...
With the suggested workaround (which elminats [sic] the offending win32 calls) the time is significantly improved (to, like, 0ms). 通过建议的解决方法(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. 但是因为我还在使用Direct3D,所以这不是问题。 This cut 3.2 seconds off of the startup time. 这减少了启动时间3.2秒。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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