feat: updated engine version to 4.4-rc1

This commit is contained in:
Sara 2025-02-23 14:38:14 +01:00
parent ee00efde1f
commit 21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python
from misc.utility.scons_hints import *
Import("env")

View file

@ -30,6 +30,10 @@
#include "egl_manager.h"
#include "core/crypto/crypto_core.h"
#include "core/io/dir_access.h"
#include "drivers/gles3/rasterizer_gles3.h"
#ifdef EGL_ENABLED
#if defined(EGL_STATIC)
@ -51,6 +55,16 @@ extern "C" EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT(EGLenum platfo
#define GLAD_EGL_EXT_platform_base 0
#endif
#ifdef WINDOWS_ENABLED
// Unofficial ANGLE extension: EGL_ANGLE_surface_orientation
#ifndef EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE
#define EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE 0x33A7
#define EGL_SURFACE_ORIENTATION_ANGLE 0x33A8
#define EGL_SURFACE_ORIENTATION_INVERT_X_ANGLE 0x0001
#define EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE 0x0002
#endif
#endif
// Creates and caches a GLDisplay. Returns -1 on error.
int EGLManager::_get_gldisplay_id(void *p_display) {
// Look for a cached GLDisplay.
@ -115,6 +129,18 @@ int EGLManager::_get_gldisplay_id(void *p_display) {
}
#endif
#ifdef WINDOWS_ENABLED
String client_extensions_string = eglQueryString(new_gldisplay.egl_display, EGL_EXTENSIONS);
if (eglGetError() == EGL_SUCCESS) {
Vector<String> egl_extensions = client_extensions_string.split(" ");
if (egl_extensions.has("EGL_ANGLE_surface_orientation")) {
new_gldisplay.has_EGL_ANGLE_surface_orientation = true;
print_verbose("EGL: EGL_ANGLE_surface_orientation is supported.");
}
}
#endif
displays.push_back(new_gldisplay);
// Return the new GLDisplay's ID.
@ -237,8 +263,29 @@ Error EGLManager::window_create(DisplayServer::WindowID p_window_id, void *p_dis
GLWindow &glwindow = windows[p_window_id];
glwindow.gldisplay_id = gldisplay_id;
Vector<EGLAttrib> egl_attribs;
#ifdef WINDOWS_ENABLED
if (gldisplay.has_EGL_ANGLE_surface_orientation) {
EGLint optimal_orientation;
if (eglGetConfigAttrib(gldisplay.egl_display, gldisplay.egl_config, EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, &optimal_orientation)) {
// We only need to support inverting Y for optimizing ANGLE on D3D11.
if (optimal_orientation & EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE && !(optimal_orientation & EGL_SURFACE_ORIENTATION_INVERT_X_ANGLE)) {
egl_attribs.push_back(EGL_SURFACE_ORIENTATION_ANGLE);
egl_attribs.push_back(EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE);
}
} else {
ERR_PRINT(vformat("Failed to get EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, error: 0x%08X", eglGetError()));
}
}
if (!egl_attribs.is_empty()) {
egl_attribs.push_back(EGL_NONE);
}
#endif
if (GLAD_EGL_VERSION_1_5) {
glwindow.egl_surface = eglCreatePlatformWindowSurface(gldisplay.egl_display, gldisplay.egl_config, p_native_window, nullptr);
glwindow.egl_surface = eglCreatePlatformWindowSurface(gldisplay.egl_display, gldisplay.egl_config, p_native_window, egl_attribs.ptr());
} else {
EGLNativeWindowType *native_window_type = (EGLNativeWindowType *)p_native_window;
glwindow.egl_surface = eglCreateWindowSurface(gldisplay.egl_display, gldisplay.egl_config, *native_window_type, nullptr);
@ -250,6 +297,20 @@ Error EGLManager::window_create(DisplayServer::WindowID p_window_id, void *p_dis
glwindow.initialized = true;
#ifdef WINDOWS_ENABLED
if (gldisplay.has_EGL_ANGLE_surface_orientation) {
EGLint orientation;
if (eglQuerySurface(gldisplay.egl_display, glwindow.egl_surface, EGL_SURFACE_ORIENTATION_ANGLE, &orientation)) {
if (orientation & EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE && !(orientation & EGL_SURFACE_ORIENTATION_INVERT_X_ANGLE)) {
glwindow.flipped_y = true;
print_verbose("EGL: Using optimal surface orientation: Invert Y");
}
} else {
ERR_PRINT(vformat("Failed to get EGL_SURFACE_ORIENTATION_ANGLE, error: 0x%08X", eglGetError()));
}
}
#endif
window_make_current(p_window_id);
return OK;
@ -316,6 +377,10 @@ void EGLManager::window_make_current(DisplayServer::WindowID p_window_id) {
GLDisplay &current_display = displays[current_window->gldisplay_id];
eglMakeCurrent(current_display.egl_display, current_window->egl_surface, current_window->egl_surface, current_display.egl_context);
#ifdef WINDOWS_ENABLED
RasterizerGLES3::set_screen_flipped_y(glwindow.flipped_y);
#endif
}
void EGLManager::set_use_vsync(bool p_use) {
@ -351,13 +416,37 @@ EGLContext EGLManager::get_context(DisplayServer::WindowID p_window_id) {
return display.egl_context;
}
EGLDisplay EGLManager::get_display(DisplayServer::WindowID p_window_id) {
GLWindow &glwindow = windows[p_window_id];
if (!glwindow.initialized) {
return EGL_NO_CONTEXT;
}
GLDisplay &display = displays[glwindow.gldisplay_id];
return display.egl_display;
}
EGLConfig EGLManager::get_config(DisplayServer::WindowID p_window_id) {
GLWindow &glwindow = windows[p_window_id];
if (!glwindow.initialized) {
return nullptr;
}
GLDisplay &display = displays[glwindow.gldisplay_id];
return display.egl_config;
}
Error EGLManager::initialize(void *p_native_display) {
#if defined(GLAD_ENABLED) && !defined(EGL_STATIC)
// Loading EGL with a new display gets us just the bare minimum API. We'll then
// have to temporarily get a proper display and reload EGL once again to
// initialize everything else.
if (!gladLoaderLoadEGL(EGL_NO_DISPLAY)) {
ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Can't load EGL.");
ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Can't load EGL dynamic library.");
}
EGLDisplay tmp_display = EGL_NO_DISPLAY;
@ -387,7 +476,7 @@ Error EGLManager::initialize(void *p_native_display) {
int version = gladLoaderLoadEGL(tmp_display);
if (!version) {
eglTerminate(tmp_display);
ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Can't load EGL.");
ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Can't load EGL dynamic library.");
}
int major = GLAD_VERSION_MAJOR(version);

View file

@ -36,10 +36,6 @@
// These must come first to avoid windows.h mess.
#include "platform_gl.h"
#include "core/config/project_settings.h"
#include "core/crypto/crypto_core.h"
#include "core/io/dir_access.h"
#include "core/io/file_access.h"
#include "core/templates/local_vector.h"
#include "servers/display_server.h"
@ -53,11 +49,18 @@ private:
EGLDisplay egl_display = EGL_NO_DISPLAY;
EGLContext egl_context = EGL_NO_CONTEXT;
EGLConfig egl_config = nullptr;
#ifdef WINDOWS_ENABLED
bool has_EGL_ANGLE_surface_orientation = false;
#endif
};
// EGL specific window data.
struct GLWindow {
bool initialized = false;
#ifdef WINDOWS_ENABLED
bool flipped_y = false;
#endif
// An handle to the GLDisplay associated with this window.
int gldisplay_id = -1;
@ -106,6 +109,8 @@ public:
bool is_using_vsync() const;
EGLContext get_context(DisplayServer::WindowID p_window_id);
EGLDisplay get_display(DisplayServer::WindowID p_window_id);
EGLConfig get_config(DisplayServer::WindowID p_window_id);
Error initialize(void *p_native_display = nullptr);