enable/disable threadpool from cmake
This commit is contained in:
@ -9,6 +9,7 @@ if(POLICY CMP0167)
|
|||||||
cmake_policy(SET CMP0167 NEW)
|
cmake_policy(SET CMP0167 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
option(DISABLE_THREADPOOL "Disable additional physics threads" OFF)
|
||||||
option(DISABLE_BACKWARD "Disable backward stacktrace printer" OFF)
|
option(DISABLE_BACKWARD "Disable backward stacktrace printer" OFF)
|
||||||
option(DISABLE_TRACY "Disable the Tracy profiler client" OFF)
|
option(DISABLE_TRACY "Disable the Tracy profiler client" OFF)
|
||||||
option(DISABLE_TESTS "Disable building tests" OFF)
|
option(DISABLE_TESTS "Disable building tests" OFF)
|
||||||
@ -41,6 +42,10 @@ if(WIN32)
|
|||||||
list(APPEND LIBS opengl32 gdi32 winmm)
|
list(APPEND LIBS opengl32 gdi32 winmm)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT DISABLE_THREADPOOL)
|
||||||
|
list(APPEND FLAGS THREADPOOL)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT DISABLE_BACKWARD)
|
if(NOT DISABLE_BACKWARD)
|
||||||
find_package(Backward REQUIRED)
|
find_package(Backward REQUIRED)
|
||||||
|
|
||||||
@ -127,4 +132,4 @@ if(supported)
|
|||||||
set_property(TARGET masssprings PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
set_property(TARGET masssprings PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||||
else()
|
else()
|
||||||
message(STATUS "IPO / LTO not supported")
|
message(STATUS "IPO / LTO not supported")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@ -254,6 +254,7 @@ rec {
|
|||||||
];
|
];
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
|
"-DDISABLE_THREADPOOL=Off"
|
||||||
"-DDISABLE_TRACY=On"
|
"-DDISABLE_TRACY=On"
|
||||||
"-DDISABLE_BACKWARD=On"
|
"-DDISABLE_BACKWARD=On"
|
||||||
"-DDISABLE_TESTS=On"
|
"-DDISABLE_TESTS=On"
|
||||||
@ -307,6 +308,7 @@ rec {
|
|||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
"-DCMAKE_SYSTEM_NAME=Windows"
|
"-DCMAKE_SYSTEM_NAME=Windows"
|
||||||
|
"-DDISABLE_THREADPOOL=Off"
|
||||||
"-DDISABLE_TRACY=On"
|
"-DDISABLE_TRACY=On"
|
||||||
"-DDISABLE_BACKWARD=On"
|
"-DDISABLE_BACKWARD=On"
|
||||||
"-DDISABLE_TESTS=On"
|
"-DDISABLE_TESTS=On"
|
||||||
|
|||||||
@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
|
|
||||||
#define THREADPOOL // Enable physics threadpool
|
|
||||||
|
|
||||||
// TODO: Using the octree from the last frame completely breaks the physics :/
|
// TODO: Using the octree from the last frame completely breaks the physics :/
|
||||||
// #define ASYNC_OCTREE
|
// #define ASYNC_OCTREE
|
||||||
|
|
||||||
// Gets set by CMake
|
// Gets set by CMake
|
||||||
|
// #define THREADPOOL // Enable physics threadpool
|
||||||
// #define BACKWARD // Enable pretty stack traces
|
// #define BACKWARD // Enable pretty stack traces
|
||||||
// #define TRACY // Enable tracy profiling support
|
// #define TRACY // Enable tracy profiling support
|
||||||
|
|
||||||
@ -93,4 +93,4 @@ constexpr Color BLOCK_COLOR = DARKBLUE;
|
|||||||
constexpr Color TARGET_BLOCK_COLOR = RED;
|
constexpr Color TARGET_BLOCK_COLOR = RED;
|
||||||
constexpr Color WALL_COLOR = BLACK;
|
constexpr Color WALL_COLOR = BLACK;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -38,7 +38,7 @@ auto set_pool_thread_name(size_t idx) -> void
|
|||||||
BS::this_thread::set_os_thread_name(std::format("worker-{}", idx));
|
BS::this_thread::set_os_thread_name(std::format("worker-{}", idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
BS::thread_pool<> threads(std::thread::hardware_concurrency() - 2, set_pool_thread_name);
|
BS::thread_pool<> threads(std::thread::hardware_concurrency(), set_pool_thread_name);
|
||||||
constexpr std::optional<BS::thread_pool<>* const> thread_pool = &threads;
|
constexpr std::optional<BS::thread_pool<>* const> thread_pool = &threads;
|
||||||
#else
|
#else
|
||||||
constexpr std::optional<BS::thread_pool<>* const> thread_pool = std::nullopt;
|
constexpr std::optional<BS::thread_pool<>* const> thread_pool = std::nullopt;
|
||||||
@ -341,4 +341,4 @@ auto main(const int argc, char* argv[]) -> int
|
|||||||
};
|
};
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user