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

Worked with Faless(Fabio Alessandrelli) to update server platform. #16653

Merged
merged 7 commits into from
Feb 16, 2018
Merged
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
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ if selected_platform in platform_list:
if not env['verbose']:
methods.no_verbose(sys, env)

if (True): # FIXME: detect GLES3
if (not env["platform"] == "server"): # FIXME: detect GLES3
env.Append( BUILDERS = { 'GLES3_GLSL' : env.Builder(action = methods.build_gles3_headers, suffix = 'glsl.gen.h',src_suffix = '.glsl') } )

scons_cache_path = os.environ.get("SCONS_CACHE")
Expand Down
7 changes: 5 additions & 2 deletions drivers/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ if env['xaudio2']:
SConscript("xaudio2/SCsub")

# Graphics drivers
SConscript('gles3/SCsub')
SConscript('gl_context/SCsub')
if (env["platform"] != "server"):
SConscript('gles3/SCsub')
SConscript('gl_context/SCsub')
else:
SConscript('dummy/SCsub')

# Core dependencies
SConscript("png/SCsub")
Expand Down
5 changes: 5 additions & 0 deletions drivers/dummy/SCsub
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env python

Import('env')

env.add_source_files(env.drivers_sources, "*.cpp")
58 changes: 58 additions & 0 deletions drivers/dummy/audio_driver_dummy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*************************************************************************/
/* audio_driver_dummy.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/

#ifndef AUDIO_DRIVER_DUMMY_H
#define AUDIO_DRIVER_DUMMY_H

#include "core/os/mutex.h"
#include "core/os/thread.h"
#include "servers/audio_server.h"

class AudioDriverDummy : public AudioDriver {
public:
const char *get_name() const {
return "Dummy";
};

virtual Error init() { return OK; }
virtual void start(){};
virtual int get_mix_rate() const {};
virtual SpeakerMode get_speaker_mode() const {};
virtual void lock(){};
virtual void unlock(){};
virtual void finish(){};

virtual float get_latency(){};

AudioDriverDummy(){};
~AudioDriverDummy(){};
};

#endif // AUDIO_DRIVER_DUMMY_H
669 changes: 669 additions & 0 deletions drivers/dummy/rasterizer_dummy.h

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions platform/server/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Import('env')

common_server = [\
"os_server.cpp",\
"#platform/x11/crash_handler_x11.cpp",
Copy link
Member

Choose a reason for hiding this comment

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

Waiting for linuxbsd platform to cleanup this mess :P

"#platform/x11/power_x11.cpp",
]

prog = env.add_program('#bin/godot_server', ['godot_server.cpp'] + common_server)
5 changes: 2 additions & 3 deletions platform/server/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ def get_name():

def can_build():

# Doesn't build against Godot 3.0 for now, disable to avoid confusing users
return False

if (os.name != "posix" or sys.platform == "darwin"):
return False

Expand All @@ -31,6 +28,7 @@ def get_opts():
def get_flags():

return [
("module_mobile_vr_enabled", False),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we doing this? There is a problem here. The mobile_vr module registers the class MobileVRInterface. By only enabling it on some platforms, this breaks API portability. This is specially harmful for GDNative and C#.

The code that registers the class is the following:

void register_mobile_vr_types() {
ClassDB::register_class<MobileVRInterface>();
Ref<MobileVRInterface> mobile_vr;
mobile_vr.instance();
ARVRServer::get_singleton()->add_interface(mobile_vr);
}

I can imagine three different situations and the possible solutions:
Can the MobileVRInterface class be used directly, or can it only be used through the ARVRInterface interface?

  • If the MobileVRInterface class cannot be used directly from scripts and scripts only use the ARVRInterface interface then this class must not be registered manually. register_class will expose the class to the scripting API, which must be portable. When you create an instance, the class will be registered automatically without exposing it to the scripting API.

  • If MobileVRInterface or any of its methods from that are not registered by ARVRInterface can be used directly from scripts, then we have a different problem. One of the possible solution could be to create a dummy class.

  • What confuses me the most though is that this class is not actually disabled on the desktop, only on server builds. I think this is because of the gl code in this class, am I right? If that is the case, then perhaps the solution is to surround such parts of the code with #ifdefs and maybe to not call ARVRServer::get_singleton()->add_interface(mobile_vr) either.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you missed the irc conversation, fales replied.

<fales> neikeq seems like VR module uses GLES header

<fales> which is of course not avail in server platform

<fales> it uses LensDistortedShaderGLES3 which is defined "shaders/lens_distorted.glsl.gen.h" maybe we could guard the functions by defines. Not sure what the best solution is. There's also a comment from Mux213 about that shader and its todo state for GLES2 support. Not sure if anything changed

Copy link
Contributor

@neikeq neikeq Sep 25, 2018

Choose a reason for hiding this comment

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

That would be the third possibility I mentioned.
Can't we ifdef that code or add a dummy class?

Copy link
Collaborator

@Faless Faless Sep 25, 2018

Choose a reason for hiding this comment

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

@neikeq yes to both.
I think we should ask @BastiaanOlij about the GLES2 comment.
He mentions some refactoring about the shader there.

// build our shader
if (lens_shader == NULL) {
///@TODO need to switch between GLES2 and GLES3 version, Reduz suggested moving this into our drivers and making this a core shader
// create a shader
lens_shader = new LensDistortedShaderGLES3();

In the meantime I'll see if we can have a dummy implementation of the interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

I hope to finally have time for this on my trip to Europe next week.

That said, for the server platform, why not change the detect.py so the module is not included on the server installation? VR is not really applicable on the server so..

Copy link
Contributor

Choose a reason for hiding this comment

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

@BastiaanOlij we're already doing that right now, and that's the problem. The mobile_vr module exposes the class MobileVRInterface to the scripting API. By disabling the module the scripting API for server builds becomes different to that of other target platforms. That breaks API portability. This hurts specially GDNative and C#, which rely on generating bindings.
Also doesn't this break GDScript scripts that make use MobileVRInterface as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also doesn't this break GDScript scripts that make use MobileVRInterface as well?

Yes, for people who uses the server platform for exporting the game (e.g. in CI).

]


Expand Down Expand Up @@ -133,3 +131,4 @@ def configure(env):
env.Append(CPPPATH=['#platform/server'])
env.Append(CPPFLAGS=['-DSERVER_ENABLED', '-DUNIX_ENABLED'])
env.Append(LIBS=['pthread'])
env.Append(LIBS=['dl'])
163 changes: 129 additions & 34 deletions platform/server/os_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/

//#include "servers/visual/visual_server_raster.h"
//#include "servers/visual/rasterizer_dummy.h"
#include "os_server.h"
#include "drivers/dummy/audio_driver_dummy.h"
#include "drivers/dummy/rasterizer_dummy.h"
#include "print_string.h"
#include "servers/visual/visual_server_raster.h"
#include <stdio.h>
#include <stdlib.h>

Expand All @@ -48,32 +48,39 @@ const char *OS_Server::get_video_driver_name(int p_driver) const {
return "Dummy";
}

int OS_Server::get_audio_driver_count() const {
return 1;
}

const char *OS_Server::get_audio_driver_name(int p_driver) const {

return "Dummy";
}

void OS_Server::initialize_core() {

crash_handler.initialize();

OS_Unix::initialize_core();
}

Error OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {

args = OS::get_singleton()->get_cmdline_args();
current_videomode = p_desired;
main_loop = NULL;

//rasterizer = memnew( RasterizerDummy );
RasterizerDummy::make_current();

//visual_server = memnew( VisualServerRaster(rasterizer) );
visual_server = memnew(VisualServerRaster);
visual_server->init();

AudioDriverManager::initialize(p_audio_driver);

sample_manager = memnew(SampleManagerMallocSW);
audio_server = memnew(AudioServerSW(sample_manager));
audio_server->init();
spatial_sound_server = memnew(SpatialSoundServerSW);
spatial_sound_server->init();
spatial_sound_2d_server = memnew(SpatialSound2DServerSW);
spatial_sound_2d_server->init();

ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE);

visual_server->init();

input = memnew(InputDefault);

power_manager = memnew(PowerX11);

_ensure_user_data_dir();

return OK;
Expand All @@ -85,37 +92,24 @@ void OS_Server::finalize() {
memdelete(main_loop);
main_loop = NULL;

spatial_sound_server->finish();
memdelete(spatial_sound_server);
spatial_sound_2d_server->finish();
memdelete(spatial_sound_2d_server);

/*
if (debugger_connection_console) {
memdelete(debugger_connection_console);
}
*/

memdelete(sample_manager);

audio_server->finish();
memdelete(audio_server);

visual_server->finish();
memdelete(visual_server);
//memdelete(rasterizer);

memdelete(input);

memdelete(power_manager);

args.clear();
}

void OS_Server::set_mouse_show(bool p_show) {
}

void OS_Server::set_mouse_grab(bool p_grab) {

grab = p_grab;
}

bool OS_Server::is_mouse_grab_enabled() const {

return grab;
Expand All @@ -136,6 +130,7 @@ void OS_Server::set_window_title(const String &p_title) {

void OS_Server::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
}

OS::VideoMode OS_Server::get_video_mode(int p_screen) const {

return current_videomode;
Expand Down Expand Up @@ -198,6 +193,10 @@ int OS_Server::get_power_percent_left() {
return power_manager->get_power_percent_left();
}

bool OS_Server::_check_internal_feature_support(const String &p_feature) {
return p_feature == "pc";
}

void OS_Server::run() {

force_quit = false;
Expand All @@ -216,6 +215,102 @@ void OS_Server::run() {
main_loop->finish();
}

String OS_Server::get_config_path() const {

if (has_environment("XDG_CONFIG_HOME")) {
return get_environment("XDG_CONFIG_HOME");
} else if (has_environment("HOME")) {
return get_environment("HOME").plus_file(".config");
} else {
return ".";
}
}

String OS_Server::get_data_path() const {

if (has_environment("XDG_DATA_HOME")) {
return get_environment("XDG_DATA_HOME");
} else if (has_environment("HOME")) {
return get_environment("HOME").plus_file(".local/share");
} else {
return get_config_path();
}
}

String OS_Server::get_cache_path() const {

if (has_environment("XDG_CACHE_HOME")) {
return get_environment("XDG_CACHE_HOME");
} else if (has_environment("HOME")) {
return get_environment("HOME").plus_file(".cache");
} else {
return get_config_path();
}
}

String OS_Server::get_system_dir(SystemDir p_dir) const {

String xdgparam;

switch (p_dir) {
case SYSTEM_DIR_DESKTOP: {

xdgparam = "DESKTOP";
} break;
case SYSTEM_DIR_DCIM: {

xdgparam = "PICTURES";

} break;
case SYSTEM_DIR_DOCUMENTS: {

xdgparam = "DOCUMENTS";

} break;
case SYSTEM_DIR_DOWNLOADS: {

xdgparam = "DOWNLOAD";

} break;
case SYSTEM_DIR_MOVIES: {

xdgparam = "VIDEOS";

} break;
case SYSTEM_DIR_MUSIC: {

xdgparam = "MUSIC";

} break;
case SYSTEM_DIR_PICTURES: {

xdgparam = "PICTURES";

} break;
case SYSTEM_DIR_RINGTONES: {

xdgparam = "MUSIC";

} break;
}

String pipe;
List<String> arg;
arg.push_back(xdgparam);
Error err = const_cast<OS_Server *>(this)->execute("xdg-user-dir", arg, true, NULL, &pipe);
if (err != OK)
return ".";
return pipe.strip_edges();
}

void OS_Server::disable_crash_handler() {
crash_handler.disable();
}

bool OS_Server::is_disable_crash_handler() const {
return crash_handler.is_disabled();
}

OS_Server::OS_Server() {

//adriver here
Expand Down
18 changes: 17 additions & 1 deletion platform/server/os_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/

#ifndef OS_SERVER_H
#define OS_SERVER_H

#include "../x11/crash_handler_x11.h"
#include "../x11/power_x11.h"
#include "drivers/rtaudio/audio_driver_rtaudio.h"
#include "drivers/unix/os_unix.h"
Expand Down Expand Up @@ -63,10 +63,16 @@ class OS_Server : public OS_Unix {

PowerX11 *power_manager;

CrashHandler crash_handler;

protected:
virtual int get_video_driver_count() const;
virtual const char *get_video_driver_name(int p_driver) const;

virtual int get_audio_driver_count() const;
virtual const char *get_audio_driver_name(int p_driver) const;

virtual void initialize_core();
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
virtual void finalize();

Expand Down Expand Up @@ -102,6 +108,16 @@ class OS_Server : public OS_Unix {
virtual OS::PowerState get_power_state();
virtual int get_power_seconds_left();
virtual int get_power_percent_left();
virtual bool _check_internal_feature_support(const String &p_feature);

virtual String get_config_path() const;
virtual String get_data_path() const;
virtual String get_cache_path() const;

virtual String get_system_dir(SystemDir p_dir) const;

void disable_crash_handler();
bool is_disable_crash_handler() const;

OS_Server();
};
Expand Down