From 71819558eecaf04e3773e43ffcb0a017f054c1da Mon Sep 17 00:00:00 2001 From: mcrcortex <{ID}+{username}@users.noreply.github.com> Date: Thu, 16 May 2024 15:33:14 +1000 Subject: [PATCH] Fixed some issues after removing jna --- .../environment/probe/GraphicsAdapterProbe.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/caffeinemc/mods/sodium/client/compatibility/environment/probe/GraphicsAdapterProbe.java b/src/main/java/net/caffeinemc/mods/sodium/client/compatibility/environment/probe/GraphicsAdapterProbe.java index ee3ea5c491..9b7f2afecc 100644 --- a/src/main/java/net/caffeinemc/mods/sodium/client/compatibility/environment/probe/GraphicsAdapterProbe.java +++ b/src/main/java/net/caffeinemc/mods/sodium/client/compatibility/environment/probe/GraphicsAdapterProbe.java @@ -80,15 +80,13 @@ private static void queryAdapterInfo(long fptr, int handle, int type, ByteBuffer } public static List findAdaptersWindowsD3DKMT() { + //(Its ok to leave open as it is only used once and used by other things) SharedLibrary gdi32 = Library.loadNative(GraphicsAdapterProbe.class, "org.lwjgl", "gdi32"); long D3DKMTQueryAdapterInfo = apiGetFunctionAddress(gdi32, "D3DKMTQueryAdapterInfo"); long D3DKMTCloseAdapter = apiGetFunctionAddress(gdi32, "D3DKMTCloseAdapter"); - long D3DKMTEnumAdapters2 = -1; - try { - D3DKMTEnumAdapters2 = apiGetFunctionAddress(gdi32, "D3DKMTEnumAdapters2"); - } catch (UnsatisfiedLinkError e) { + long D3DKMTEnumAdapters2 = apiGetFunctionAddress(gdi32, "D3DKMTEnumAdapters2"); + if (D3DKMTQueryAdapterInfo == 0 || D3DKMTCloseAdapter == 0 || D3DKMTEnumAdapters2 == 0) { //Could not load D3DKMTEnumAdapters2 meaning < windows 8, fallback to cross-platform - gdi32.close(); LOGGER.warn("Unable to find D3DKMTEnumAdapters2. running windows 7 or earlier, using fallback probe"); return findAdaptersCrossPlatform(); }