检测Java FX是否使用硬件加速的方法是什么?

4

与此相关的是,有没有一种方法可以强制Java FX使用硬件加速并在无法使用时崩溃?

5个回答

15

刚刚发现:

你可以使用-Dprism.verbose=true来运行,它将打印出它使用的图形管道。软件渲染是"sw"或"j2d",硬件加速渲染是"d3d"或"es2"。


2
您可以尝试这个技巧。
@SuppressWarnings("restriction")
static String getCurrentGraphicsPipeline() {
    return com.sun.prism.GraphicsPipeline.getPipeline().getClass().getName();
}

如果返回"com.sun.prism.sw.SWPipeline",那么你正在使用软件加速。所有其他值都意味着可能正在使用某种形式的硬件加速。

1
如果您使用Eclipse作为IDE,则需要传递这些VM参数。您可以在运行配置中添加这些VM参数。
请将这些参数添加到那里: -Dprism.verbose=true

Have a look at the image for more information


0

对于软件渲染器,SCENE 3D 功能被禁用。

if(Platform.isSupported(ConditionalFeature.SCENE3D)) {
    // hardware accelerated renderer
} else {
    // software renderer
}

0

可以使用-Dprism.order=es2虚拟机选项设置图形管线。您可以将es2替换为所需的管线(d3d、sw、j2d)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接