如何让 Java3D 启动得更快?

发布于 2024-07-12 08:32:59 字数 268 浏览 5 评论 0原文

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

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

櫻之舞 2024-07-19 08:32:59

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

问题是 ::DescribePixelFormat Win32 调用很慢 - 需要
最多需要 60 毫秒才能完成。
...
使用建议的解决方法(消除[原文如此]有问题的 win32 调用)
时间显着缩短(例如 0 毫秒)。

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

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

...一些
将 OpenGL 与 Java 结合使用的应用程序可能无法正常工作。

但由于我无论如何都使用 Direct3D,所以这不是问题。 启动时间缩短了 3.2 秒。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文