Skip to content

Commit 5ce718e

Browse files
committedOct 25, 2023
8318100: Remove redundant check for Metal support
Reviewed-by: prr, dnguyen
1 parent f1dfdc1 commit 5ce718e

File tree

3 files changed

+1
-40
lines changed

3 files changed

+1
-40
lines changed
 

‎src/java.desktop/macosx/classes/sun/java2d/MacOSFlags.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,7 @@ private static void initJavaFlags() {
125125
System.out.println("Could not enable OpenGL pipeline (CGL not available)");
126126
}
127127
oglEnabled = false;
128-
metalEnabled = MTLGraphicsConfig.isMetalAvailable();
129-
}
130-
} else if (metalEnabled && !oglEnabled) {
131-
// Check whether Metal framework is available
132-
if (!MTLGraphicsConfig.isMetalAvailable()) {
133-
if (metalVerbose) {
134-
System.out.println("Could not enable Metal pipeline (Metal framework not available)");
135-
}
136-
metalEnabled = false;
137-
oglEnabled = CGLGraphicsConfig.isCGLAvailable();
128+
metalEnabled = true;
138129
}
139130
}
140131

‎src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java

-14
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
public final class MTLGraphicsConfig extends CGraphicsConfig
7373
implements AccelGraphicsConfig, SurfaceManager.ProxiedGraphicsConfig
7474
{
75-
private static boolean mtlAvailable;
7675
private static ImageCapabilities imageCaps = new MTLImageCaps();
7776

7877
@SuppressWarnings("removal")
@@ -89,7 +88,6 @@ public final class MTLGraphicsConfig extends CGraphicsConfig
8988
private final Object disposerReferent = new Object();
9089
private final int maxTextureSize;
9190

92-
private static native boolean isMetalFrameworkAvailable();
9391
private static native boolean tryLoadMetalLibrary(int displayID, String shaderLib);
9492
private static native long getMTLConfigInfo(int displayID, String mtlShadersLib);
9593

@@ -99,10 +97,6 @@ public final class MTLGraphicsConfig extends CGraphicsConfig
9997
*/
10098
private static native int nativeGetMaxTextureSize();
10199

102-
static {
103-
mtlAvailable = isMetalFrameworkAvailable();
104-
}
105-
106100
private MTLGraphicsConfig(CGraphicsDevice device,
107101
long configInfo, int maxTextureSize,
108102
ContextCapabilities mtlCaps) {
@@ -133,10 +127,6 @@ public SurfaceData createManagedSurface(int w, int h, int transparency) {
133127
public static MTLGraphicsConfig getConfig(CGraphicsDevice device,
134128
int displayID)
135129
{
136-
if (!mtlAvailable) {
137-
return null;
138-
}
139-
140130
if (!tryLoadMetalLibrary(displayID, mtlShadersLib)) {
141131
return null;
142132
}
@@ -171,10 +161,6 @@ public static MTLGraphicsConfig getConfig(CGraphicsDevice device,
171161
return new MTLGraphicsConfig(device, cfginfo, textureSize, caps);
172162
}
173163

174-
public static boolean isMetalAvailable() {
175-
return mtlAvailable;
176-
}
177-
178164
/**
179165
* Returns true if the provided capability bit is present for this config.
180166
* See MTLContext.java for a list of supported capabilities.

‎src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGraphicsConfig.m

-16
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,6 @@
5454
free(mtlinfo);
5555
}
5656

57-
JNIEXPORT jboolean JNICALL
58-
Java_sun_java2d_metal_MTLGraphicsConfig_isMetalFrameworkAvailable
59-
(JNIEnv *env, jclass mtlgc)
60-
{
61-
jboolean metalSupported = JNI_FALSE;
62-
63-
// It is guaranteed that metal supported GPU is available since macOS 10.14
64-
if (@available(macOS 10.14, *)) {
65-
metalSupported = JNI_TRUE;
66-
}
67-
68-
J2dRlsTraceLn1(J2D_TRACE_INFO, "MTLGraphicsConfig_isMetalFrameworkAvailable : %d", metalSupported);
69-
70-
return metalSupported;
71-
}
72-
7357
JNIEXPORT jboolean JNICALL
7458
Java_sun_java2d_metal_MTLGraphicsConfig_tryLoadMetalLibrary
7559
(JNIEnv *env, jclass mtlgc, jint displayID, jstring shadersLibName)

0 commit comments

Comments
 (0)
Please sign in to comment.