diff --git a/core/extension/godot_instance.h b/core/extension/godot_instance.h index e3fa6bf2c7dd..ed7d4c77536e 100644 --- a/core/extension/godot_instance.h +++ b/core/extension/godot_instance.h @@ -52,6 +52,8 @@ class GodotInstanceCallbacks { virtual void focus_in(GodotInstance *p_instance) {} virtual void pause(GodotInstance *p_instance) {} virtual void resume(GodotInstance *p_instance) {} + + virtual ~GodotInstanceCallbacks() {} }; class TaskExecutor { diff --git a/core/object/object.cpp b/core/object/object.cpp index 372b71d9989e..d231b6e31645 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -170,32 +170,32 @@ MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) { uint32_t MethodInfo::get_compatibility_hash() const { bool has_return = (return_val.type != Variant::NIL) || (return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT); - uint32_t hash = hash_murmur3_one_32(has_return); - hash = hash_murmur3_one_32(arguments.size(), hash); + uint32_t compat_hash = hash_murmur3_one_32(has_return); + compat_hash = hash_murmur3_one_32(arguments.size(), compat_hash); if (has_return) { - hash = hash_murmur3_one_32(return_val.type, hash); + compat_hash = hash_murmur3_one_32(return_val.type, compat_hash); if (return_val.class_name != StringName()) { - hash = hash_murmur3_one_32(return_val.class_name.hash(), hash); + compat_hash = hash_murmur3_one_32(return_val.class_name.hash(), compat_hash); } } for (const PropertyInfo &arg : arguments) { - hash = hash_murmur3_one_32(arg.type, hash); + compat_hash = hash_murmur3_one_32(arg.type, compat_hash); if (arg.class_name != StringName()) { - hash = hash_murmur3_one_32(arg.class_name.hash(), hash); + compat_hash = hash_murmur3_one_32(arg.class_name.hash(), compat_hash); } } - hash = hash_murmur3_one_32(default_arguments.size(), hash); + compat_hash = hash_murmur3_one_32(default_arguments.size(), compat_hash); for (const Variant &v : default_arguments) { - hash = hash_murmur3_one_32(v.hash(), hash); + compat_hash = hash_murmur3_one_32(v.hash(), compat_hash); } - hash = hash_murmur3_one_32(flags & METHOD_FLAG_CONST ? 1 : 0, hash); - hash = hash_murmur3_one_32(flags & METHOD_FLAG_VARARG ? 1 : 0, hash); + compat_hash = hash_murmur3_one_32(flags & METHOD_FLAG_CONST ? 1 : 0, compat_hash); + compat_hash = hash_murmur3_one_32(flags & METHOD_FLAG_VARARG ? 1 : 0, compat_hash); - return hash_fmix32(hash); + return hash_fmix32(compat_hash); } Object::Connection::operator Variant() const { diff --git a/core/os/mutex.h b/core/os/mutex.h index c650d842ec89..bbfbedac5f66 100644 --- a/core/os/mutex.h +++ b/core/os/mutex.h @@ -37,6 +37,7 @@ #define MINGW_STDTHREAD_REDUNDANCY_WARNING #include "thirdparty/mingw-std-threads/mingw.mutex.h" #define THREADING_NAMESPACE mingw_stdthread +#undef MemoryBarrier // override from Windows SDK, clashes with RenderingDeviceDriver::MemoryBarrier #else #include #define THREADING_NAMESPACE std diff --git a/core/typedefs.h b/core/typedefs.h index 7802b727166d..b9833216da9f 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -91,7 +91,7 @@ static_assert(__cplusplus >= 201703L); #undef Error #undef OK #undef CONNECT_DEFERRED // override from Windows SDK, clashes with Object enum -#undef MemoryBarrier +#undef MemoryBarrier // override from Windows SDK, clashes with RenderingDeviceDriver::MemoryBarrier #undef MONO_FONT #endif diff --git a/doc/classes/DisplayServerEmbedded.xml b/doc/classes/DisplayServerEmbedded.xml new file mode 100644 index 000000000000..5e0ce5a605f7 --- /dev/null +++ b/doc/classes/DisplayServerEmbedded.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/classes/GDExtensionManager.xml b/doc/classes/GDExtensionManager.xml index 97d2d08752bc..bf5170bab769 100644 --- a/doc/classes/GDExtensionManager.xml +++ b/doc/classes/GDExtensionManager.xml @@ -39,6 +39,13 @@ Loads an extension by absolute file path. The [param path] needs to point to a valid [GDExtension]. Returns [constant LOAD_STATUS_OK] if successful. + + + + + + + diff --git a/doc/classes/GodotInstance.xml b/doc/classes/GodotInstance.xml new file mode 100644 index 000000000000..60a4092d8c6c --- /dev/null +++ b/doc/classes/GodotInstance.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/classes/RenderingNativeSurface.xml b/doc/classes/RenderingNativeSurface.xml new file mode 100644 index 000000000000..7f3cbdbd5ada --- /dev/null +++ b/doc/classes/RenderingNativeSurface.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/doc/classes/RenderingNativeSurfaceVulkan.xml b/doc/classes/RenderingNativeSurfaceVulkan.xml new file mode 100644 index 000000000000..4a15cdf965d7 --- /dev/null +++ b/doc/classes/RenderingNativeSurfaceVulkan.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/doc/classes/RenderingNativeSurfaceWayland.xml b/doc/classes/RenderingNativeSurfaceWayland.xml new file mode 100644 index 000000000000..ca3146c2f4df --- /dev/null +++ b/doc/classes/RenderingNativeSurfaceWayland.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/doc/classes/RenderingNativeSurfaceX11.xml b/doc/classes/RenderingNativeSurfaceX11.xml new file mode 100644 index 000000000000..3f7a7a0f2a83 --- /dev/null +++ b/doc/classes/RenderingNativeSurfaceX11.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml index 90eba0bdea85..de689d720553 100644 --- a/doc/classes/Window.xml +++ b/doc/classes/Window.xml @@ -114,6 +114,11 @@ Returns layout direction and text writing direction. + + + + + @@ -536,6 +541,12 @@ Sets layout direction and text writing direction. Right-to-left layouts are necessary for certain languages (e.g. Arabic and Hebrew). + + + + + + diff --git a/drivers/d3d12/rendering_context_driver_d3d12.cpp b/drivers/d3d12/rendering_context_driver_d3d12.cpp index cb242266d168..4d2d6c381267 100644 --- a/drivers/d3d12/rendering_context_driver_d3d12.cpp +++ b/drivers/d3d12/rendering_context_driver_d3d12.cpp @@ -35,6 +35,7 @@ #include "core/string/ustring.h" #include "core/templates/local_vector.h" #include "core/version.h" +#include "platform/windows/rendering_native_surface_windows.h" #include "servers/rendering/rendering_device.h" #if defined(__GNUC__) && !defined(__clang__) diff --git a/drivers/d3d12/rendering_device_driver_d3d12.h b/drivers/d3d12/rendering_device_driver_d3d12.h index 50d0f2cddf84..d9cb82a4217e 100644 --- a/drivers/d3d12/rendering_device_driver_d3d12.h +++ b/drivers/d3d12/rendering_device_driver_d3d12.h @@ -64,10 +64,7 @@ #include -#if defined(_MSC_VER) && defined(MemoryBarrier) -// Annoying define from winnt.h. Reintroduced by some of the headers above. -#undef MemoryBarrier -#endif +#undef MemoryBarrier // override from Windows SDK, clashes with RenderingDeviceDriver::MemoryBarrier #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index cd77d91f0a7c..b2904de1f661 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -464,19 +464,19 @@ void RasterizerGLES3::blit_render_targets_to_screen(DisplayServer::WindowID p_sc } } -void RasterizerGLES3::set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, DisplayServer::WindowID p_screen, bool p_use_filter) { +void RasterizerGLES3::set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter) { if (p_image.is_null() || p_image->is_empty()) { return; } - Size2i win_size = DisplayServer::get_singleton()->window_get_size(p_screen); + Size2i win_size = DisplayServer::get_singleton()->window_get_size(); if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { // This is currently needed for GLES to keep the current window being rendered to up to date - DisplayServer::get_singleton()->gl_window_make_current(p_screen); + DisplayServer::get_singleton()->gl_window_make_current(DisplayServer::MAIN_WINDOW_ID); } - glBindFramebuffer(GL_FRAMEBUFFER, DisplayServer::get_singleton()->window_get_native_handle(DisplayServer::OPENGL_FBO, p_screen)); + glBindFramebuffer(GL_FRAMEBUFFER, DisplayServer::get_singleton()->window_get_native_handle(DisplayServer::OPENGL_FBO)); glViewport(0, 0, win_size.width, win_size.height); glEnable(GL_BLEND); glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE); diff --git a/drivers/gles3/rasterizer_gles3.h b/drivers/gles3/rasterizer_gles3.h index e00a366ac631..abda2a5e0628 100644 --- a/drivers/gles3/rasterizer_gles3.h +++ b/drivers/gles3/rasterizer_gles3.h @@ -98,7 +98,7 @@ class RasterizerGLES3 : public RendererCompositor { RendererCanvasRender *get_canvas() { return canvas; } RendererSceneRender *get_scene() { return scene; } - void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, DisplayServer::WindowID p_screen, bool p_use_filter = true); + void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true); void initialize(); void begin_frame(double frame_step); diff --git a/drivers/gles3/storage/utilities.h b/drivers/gles3/storage/utilities.h index d7493fb487fd..68216d6d0d75 100644 --- a/drivers/gles3/storage/utilities.h +++ b/drivers/gles3/storage/utilities.h @@ -47,7 +47,7 @@ class FramebufferBinding { FramebufferBinding(GLenum p_target, GLuint p_framebuffer, bool p_bind) { target = p_target; - GLenum binding_target; + GLenum binding_target = 0; switch (p_target) { case GL_FRAMEBUFFER: binding_target = GL_FRAMEBUFFER_BINDING; diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp index 68473275c912..b957b1d35564 100644 --- a/drivers/register_driver_types.cpp +++ b/drivers/register_driver_types.cpp @@ -40,6 +40,8 @@ static Ref image_loader_png; static Ref resource_saver_png; void register_core_driver_types() { + GDREGISTER_ABSTRACT_CLASS(RenderingNativeSurface) + #ifdef VULKAN_ENABLED GDREGISTER_ABSTRACT_CLASS(RenderingNativeSurfaceVulkan) #endif diff --git a/drivers/vulkan/rendering_context_driver_vulkan.cpp b/drivers/vulkan/rendering_context_driver_vulkan.cpp index 4d4d0454b675..6c70e5842a60 100644 --- a/drivers/vulkan/rendering_context_driver_vulkan.cpp +++ b/drivers/vulkan/rendering_context_driver_vulkan.cpp @@ -971,7 +971,7 @@ void RenderingContextDriverVulkan::driver_free(RenderingDeviceDriver *p_driver) RenderingContextDriver::SurfaceID RenderingContextDriverVulkan::surface_create(Ref p_native_surface) { Ref vulkan_native_surface = Object::cast_to(*p_native_surface); - ERR_FAIL_COND_V(vulkan_native_surface == nullptr, SurfaceID()); + ERR_FAIL_COND_V(vulkan_native_surface.is_null(), SurfaceID()); Surface *surface = memnew(Surface); surface->vk_surface = vulkan_native_surface->get_vulkan_surface(); diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp index 7d8234a590f8..bf8c3ae61b72 100644 --- a/platform/android/display_server_android.cpp +++ b/platform/android/display_server_android.cpp @@ -33,6 +33,7 @@ #include "java_godot_io_wrapper.h" #include "java_godot_wrapper.h" #include "os_android.h" +#include "rendering_native_surface_android.h" #include "tts_android.h" #include "core/config/project_settings.h" diff --git a/platform/android/rendering_context_driver_vulkan_android.cpp b/platform/android/rendering_context_driver_vulkan_android.cpp index 522024d7d6a4..271825266edf 100644 --- a/platform/android/rendering_context_driver_vulkan_android.cpp +++ b/platform/android/rendering_context_driver_vulkan_android.cpp @@ -46,7 +46,7 @@ RenderingContextDriver::SurfaceID RenderingContextDriverVulkanAndroid::surface_c VkAndroidSurfaceCreateInfoKHR create_info = {}; create_info.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR; - create_info.window = wpd->window; + create_info.window = android_native_surface->get_window(); VkSurfaceKHR vk_surface = VK_NULL_HANDLE; VkResult err = vkCreateAndroidSurfaceKHR(instance_get(), &create_info, get_allocation_callbacks(VK_OBJECT_TYPE_SURFACE_KHR), &vk_surface); @@ -54,7 +54,7 @@ RenderingContextDriver::SurfaceID RenderingContextDriverVulkanAndroid::surface_c Ref vulkan_surface = RenderingNativeSurfaceVulkan::create(vk_surface); RenderingContextDriver::SurfaceID result = RenderingContextDriverVulkan::surface_create(vulkan_surface); - memdelete(vulkan_surface); + vulkan_surface = nullptr; return result; } diff --git a/platform/linuxbsd/wayland/SCsub b/platform/linuxbsd/wayland/SCsub index ace0acc61008..ebb8dea8de9e 100644 --- a/platform/linuxbsd/wayland/SCsub +++ b/platform/linuxbsd/wayland/SCsub @@ -3,6 +3,8 @@ from misc.utility.scons_hints import * Import("env") +base = "#platform/linuxbsd/wayland/" + # TODO: Add warning to headers and code about their autogenerated status. if env["use_sowrap"]: # We have to implement separate builders for so wrappers as the @@ -40,168 +42,169 @@ else: env.Append(BUILDERS=WAYLAND_BUILDERS) env.NoCache( - env.WAYLAND_API_HEADER("protocol/wayland.gen.h", "#thirdparty/wayland/protocol/wayland.xml"), - env.WAYLAND_API_CODE("protocol/wayland.gen.c", "#thirdparty/wayland/protocol/wayland.xml"), + env.WAYLAND_API_HEADER(base + "protocol/wayland.gen.h", "#thirdparty/wayland/protocol/wayland.xml"), + env.WAYLAND_API_CODE(base + "protocol/wayland.gen.c", "#thirdparty/wayland/protocol/wayland.xml"), env.WAYLAND_API_HEADER( - "protocol/viewporter.gen.h", "#thirdparty/wayland-protocols/stable/viewporter/viewporter.xml" + base + "protocol/viewporter.gen.h", "#thirdparty/wayland-protocols/stable/viewporter/viewporter.xml" + ), + env.WAYLAND_API_CODE( + base + "protocol/viewporter.gen.c", "#thirdparty/wayland-protocols/stable/viewporter/viewporter.xml" ), - env.WAYLAND_API_CODE("protocol/viewporter.gen.c", "#thirdparty/wayland-protocols/stable/viewporter/viewporter.xml"), env.WAYLAND_API_HEADER( - "protocol/fractional_scale.gen.h", + base + "protocol/fractional_scale.gen.h", "#thirdparty/wayland-protocols/staging/fractional-scale/fractional-scale-v1.xml", ), env.WAYLAND_API_CODE( - "protocol/fractional_scale.gen.c", + base + "protocol/fractional_scale.gen.c", "#thirdparty/wayland-protocols/staging/fractional-scale/fractional-scale-v1.xml", ), - env.WAYLAND_API_HEADER("protocol/xdg_shell.gen.h", "#thirdparty/wayland-protocols/stable/xdg-shell/xdg-shell.xml"), - env.WAYLAND_API_CODE("protocol/xdg_shell.gen.c", "#thirdparty/wayland-protocols/stable/xdg-shell/xdg-shell.xml"), env.WAYLAND_API_HEADER( - "protocol/xdg_decoration.gen.h", + base + "protocol/xdg_shell.gen.h", "#thirdparty/wayland-protocols/stable/xdg-shell/xdg-shell.xml" + ), + env.WAYLAND_API_CODE( + base + "protocol/xdg_shell.gen.c", "#thirdparty/wayland-protocols/stable/xdg-shell/xdg-shell.xml" + ), + env.WAYLAND_API_HEADER( + base + "protocol/xdg_decoration.gen.h", "#thirdparty/wayland-protocols/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml", ), env.WAYLAND_API_CODE( - "protocol/xdg_decoration.gen.c", + base + "protocol/xdg_decoration.gen.c", "#thirdparty/wayland-protocols/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml", ), env.WAYLAND_API_HEADER( - "protocol/xdg_activation.gen.h", + base + "protocol/xdg_activation.gen.h", "#thirdparty/wayland-protocols/staging/xdg-activation/xdg-activation-v1.xml", ), env.WAYLAND_API_CODE( - "protocol/xdg_activation.gen.c", + base + "protocol/xdg_activation.gen.c", "#thirdparty/wayland-protocols/staging/xdg-activation/xdg-activation-v1.xml", ), env.WAYLAND_API_HEADER( - "protocol/relative_pointer.gen.h", + base + "protocol/relative_pointer.gen.h", "#thirdparty/wayland-protocols/unstable/relative-pointer/relative-pointer-unstable-v1.xml", ), env.WAYLAND_API_CODE( - "protocol/relative_pointer.gen.c", + base + "protocol/relative_pointer.gen.c", "#thirdparty/wayland-protocols/unstable/relative-pointer/relative-pointer-unstable-v1.xml", ), env.WAYLAND_API_HEADER( - "protocol/pointer_constraints.gen.h", + base + "protocol/pointer_constraints.gen.h", "#thirdparty/wayland-protocols/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml", ), env.WAYLAND_API_CODE( - "protocol/pointer_constraints.gen.c", + base + "protocol/pointer_constraints.gen.c", "#thirdparty/wayland-protocols/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml", ), env.WAYLAND_API_HEADER( - "protocol/pointer_gestures.gen.h", + base + "protocol/pointer_gestures.gen.h", "#thirdparty/wayland-protocols/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml", ), env.WAYLAND_API_CODE( - "protocol/pointer_gestures.gen.c", + base + "protocol/pointer_gestures.gen.c", "#thirdparty/wayland-protocols/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml", ), env.WAYLAND_API_HEADER( - "protocol/primary_selection.gen.h", + base + "protocol/primary_selection.gen.h", "#thirdparty/wayland-protocols/unstable/primary-selection/primary-selection-unstable-v1.xml", ), env.WAYLAND_API_CODE( - "protocol/primary_selection.gen.c", + base + "protocol/primary_selection.gen.c", "#thirdparty/wayland-protocols/unstable/primary-selection/primary-selection-unstable-v1.xml", ), env.WAYLAND_API_HEADER( - "protocol/idle_inhibit.gen.h", + base + "protocol/idle_inhibit.gen.h", "#thirdparty/wayland-protocols/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml", ), env.WAYLAND_API_CODE( - "protocol/idle_inhibit.gen.c", + base + "protocol/idle_inhibit.gen.c", "#thirdparty/wayland-protocols/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml", ), env.WAYLAND_API_HEADER( - "protocol/tablet.gen.h", + base + "protocol/tablet.gen.h", "#thirdparty/wayland-protocols/unstable/tablet/tablet-unstable-v2.xml", ), env.WAYLAND_API_CODE( - "protocol/tablet.gen.c", + base + "protocol/tablet.gen.c", "#thirdparty/wayland-protocols/unstable/tablet/tablet-unstable-v2.xml", ), env.WAYLAND_API_HEADER( - "protocol/text_input.gen.h", + base + "protocol/text_input.gen.h", "#thirdparty/wayland-protocols/unstable/text-input/text-input-unstable-v3.xml", ), env.WAYLAND_API_CODE( - "protocol/text_input.gen.c", + base + "protocol/text_input.gen.c", "#thirdparty/wayland-protocols/unstable/text-input/text-input-unstable-v3.xml", ), env.WAYLAND_API_HEADER( - "protocol/xdg_foreign_v1.gen.h", + base + "protocol/xdg_foreign_v1.gen.h", "#thirdparty/wayland-protocols/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml", ), env.WAYLAND_API_CODE( - "protocol/xdg_foreign_v1.gen.c", + base + "protocol/xdg_foreign_v1.gen.c", "#thirdparty/wayland-protocols/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml", ), env.WAYLAND_API_HEADER( - "protocol/xdg_foreign_v2.gen.h", + base + "protocol/xdg_foreign_v2.gen.h", "#thirdparty/wayland-protocols/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml", ), env.WAYLAND_API_CODE( - "protocol/xdg_foreign_v2.gen.c", + base + "protocol/xdg_foreign_v2.gen.c", "#thirdparty/wayland-protocols/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml", ), env.WAYLAND_API_HEADER( - "protocol/xdg_system_bell.gen.h", + base + "protocol/xdg_system_bell.gen.h", "#thirdparty/wayland-protocols/staging/xdg-system-bell/xdg-system-bell-v1.xml", ), env.WAYLAND_API_CODE( - "protocol/xdg_system_bell.gen.c", + base + "protocol/xdg_system_bell.gen.c", "#thirdparty/wayland-protocols/staging/xdg-system-bell/xdg-system-bell-v1.xml", ), ) source_files = [ - "protocol/wayland.gen.c", - "protocol/viewporter.gen.c", - "protocol/fractional_scale.gen.c", - "protocol/xdg_shell.gen.c", - "protocol/xdg_system_bell.gen.c", - "protocol/xdg_foreign_v1.gen.c", - "protocol/xdg_foreign_v2.gen.c", - "protocol/xdg_decoration.gen.c", - "protocol/xdg_activation.gen.c", - "protocol/relative_pointer.gen.c", - "protocol/pointer_constraints.gen.c", - "protocol/pointer_gestures.gen.c", - "protocol/primary_selection.gen.c", - "protocol/idle_inhibit.gen.c", - "protocol/tablet.gen.c", - "protocol/text_input.gen.c", - "display_server_wayland.cpp", - "wayland_thread.cpp", - "key_mapping_xkb.cpp", - "detect_prime_egl.cpp", - "rendering_native_surface_wayland.cpp", + base + "protocol/wayland.gen.c", + base + "protocol/viewporter.gen.c", + base + "protocol/fractional_scale.gen.c", + base + "protocol/xdg_shell.gen.c", + base + "protocol/xdg_system_bell.gen.c", + base + "protocol/xdg_foreign_v1.gen.c", + base + "protocol/xdg_foreign_v2.gen.c", + base + "protocol/xdg_decoration.gen.c", + base + "protocol/xdg_activation.gen.c", + base + "protocol/relative_pointer.gen.c", + base + "protocol/pointer_constraints.gen.c", + base + "protocol/pointer_gestures.gen.c", + base + "protocol/primary_selection.gen.c", + base + "protocol/idle_inhibit.gen.c", + base + "protocol/tablet.gen.c", + base + "protocol/text_input.gen.c", + base + "display_server_wayland.cpp", + base + "wayland_thread.cpp", + base + "key_mapping_xkb.cpp", + base + "detect_prime_egl.cpp", + base + "rendering_native_surface_wayland.cpp", ] if env["use_sowrap"]: source_files.append( [ - "dynwrappers/wayland-cursor-so_wrap.c", - "dynwrappers/wayland-client-core-so_wrap.c", - "dynwrappers/wayland-egl-core-so_wrap.c", + base + "dynwrappers/wayland-cursor-so_wrap.c", + base + "dynwrappers/wayland-client-core-so_wrap.c", + base + "dynwrappers/wayland-egl-core-so_wrap.c", ] ) if env["libdecor"]: - source_files.append("dynwrappers/libdecor-so_wrap.c") + source_files.append(base + "dynwrappers/libdecor-so_wrap.c") if env["vulkan"]: - source_files.append("rendering_context_driver_vulkan_wayland.cpp") + source_files.append(base + "rendering_context_driver_vulkan_wayland.cpp") if env["opengl3"]: - source_files.append("egl_manager_wayland.cpp") - source_files.append("egl_manager_wayland_gles.cpp") - -objects = [] - -for source_file in source_files: - objects.append(env.Object(source_file)) + source_files.append(base + "egl_manager_wayland.cpp") + source_files.append(base + "egl_manager_wayland_gles.cpp") -Return("objects") +Return("source_files") diff --git a/platform/linuxbsd/wayland/display_server_wayland.cpp b/platform/linuxbsd/wayland/display_server_wayland.cpp index 709c050bcd51..060fff020c07 100644 --- a/platform/linuxbsd/wayland/display_server_wayland.cpp +++ b/platform/linuxbsd/wayland/display_server_wayland.cpp @@ -187,7 +187,7 @@ bool DisplayServerWayland::_show_window() { struct wl_surface *wl_surface = wayland_thread.window_get_wl_surface(wd.id); wd.wl_egl_window = wl_egl_window_create(wl_surface, wd.rect.size.width, wd.rect.size.height); - Error err = egl_manager->window_create(MAIN_WINDOW_ID, wayland_thread.get_wl_display(), wd.wl_egl_window, wd.rect.size.width, wd.rect.size.height); + err = egl_manager->window_create(MAIN_WINDOW_ID, wayland_thread.get_wl_display(), wd.wl_egl_window, wd.rect.size.width, wd.rect.size.height); ERR_FAIL_COND_V_MSG(err == ERR_CANT_CREATE, false, "Can't show a GLES3 window."); window_set_vsync_mode(wd.vsync_mode, MAIN_WINDOW_ID); diff --git a/platform/linuxbsd/x11/SCsub b/platform/linuxbsd/x11/SCsub index 0d2cbb29e3c4..73df5336d0d2 100644 --- a/platform/linuxbsd/x11/SCsub +++ b/platform/linuxbsd/x11/SCsub @@ -3,37 +3,39 @@ from misc.utility.scons_hints import * Import("env") +base = "#platform/linuxbsd/x11/" + source_files = [ - "display_server_x11.cpp", - "key_mapping_x11.cpp", - "rendering_native_surface_x11.cpp", + base + "display_server_x11.cpp", + base + "key_mapping_x11.cpp", + base + "rendering_native_surface_x11.cpp", ] if env["use_sowrap"]: source_files.append( [ - "dynwrappers/xlib-so_wrap.c", - "dynwrappers/xcursor-so_wrap.c", - "dynwrappers/xinerama-so_wrap.c", - "dynwrappers/xinput2-so_wrap.c", - "dynwrappers/xrandr-so_wrap.c", - "dynwrappers/xrender-so_wrap.c", - "dynwrappers/xext-so_wrap.c", + base + "dynwrappers/xlib-so_wrap.c", + base + "dynwrappers/xcursor-so_wrap.c", + base + "dynwrappers/xinerama-so_wrap.c", + base + "dynwrappers/xinput2-so_wrap.c", + base + "dynwrappers/xrandr-so_wrap.c", + base + "dynwrappers/xrender-so_wrap.c", + base + "dynwrappers/xext-so_wrap.c", ] ) if env["vulkan"]: - source_files.append("rendering_context_driver_vulkan_x11.cpp") + source_files.append(base + "rendering_context_driver_vulkan_x11.cpp") if env["opengl3"]: env.Append(CPPDEFINES=["GLAD_GLX_NO_X11"]) source_files.append( - ["gl_manager_x11_egl.cpp", "gl_manager_x11.cpp", "detect_prime_x11.cpp", "#thirdparty/glad/glx.c"] + [ + base + "gl_manager_x11_egl.cpp", + base + "gl_manager_x11.cpp", + base + "detect_prime_x11.cpp", + "#thirdparty/glad/glx.c", + ] ) -objects = [] - -for source_file in source_files: - objects.append(env.Object(source_file)) - -Return("objects") +Return("source_files") diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index e9c87a04c43f..6a177b0b7c25 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -6830,7 +6830,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode driver_found = true; } #endif -#endif + // Initialize context and rendering device. #if defined(GLES3_ENABLED) if (rendering_driver == "opengl3" || rendering_driver == "opengl3_es") { diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 0e47451d0cb5..662440be9312 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -32,6 +32,7 @@ #include "drop_target_windows.h" #include "os_windows.h" +#include "rendering_native_surface_windows.h" #include "wgl_detect_version.h" #include "core/config/project_settings.h" @@ -6254,7 +6255,7 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, #ifdef RD_ENABLED Ref windows_surface = nullptr; -#ifdef VULKAN_ENABLED || D3D12_ENABLED +#if defined(VULKAN_ENABLED) || defined(D3D12_ENABLED) if (rendering_driver == "vulkan" || rendering_driver == "d3d12") { windows_surface = RenderingNativeSurfaceWindows::create(wd.hWnd, hInstance); } @@ -6278,7 +6279,7 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, if (rendering_context->window_create(id, windows_surface) != OK) { ERR_PRINT(vformat("Failed to create %s window.", rendering_driver)); memdelete(rendering_context); - memdelete(windows_surface); + windows_surface = nullptr; rendering_context = nullptr; windows.erase(id); return INVALID_WINDOW_ID; @@ -6287,7 +6288,7 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, rendering_context->window_set_size(id, real_client_rect.right - real_client_rect.left, real_client_rect.bottom - real_client_rect.top); rendering_context->window_set_vsync_mode(id, p_vsync_mode); wd.context_created = true; - memdelete(windows_surface); + windows_surface = nullptr; } #endif diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index 4a6b51b59235..acc82f0a0fac 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -251,6 +251,8 @@ typedef UINT32 PEN_MASK; #define GET_POINTERID_WPARAM(wParam) (LOWORD(wParam)) #endif +#undef MemoryBarrier // override from Windows SDK, clashes with RenderingDeviceDriver::MemoryBarrier + #if WINVER < 0x0602 enum tagPOINTER_INPUT_TYPE { PT_POINTER = 0x00000001, diff --git a/platform/windows/native_menu_windows.h b/platform/windows/native_menu_windows.h index c23ac61fa258..35dd7f8fb370 100644 --- a/platform/windows/native_menu_windows.h +++ b/platform/windows/native_menu_windows.h @@ -38,6 +38,7 @@ #define WIN32_LEAN_AND_MEAN #include +#undef MemoryBarrier // override from Windows SDK, clashes with RenderingDeviceDriver::MemoryBarrier class NativeMenuWindows : public NativeMenu { GDCLASS(NativeMenuWindows, NativeMenu) diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index d9b8233e511e..aca52fbf4498 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -59,6 +59,8 @@ #include #include +#undef MemoryBarrier // override from Windows SDK, clashes with RenderingDeviceDriver::MemoryBarrier + #ifdef DEBUG_ENABLED // forward error messages to OutputDebugString #define WINDOWS_DEBUG_OUTPUT_ENABLED diff --git a/platform/windows/rendering_context_driver_vulkan_windows.cpp b/platform/windows/rendering_context_driver_vulkan_windows.cpp index e5bd7908e258..c119726ccb3a 100644 --- a/platform/windows/rendering_context_driver_vulkan_windows.cpp +++ b/platform/windows/rendering_context_driver_vulkan_windows.cpp @@ -33,8 +33,10 @@ #include "core/os/os.h" #include "rendering_context_driver_vulkan_windows.h" +#include "rendering_native_surface_windows.h" #include "drivers/vulkan/godot_vulkan.h" +#include "drivers/vulkan/rendering_native_surface_vulkan.h" const char *RenderingContextDriverVulkanWindows::_get_platform_surface_extension() const { return VK_KHR_WIN32_SURFACE_EXTENSION_NAME; @@ -64,7 +66,7 @@ RenderingContextDriver::SurfaceID RenderingContextDriverVulkanWindows::surface_c VkResult err = vkCreateWin32SurfaceKHR(instance_get(), &create_info, get_allocation_callbacks(VK_OBJECT_TYPE_SURFACE_KHR), &vk_surface); ERR_FAIL_COND_V(err != VK_SUCCESS, SurfaceID()); - Ref vulkan_surface = RenderingContextDriverVulkan::create(vk_surface); + Ref vulkan_surface = RenderingNativeSurfaceVulkan::create(vk_surface); RenderingContextDriver::SurfaceID result = RenderingContextDriverVulkan::surface_create(vulkan_surface); return result; } diff --git a/platform/windows/rendering_native_surface_windows.cpp b/platform/windows/rendering_native_surface_windows.cpp index 76ce67cdb801..b214ecc3a1e1 100644 --- a/platform/windows/rendering_native_surface_windows.cpp +++ b/platform/windows/rendering_native_surface_windows.cpp @@ -30,22 +30,27 @@ #include "rendering_native_surface_windows.h" +#include "rendering_context_driver_vulkan_windows.h" + +#include "core/os/memory.h" +#include "drivers/d3d12/rendering_context_driver_d3d12.h" + void RenderingNativeSurfaceWindows::_bind_methods() { ClassDB::bind_static_method("RenderingNativeSurfaceWindows", D_METHOD("create", "hwnd", "instance"), &RenderingNativeSurfaceWindows::create_api); } -Ref RenderingNativeSurfaceWindows::create(GDExtensionConstPtr p_window, GDExtensionConstPtr p_instance) { +Ref RenderingNativeSurfaceWindows::create_api(GDExtensionConstPtr p_window, GDExtensionConstPtr p_instance) { return RenderingNativeSurfaceWindows::create((HWND)p_window.operator const void *(), (HINSTANCE)p_instance.operator const void *()); } Ref RenderingNativeSurfaceWindows::create(HWND p_window, HINSTANCE p_instance) { Ref result = memnew(RenderingNativeSurfaceWindows); - result->window(p_window); - result->instance(p_instance); + result->window = p_window; + result->instance = p_instance; return result; } -RenderingContextDriver *RenderingNativeSurfaceWayland::create_rendering_context(const String &p_driver_name) { +RenderingContextDriver *RenderingNativeSurfaceWindows::create_rendering_context(const String &p_driver_name) { #if defined(VULKAN_ENABLED) if (p_driver_name == "vulkan") { return memnew(RenderingContextDriverVulkanWindows); diff --git a/platform/windows/rendering_native_surface_windows.h b/platform/windows/rendering_native_surface_windows.h index 466aaaea284d..945deb82cc2b 100644 --- a/platform/windows/rendering_native_surface_windows.h +++ b/platform/windows/rendering_native_surface_windows.h @@ -36,6 +36,7 @@ #define WIN32_LEAN_AND_MEAN #include +#undef MemoryBarrier // override from Windows SDK, clashes with RenderingDeviceDriver::MemoryBarrier class RenderingNativeSurfaceWindows : public RenderingNativeSurface { public: diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 5cdce5a9a26a..a1f1a1ff05eb 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -642,7 +642,7 @@ bool Window::is_in_edited_scene_root() const { void Window::_make_window() { ERR_FAIL_COND(window_id != DisplayServer::INVALID_WINDOW_ID); - if (native_surface != nullptr) { + if (native_surface.is_valid()) { window_id = DisplayServer::get_singleton()->create_native_window(native_surface); ERR_FAIL_COND(window_id == DisplayServer::INVALID_WINDOW_ID); @@ -715,7 +715,7 @@ void Window::_update_from_window() { void Window::_clear_window() { ERR_FAIL_COND(window_id == DisplayServer::INVALID_WINDOW_ID); - if (native_surface != nullptr) { + if (native_surface.is_valid()) { DisplayServer::get_singleton()->delete_native_window(window_id); window_id = DisplayServer::INVALID_WINDOW_ID; @@ -1364,7 +1364,7 @@ Viewport *Window::get_embedder() const { return nullptr; } - if (native_surface != nullptr) { + if (native_surface.is_valid()) { return nullptr; } diff --git a/servers/display_server.cpp b/servers/display_server.cpp index 6eeab997b28b..d92fee61c125 100644 --- a/servers/display_server.cpp +++ b/servers/display_server.cpp @@ -1343,7 +1343,7 @@ bool DisplayServer::is_rendering_device_supported() { Error err; -#if defined(WINDOWS_ENABLED) || defined(LINUXBSD_ENABLED) +#if defined(WINDOWS_ENABLED) || defined(LINUXBSD_ENABLED) && !defined(LIBGODOT_ENABLED) // On some drivers combining OpenGL and RenderingDevice can result in crash, offload the check to the subprocess. List arguments; arguments.push_back("--test-rd-support"); diff --git a/servers/display_server_embedded.cpp b/servers/display_server_embedded.cpp index 242b3b91d70d..9051175df8e7 100644 --- a/servers/display_server_embedded.cpp +++ b/servers/display_server_embedded.cpp @@ -62,7 +62,7 @@ void DisplayServerEmbedded::_bind_methods() { } DisplayServerEmbedded::DisplayServerEmbedded(const String &p_rendering_driver, WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Context p_context, Error &r_error) { - ERR_FAIL_NULL_MSG(native_surface, "Native surface has not been set."); + ERR_FAIL_COND_MSG(native_surface.is_null(), "Native surface has not been set."); rendering_driver = p_rendering_driver; diff --git a/servers/rendering/dummy/rasterizer_dummy.h b/servers/rendering/dummy/rasterizer_dummy.h index fcc84c41ef39..33b4c38018b4 100644 --- a/servers/rendering/dummy/rasterizer_dummy.h +++ b/servers/rendering/dummy/rasterizer_dummy.h @@ -77,7 +77,7 @@ class RasterizerDummy : public RendererCompositor { RendererCanvasRender *get_canvas() override { return &canvas; } RendererSceneRender *get_scene() override { return &scene; } - void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, DisplayServer::WindowID p_screen, bool p_use_filter = true) override {} + void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) override {} void initialize() override {} void begin_frame(double frame_step) override { diff --git a/servers/rendering/gles_context.h b/servers/rendering/gles_context.h index 7e06a298359d..091417085805 100644 --- a/servers/rendering/gles_context.h +++ b/servers/rendering/gles_context.h @@ -46,6 +46,8 @@ class GLESContext { virtual bool destroy_framebuffer(DisplayServer::WindowID p_id) = 0; virtual void deinitialize() = 0; virtual uint64_t get_fbo(DisplayServer::WindowID p_id) const = 0; + + virtual ~GLESContext() {} }; #endif // GLES_CONTEXT_H diff --git a/servers/rendering/renderer_compositor.h b/servers/rendering/renderer_compositor.h index 6f838ffff5ad..ac23172af7b1 100644 --- a/servers/rendering/renderer_compositor.h +++ b/servers/rendering/renderer_compositor.h @@ -88,7 +88,7 @@ class RendererCompositor { virtual RendererCanvasRender *get_canvas() = 0; virtual RendererSceneRender *get_scene() = 0; - virtual void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, DisplayServer::WindowID p_screen, bool p_use_filter = true) = 0; + virtual void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) = 0; virtual void initialize() = 0; virtual void begin_frame(double frame_step) = 0; diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp index 3018b02d375f..336818cc15e7 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp @@ -178,12 +178,12 @@ void RendererCompositorRD::finalize() { RD::get_singleton()->free(blit.sampler); } -void RendererCompositorRD::set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, DisplayServer::WindowID p_screen, bool p_use_filter) { +void RendererCompositorRD::set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter) { if (p_image.is_null() || p_image->is_empty()) { return; } - Error err = RD::get_singleton()->screen_prepare_for_drawing(p_screen); + Error err = RD::get_singleton()->screen_prepare_for_drawing(); if (err != OK) { // Window is minimized and does not have valid swapchain, skip drawing without printing errors. return; @@ -211,7 +211,7 @@ void RendererCompositorRD::set_boot_image(const Ref &p_image, const Color uset = RD::get_singleton()->uniform_set_create(uniforms, blit.shader.version_get_shader(blit.shader_version, BLIT_MODE_NORMAL), 0); } - Size2 window_size = DisplayServer::get_singleton()->window_get_size(p_screen); + Size2 window_size = DisplayServer::get_singleton()->window_get_size(); Rect2 imgrect(0, 0, p_image->get_width(), p_image->get_height()); Rect2 screenrect; @@ -225,7 +225,7 @@ void RendererCompositorRD::set_boot_image(const Ref &p_image, const Color screenrect.position /= window_size; screenrect.size /= window_size; - RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin_for_screen(p_screen, p_color); + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin_for_screen(DisplayServer::MAIN_WINDOW_ID, p_color); RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, blit.pipelines[BLIT_MODE_NORMAL_ALPHA]); RD::get_singleton()->draw_list_bind_index_array(draw_list, blit.array); diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.h b/servers/rendering/renderer_rd/renderer_compositor_rd.h index bc3cd87cc51d..41457e4f4805 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.h +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.h @@ -119,7 +119,7 @@ class RendererCompositorRD : public RendererCompositor { RendererCanvasRender *get_canvas() { return canvas; } RendererSceneRender *get_scene() { return scene; } - void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, DisplayServer::WindowID p_screen, bool p_use_filter); + void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter); void initialize(); void begin_frame(double frame_step); diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h index ea31dcfdc1ab..ffbc5c709500 100644 --- a/servers/rendering/rendering_server_default.h +++ b/servers/rendering/rendering_server_default.h @@ -1091,7 +1091,7 @@ class RenderingServerDefault : public RenderingServer { #define ServerName RendererCompositor #define server_name RSG::rasterizer - FUNC5S(set_boot_image, const Ref &, const Color &, bool, DisplayServer::WindowID, bool) + FUNC4S(set_boot_image, const Ref &, const Color &, bool, bool) /* STATUS INFORMATION */ diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 9ef0325b666a..0b3c9182495f 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -3470,7 +3470,7 @@ void RenderingServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_test_texture"), &RenderingServer::get_test_texture); ClassDB::bind_method(D_METHOD("get_white_texture"), &RenderingServer::get_white_texture); - ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale", "screen", "use_filter"), &RenderingServer::set_boot_image, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale", "use_filter"), &RenderingServer::set_boot_image, DEFVAL(true)); ClassDB::bind_method(D_METHOD("get_default_clear_color"), &RenderingServer::get_default_clear_color); ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &RenderingServer::set_default_clear_color); diff --git a/servers/rendering_server.h b/servers/rendering_server.h index 8e8499763778..f889cce04820 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -1815,7 +1815,7 @@ class RenderingServer : public Object { virtual void mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry3D::MeshData &p_mesh_data); virtual void mesh_add_surface_from_planes(RID p_mesh, const Vector &p_planes); - virtual void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, DisplayServer::WindowID p_screen = DisplayServer::MAIN_WINDOW_ID, bool p_use_filter = true) = 0; + virtual void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) = 0; virtual Color get_default_clear_color() = 0; virtual void set_default_clear_color(const Color &p_color) = 0;