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

[WIP] Godot 4 GLES2 2D renderer + linux display manager #44399

Closed
wants to merge 5 commits into from
Closed
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
22 changes: 22 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ from collections import OrderedDict
# Local
import methods
import glsl_builders
import gles_builders
from platform_methods import run_in_subprocess

# Scan possible build platforms

Expand Down Expand Up @@ -615,6 +617,26 @@ if selected_platform in platform_list:
}
env.Append(BUILDERS=GLSL_BUILDERS)

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

scons_cache_path = os.environ.get("SCONS_CACHE")
if scons_cache_path != None:
CacheDir(scons_cache_path)
Expand Down
19 changes: 19 additions & 0 deletions core/os/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ class OS {
bool restart_on_exit = false;
List<String> restart_commandline;

// for the user interface we keep a record of the current display driver
// so we can retrieve the rendering drivers available
int _display_driver_id = -1;
String _current_rendering_driver_name = "";

protected:
void _set_logger(CompositeLogger *p_logger);

Expand All @@ -80,20 +85,29 @@ class OS {
RENDER_SEPARATE_THREAD
};

enum RenderMainThreadMode {
RENDER_MAIN_THREAD_ONLY,
RENDER_ANY_THREAD,
};

protected:
friend class Main;
// Needed by tests to setup command-line args.
friend int test_main(int argc, char *argv[]);

HasServerFeatureCallback has_server_feature_callback = nullptr;
RenderThreadMode _render_thread_mode = RENDER_THREAD_SAFE;
RenderMainThreadMode _render_main_thread_mode = RENDER_ANY_THREAD;

// Functions used by Main to initialize/deinitialize the OS.
void add_logger(Logger *p_logger);

virtual void initialize() = 0;
virtual void initialize_joypads() = 0;

void set_current_rendering_driver_name(String p_driver_name) { _current_rendering_driver_name = p_driver_name; }
void set_display_driver_id(int p_display_driver_id) { _display_driver_id = p_display_driver_id; }

virtual void set_main_loop(MainLoop *p_main_loop) = 0;
virtual void delete_main_loop() = 0;

Expand All @@ -109,6 +123,9 @@ class OS {

static OS *get_singleton();

String get_current_rendering_driver_name() const { return _current_rendering_driver_name; }
int get_display_driver_id() const { return _display_driver_id; }

void print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, Logger::ErrorType p_type = Logger::ERR_ERROR);
void print(const char *p_format, ...) _PRINTF_FORMAT_ATTRIBUTE_2_3;
void printerr(const char *p_format, ...) _PRINTF_FORMAT_ATTRIBUTE_2_3;
Expand Down Expand Up @@ -236,6 +253,8 @@ class OS {
virtual uint64_t get_free_static_memory() const;

RenderThreadMode get_render_thread_mode() const { return _render_thread_mode; }
RenderMainThreadMode get_render_main_thread_mode() const { return _render_main_thread_mode; }
void set_render_main_thread_mode(RenderMainThreadMode p_thread_mode) { _render_main_thread_mode = p_thread_mode; }

virtual String get_locale() const;

Expand Down
3 changes: 3 additions & 0 deletions drivers/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ SConscript("winmidi/SCsub")
# Graphics drivers
if env["platform"] != "server" and env["platform"] != "javascript":
SConscript("vulkan/SCsub")
SConscript("gles2/SCsub")
SConscript("gles_common/SCsub")
SConscript("gl_context/SCsub")
else:
SConscript("dummy/SCsub")

Expand Down
23 changes: 23 additions & 0 deletions drivers/gl_context/SCsub
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python

Import("env")

if env["platform"] in ["haiku", "osx", "windows", "linuxbsd"]:
# Thirdparty source files
thirdparty_dir = "#thirdparty/glad/"
thirdparty_sources = [
"glad.c",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

env.Prepend(CPPPATH=[thirdparty_dir])

env.Append(CPPDEFINES=["GLAD_ENABLED"])
env.Append(CPPDEFINES=["GLES_OVER_GL"])

env_thirdparty = env.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.drivers_sources, thirdparty_sources)

# Godot source files
env.add_source_files(env.drivers_sources, "*.cpp")
7 changes: 7 additions & 0 deletions drivers/gles2/SCsub
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python

Import("env")

env.add_source_files(env.drivers_sources, "*.cpp")

SConscript("shaders/SCsub")
Loading