godot-changes-android.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. diff --git a/thirdparty/embree/common/sys/sysinfo.cpp b/thirdparty/embree/common/sys/sysinfo.cpp
  2. index ba97dc227b..1679599608 100644
  3. --- a/thirdparty/embree/common/sys/sysinfo.cpp
  4. +++ b/thirdparty/embree/common/sys/sysinfo.cpp
  5. @@ -618,7 +618,10 @@ namespace embree
  6. static int nThreads = -1;
  7. if (nThreads != -1) return nThreads;
  8. -#if defined(__MACOSX__)
  9. +// -- GODOT start --
  10. +// #if defined(__MACOSX__)
  11. +#if defined(__MACOSX__) || defined(__ANDROID__)
  12. +// -- GODOT end --
  13. nThreads = sysconf(_SC_NPROCESSORS_ONLN); // does not work in Linux LXC container
  14. assert(nThreads);
  15. #else
  16. diff --git a/thirdparty/embree/common/sys/thread.cpp b/thirdparty/embree/common/sys/thread.cpp
  17. index a7827e18f7..f4014be89b 100644
  18. --- a/thirdparty/embree/common/sys/thread.cpp
  19. +++ b/thirdparty/embree/common/sys/thread.cpp
  20. @@ -158,7 +158,9 @@ namespace embree
  21. /// Linux Platform
  22. ////////////////////////////////////////////////////////////////////////////////
  23. -#if defined(__LINUX__)
  24. +// -- GODOT start --
  25. +#if defined(__LINUX__) && !defined(__ANDROID__)
  26. +// -- GODOT end --
  27. #include <fstream>
  28. #include <sstream>
  29. @@ -247,6 +249,28 @@ namespace embree
  30. }
  31. #endif
  32. +// -- GODOT start --
  33. +////////////////////////////////////////////////////////////////////////////////
  34. +/// Android Platform
  35. +////////////////////////////////////////////////////////////////////////////////
  36. +
  37. +#if defined(__ANDROID__)
  38. +
  39. +namespace embree
  40. +{
  41. + /*! set affinity of the calling thread */
  42. + void setAffinity(ssize_t affinity)
  43. + {
  44. + cpu_set_t cset;
  45. + CPU_ZERO(&cset);
  46. + CPU_SET(affinity, &cset);
  47. +
  48. + sched_setaffinity(0, sizeof(cset), &cset);
  49. + }
  50. +}
  51. +#endif
  52. +// -- GODOT end --
  53. +
  54. ////////////////////////////////////////////////////////////////////////////////
  55. /// FreeBSD Platform
  56. ////////////////////////////////////////////////////////////////////////////////
  57. @@ -355,7 +379,9 @@ namespace embree
  58. pthread_attr_destroy(&attr);
  59. /* set affinity */
  60. -#if defined(__LINUX__)
  61. +// -- GODOT start --
  62. +#if defined(__LINUX__) && !defined(__ANDROID__)
  63. +// -- GODOT end --
  64. if (threadID >= 0) {
  65. cpu_set_t cset;
  66. CPU_ZERO(&cset);
  67. @@ -370,7 +396,16 @@ namespace embree
  68. CPU_SET(threadID, &cset);
  69. pthread_setaffinity_np(*tid, sizeof(cset), &cset);
  70. }
  71. +// -- GODOT start --
  72. +#elif defined(__ANDROID__)
  73. + if (threadID >= 0) {
  74. + cpu_set_t cset;
  75. + CPU_ZERO(&cset);
  76. + CPU_SET(threadID, &cset);
  77. + sched_setaffinity(pthread_gettid_np(*tid), sizeof(cset), &cset);
  78. + }
  79. #endif
  80. +// -- GODOT end --
  81. return thread_t(tid);
  82. }
  83. @@ -389,8 +424,14 @@ namespace embree
  84. /*! destroy a hardware thread by its handle */
  85. void destroyThread(thread_t tid) {
  86. +// -- GODOT start --
  87. +#if defined(__ANDROID__)
  88. + FATAL("Can't destroy threads on Android.");
  89. +#else
  90. pthread_cancel(*(pthread_t*)tid);
  91. delete (pthread_t*)tid;
  92. +#endif
  93. +// -- GODOT end --
  94. }
  95. /*! creates thread local storage */