SCsub 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #!/usr/bin/env python
  2. import resource_to_cpp
  3. Import("env")
  4. Import("env_modules")
  5. env_oidn = env_modules.Clone()
  6. # Thirdparty source files
  7. thirdparty_obj = []
  8. thirdparty_dir = "#thirdparty/oidn/"
  9. thirdparty_sources = [
  10. "core/api.cpp",
  11. "core/device.cpp",
  12. "core/filter.cpp",
  13. "core/network.cpp",
  14. "core/autoencoder.cpp",
  15. "core/transfer_function.cpp",
  16. "weights/rtlightmap_hdr.gen.cpp",
  17. "mkl-dnn/src/common/batch_normalization.cpp",
  18. "mkl-dnn/src/common/concat.cpp",
  19. "mkl-dnn/src/common/convolution.cpp",
  20. "mkl-dnn/src/common/convolution_pd.cpp",
  21. "mkl-dnn/src/common/deconvolution.cpp",
  22. "mkl-dnn/src/common/eltwise.cpp",
  23. "mkl-dnn/src/common/engine.cpp",
  24. "mkl-dnn/src/common/inner_product.cpp",
  25. "mkl-dnn/src/common/inner_product_pd.cpp",
  26. "mkl-dnn/src/common/lrn.cpp",
  27. "mkl-dnn/src/common/memory.cpp",
  28. "mkl-dnn/src/common/memory_desc_wrapper.cpp",
  29. "mkl-dnn/src/common/mkldnn_debug.cpp",
  30. "mkl-dnn/src/common/mkldnn_debug_autogenerated.cpp",
  31. "mkl-dnn/src/common/pooling.cpp",
  32. "mkl-dnn/src/common/primitive.cpp",
  33. "mkl-dnn/src/common/primitive_attr.cpp",
  34. "mkl-dnn/src/common/primitive_desc.cpp",
  35. "mkl-dnn/src/common/primitive_exec_types.cpp",
  36. "mkl-dnn/src/common/primitive_iterator.cpp",
  37. "mkl-dnn/src/common/query.cpp",
  38. "mkl-dnn/src/common/reorder.cpp",
  39. "mkl-dnn/src/common/rnn.cpp",
  40. "mkl-dnn/src/common/scratchpad.cpp",
  41. "mkl-dnn/src/common/shuffle.cpp",
  42. "mkl-dnn/src/common/softmax.cpp",
  43. "mkl-dnn/src/common/stream.cpp",
  44. "mkl-dnn/src/common/sum.cpp",
  45. "mkl-dnn/src/common/utils.cpp",
  46. "mkl-dnn/src/common/verbose.cpp",
  47. "mkl-dnn/src/cpu/cpu_barrier.cpp",
  48. "mkl-dnn/src/cpu/cpu_concat.cpp",
  49. "mkl-dnn/src/cpu/cpu_engine.cpp",
  50. "mkl-dnn/src/cpu/cpu_memory.cpp",
  51. "mkl-dnn/src/cpu/cpu_reducer.cpp",
  52. "mkl-dnn/src/cpu/cpu_reorder.cpp",
  53. "mkl-dnn/src/cpu/cpu_sum.cpp",
  54. "mkl-dnn/src/cpu/jit_avx2_conv_kernel_f32.cpp",
  55. "mkl-dnn/src/cpu/jit_avx2_convolution.cpp",
  56. "mkl-dnn/src/cpu/jit_avx512_common_conv_kernel.cpp",
  57. "mkl-dnn/src/cpu/jit_avx512_common_conv_winograd_kernel_f32.cpp",
  58. "mkl-dnn/src/cpu/jit_avx512_common_convolution.cpp",
  59. "mkl-dnn/src/cpu/jit_avx512_common_convolution_winograd.cpp",
  60. "mkl-dnn/src/cpu/jit_avx512_core_fp32_wino_conv_2x3.cpp",
  61. "mkl-dnn/src/cpu/jit_avx512_core_fp32_wino_conv_4x3.cpp",
  62. "mkl-dnn/src/cpu/jit_avx512_core_fp32_wino_conv_4x3_kernel.cpp",
  63. "mkl-dnn/src/cpu/jit_sse42_conv_kernel_f32.cpp",
  64. "mkl-dnn/src/cpu/jit_sse42_convolution.cpp",
  65. "mkl-dnn/src/cpu/jit_transpose_src_utils.cpp",
  66. "mkl-dnn/src/cpu/jit_uni_eltwise.cpp",
  67. "mkl-dnn/src/cpu/jit_uni_pool_kernel_f32.cpp",
  68. "mkl-dnn/src/cpu/jit_uni_pooling.cpp",
  69. "mkl-dnn/src/cpu/jit_uni_reorder.cpp",
  70. "mkl-dnn/src/cpu/jit_uni_reorder_utils.cpp",
  71. "mkl-dnn/src/cpu/jit_utils/jit_utils.cpp",
  72. "mkl-dnn/src/cpu/jit_utils/jitprofiling/jitprofiling.c",
  73. "common/platform.cpp",
  74. "common/thread.cpp",
  75. "common/tensor.cpp",
  76. ]
  77. thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
  78. thirdparty_include_dirs = [
  79. "",
  80. "include",
  81. "mkl-dnn/include",
  82. "mkl-dnn/src",
  83. "mkl-dnn/src/common",
  84. "mkl-dnn/src/cpu/xbyak",
  85. "mkl-dnn/src/cpu",
  86. ]
  87. thirdparty_include_dirs = [thirdparty_dir + file for file in thirdparty_include_dirs]
  88. env_oidn.Prepend(CPPPATH=thirdparty_include_dirs)
  89. env_oidn.Append(
  90. CPPDEFINES=[
  91. "MKLDNN_THR=MKLDNN_THR_SEQ",
  92. "OIDN_STATIC_LIB",
  93. "__STDC_CONSTANT_MACROS",
  94. "__STDC_LIMIT_MACROS",
  95. "DISABLE_VERBOSE",
  96. "MKLDNN_ENABLE_CONCURRENT_EXEC",
  97. ]
  98. )
  99. env_oidn.AppendUnique(CPPDEFINES=["NDEBUG"]) # No assert() even in debug builds.
  100. env_thirdparty = env_oidn.Clone()
  101. env_thirdparty.disable_warnings()
  102. if env["disable_exceptions"]:
  103. # OIDN hard-requires exceptions, so we re-enable them here.
  104. if env.msvc and ("_HAS_EXCEPTIONS", 0) in env_thirdparty["CPPDEFINES"]:
  105. env_thirdparty["CPPDEFINES"].remove(("_HAS_EXCEPTIONS", 0))
  106. env_thirdparty.AppendUnique(CCFLAGS=["/EHsc"])
  107. elif not env.msvc and "-fno-exceptions" in env_thirdparty["CCFLAGS"]:
  108. env_thirdparty["CCFLAGS"].remove("-fno-exceptions")
  109. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
  110. env.modules_sources += thirdparty_obj
  111. if env["platform"] == "windows" and not env.msvc:
  112. env_thirdparty.Append(CPPFLAGS=["-mstackrealign"])
  113. weights_in_path = thirdparty_dir + "weights/rtlightmap_hdr.tza"
  114. weights_out_path = thirdparty_dir + "weights/rtlightmap_hdr.gen.cpp"
  115. env_thirdparty.Depends(weights_out_path, weights_in_path)
  116. env_thirdparty.CommandNoCache(weights_out_path, weights_in_path, resource_to_cpp.tza_to_cpp)
  117. # Godot source files
  118. module_obj = []
  119. env_oidn.add_source_files(module_obj, "denoise_wrapper.cpp")
  120. env_modules.add_source_files(module_obj, ["register_types.cpp", "lightmap_denoiser.cpp"])
  121. env.modules_sources += module_obj
  122. # Needed to force rebuilding the module files when the thirdparty library is updated.
  123. env.Depends(module_obj, thirdparty_obj)