diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 716f089b..fc09d47c 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -72,7 +72,7 @@ option(USE_VMA "Use VMA allocator instead of the NVRHI builtin one" ON) option(OPTICK - "Enable profiling with Optick" ON) + "Enable profiling with Optick" OFF) set(NVRHI_INSTALL OFF) @@ -479,6 +479,16 @@ else (RAPIDJSON_FOUND) include_directories("libs/rapidjson/include") endif (RAPIDJSON_FOUND) +if(OPTICK) + file(GLOB OPTICK_INCLUDES libs/optick/*.h) + file(GLOB OPTICK_SOURCES libs/optick/*.cpp) + add_definitions(-DUSE_OPTICK) + include_directories("libs/optick") + + source_group("libs\\optick" FILES ${OPTICK_INCLUDES}) + source_group("libs\\optick" FILES ${OPTICK_SOURCES}) +endif() + add_subdirectory(idlib) file(GLOB NATVIS_SOURCES .natvis) @@ -629,16 +639,6 @@ if(BINKDEC) include_directories("libs/libbinkdec/include") endif() -if(OPTICK) - file(GLOB OPTICK_INCLUDES libs/optick/*.h) - file(GLOB OPTICK_SOURCES libs/optick/*.cpp) - add_definitions(-DUSE_OPTICK) - include_directories("libs/optick") - - source_group("libs\\optick" FILES ${OPTICK_INCLUDES}) - source_group("libs\\optick" FILES ${OPTICK_SOURCES}) -endif() - file(GLOB MINIZIP_INCLUDES libs/zlib/minizip/*.h) file(GLOB MINIZIP_SOURCES libs/zlib/minizip/*.c libs/zlib/minizip/*.cpp) diff --git a/neo/framework/Common.h b/neo/framework/Common.h index a4a9b369..dc142758 100644 --- a/neo/framework/Common.h +++ b/neo/framework/Common.h @@ -103,7 +103,11 @@ public: } }; -#define SCOPED_PROFILE_EVENT( x ) idScopedProfileEvent scopedProfileEvent_##__LINE__( x ) +#if USE_OPTICK + #define SCOPED_PROFILE_EVENT( x ) OPTICK_EVENT( x ) +#else + #define SCOPED_PROFILE_EVENT( x ) idScopedProfileEvent scopedProfileEvent_##__LINE__( x ) +#endif ID_INLINE bool BeginTraceRecording( const char* szName ) { diff --git a/neo/framework/File_SaveGame.cpp b/neo/framework/File_SaveGame.cpp index dc54eb65..65e2e94b 100644 --- a/neo/framework/File_SaveGame.cpp +++ b/neo/framework/File_SaveGame.cpp @@ -71,6 +71,8 @@ class idSGFcompressThread : public idSysThread public: virtual int Run() { + OPTICK_THREAD( "idSGFcompressThread" ); + sgf->CompressBlock(); return 0; } @@ -81,6 +83,8 @@ class idSGFdecompressThread : public idSysThread public: virtual int Run() { + OPTICK_THREAD( "idSGFdecompressThread" ); + sgf->DecompressBlock(); return 0; } @@ -91,6 +95,8 @@ class idSGFwriteThread : public idSysThread public: virtual int Run() { + OPTICK_THREAD( "idSGFwriteThread" ); + sgf->WriteBlock(); return 0; } @@ -101,6 +107,8 @@ class idSGFreadThread : public idSysThread public: virtual int Run() { + OPTICK_THREAD( "idSGFreadThread" ); + sgf->ReadBlock(); return 0; } diff --git a/neo/framework/common_frame.cpp b/neo/framework/common_frame.cpp index 905777fe..36a3a5ec 100644 --- a/neo/framework/common_frame.cpp +++ b/neo/framework/common_frame.cpp @@ -90,6 +90,8 @@ be called directly in the foreground thread for comparison. */ int idGameThread::Run() { + OPTICK_THREAD( "idGameThread" ); + commonLocal.frameTiming.startGameTime = Sys_Microseconds(); // debugging tool to test frame dropping behavior diff --git a/neo/idlib/ParallelJobList.cpp b/neo/idlib/ParallelJobList.cpp index c05857c9..54b14c5d 100644 --- a/neo/idlib/ParallelJobList.cpp +++ b/neo/idlib/ParallelJobList.cpp @@ -1145,6 +1145,8 @@ idJobThread::Run */ int idJobThread::Run() { + OPTICK_THREAD( GetName() ); + threadJobListState_t threadJobListState[MAX_JOBLISTS]; int numJobLists = 0; int lastStalledJobList = -1; diff --git a/neo/idlib/precompiled.h b/neo/idlib/precompiled.h index 9194be64..90dfe8d3 100644 --- a/neo/idlib/precompiled.h +++ b/neo/idlib/precompiled.h @@ -106,7 +106,7 @@ const int MAX_EXPRESSION_REGISTERS = 4096; #endif // RB: make Optick profiling available everywhere -#if 1 //defined( USE_OPTICK ) +#if defined( USE_OPTICK ) #include "../libs/optick/optick.h" #endif diff --git a/neo/sys/common/savegame.cpp b/neo/sys/common/savegame.cpp index 7f27eb98..65de9bb8 100644 --- a/neo/sys/common/savegame.cpp +++ b/neo/sys/common/savegame.cpp @@ -746,6 +746,8 @@ idSaveGameThread::Run */ int idSaveGameThread::Run() { + OPTICK_THREAD( "idSaveGameThread" ); + int ret = ERROR_SUCCESS; try