godot-changes-c58c5216.patch 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. diff --git a/common/platform.h b/common/platform.h
  2. index be14bc7..9373b61 100644
  3. --- a/common/platform.h
  4. +++ b/common/platform.h
  5. @@ -19,7 +19,7 @@
  6. #if defined(_WIN32)
  7. #define WIN32_LEAN_AND_MEAN
  8. #define NOMINMAX
  9. - #include <Windows.h>
  10. + #include <windows.h>
  11. #elif defined(__APPLE__)
  12. #include <sys/sysctl.h>
  13. #endif
  14. @@ -129,4 +129,3 @@ namespace oidn {
  15. std::string getBuildName();
  16. } // namespace oidn
  17. -
  18. diff --git a/core/autoencoder.cpp b/core/autoencoder.cpp
  19. index d6915e6..d8da684 100644
  20. --- a/core/autoencoder.cpp
  21. +++ b/core/autoencoder.cpp
  22. @@ -90,13 +90,19 @@ namespace oidn {
  23. if (!dirty)
  24. return;
  25. - device->executeTask([&]()
  26. - {
  27. + // -- GODOT start --
  28. + //device->executeTask([&]()
  29. + //{
  30. + // GODOT end --
  31. +
  32. if (mayiuse(avx512_common))
  33. net = buildNet<16>();
  34. else
  35. net = buildNet<8>();
  36. - });
  37. +
  38. + // GODOT start --
  39. + //});
  40. + // GODOT end --
  41. dirty = false;
  42. }
  43. @@ -108,9 +114,10 @@ namespace oidn {
  44. if (!net)
  45. return;
  46. -
  47. - device->executeTask([&]()
  48. - {
  49. + // -- GODOT start --
  50. + //device->executeTask([&]()
  51. + //{
  52. + // -- GODOT end --
  53. Progress progress;
  54. progress.func = progressFunc;
  55. progress.userPtr = progressUserPtr;
  56. @@ -156,7 +163,9 @@ namespace oidn {
  57. tileIndex++;
  58. }
  59. }
  60. - });
  61. + // -- GODOT start --
  62. + //});
  63. + // -- GODOT end --
  64. }
  65. void AutoencoderFilter::computeTileSize()
  66. @@ -464,6 +473,11 @@ namespace oidn {
  67. return std::make_shared<GammaTransferFunction>();
  68. }
  69. +// -- GODOT start --
  70. +// Godot doesn't need Raytracing filters. Removing them saves space in the weights files.
  71. +#if 0
  72. +// -- GODOT end --
  73. +
  74. // --------------------------------------------------------------------------
  75. // RTFilter
  76. // --------------------------------------------------------------------------
  77. @@ -491,6 +505,9 @@ namespace oidn {
  78. weightData.hdr_alb = weights::rt_hdr_alb;
  79. weightData.hdr_alb_nrm = weights::rt_hdr_alb_nrm;
  80. }
  81. +// -- GODOT start --
  82. +#endif
  83. +// -- GODOT end --
  84. // --------------------------------------------------------------------------
  85. // RTLightmapFilter
  86. diff --git a/core/autoencoder.h b/core/autoencoder.h
  87. index c199052..98b6108 100644
  88. --- a/core/autoencoder.h
  89. +++ b/core/autoencoder.h
  90. @@ -93,11 +93,18 @@ namespace oidn {
  91. // RTFilter - Generic ray tracing denoiser
  92. // --------------------------------------------------------------------------
  93. +// -- GODOT start --
  94. +// Godot doesn't need Raytracing filters. Removing them saves space in the weights files.
  95. +#if 0
  96. +// -- GODOT end --
  97. class RTFilter : public AutoencoderFilter
  98. {
  99. public:
  100. explicit RTFilter(const Ref<Device>& device);
  101. };
  102. +// -- GODOT start --
  103. +#endif
  104. +// -- GODOT end --
  105. // --------------------------------------------------------------------------
  106. // RTLightmapFilter - Ray traced lightmap denoiser
  107. diff --git a/core/common.h b/core/common.h
  108. index a3a7e8a..a35dd90 100644
  109. --- a/core/common.h
  110. +++ b/core/common.h
  111. @@ -27,7 +27,9 @@
  112. #include "common/ref.h"
  113. #include "common/exception.h"
  114. #include "common/thread.h"
  115. -#include "common/tasking.h"
  116. +// -- GODOT start --
  117. +//#include "common/tasking.h"
  118. +// -- GODOT end --
  119. #include "math.h"
  120. namespace oidn {
  121. diff --git a/core/device.cpp b/core/device.cpp
  122. index c455695..3cd658b 100644
  123. --- a/core/device.cpp
  124. +++ b/core/device.cpp
  125. @@ -29,7 +29,9 @@ namespace oidn {
  126. Device::~Device()
  127. {
  128. - observer.reset();
  129. + // -- GODOT start --
  130. + //observer.reset();
  131. + // -- GODOT end --
  132. }
  133. void Device::setError(Device* device, Error code, const std::string& message)
  134. @@ -141,6 +143,9 @@ namespace oidn {
  135. if (isCommitted())
  136. throw Exception(Error::InvalidOperation, "device can be committed only once");
  137. + // -- GODOT start --
  138. + #if 0
  139. + // -- GODOT end --
  140. // Get the optimal thread affinities
  141. if (setAffinity)
  142. {
  143. @@ -157,7 +162,10 @@ namespace oidn {
  144. // Automatically set the thread affinities
  145. if (affinity)
  146. observer = std::make_shared<PinningObserver>(affinity, *arena);
  147. -
  148. + // -- GODOT start --
  149. + #endif
  150. + numThreads = 1;
  151. + // -- GODOT end --
  152. dirty = false;
  153. if (isVerbose())
  154. @@ -191,9 +199,17 @@ namespace oidn {
  155. Ref<Filter> filter;
  156. +// -- GODOT start --
  157. +// Godot doesn't need Raytracing filters. Removing them saves space in the weights files.
  158. +#if 0
  159. +// -- GODOT end --
  160. if (type == "RT")
  161. filter = makeRef<RTFilter>(Ref<Device>(this));
  162. - else if (type == "RTLightmap")
  163. +// -- GODOT start --
  164. +// Godot doesn't need Raytracing filters. Removing them saves space in the weights files.
  165. +#endif
  166. + if (type == "RTLightmap")
  167. +// -- GODOT end --
  168. filter = makeRef<RTLightmapFilter>(Ref<Device>(this));
  169. else
  170. throw Exception(Error::InvalidArgument, "unknown filter type");
  171. @@ -210,11 +226,12 @@ namespace oidn {
  172. std::cout << " Build : " << getBuildName() << std::endl;
  173. std::cout << " Platform: " << getPlatformName() << std::endl;
  174. - std::cout << " Tasking :";
  175. - std::cout << " TBB" << TBB_VERSION_MAJOR << "." << TBB_VERSION_MINOR;
  176. - std::cout << " TBB_header_interface_" << TBB_INTERFACE_VERSION << " TBB_lib_interface_" << tbb::TBB_runtime_interface_version();
  177. - std::cout << std::endl;
  178. -
  179. +// -- GODOT start --
  180. +// std::cout << " Tasking :";
  181. +// std::cout << " TBB" << TBB_VERSION_MAJOR << "." << TBB_VERSION_MINOR;
  182. +// std::cout << " TBB_header_interface_" << TBB_INTERFACE_VERSION << " TBB_lib_interface_" << tbb::TBB_runtime_interface_version();
  183. +// std::cout << std::endl;
  184. +// -- GODOT end --
  185. std::cout << std::endl;
  186. }
  187. diff --git a/core/device.h b/core/device.h
  188. index c2df714..d9cfd85 100644
  189. --- a/core/device.h
  190. +++ b/core/device.h
  191. @@ -41,10 +41,12 @@ namespace oidn {
  192. ErrorFunction errorFunc = nullptr;
  193. void* errorUserPtr = nullptr;
  194. - // Tasking
  195. - std::shared_ptr<tbb::task_arena> arena;
  196. - std::shared_ptr<PinningObserver> observer;
  197. - std::shared_ptr<ThreadAffinity> affinity;
  198. +// -- GODOT start --
  199. +// // Tasking
  200. +// std::shared_ptr<tbb::task_arena> arena;
  201. +// std::shared_ptr<PinningObserver> observer;
  202. +// std::shared_ptr<ThreadAffinity> affinity;
  203. +// -- GODOT end --
  204. // Parameters
  205. int numThreads = 0; // autodetect by default
  206. @@ -66,17 +68,19 @@ namespace oidn {
  207. void commit();
  208. - template<typename F>
  209. - void executeTask(F& f)
  210. - {
  211. - arena->execute(f);
  212. - }
  213. +// -- GODOT start --
  214. +// template<typename F>
  215. +// void executeTask(F& f)
  216. +// {
  217. +// arena->execute(f);
  218. +// }
  219. - template<typename F>
  220. - void executeTask(const F& f)
  221. - {
  222. - arena->execute(f);
  223. - }
  224. +// template<typename F>
  225. +// void executeTask(const F& f)
  226. +// {
  227. +// arena->execute(f);
  228. +// }
  229. +// -- GODOT end --
  230. Ref<Buffer> newBuffer(size_t byteSize);
  231. Ref<Buffer> newBuffer(void* ptr, size_t byteSize);
  232. @@ -86,7 +90,10 @@ namespace oidn {
  233. __forceinline std::mutex& getMutex() { return mutex; }
  234. private:
  235. - bool isCommitted() const { return bool(arena); }
  236. +// -- GODOT start --
  237. + //bool isCommitted() const { return bool(arena); }
  238. + bool isCommitted() const { return false; }
  239. +// -- GODOT end --
  240. void checkCommitted();
  241. void print();
  242. diff --git a/core/network.cpp b/core/network.cpp
  243. index 8c2de09..ed8328c 100644
  244. --- a/core/network.cpp
  245. +++ b/core/network.cpp
  246. @@ -17,6 +17,9 @@
  247. #include "upsample.h"
  248. #include "weights_reorder.h"
  249. #include "network.h"
  250. +// -- GODOT start --
  251. +#include <cstring>
  252. +// -- GODOT end --
  253. namespace oidn {
  254. diff --git a/core/transfer_function.cpp b/core/transfer_function.cpp
  255. index 601f814..ce5deca 100644
  256. --- a/core/transfer_function.cpp
  257. +++ b/core/transfer_function.cpp
  258. @@ -38,16 +38,24 @@ namespace oidn {
  259. // Compute the average log luminance of the downsampled image
  260. using Sum = std::pair<float, int>;
  261. - Sum sum =
  262. - tbb::parallel_reduce(
  263. - tbb::blocked_range2d<int>(0, HK, 0, WK),
  264. - Sum(0.f, 0),
  265. - [&](const tbb::blocked_range2d<int>& r, Sum sum) -> Sum
  266. + // -- GODOT start --
  267. + // Sum sum =
  268. + // tbb::parallel_reduce(
  269. + // tbb::blocked_range2d<int>(0, HK, 0, WK),
  270. + // Sum(0.f, 0),
  271. + // [&](const tbb::blocked_range2d<int>& r, Sum sum) -> Sum
  272. + // {
  273. + // // Iterate over blocks
  274. + // for (int i = r.rows().begin(); i != r.rows().end(); ++i)
  275. + // {
  276. + // for (int j = r.cols().begin(); j != r.cols().end(); ++j)
  277. + // {
  278. +
  279. + Sum sum = Sum(0.0f, 0);
  280. +
  281. + for (int i = 0; i != HK; ++i)
  282. {
  283. - // Iterate over blocks
  284. - for (int i = r.rows().begin(); i != r.rows().end(); ++i)
  285. - {
  286. - for (int j = r.cols().begin(); j != r.cols().end(); ++j)
  287. + for (int j = 0; j != WK; ++j)
  288. {
  289. // Compute the average luminance in the current block
  290. const int beginH = int(ptrdiff_t(i) * H / HK);
  291. @@ -82,11 +90,12 @@ namespace oidn {
  292. }
  293. }
  294. - return sum;
  295. - },
  296. - [](Sum a, Sum b) -> Sum { return Sum(a.first+b.first, a.second+b.second); },
  297. - tbb::static_partitioner()
  298. - );
  299. + // return sum;
  300. + // },
  301. + // [](Sum a, Sum b) -> Sum { return Sum(a.first+b.first, a.second+b.second); },
  302. + // tbb::static_partitioner()
  303. + // );
  304. + // -- GODOT end --
  305. return (sum.second > 0) ? (key / exp2(sum.first / float(sum.second))) : 1.f;
  306. }