8318100: Remove redundant check for Metal support

Reviewed-by: prr, dnguyen
This commit is contained in:
Jayathirth D V 2023-10-25 04:01:59 +00:00
parent f1dfdc1a79
commit 5ce718eb17
3 changed files with 1 additions and 40 deletions

View File

@ -125,16 +125,7 @@ public class MacOSFlags {
System.out.println("Could not enable OpenGL pipeline (CGL not available)");
}
oglEnabled = false;
metalEnabled = MTLGraphicsConfig.isMetalAvailable();
}
} else if (metalEnabled && !oglEnabled) {
// Check whether Metal framework is available
if (!MTLGraphicsConfig.isMetalAvailable()) {
if (metalVerbose) {
System.out.println("Could not enable Metal pipeline (Metal framework not available)");
}
metalEnabled = false;
oglEnabled = CGLGraphicsConfig.isCGLAvailable();
metalEnabled = true;
}
}

View File

@ -72,7 +72,6 @@ import static sun.java2d.metal.MTLContext.MTLContextCaps.CAPS_EXT_BIOP_SHADER;
public final class MTLGraphicsConfig extends CGraphicsConfig
implements AccelGraphicsConfig, SurfaceManager.ProxiedGraphicsConfig
{
private static boolean mtlAvailable;
private static ImageCapabilities imageCaps = new MTLImageCaps();
@SuppressWarnings("removal")
@ -89,7 +88,6 @@ public final class MTLGraphicsConfig extends CGraphicsConfig
private final Object disposerReferent = new Object();
private final int maxTextureSize;
private static native boolean isMetalFrameworkAvailable();
private static native boolean tryLoadMetalLibrary(int displayID, String shaderLib);
private static native long getMTLConfigInfo(int displayID, String mtlShadersLib);
@ -99,10 +97,6 @@ public final class MTLGraphicsConfig extends CGraphicsConfig
*/
private static native int nativeGetMaxTextureSize();
static {
mtlAvailable = isMetalFrameworkAvailable();
}
private MTLGraphicsConfig(CGraphicsDevice device,
long configInfo, int maxTextureSize,
ContextCapabilities mtlCaps) {
@ -133,10 +127,6 @@ public final class MTLGraphicsConfig extends CGraphicsConfig
public static MTLGraphicsConfig getConfig(CGraphicsDevice device,
int displayID)
{
if (!mtlAvailable) {
return null;
}
if (!tryLoadMetalLibrary(displayID, mtlShadersLib)) {
return null;
}
@ -171,10 +161,6 @@ public final class MTLGraphicsConfig extends CGraphicsConfig
return new MTLGraphicsConfig(device, cfginfo, textureSize, caps);
}
public static boolean isMetalAvailable() {
return mtlAvailable;
}
/**
* Returns true if the provided capability bit is present for this config.
* See MTLContext.java for a list of supported capabilities.

View File

@ -54,22 +54,6 @@ MTLGC_DestroyMTLGraphicsConfig(jlong pConfigInfo)
free(mtlinfo);
}
JNIEXPORT jboolean JNICALL
Java_sun_java2d_metal_MTLGraphicsConfig_isMetalFrameworkAvailable
(JNIEnv *env, jclass mtlgc)
{
jboolean metalSupported = JNI_FALSE;
// It is guaranteed that metal supported GPU is available since macOS 10.14
if (@available(macOS 10.14, *)) {
metalSupported = JNI_TRUE;
}
J2dRlsTraceLn1(J2D_TRACE_INFO, "MTLGraphicsConfig_isMetalFrameworkAvailable : %d", metalSupported);
return metalSupported;
}
JNIEXPORT jboolean JNICALL
Java_sun_java2d_metal_MTLGraphicsConfig_tryLoadMetalLibrary
(JNIEnv *env, jclass mtlgc, jint displayID, jstring shadersLibName)