livepp-v4.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. diff --git a/methods.py b/methods.py
  2. index fe84641e9d0625b4f0c4d90a65839337d6120ff8..51ef8550d3a9def0a2ff88a2fde4fa096c085de9 100644
  3. --- a/methods.py
  4. +++ b/methods.py
  5. @@ -734,6 +734,7 @@ def generate_vs_project(env, num_jobs):
  6. f"target={configuration_getter}",
  7. "progress=no",
  8. "tools=!tools!",
  9. + "livepp=%s" % env["livepp"],
  10. "-j%s" % num_jobs,
  11. ]
  12. diff --git a/platform/windows/detect.py b/platform/windows/detect.py
  13. index 0b18fb74fb145e4d2e88ee91abe99f8f39312a46..04880a8fa8209c4002b49f964d86227974ce9ca8 100644
  14. --- a/platform/windows/detect.py
  15. +++ b/platform/windows/detect.py
  16. @@ -44,7 +44,7 @@ def can_build():
  17. def get_opts():
  18. - from SCons.Variables import BoolVariable, EnumVariable
  19. + from SCons.Variables import BoolVariable, EnumVariable, PathVariable
  20. mingw32 = ""
  21. mingw64 = ""
  22. @@ -73,6 +73,7 @@ def get_opts():
  23. BoolVariable("use_thinlto", "Use ThinLTO", False),
  24. BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True),
  25. BoolVariable("use_asan", "Use address sanitizer (ASAN)", False),
  26. + PathVariable("livepp", "Path to the Live++ installation", "", PathVariable.PathAccept),
  27. ]
  28. @@ -310,6 +311,19 @@ def configure_msvc(env, manual_msvc_config):
  29. env.AppendUnique(LINKFLAGS=["/STACK:" + str(STACK_SIZE)])
  30. + # Check if LIVEPP_PATH is set and add #define. Perform
  31. + # some sanity checks.
  32. + if env.get("livepp"):
  33. + if env["target"] == "release_debug" or env["target"] == "debug":
  34. + print("Found Live++ at %s" % env.get("livepp"))
  35. + env.AppendUnique(CPPDEFINES=["LIVEPP_PATH=%s" % env.get("livepp")])
  36. + env.AppendUnique(CPPPATH=[env.get("livepp")])
  37. + env.AppendUnique(LINKFLAGS=["/FUNCTIONPADMIN"])
  38. + else:
  39. + print("Live++ can only be used with targets 'debug' and 'release_debug'")
  40. + else:
  41. + print("No Live++ specified.")
  42. +
  43. def configure_mingw(env):
  44. # Workaround for MinGW. See:
  45. diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp
  46. index 8de3ef294a99c6f02f6f1380e331e4bb598864ce..8e4c15dd66d1b640a352ed826b25b23917f72cc4 100644
  47. --- a/platform/windows/godot_windows.cpp
  48. +++ b/platform/windows/godot_windows.cpp
  49. @@ -34,6 +34,11 @@
  50. #include <locale.h>
  51. #include <stdio.h>
  52. +#ifdef LIVEPP_PATH
  53. +#include "API/LPP_API.h"
  54. +HMODULE livePP;
  55. +#endif
  56. +
  57. // For export templates, add a section; the exporter will patch it to enclose
  58. // the data appended to the executable (bundled PCK)
  59. #ifndef TOOLS_ENABLED
  60. @@ -147,6 +152,16 @@ char *wc_to_utf8(const wchar_t *wc) {
  61. }
  62. int widechar_main(int argc, wchar_t **argv) {
  63. +#ifdef LIVEPP_PATH
  64. +#define _MKSTR_L(x) _STR_L(x)
  65. +#define _STR_L(x) L#x
  66. + livePP = lpp::lppLoadAndRegister(_MKSTR_L(LIVEPP_PATH), "Godot");
  67. + lpp::lppEnableAllCallingModulesSync(livePP);
  68. + lpp::lppInstallExceptionHandler(livePP);
  69. +#undef _MKSTR_L
  70. +#undef _STR_L
  71. +#endif
  72. +
  73. OS_Windows os(nullptr);
  74. setlocale(LC_CTYPE, "");
  75. @@ -179,6 +194,11 @@ int widechar_main(int argc, wchar_t **argv) {
  76. }
  77. delete[] argv_utf8;
  78. +#ifdef LIVEPP_PATH
  79. + lpp::lppShutdown(livePP);
  80. + ::FreeLibrary(livePP);
  81. +#endif
  82. +
  83. return os.get_exit_code();
  84. }
  85. diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
  86. index 8755bc65dce7e4b88fd509d0cbdbec576356c5f5..50e0d8d0b06bf76d5f4d085d010cf6a683a9e64f 100644
  87. --- a/platform/windows/os_windows.cpp
  88. +++ b/platform/windows/os_windows.cpp
  89. @@ -53,6 +53,11 @@
  90. #include <regstr.h>
  91. #include <shlobj.h>
  92. +#ifdef LIVEPP_PATH
  93. +#include "API/LPP_API.h"
  94. +extern HMODULE livePP;
  95. +#endif
  96. +
  97. extern "C" {
  98. __declspec(dllexport) DWORD NvOptimusEnablement = 1;
  99. __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
  100. @@ -677,6 +682,9 @@ void OS_Windows::run() {
  101. if (Main::iteration()) {
  102. break;
  103. }
  104. +#ifdef LIVEPP_PATH
  105. + lpp::lppSyncPoint(livePP);
  106. +#endif
  107. }
  108. main_loop->finalize();