Skip to content

Move some values from DisplayServer to DSTypes namespace, to reduce includers #107492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions core/typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,20 @@ inline constexpr bool is_zero_constructible_v = is_zero_constructible<T>::value;
#define GODOT_MSVC_WARNING_POP
#define GODOT_MSVC_WARNING_PUSH_AND_IGNORE(m_warning)
#endif

template <typename T, typename = void>
struct is_incomplete_type : std::true_type {};

template <typename T>
struct is_incomplete_type<T, std::void_t<decltype(sizeof(T))>> : std::false_type {};

template <typename T>
constexpr bool is_incomplete_type_v = is_incomplete_type<T>::value;

#ifndef SCU_BUILD
#define STATIC_ASSERT_INCOMPLETE_CLASS(m_type) \
class m_type; \
static_assert(is_incomplete_type_v<m_type>, #m_type " was defined when it should not be. Please check include hierarchy of " __FILE__);
Copy link
Member

@lawnjelly lawnjelly Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I can see a problem here with SCU builds. It will depend on the build parameters whether in some cases display_types.h might get included before the cpp I think?

If so and you really want this to work, we could set a c++ define when in a SCU build, and omit this check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the checks are absolutely necessary, otherwise we'll be hunting include regressions forever.
An SCU define would totally work 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok remind me tommorrow on RocketChat, I'll take a look into it if you can't work out how to (I'm not super familiar with the build files and #defines but I'm sure we can work it out).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually away over the weekend, so feel free to take it 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I got it working

#else
#define STATIC_ASSERT_INCOMPLETE_CLASS(m_type)
#endif
4 changes: 2 additions & 2 deletions drivers/d3d12/rendering_context_driver_d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@ void RenderingContextDriverD3D12::surface_set_size(SurfaceID p_surface, uint32_t
surface->needs_resize = true;
}

void RenderingContextDriverD3D12::surface_set_vsync_mode(SurfaceID p_surface, DisplayServer::VSyncMode p_vsync_mode) {
void RenderingContextDriverD3D12::surface_set_vsync_mode(SurfaceID p_surface, DSTypes::VSyncMode p_vsync_mode) {
Surface *surface = (Surface *)(p_surface);
surface->vsync_mode = p_vsync_mode;
surface->needs_resize = true;
}

DisplayServer::VSyncMode RenderingContextDriverD3D12::surface_get_vsync_mode(SurfaceID p_surface) const {
DSTypes::VSyncMode RenderingContextDriverD3D12::surface_get_vsync_mode(SurfaceID p_surface) const {
Surface *surface = (Surface *)(p_surface);
return surface->vsync_mode;
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/d3d12/rendering_context_driver_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "core/string/ustring.h"
#include "core/templates/rid_owner.h"
#include "rendering_device_driver_d3d12.h"
#include "servers/display_server.h"
#include "servers/display/dstypes.h"
#include "servers/rendering/rendering_context_driver.h"

#if defined(AS)
Expand Down Expand Up @@ -73,8 +73,8 @@ class RenderingContextDriverD3D12 : public RenderingContextDriver {
virtual void driver_free(RenderingDeviceDriver *p_driver) override;
virtual SurfaceID surface_create(const void *p_platform_data) override;
virtual void surface_set_size(SurfaceID p_surface, uint32_t p_width, uint32_t p_height) override;
virtual void surface_set_vsync_mode(SurfaceID p_surface, DisplayServer::VSyncMode p_vsync_mode) override;
virtual DisplayServer::VSyncMode surface_get_vsync_mode(SurfaceID p_surface) const override;
virtual void surface_set_vsync_mode(SurfaceID p_surface, DSTypes::VSyncMode p_vsync_mode) override;
virtual DSTypes::VSyncMode surface_get_vsync_mode(SurfaceID p_surface) const override;
virtual uint32_t surface_get_width(SurfaceID p_surface) const override;
virtual uint32_t surface_get_height(SurfaceID p_surface) const override;
virtual void surface_set_needs_resize(SurfaceID p_surface, bool p_needs_resize) override;
Expand All @@ -92,7 +92,7 @@ class RenderingContextDriverD3D12 : public RenderingContextDriver {
HWND hwnd = nullptr;
uint32_t width = 0;
uint32_t height = 0;
DisplayServer::VSyncMode vsync_mode = DisplayServer::VSYNC_ENABLED;
DSTypes::VSyncMode vsync_mode = DSTypes::VSYNC_ENABLED;
bool needs_resize = false;
#ifdef DCOMP_ENABLED
ComPtr<IDCompositionDevice> composition_device;
Expand Down
1 change: 1 addition & 0 deletions drivers/d3d12/rendering_device_driver_d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include "core/config/project_settings.h"
#include "core/io/marshalls.h"
#include "servers/display_server.h"
#include "servers/rendering/rendering_device.h"
#include "thirdparty/zlib/zlib.h"

Expand Down
1 change: 1 addition & 0 deletions drivers/gles3/rasterizer_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "core/io/dir_access.h"
#include "core/io/image.h"
#include "core/os/os.h"
#include "servers/display_server.h"
#include "storage/texture_storage.h"

#define _EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242
Expand Down
4 changes: 2 additions & 2 deletions drivers/gles3/rasterizer_gles3.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class RasterizerGLES3 : public RendererCompositor {
RasterizerSceneGLES3 *scene = nullptr;
static RasterizerGLES3 *singleton;

void _blit_render_target_to_screen(RID p_render_target, DisplayServer::WindowID p_screen, const Rect2 &p_screen_rect, uint32_t p_layer, bool p_first = true);
void _blit_render_target_to_screen(RID p_render_target, DSTypes::WindowID p_screen, const Rect2 &p_screen_rect, uint32_t p_layer, bool p_first = true);

public:
RendererUtilities *get_utilities() { return utilities; }
Expand All @@ -102,7 +102,7 @@ class RasterizerGLES3 : public RendererCompositor {
void initialize();
void begin_frame(double frame_step);

void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount);
void blit_render_targets_to_screen(DSTypes::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount);

bool is_opengl() { return true; }
void gl_end_frame(bool p_swap_buffers);
Expand Down
6 changes: 3 additions & 3 deletions drivers/metal/rendering_context_driver_metal.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ class API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) RenderingContextDriverMe
void driver_free(RenderingDeviceDriver *p_driver) final override;
SurfaceID surface_create(const void *p_platform_data) final override;
void surface_set_size(SurfaceID p_surface, uint32_t p_width, uint32_t p_height) final override;
void surface_set_vsync_mode(SurfaceID p_surface, DisplayServer::VSyncMode p_vsync_mode) final override;
DisplayServer::VSyncMode surface_get_vsync_mode(SurfaceID p_surface) const final override;
void surface_set_vsync_mode(SurfaceID p_surface, DSTypes::VSyncMode p_vsync_mode) final override;
DSTypes::VSyncMode surface_get_vsync_mode(SurfaceID p_surface) const final override;
uint32_t surface_get_width(SurfaceID p_surface) const final override;
uint32_t surface_get_height(SurfaceID p_surface) const final override;
void surface_set_needs_resize(SurfaceID p_surface, bool p_needs_resize) final override;
Expand Down Expand Up @@ -106,7 +106,7 @@ class API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) RenderingContextDriverMe
public:
uint32_t width = 0;
uint32_t height = 0;
DisplayServer::VSyncMode vsync_mode = DisplayServer::VSYNC_ENABLED;
DSTypes::VSyncMode vsync_mode = DSTypes::VSYNC_ENABLED;
bool needs_resize = false;
double present_minimum_duration = 0.0;

Expand Down
14 changes: 7 additions & 7 deletions drivers/metal/rendering_context_driver_metal.mm
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ Error resize(uint32_t p_desired_framebuffer_count) override final {
#if TARGET_OS_OSX
// Display sync is only supported on macOS.
switch (vsync_mode) {
case DisplayServer::VSYNC_MAILBOX:
case DisplayServer::VSYNC_ADAPTIVE:
case DisplayServer::VSYNC_ENABLED:
case DSTypes::VSYNC_MAILBOX:
case DSTypes::VSYNC_ADAPTIVE:
case DSTypes::VSYNC_ENABLED:
layer.displaySyncEnabled = YES;
break;
case DisplayServer::VSYNC_DISABLED:
case DSTypes::VSYNC_DISABLED:
layer.displaySyncEnabled = NO;
break;
}
Expand Down Expand Up @@ -176,7 +176,7 @@ void present(MDCommandBuffer *p_cmd_buffer) override final {
count--;
front = (front + 1) % frame_buffers.size();

if (vsync_mode != DisplayServer::VSYNC_DISABLED) {
if (vsync_mode != DSTypes::VSYNC_DISABLED) {
[p_cmd_buffer->get_command_buffer() presentDrawable:drawable afterMinimumDuration:present_minimum_duration];
} else {
[p_cmd_buffer->get_command_buffer() presentDrawable:drawable];
Expand All @@ -201,7 +201,7 @@ void present(MDCommandBuffer *p_cmd_buffer) override final {
surface->needs_resize = true;
}

void RenderingContextDriverMetal::surface_set_vsync_mode(SurfaceID p_surface, DisplayServer::VSyncMode p_vsync_mode) {
void RenderingContextDriverMetal::surface_set_vsync_mode(SurfaceID p_surface, DSTypes::VSyncMode p_vsync_mode) {
Surface *surface = (Surface *)(p_surface);
if (surface->vsync_mode == p_vsync_mode) {
return;
Expand All @@ -210,7 +210,7 @@ void present(MDCommandBuffer *p_cmd_buffer) override final {
surface->needs_resize = true;
}

DisplayServer::VSyncMode RenderingContextDriverMetal::surface_get_vsync_mode(SurfaceID p_surface) const {
DSTypes::VSyncMode RenderingContextDriverMetal::surface_get_vsync_mode(SurfaceID p_surface) const {
Surface *surface = (Surface *)(p_surface);
return surface->vsync_mode;
}
Expand Down
1 change: 1 addition & 0 deletions drivers/vulkan/rendering_context_driver_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#include "core/config/project_settings.h"
#include "core/version.h"
#include "servers/display_server.h"

#include "rendering_device_driver_vulkan.h"
#include "vulkan_hooks.h"
Expand Down
8 changes: 5 additions & 3 deletions drivers/vulkan/rendering_context_driver_vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#ifdef VULKAN_ENABLED

#include "core/templates/hash_set.h"
#include "core/templates/local_vector.h"
#include "servers/rendering/rendering_context_driver.h"

#if defined(DEBUG_ENABLED) || defined(DEV_ENABLED)
Expand Down Expand Up @@ -136,8 +138,8 @@ class RenderingContextDriverVulkan : public RenderingContextDriver {
virtual void driver_free(RenderingDeviceDriver *p_driver) override;
virtual SurfaceID surface_create(const void *p_platform_data) override;
virtual void surface_set_size(SurfaceID p_surface, uint32_t p_width, uint32_t p_height) override;
virtual void surface_set_vsync_mode(SurfaceID p_surface, DisplayServer::VSyncMode p_vsync_mode) override;
virtual DisplayServer::VSyncMode surface_get_vsync_mode(SurfaceID p_surface) const override;
virtual void surface_set_vsync_mode(SurfaceID p_surface, DSTypes::VSyncMode p_vsync_mode) override;
virtual DSTypes::VSyncMode surface_get_vsync_mode(SurfaceID p_surface) const override;
virtual uint32_t surface_get_width(SurfaceID p_surface) const override;
virtual uint32_t surface_get_height(SurfaceID p_surface) const override;
virtual void surface_set_needs_resize(SurfaceID p_surface, bool p_needs_resize) override;
Expand All @@ -150,7 +152,7 @@ class RenderingContextDriverVulkan : public RenderingContextDriver {
VkSurfaceKHR vk_surface = VK_NULL_HANDLE;
uint32_t width = 0;
uint32_t height = 0;
DisplayServer::VSyncMode vsync_mode = DisplayServer::VSYNC_ENABLED;
DSTypes::VSyncMode vsync_mode = DSTypes::VSYNC_ENABLED;
bool needs_resize = false;
};

Expand Down
1 change: 1 addition & 0 deletions drivers/vulkan/rendering_device_driver_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "core/config/project_settings.h"
#include "core/io/marshalls.h"
#include "servers/display_server.h"
#include "vulkan_hooks.h"

#if RENDERING_SHADER_CONTAINER_VULKAN_SMOLV
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class EditorNode : public Node {
bool exiting = false;
bool dimmed = false;

DisplayServer::WindowMode prev_mode = DisplayServer::WINDOW_MODE_MAXIMIZED;
DSTypes::WindowMode prev_mode = DSTypes::WINDOW_MODE_MAXIMIZED;
int old_split_ofs = 0;
VSplitContainer *top_split = nullptr;
Control *vp_base = nullptr;
Expand Down
6 changes: 3 additions & 3 deletions editor/engine_update_label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,20 @@ void EngineUpdateLabel::_set_status(UpdateStatus p_status) {
} else {
_set_message(TTR("Update checks disabled."), theme_cache.disabled_color);
}
set_accessibility_live(DisplayServer::AccessibilityLiveMode::LIVE_OFF);
set_accessibility_live(DSTypes::AccessibilityLiveMode::LIVE_OFF);
set_tooltip_text("");
break;
}

case UpdateStatus::ERROR: {
set_disabled(false);
set_accessibility_live(DisplayServer::AccessibilityLiveMode::LIVE_POLITE);
set_accessibility_live(DSTypes::AccessibilityLiveMode::LIVE_POLITE);
set_tooltip_text(TTR("An error has occurred. Click to try again."));
} break;

case UpdateStatus::UPDATE_AVAILABLE: {
set_disabled(false);
set_accessibility_live(DisplayServer::AccessibilityLiveMode::LIVE_POLITE);
set_accessibility_live(DSTypes::AccessibilityLiveMode::LIVE_POLITE);
set_tooltip_text(TTR("Click to open download page."));
} break;

Expand Down
1 change: 1 addition & 0 deletions editor/gui/editor_toaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "scene/gui/label.h"
#include "scene/gui/panel_container.h"
#include "scene/resources/style_box_flat.h"
#include "servers/display_server.h"

EditorToaster *EditorToaster::singleton = nullptr;

Expand Down
1 change: 1 addition & 0 deletions editor/gui/editor_version_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "core/os/time.h"
#include "core/version.h"
#include "servers/display_server.h"

String _get_version_string(EditorVersionButton::VersionFormat p_format) {
String main;
Expand Down
1 change: 1 addition & 0 deletions editor/gui/touch_actions_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "scene/gui/color_rect.h"
#include "scene/gui/texture_rect.h"
#include "scene/resources/style_box_flat.h"
#include "servers/display_server.h"

void TouchActionsPanel::_notification(int p_what) {
switch (p_what) {
Expand Down
1 change: 1 addition & 0 deletions editor/themes/editor_theme_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "scene/resources/style_box_texture.h"
#include "scene/resources/svg_texture.h"
#include "scene/resources/texture.h"
#include "servers/display_server.h"

// Theme configuration.

Expand Down
1 change: 1 addition & 0 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def add_source_files_scu(self, sources, files, allow_gen=False):

# Add all the gen.cpp files in the SCU directory
add_source_files_orig(self, sources, subdir + ".scu/scu_*.gen.cpp", True)
self.Append(CPPDEFINES=["SCU_BUILD"])
return True
return False

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@

#ifdef GLES3_ENABLED

#include "../../openxr_util.h"

#include "core/input/input.h"
#include "drivers/gles3/effects/copy_effects.h"
#include "drivers/gles3/storage/texture_storage.h"
#include "servers/display_server.h"
#include "servers/rendering/rendering_server_globals.h"
#include "servers/rendering_server.h"

#include "../../openxr_util.h"

// OpenXR requires us to submit sRGB textures so that it recognizes the content
// as being in sRGB color space. We do fall back on "normal" textures but this
// will likely result in incorrect colors as OpenXR will double the sRGB conversion.
Expand Down
1 change: 1 addition & 0 deletions modules/openxr/openxr_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "extensions/openxr_eye_gaze_interaction.h"
#include "extensions/openxr_hand_interaction_extension.h"
#include "extensions/openxr_performance_settings_extension.h"
#include "servers/display_server.h"
#include "servers/rendering/renderer_compositor.h"

#include <openxr/openxr.h>
Expand Down
6 changes: 3 additions & 3 deletions platform/macos/editor/embedded_process_macos.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class EmbeddedProcessMacOS final : public EmbeddedProcessBase {
// Embedded process state.

// The last mouse mode sent by the embedded process.
DisplayServer::MouseMode mouse_mode = DisplayServer::MOUSE_MODE_VISIBLE;
DSTypes::MouseMode mouse_mode = DSTypes::MOUSE_MODE_VISIBLE;

// Helper functions.

Expand All @@ -90,7 +90,7 @@ class EmbeddedProcessMacOS final : public EmbeddedProcessBase {
// MARK: - Message Handlers

void set_context_id(uint32_t p_context_id);
void mouse_set_mode(DisplayServer::MouseMode p_mode);
void mouse_set_mode(DSTypes::MouseMode p_mode);

uint32_t get_context_id() const { return context_id; }
void set_script_debugger(ScriptEditorDebugger *p_debugger) override;
Expand All @@ -117,7 +117,7 @@ class EmbeddedProcessMacOS final : public EmbeddedProcessBase {
void display_state_changed();

// MARK: - Embedded process state
_FORCE_INLINE_ DisplayServer::MouseMode get_mouse_mode() const { return mouse_mode; }
_FORCE_INLINE_ DSTypes::MouseMode get_mouse_mode() const { return mouse_mode; }

EmbeddedProcessMacOS();
~EmbeddedProcessMacOS() override;
Expand Down
1 change: 1 addition & 0 deletions scene/2d/animated_sprite_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "animated_sprite_2d.h"

#include "scene/main/viewport.h"
#include "servers/display_server.h"

#ifdef TOOLS_ENABLED
Dictionary AnimatedSprite2D::_edit_get_state() const {
Expand Down
3 changes: 3 additions & 0 deletions scene/2d/node_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@

#include "node_2d.h"

STATIC_ASSERT_INCOMPLETE_CLASS(DisplayServer);

#include "scene/main/viewport.h"
#include "servers/display_server.h"

#ifdef TOOLS_ENABLED
Dictionary Node2D::_edit_get_state() const {
Expand Down
1 change: 1 addition & 0 deletions scene/2d/physics/touch_screen_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "touch_screen_button.h"

#include "scene/main/viewport.h"
#include "servers/display_server.h"

void TouchScreenButton::set_texture_normal(const Ref<Texture2D> &p_texture) {
if (texture_normal == p_texture) {
Expand Down
1 change: 1 addition & 0 deletions scene/2d/sprite_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "core/input/input.h"
#include "scene/main/viewport.h"
#include "servers/display_server.h"

#ifdef TOOLS_ENABLED
Dictionary Sprite2D::_edit_get_state() const {
Expand Down
1 change: 1 addition & 0 deletions scene/3d/lightmap_gi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "scene/resources/environment.h"
#include "scene/resources/image_texture.h"
#include "scene/resources/sky.h"
#include "servers/display_server.h"

#include "modules/modules_enabled.gen.h" // For lightmapper_rd.

Expand Down
3 changes: 3 additions & 0 deletions scene/3d/node_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@

#include "node_3d.h"

STATIC_ASSERT_INCOMPLETE_CLASS(DisplayServer);

#include "core/math/transform_interpolator.h"
#include "scene/3d/visual_instance_3d.h"
#include "scene/main/viewport.h"
#include "scene/property_utils.h"
#include "servers/display_server.h"

/*

Expand Down
1 change: 1 addition & 0 deletions scene/audio/audio_stream_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include "scene/audio/audio_stream_player_internal.h"
#include "servers/audio/audio_stream.h"
#include "servers/display_server.h"

void AudioStreamPlayer::_notification(int p_what) {
if (p_what == NOTIFICATION_ACCESSIBILITY_UPDATE) {
Expand Down
Loading
Loading