-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
功能[使用系统Vulkan驱动程序]: 强制检测设备为"AdrenoGPU"的用户在打开"使用系统Vulkan驱动"选项时进行二次确认
- Loading branch information
1 parent
305ba40
commit 826b338
Showing
5 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
app_pojavlauncher/src/main/java/com/firefly/utils/PGWTools.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.firefly.utils; | ||
|
||
import android.opengl.EGL14; | ||
import android.opengl.EGLConfig; | ||
import android.opengl.EGLContext; | ||
import android.opengl.EGLDisplay; | ||
import android.opengl.GLES20; | ||
import android.util.Log; | ||
|
||
public class PGWTools { | ||
|
||
public static boolean isAdrenoGPU() { | ||
EGLDisplay eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); | ||
if (eglDisplay == EGL14.EGL_NO_DISPLAY) { | ||
Log.e("CheckVendor", "Failed to get EGL display"); | ||
return false; | ||
} | ||
|
||
if (!EGL14.eglInitialize(eglDisplay, null, 0, null, 0)) { | ||
Log.e("CheckVendor", "Failed to initialize EGL"); | ||
return false; | ||
} | ||
|
||
int[] eglAttributes = new int[]{ | ||
EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, | ||
EGL14.EGL_NONE | ||
}; | ||
|
||
EGLConfig[] configs = new EGLConfig[1]; | ||
int[] numConfigs = new int[1]; | ||
if (!EGL14.eglChooseConfig(eglDisplay, eglAttributes, 0, configs, 0, 1, numConfigs, 0) || numConfigs[0] == 0) { | ||
EGL14.eglTerminate(eglDisplay); | ||
Log.e("CheckVendor", "Failed to choose EGL config"); | ||
return false; | ||
} | ||
|
||
int[] contextAttributes = new int[]{ | ||
EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, // OpenGL ES 2.0 | ||
EGL14.EGL_NONE | ||
}; | ||
|
||
EGLContext context = EGL14.eglCreateContext(eglDisplay, configs[0], EGL14.EGL_NO_CONTEXT, contextAttributes, 0); | ||
if (context == EGL14.EGL_NO_CONTEXT) { | ||
EGL14.eglTerminate(eglDisplay); | ||
Log.e("CheckVendor", "Failed to create EGL context"); | ||
return false; | ||
} | ||
|
||
if (!EGL14.eglMakeCurrent(eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, context)) { | ||
EGL14.eglDestroyContext(eglDisplay, context); | ||
EGL14.eglTerminate(eglDisplay); | ||
Log.e("CheckVendor", "Failed to make EGL context current"); | ||
return false; | ||
} | ||
|
||
String vendor = GLES20.glGetString(GLES20.GL_VENDOR); | ||
String renderer = GLES20.glGetString(GLES20.GL_RENDERER); | ||
boolean isAdreno = (vendor != null && renderer != null && | ||
vendor.equalsIgnoreCase("Qualcomm") && | ||
renderer.toLowerCase().contains("adreno")); | ||
|
||
// Cleanup | ||
EGL14.eglMakeCurrent(eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT); | ||
EGL14.eglDestroyContext(eglDisplay, context); | ||
EGL14.eglTerminate(eglDisplay); | ||
|
||
Log.d("CheckVendor", "Running on Adreno GPU: " + isAdreno); | ||
return isAdreno; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters