如何使用 JavaFX 强制使用 gpu?

How to force gpu usage with JavaFX?

我将 JavaFX 与 Java 8 一起使用,并在启动我的应用程序之前设置此属性
System.setProperty("prism.forceGPU","true");
System.setProperty("prism.order","d3d,sw");
棱镜的详细模式给了我这个:

Prism pipeline init order: d3d sw
Using native-based Pisces rasterizer
Using dirty region optimizations
Not using texture mask for primitives
Not forcing power of 2 sizes for textures
Using hardware CLAMP_TO_ZERO mode
Opting in for HiDPI pixel scaling
Threshold to enable UI scaling factor: 1.5
Prism pipeline name = com.sun.prism.d3d.D3DPipeline
Loading D3D native library ...
        succeeded.
D3DPipelineManager: Created D3D9Ex device
Direct3D initialization succeeded
(X) Got class = class com.sun.prism.d3d.D3DPipeline
Initialized prism pipeline: com.sun.prism.d3d.D3DPipeline
Maximum supported texture size: 8192
Maximum texture size clamped to 4096
OS Information:
        Windows version 10.0 build 19044
D3D Driver Information:
        Intel(R) HD Graphics 630
        \.\DISPLAY1
        Driver igdumdim64.dll, version 25.20.100.6373
        Pixel Shader version 3.0
        Device : ven_8086, dev_591B, subsys_11C81462
        Max Multisamples supported: 4
 vsync: true vpipe: true
PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_16

这表明支持硬件加速,但我有一个 Nvidia GTX 1050m TI 完美安装和设置并且 JavaFX 似乎不想使用它,它总是使用 Intel(R)高清显卡 630.

有没有办法强制使用 gpu?

答案:

经过数小时的研究,我通过简单地将 java.exe 默认 gpu 设置为 nvidia 的 gpu 来解决问题,它似乎可以工作,但无法通过应用程序代码完成。

对于那些试图解决类似问题的人,它可能来自 java.exe 可执行文件未使用您想要作为默认设备的 gpu,您可以在 Windows 中更改它设置。