Skip to content

Commit

Permalink
Merge pull request #94943 from bruvzg/arm64_gl_switch
Browse files Browse the repository at this point in the history
[Windows] Improve OpenGL/ANGLE switching on ARM64.
  • Loading branch information
akien-mga committed Jul 30, 2024
2 parents 862d881 + ad0ab2f commit 3e0c10d
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions platform/windows/display_server_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
bool fallback = GLOBAL_GET("rendering/gl_compatibility/fallback_to_angle");
bool show_warning = true;

if (rendering_driver == "opengl3") {
rendering_driver = "opengl3_angle";
// 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
}
#elif defined(EGL_STATIC)
bool fallback = GLOBAL_GET("rendering/gl_compatibility/fallback_to_angle");

if (fallback && (rendering_driver == "opengl3")) {
Dictionary gl_info = detect_wgl();

Expand All @@ -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);
Expand Down

0 comments on commit 3e0c10d

Please sign in to comment.