Merge pull request #94943 from bruvzg/arm64_gl_switch

[Windows] Improve OpenGL/ANGLE switching on ARM64.
This commit is contained in:
Rémi Verschelde 2024-07-30 12:29:13 +02:00
commit 3e0c10d393
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 28 additions and 8 deletions

View File

@ -5984,13 +5984,32 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
// Init context and rendering device
#if defined(GLES3_ENABLED)
#if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64)
// There's no native OpenGL drivers on Windows for ARM, switch to ANGLE over DX.
if (rendering_driver == "opengl3") {
rendering_driver = "opengl3_angle";
}
#elif defined(EGL_STATIC)
bool fallback = GLOBAL_GET("rendering/gl_compatibility/fallback_to_angle");
bool show_warning = true;
if (rendering_driver == "opengl3") {
// There's no native OpenGL drivers on Windows for ARM, always enable fallback.
#if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64)
fallback = true;
show_warning = false;
#else
typedef BOOL(WINAPI * IsWow64Process2Ptr)(HANDLE, USHORT *, USHORT *);
IsWow64Process2Ptr IsWow64Process2 = (IsWow64Process2Ptr)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process2");
if (IsWow64Process2) {
USHORT process_arch = 0;
USHORT machine_arch = 0;
if (!IsWow64Process2(GetCurrentProcess(), &process_arch, &machine_arch)) {
machine_arch = 0;
}
if (machine_arch == 0xAA64) {
fallback = true;
show_warning = false;
}
}
#endif
}
if (fallback && (rendering_driver == "opengl3")) {
Dictionary gl_info = detect_wgl();
@ -6016,11 +6035,12 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
}
if (force_angle || (gl_info["version"].operator int() < 30003)) {
WARN_PRINT("Your video card drivers seem not to support the required OpenGL 3.3 version, switching to ANGLE.");
if (show_warning) {
WARN_PRINT("Your video card drivers seem not to support the required OpenGL 3.3 version, switching to ANGLE.");
}
rendering_driver = "opengl3_angle";
}
}
#endif
if (rendering_driver == "opengl3") {
gl_manager_native = memnew(GLManagerNative_Windows);