@@ -211,20 +211,29 @@ private void launch0() {
211211 launchOptionsBuilder .setQuickPlayOption (quickPlayOption );
212212 }
213213 if (config ().isWindowsHighPerformance ()) {
214- Object current = WinReg .INSTANCE .queryValue (
215- WinReg .HKEY .HKEY_CURRENT_USER ,
216- "Software\\ Microsoft\\ DirectX\\ UserGpuPreferences" ,
217- FileUtils .getAbsolutePath (javaVersionRef .get ().getBinary ())
218- );
219- if (current instanceof String ) {
220- gpuRegAlreadyExistsed = true ;
214+ if (!SYSTEM_PLATFORM .isWindows ()) {
215+ LOG .warning ("Windows high performance GPU setting is enabled, but current platform is not Windows; skipping registry configuration." );
221216 } else {
222- WinReg .INSTANCE .setValue (
223- WinReg .HKEY .HKEY_CURRENT_USER ,
224- "Software\\ Microsoft\\ DirectX\\ UserGpuPreferences" ,
225- FileUtils .getAbsolutePath (javaVersionRef .get ().getBinary ()),
226- "GpuPreference=2;"
227- );
217+ WinReg reg = WinReg .INSTANCE ;
218+ if (reg == null ) {
219+ LOG .warning ("Windows registry access (WinReg) is unavailable; cannot apply high performance GPU preference." );
220+ } else {
221+ Object current = reg .queryValue (
222+ WinReg .HKEY .HKEY_CURRENT_USER ,
223+ "Software\\ Microsoft\\ DirectX\\ UserGpuPreferences" ,
224+ FileUtils .getAbsolutePath (javaVersionRef .get ().getBinary ())
225+ );
226+ if (current instanceof String ) {
227+ gpuRegAlreadyExistsed = true ;
228+ } else {
229+ reg .setValue (
230+ WinReg .HKEY .HKEY_CURRENT_USER ,
231+ "Software\\ Microsoft\\ DirectX\\ UserGpuPreferences" ,
232+ FileUtils .getAbsolutePath (javaVersionRef .get ().getBinary ()),
233+ "GpuPreference=2;"
234+ );
235+ }
236+ }
228237 }
229238 }
230239
0 commit comments