Merge pull request #46119 from Faless/js/4.x_processor_count
[HTML5] Implement OS.get_processor_count(), 4.0 fixes
This commit is contained in:
commit
fa24c99a5c
@ -210,8 +210,22 @@ public:
|
|||||||
bool can_create_resources_async() const override { return false; }
|
bool can_create_resources_async() const override { return false; }
|
||||||
|
|
||||||
/* TEXTURE API */
|
/* TEXTURE API */
|
||||||
RID texture_allocate() override { return RID(); }
|
struct DummyTexture {
|
||||||
void texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) override {}
|
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_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_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 {}
|
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_2d_layered_placeholder_initialize(RID p_texture, RenderingServer::TextureLayeredType p_layered_type) override {}
|
||||||
void texture_3d_placeholder_initialize(RID p_texture) 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>(); }
|
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>>(); }
|
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(); }
|
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; }
|
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; }
|
bool has_os_feature(const String &p_feature) const override { return false; }
|
||||||
|
|
||||||
|
@ -92,9 +92,9 @@ def configure(env):
|
|||||||
if not env["threads_enabled"]:
|
if not env["threads_enabled"]:
|
||||||
print("Threads must be enabled to build the editor. Please add the 'threads_enabled=yes' option")
|
print("Threads must be enabled to build the editor. Please add the 'threads_enabled=yes' option")
|
||||||
sys.exit(255)
|
sys.exit(255)
|
||||||
if env["initial_memory"] < 32:
|
if env["initial_memory"] < 64:
|
||||||
print("Editor build requires at least 32MiB of initial memory. Forcing it.")
|
print("Editor build requires at least 64MiB of initial memory. Forcing it.")
|
||||||
env["initial_memory"] = 32
|
env["initial_memory"] = 64
|
||||||
elif env["builtin_icu"]:
|
elif env["builtin_icu"]:
|
||||||
env.Append(CCFLAGS=["-frtti"])
|
env.Append(CCFLAGS=["-frtti"])
|
||||||
else:
|
else:
|
||||||
@ -233,3 +233,11 @@ def configure(env):
|
|||||||
|
|
||||||
# Add code that allow exiting runtime.
|
# Add code that allow exiting runtime.
|
||||||
env.Append(LINKFLAGS=["-s", "EXIT_RUNTIME=1"])
|
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']",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
@ -49,6 +49,7 @@ extern int godot_js_os_fs_is_persistent();
|
|||||||
extern void godot_js_os_fs_sync(void (*p_callback)());
|
extern void godot_js_os_fs_sync(void (*p_callback)());
|
||||||
extern int godot_js_os_execute(const char *p_json);
|
extern int godot_js_os_execute(const char *p_json);
|
||||||
extern void godot_js_os_shell_open(const char *p_uri);
|
extern void godot_js_os_shell_open(const char *p_uri);
|
||||||
|
extern int godot_js_os_hw_concurrency_get();
|
||||||
|
|
||||||
// Display
|
// Display
|
||||||
extern int godot_js_display_screen_dpi_get();
|
extern int godot_js_display_screen_dpi_get();
|
||||||
|
@ -282,6 +282,11 @@ const GodotOS = {
|
|||||||
godot_js_os_shell_open: function (p_uri) {
|
godot_js_os_shell_open: function (p_uri) {
|
||||||
window.open(GodotRuntime.parseString(p_uri), '_blank');
|
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');
|
autoAddDeps(GodotOS, '$GodotOS');
|
||||||
|
@ -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.");
|
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) {
|
bool OS_JavaScript::_check_internal_feature_support(const String &p_feature) {
|
||||||
if (p_feature == "HTML5" || p_feature == "web") {
|
if (p_feature == "HTML5" || p_feature == "web") {
|
||||||
return true;
|
return true;
|
||||||
|
@ -74,6 +74,7 @@ public:
|
|||||||
Error create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id = nullptr) override;
|
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;
|
Error kill(const ProcessID &p_pid) override;
|
||||||
int get_process_id() const override;
|
int get_process_id() const override;
|
||||||
|
int get_processor_count() const override;
|
||||||
|
|
||||||
String get_executable_path() const override;
|
String get_executable_path() const override;
|
||||||
Error shell_open(String p_uri) override;
|
Error shell_open(String p_uri) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user