Skip to content
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

Generic Headless support, drop server platform, enable linuxbsd build without vulkan/X11. #49074

Merged
merged 5 commits into from
Jun 1, 2021

Conversation

Faless
Copy link
Collaborator

@Faless Faless commented May 25, 2021

Implement a new "headless" DisplayServerDummyDisplayServerHeadless. Uses the dummy rasterizer internally, and is always compiled in (we could exclude it, but frankly, it's a bunch of empty functions).

You can run ideally any platform via --display-driver headless, e.g.:

bin/godot.linuxbsd.tools.64 --display-driver headless -s script.gd

An extra commit removes the old "server" platform, and the last one enable building the linuxbsd platform without vulkan/X11 dependencies.

$ scons p=x11 target=release_debug tools=no vulkan=no x11=no
$ ldd bin/godot.linuxbsd.opt.debug.64 
linux-vdso.so.1 (0x00007fff9e1ee000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f55142cf000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f55142c9000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f551417a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5513f88000)
/lib64/ld-linux-x86-64.so.2 (0x00007f5514320000)

This effectively adds the RasterizerDummy back to CI, and for all platforms. so, as mentioned above, I can also add an headless flag to scons and default it to False if that's preferred.

EDIT: Closes godotengine/godot-proposals#991 . Only tested on linuxbsd. EDIT: Also briefly tested on windows.

@YuriSizov
Copy link
Contributor

Part of godotengine/godot-proposals#991?

@Faless Faless marked this pull request as ready for review May 31, 2021 12:54
@Faless Faless requested review from a team as code owners May 31, 2021 12:54
@Faless Faless changed the title [RFC] Generic Headless support, drop server platform, enable linuxbsd build without vulkan/X11. Generic Headless support, drop server platform, enable linuxbsd build without vulkan/X11. May 31, 2021
@Faless Faless marked this pull request as draft May 31, 2021 12:54
@Faless Faless marked this pull request as ready for review May 31, 2021 13:25
@Faless
Copy link
Collaborator Author

Faless commented May 31, 2021

Rebased and ready to go.

@reduz
Copy link
Member

reduz commented May 31, 2021

Looks good to me, up to @akien-mga to merge.

Comment on lines -28 to -29
else:
SConscript("dummy/SCsub")
Copy link
Member

Choose a reason for hiding this comment

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

As discussed on chat, since this SCsub is removed it doesn't really make sense anymore to keep a drivers/dummy folder. Instead, we should move the respective dummy/null implementations close to their virtual class definitions (as was done already with servers/audio/audio_driver_dummy.h).

This can be done in a follow-up PR though.

class DisplayServerDummy : public DisplayServer {
public:
bool has_feature(Feature p_feature) const override { return false; }
String get_name() const override { return "headless"; }
Copy link
Member

Choose a reason for hiding this comment

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

I guess we'd want this capitalized to be consistent with other platforms.

And maybe the name should be "Dummy" (respectively "Null" if we do this change).

@akien-mga
Copy link
Member

akien-mga commented May 31, 2021

Tested on Windows, seems to work fine:

$ cat main.gd
extends MainLoop

var time_elapsed = 0

func _initialize():
        print("Sleepy Hollow is in da place")

func _process(delta):
        time_elapsed += delta
        print(time_elapsed)
        return time_elapsed > 0.1

func _finalize():
        print("The end.")

$ godot-git --display-driver headless -s main.gd
Godot Engine v4.0.dev.custom_build.0e944defc - https://godotengine.org

WARNING: Icon not supported by this display server.
     at: DisplayServer::set_icon (servers\display_server.cpp:305)
WARNING: Icon not supported by this display server.
     at: DisplayServer::set_icon (servers\display_server.cpp:305)
Sleepy Hollow is in da place
0.008333
0.012155
0.012187
0.016667
0.02
0.024167
0.028333
0.033333
0.037541
0.044585
0.051609
0.057651
0.064641
0.071662
0.078666
0.084737
0.092739
0.099784
0.106808
The end.

We could possibly silence those by replacing the default implementation with a no-op:


WARNING: Icon not supported by this display server.
     at: DisplayServer::set_icon (servers\display_server.cpp:305)
WARNING: Icon not supported by this display server.
     at: DisplayServer::set_icon (servers\display_server.cpp:305)\

void process_events() override {}

static void register_headless_driver() {
register_create_function("headless", create_func, get_rendering_drivers_func);
Copy link
Member

Choose a reason for hiding this comment

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

Since we name it headless internally, maybe the implementation should be DisplayServerHeadless?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I think that's a good idea.

@Faless
Copy link
Collaborator Author

Faless commented Jun 1, 2021

Renamed DisplayServerDummy to DisplayServerHeadless, added set_icon function to avoid console warning spam on startup.

@@ -0,0 +1,128 @@
/*************************************************************************/
/* display_server_dummy.h */
Copy link
Member

Choose a reason for hiding this comment

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

Needs renaming too.

Uses RasterizerDummy internally. This is always compiled in, maybe we
should add a switch to enable/disable it via scons?
@akien-mga
Copy link
Member

I think you can do the git mv we discussed yesterday in this PR too:

drivers/dummy/display_server_headless.* -> servers/display_server_headless.*
drivers/dummy/rasterizer_dummy.* -> servers/rendering/rasterizer_dummy.*

@akien-mga akien-mga merged commit 0aabfb3 into godotengine:master Jun 1, 2021
@akien-mga
Copy link
Member

Thanks!

@SebastianAtWork
Copy link

Hi guys, quick question. Is this commit also in 3.5.1 and if yes, how do I make a headless build with windows?

@YuriSizov
Copy link
Contributor

YuriSizov commented Oct 15, 2022

@SebastianAtWork This is not a part of 3.x and won't be a part of 3.x, as it's a breaking change.

In 3.x you can still use the --no-window command line argument to run without spawning a window (no custom build required).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add headless / server mode support to all platforms as a DisplayServer
5 participants