0003-emscripten-nthreads.patch 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. diff --git a/thirdparty/embree/common/sys/sysinfo.cpp b/thirdparty/embree/common/sys/sysinfo.cpp
  2. index 5f375cd95c..3c23fb1610 100644
  3. --- a/thirdparty/embree/common/sys/sysinfo.cpp
  4. +++ b/thirdparty/embree/common/sys/sysinfo.cpp
  5. @@ -659,6 +659,10 @@ namespace embree
  6. #if defined(__EMSCRIPTEN__)
  7. #include <emscripten.h>
  8. +
  9. +extern "C" {
  10. +extern int godot_js_os_hw_concurrency_get();
  11. +}
  12. #endif
  13. namespace embree
  14. @@ -672,6 +676,8 @@ namespace embree
  15. nThreads = sysconf(_SC_NPROCESSORS_ONLN); // does not work in Linux LXC container
  16. assert(nThreads);
  17. #elif defined(__EMSCRIPTEN__)
  18. + nThreads = godot_js_os_hw_concurrency_get();
  19. +#if 0
  20. // WebAssembly supports pthreads, but not pthread_getaffinity_np. Get the number of logical
  21. // threads from the browser or Node.js using JavaScript.
  22. nThreads = MAIN_THREAD_EM_ASM_INT({
  23. @@ -687,6 +693,7 @@ namespace embree
  24. return 1;
  25. }
  26. });
  27. +#endif
  28. #else
  29. cpu_set_t set;
  30. if (pthread_getaffinity_np(pthread_self(), sizeof(set), &set) == 0)