diff options
-rw-r--r-- | drivers/dummy/rasterizer_dummy.h | 35 | ||||
-rw-r--r-- | platform/javascript/detect.py | 14 | ||||
-rw-r--r-- | platform/javascript/godot_js.h | 1 | ||||
-rw-r--r-- | platform/javascript/js/libs/library_godot_os.js | 5 | ||||
-rw-r--r-- | platform/javascript/os_javascript.cpp | 4 | ||||
-rw-r--r-- | platform/javascript/os_javascript.h | 1 |
6 files changed, 53 insertions, 7 deletions
diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index 082f247476..a76520dcdb 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -210,8 +210,22 @@ public: bool can_create_resources_async() const override { return false; } /* TEXTURE API */ - RID texture_allocate() override { return RID(); } - void texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) override {} + struct DummyTexture { + Ref<Image> image; + }; + mutable RID_PtrOwner<DummyTexture> texture_owner; + + RID texture_allocate() override { + DummyTexture *texture = memnew(DummyTexture); + ERR_FAIL_COND_V(!texture, RID()); + return texture_owner.make_rid(texture); + } + void texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) override { + DummyTexture *t = texture_owner.getornull(p_texture); + ERR_FAIL_COND(!t); + t->image = p_image->duplicate(); + } + void texture_2d_layered_initialize(RID p_texture, const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) override {} void texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) override {} void texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) override {} @@ -224,7 +238,12 @@ public: void texture_2d_layered_placeholder_initialize(RID p_texture, RenderingServer::TextureLayeredType p_layered_type) override {} void texture_3d_placeholder_initialize(RID p_texture) override {} - Ref<Image> texture_2d_get(RID p_texture) const override { return Ref<Image>(); } + Ref<Image> texture_2d_get(RID p_texture) const override { + DummyTexture *t = texture_owner.getornull(p_texture); + ERR_FAIL_COND_V(!t, Ref<Image>()); + return t->image; + } + Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const override { return Ref<Image>(); } Vector<Ref<Image>> texture_3d_get(RID p_texture) const override { return Vector<Ref<Image>>(); } @@ -635,7 +654,15 @@ public: Rect2i render_target_get_sdf_rect(RID p_render_target) const override { return Rect2i(); } RS::InstanceType get_base_type(RID p_rid) const override { return RS::INSTANCE_NONE; } - bool free(RID p_rid) override { return true; } + bool free(RID p_rid) override { + if (texture_owner.owns(p_rid)) { + // delete the texture + DummyTexture *texture = texture_owner.getornull(p_rid); + texture_owner.free(p_rid); + memdelete(texture); + } + return true; + } bool has_os_feature(const String &p_feature) const override { return false; } diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 06f88dc83f..4297088c09 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -92,9 +92,9 @@ def configure(env): if not env["threads_enabled"]: print("Threads must be enabled to build the editor. Please add the 'threads_enabled=yes' option") sys.exit(255) - if env["initial_memory"] < 32: - print("Editor build requires at least 32MiB of initial memory. Forcing it.") - env["initial_memory"] = 32 + if env["initial_memory"] < 64: + print("Editor build requires at least 64MiB of initial memory. Forcing it.") + env["initial_memory"] = 64 elif env["builtin_icu"]: env.Append(CCFLAGS=["-frtti"]) else: @@ -233,3 +233,11 @@ def configure(env): # Add code that allow exiting runtime. env.Append(LINKFLAGS=["-s", "EXIT_RUNTIME=1"]) + + # TODO remove once we have GLES support back (temporary fix undefined symbols due to dead code elimination). + env.Append( + LINKFLAGS=[ + "-s", + "EXPORTED_FUNCTIONS=['_main', '_emscripten_webgl_get_current_context', '_emscripten_webgl_commit_frame', '_emscripten_webgl_create_context']", + ] + ) diff --git a/platform/javascript/godot_js.h b/platform/javascript/godot_js.h index d2a2fbd6db..f0da8b7ca3 100644 --- a/platform/javascript/godot_js.h +++ b/platform/javascript/godot_js.h @@ -49,6 +49,7 @@ extern int godot_js_os_fs_is_persistent(); extern void godot_js_os_fs_sync(void (*p_callback)()); extern int godot_js_os_execute(const char *p_json); extern void godot_js_os_shell_open(const char *p_uri); +extern int godot_js_os_hw_concurrency_get(); // Display extern int godot_js_display_screen_dpi_get(); diff --git a/platform/javascript/js/libs/library_godot_os.js b/platform/javascript/js/libs/library_godot_os.js index 9fde4a84e1..3ffcd655b7 100644 --- a/platform/javascript/js/libs/library_godot_os.js +++ b/platform/javascript/js/libs/library_godot_os.js @@ -282,6 +282,11 @@ const GodotOS = { godot_js_os_shell_open: function (p_uri) { window.open(GodotRuntime.parseString(p_uri), '_blank'); }, + + godot_js_os_hw_concurrency_get__sig: 'i', + godot_js_os_hw_concurrency_get: function () { + return navigator.hardwareConcurrency || 1; + }, }; autoAddDeps(GodotOS, '$GodotOS'); diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index b922b2ba91..0b1650076c 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -129,6 +129,10 @@ int OS_JavaScript::get_process_id() const { ERR_FAIL_V_MSG(0, "OS::get_process_id() is not available on the HTML5 platform."); } +int OS_JavaScript::get_processor_count() const { + return godot_js_os_hw_concurrency_get(); +} + bool OS_JavaScript::_check_internal_feature_support(const String &p_feature) { if (p_feature == "HTML5" || p_feature == "web") { return true; diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 8db62d9d1c..81bb9c5f3d 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -74,6 +74,7 @@ public: Error create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id = nullptr) override; Error kill(const ProcessID &p_pid) override; int get_process_id() const override; + int get_processor_count() const override; String get_executable_path() const override; Error shell_open(String p_uri) override; |