Skip to content

Commit

Permalink
Fix incorrect warning message when D3DKMT is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
jellysquid3 committed Oct 20, 2024
1 parent dd25399 commit 3bc519f
Showing 1 changed file with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.caffeinemc.mods.sodium.client.platform.windows.api.d3dkmt;

import com.sun.jna.platform.win32.VersionHelpers;
import net.caffeinemc.mods.sodium.client.compatibility.environment.probe.GraphicsAdapterInfo;
import net.caffeinemc.mods.sodium.client.compatibility.environment.probe.GraphicsAdapterVendor;
import net.caffeinemc.mods.sodium.client.platform.windows.WindowsFileVersion;
Expand All @@ -25,12 +24,11 @@
public class D3DKMT {
private static final Logger LOGGER = LoggerFactory.getLogger("Sodium-D3DKMT");

private static final boolean SUPPORTS_D3DKMT = VersionHelpers.IsWindowsVistaOrGreater() && Gdi32.isD3DKMTSupported();
private static final boolean SUPPORTS_QUERYING_ADAPTER_TYPE = VersionHelpers.IsWindows8OrGreater();

public static List<WDDMAdapterInfo> findGraphicsAdapters() {
if (!SUPPORTS_D3DKMT) {
LOGGER.warn("Unable to query graphics adapters when the operating system is older than Windows Vista.");
if (!Gdi32.isD3DKMTSupported()) {
// D3DKMT was introduced with Windows Vista, but it was not possible to enumerate adapters and their
// rendering capabilities until Windows 8.0.
LOGGER.warn("Unable to query graphics adapters when the operating system is older than Windows 8.0.");
return List.of();
}

Expand Down Expand Up @@ -74,14 +72,10 @@ private static void freeAdapters(@NotNull D3DKMTAdapterInfoStruct.Buffer adapter
}

private static @Nullable D3DKMT.WDDMAdapterInfo getAdapterInfo(int adapter) {
int adapterType = -1;

if (SUPPORTS_QUERYING_ADAPTER_TYPE) {
adapterType = queryAdapterType(adapter);
int adapterType = queryAdapterType(adapter);

if (!isSupportedAdapterType(adapterType)) {
return null;
}
if (!isSupportedAdapterType(adapterType)) {
return null;
}

String adapterName = queryFriendlyName(adapter);
Expand Down

0 comments on commit 3bc519f

Please sign in to comment.