diff --git a/base/sources/backends/data/wasm/start.js b/base/sources/backends/data/wasm/start.js index 524f5e90..0362ef7d 100644 --- a/base/sources/backends/data/wasm/start.js +++ b/base/sources/backends/data/wasm/start.js @@ -83,7 +83,7 @@ async function init() { let wasm_bytes = null; await fetch("./start.wasm").then(res => res.arrayBuffer()).then(buffer => wasm_bytes = new Uint8Array(buffer)); - memory = new WebAssembly.Memory({initial : 4356, maximum : 4356, shared : true}); // * 65536 = 285474816 (make.js --initial-memory) + memory = new WebAssembly.Memory({initial : 8192, maximum : 8192, shared : true}); // * 65536 = 536870912 (make.js --initial-memory) heapu8 = new Uint8Array(memory.buffer); heapu16 = new Uint16Array(memory.buffer); heapu32 = new Uint32Array(memory.buffer); diff --git a/base/sources/backends/wasm_system.c b/base/sources/backends/wasm_system.c index 30882a7e..32be7580 100644 --- a/base/sources/backends/wasm_system.c +++ b/base/sources/backends/wasm_system.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -160,3 +161,22 @@ void iron_net_update() { } volatile uint64_t iron_net_bytes_downloaded = 0; + +void iron_net_request(const char *url_base, const char *url_path, const char *data, int port, int method, iron_https_callback_t callback, void *callbackdata, + const char *dst_path) { +} + +bool _save_and_quit_callback_internal() { + return false; +} + +const char *iron_language() { + return "en"; +} + +void iron_load_url(const char *url) { +} + +const char *iron_system_id() { + return "wasm"; +} diff --git a/base/sources/backends/webgpu_gpu.c b/base/sources/backends/webgpu_gpu.c index d3813982..eacef38e 100644 --- a/base/sources/backends/webgpu_gpu.c +++ b/base/sources/backends/webgpu_gpu.c @@ -782,3 +782,17 @@ void gpu_buffer_destroy_internal(gpu_buffer_t *buffer) { char *gpu_device_name() { return device_name; } + +bool gpu_raytrace_supported(void) { return false; } +void gpu_raytrace_pipeline_init(gpu_raytrace_pipeline_t *pipeline, void *ray_shader, int ray_shader_size, gpu_buffer_t *constant_buffer) {} +void gpu_raytrace_pipeline_destroy(gpu_raytrace_pipeline_t *pipeline) {} +void gpu_raytrace_acceleration_structure_init(gpu_raytrace_acceleration_structure_t *accel) {} +void gpu_raytrace_acceleration_structure_add(gpu_raytrace_acceleration_structure_t *accel, gpu_buffer_t *vb, gpu_buffer_t *ib, iron_matrix4x4_t transform) {} +void gpu_raytrace_acceleration_structure_build(gpu_raytrace_acceleration_structure_t *accel, gpu_buffer_t *_vb_full, gpu_buffer_t *_ib_full) {} +void gpu_raytrace_acceleration_structure_destroy(gpu_raytrace_acceleration_structure_t *accel) {} +void gpu_raytrace_set_textures(gpu_texture_t *texpaint0, gpu_texture_t *texpaint1, gpu_texture_t *texpaint2, gpu_texture_t *texenv, gpu_texture_t *texsobol, + gpu_texture_t *texscramble, gpu_texture_t *texrank) {} +void gpu_raytrace_set_acceleration_structure(gpu_raytrace_acceleration_structure_t *accel) {} +void gpu_raytrace_set_pipeline(gpu_raytrace_pipeline_t *pipeline) {} +void gpu_raytrace_set_target(gpu_texture_t *output) {} +void gpu_raytrace_dispatch_rays() {} diff --git a/base/sources/iron.h b/base/sources/iron.h index 0477db54..445c07d9 100644 --- a/base/sources/iron.h +++ b/base/sources/iron.h @@ -1473,6 +1473,17 @@ char *iron_save_dialog(char *filter_list, char *default_path) { wcstombs(temp_string, out_path, sizeof(temp_string)); return temp_string; } + +#elif defined(IRON_WASM) + +char_ptr_array_t *iron_open_dialog(char *filter_list, char *default_path, bool open_multiple) { + return NULL; +} + +char *iron_save_dialog(char *filter_list, char *default_path) { + return NULL; +} + #endif char *iron_read_directory(char *path) { diff --git a/base/sources/libs/miniclib/inttypes.h b/base/sources/libs/miniclib/inttypes.h new file mode 100644 index 00000000..c48840b5 --- /dev/null +++ b/base/sources/libs/miniclib/inttypes.h @@ -0,0 +1,3 @@ +#pragma once + +#define PRIu64 "llu" diff --git a/base/sources/libs/miniclib/math.c b/base/sources/libs/miniclib/math.c index 5380fc9d..8657ee7f 100644 --- a/base/sources/libs/miniclib/math.c +++ b/base/sources/libs/miniclib/math.c @@ -193,6 +193,22 @@ float expf(float x) { return 0.0; } +double exp2(double x) { + return 0.0; +} + +float exp2f(float x) { + return 0.0f; +} + +double frexp(double x, int *exp) { + return 0.0; +} + +float frexpf(float x, int *exp) { + return 0.0; +} + double sqrt(double x) { #ifdef IRON_WASM return js_sqrt(x); @@ -211,6 +227,10 @@ double fmod(double x, double y) { return 0.0; } +float fmodf(float x, float y) { + return 0.0f; +} + int isnan(float x) { return 0; } diff --git a/base/sources/libs/miniclib/math.h b/base/sources/libs/miniclib/math.h index 29b01e53..10fe9f2f 100644 --- a/base/sources/libs/miniclib/math.h +++ b/base/sources/libs/miniclib/math.h @@ -32,9 +32,14 @@ float logf(float x); float log2f(float x); double exp(double x); float expf(float x); +double exp2(double x); +float exp2f(float x); +double frexp(double x, int *exp); +float frexpf(float x, int *exp); double sqrt(double x); float sqrtf(float x); double fmod(double x, double y); +float fmodf(float x, float y); int isnan(float x); #define NAN (0.0F / 0.0F) diff --git a/base/sources/libs/miniclib/memory.c b/base/sources/libs/miniclib/memory.c index 8029ce2c..fde3bf94 100644 --- a/base/sources/libs/miniclib/memory.c +++ b/base/sources/libs/miniclib/memory.c @@ -39,6 +39,10 @@ void *realloc(void *mem, size_t size) { void free(void *mem) {} +void *aligned_alloc(size_t align, size_t size) { + return NULL; +} + void *memset(void *ptr, int value, size_t num) { unsigned char *data = (unsigned char *)ptr; for (size_t i = 0; i < num; ++i) { @@ -66,3 +70,7 @@ int memcmp(const void *ptr1, const void *ptr2, size_t num) { } return 0; } + +void *memmove(void *destination, const void *source, size_t num) { + return NULL; +} diff --git a/base/sources/libs/miniclib/stdlib.c b/base/sources/libs/miniclib/stdlib.c index e689b6c6..ff67f889 100644 --- a/base/sources/libs/miniclib/stdlib.c +++ b/base/sources/libs/miniclib/stdlib.c @@ -16,6 +16,10 @@ float strtof(const char *str, char **endptr) { return 0.0f; } +double strtod(const char *str, char **endptr) { + return 0.0; +} + double atof (const char* str) { return 0.0; } diff --git a/base/sources/libs/miniclib/stdlib.h b/base/sources/libs/miniclib/stdlib.h index 9ac5dc0d..73a694cb 100644 --- a/base/sources/libs/miniclib/stdlib.h +++ b/base/sources/libs/miniclib/stdlib.h @@ -9,12 +9,14 @@ void *malloc(size_t size); void *calloc(size_t num, size_t size); void *realloc(void *mem, size_t size); void free(void *mem); +void *aligned_alloc(size_t align, size_t size); int system(const char *string); void exit(int code); long int strtol(const char *str, char **endptr, int base); float strtof(const char *str, char **endptr); +double strtod(const char *str, char **endptr); double atof(const char *str); int abs(int n); long long int llabs(long long int n); diff --git a/base/sources/libs/miniclib/string.h b/base/sources/libs/miniclib/string.h index 2c88c8d3..c829eda4 100644 --- a/base/sources/libs/miniclib/string.h +++ b/base/sources/libs/miniclib/string.h @@ -2,37 +2,23 @@ #include -void *memset(void *ptr, int value, size_t num); - -void *memcpy(void *destination, const void *source, size_t num); - -int memcmp(const void *ptr1, const void *ptr2, size_t num); - +void *memset(void *ptr, int value, size_t num); +void *memcpy(void *destination, const void *source, size_t num); +int memcmp(const void *ptr1, const void *ptr2, size_t num); +void *memmove(void *destination, const void *source, size_t num); size_t strlen(const char *str); - -char *strcpy(char *destination, const char *source); - -char *strncpy(char *destination, const char *source, size_t num); - -char *strcat(char *destination, const char *source); +char *strcpy(char *destination, const char *source); +char *strncpy(char *destination, const char *source, size_t num); +char *strcat(char *destination, const char *source); // built-in in Clang -char *strstr(const char *str1, const char *str2); - -int strcmp(const char *str1, const char *str2); - -int strncmp(const char *str1, const char *str2, size_t num); - -size_t wcslen(const wchar_t *str); - +char *strstr(const char *str1, const char *str2); +int strcmp(const char *str1, const char *str2); +int strncmp(const char *str1, const char *str2, size_t num); +size_t wcslen(const wchar_t *str); wchar_t *wcscpy(wchar_t *destination, const wchar_t *source); - wchar_t *wcsncpy(wchar_t *destination, const wchar_t *source, size_t num); - wchar_t *wcscat(wchar_t *destination, const wchar_t *source); - wchar_t *wcsstr(wchar_t *str1, const wchar_t *str2); - -int wcscmp(const wchar_t *str1, const wchar_t *str2); - -int wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t num); +int wcscmp(const wchar_t *str1, const wchar_t *str2); +int wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t num); diff --git a/base/tools/make.js b/base/tools/make.js index 5d138ee9..209dcf60 100644 --- a/base/tools/make.js +++ b/base/tools/make.js @@ -947,7 +947,7 @@ class WasmExporter extends Exporter { let compilerFlags = ""; this.make = new MakeExporter(compiler, compiler, compilerFlags, compilerFlags, - '--target=wasm32 -nostdlib -matomics -mbulk-memory "-Wl,--import-memory,--shared-memory,--allow-undefined,--no-entry,--stack-first,--initial-memory=285474816,--max-memory=285474816,-z,stack-size=10000"', '.wasm'); + '--target=wasm32 -nostdlib -matomics -mbulk-memory "-Wl,--import-memory,--shared-memory,--allow-undefined,--no-entry,--stack-first,--initial-memory=536870912,--max-memory=536870912,-z,stack-size=10000"', '.wasm'); } export_solution(project) { diff --git a/paint/project.js b/paint/project.js index 065e41d4..c330d938 100644 --- a/paint/project.js +++ b/paint/project.js @@ -17,6 +17,16 @@ flags.idle_sleep = true; flags.export_version_info = true; flags.export_data_list = platform == "android"; // .apk contents +if (platform == "wasm") { + flags.with_nfd = false; + flags.with_compress = false; + flags.with_video_write = false; + flags.with_eval = false; + flags.with_plugins = false; + flags.with_raytrace = false; + flags.idle_sleep = false; +} + let project = new Project(flags.name); project.add_project("../base"); project.add_tsfiles("sources");