feature: Mirror Performance Profiling & Editor Performance View (#11667) 9ff17d62ca * feature: adding profiler to ffi * feature: performance metrics * fix: mirror shows coop loading progress * feature: add mirror tests * fix: feature flagged performance profiler * fix: mirror strings * fix: ui strings for profiler panel * fix: missed performance_panel.dart * fix: microprofile wasm * fix: rive_binding Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
diff --git a/.rive_head b/.rive_head index a0c43f6..8768db0 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -838cad2bf2c34bd2820de1f3058f6c360fadc99f +9ff17d62ca0f4db795fb8bc6715d713bab70c53a
diff --git a/include/rive/profiler/microprofile_emscripten.h b/include/rive/profiler/microprofile_emscripten.h new file mode 100644 index 0000000..73eb3d0 --- /dev/null +++ b/include/rive/profiler/microprofile_emscripten.h
@@ -0,0 +1,32 @@ +#pragma once + +// Emscripten/WASM compatibility shim for microprofile. +// microprofile.h only defines MP_TICK, MP_BREAK, etc. for __APPLE__, _WIN32, +// and __linux__. Emscripten supports the same POSIX APIs as Linux so we +// replicate the Linux platform block here and include this header before +// microprofile.h. + +#if defined(__EMSCRIPTEN__) && !defined(MP_TICK) + +#include <stdint.h> +#include <strings.h> +#include <time.h> +#include <unistd.h> + +inline int64_t MicroProfileTicksPerSecondCpu() { return 1000000000ll; } + +inline int64_t MicroProfileGetTick() +{ + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + return 1000000000ll * ts.tv_sec + ts.tv_nsec; +} + +#define MP_TICK() MicroProfileGetTick() +#define MP_BREAK() __builtin_trap() +#define MP_THREAD_LOCAL __thread +#define MP_STRCASECMP strcasecmp +#define MP_GETCURRENTTHREADID() (uint64_t)pthread_self() +typedef uint64_t MicroProfileThreadIdType; + +#endif // __EMSCRIPTEN__ && !MP_TICK
diff --git a/include/rive/profiler/profiler_macros.h b/include/rive/profiler/profiler_macros.h index f62e4d5..9e240fc 100644 --- a/include/rive/profiler/profiler_macros.h +++ b/include/rive/profiler/profiler_macros.h
@@ -32,17 +32,16 @@ #define RIVE_PROF_ENDFRAME() #elif defined(RIVE_MICROPROFILE) // Microprofile integration +#include "rive/profiler/microprofile_emscripten.h" #include "microprofile.h" #include "microprofiledraw.h" #include "microprofileui.h" -#define MICROPROFILE_WEBSERVER 1 #define MICROPROFILE_GPU_TIMERS 1 #define RIVE_PROF_INIT() \ MicroProfileSetEnableAllGroups(true); \ MicroProfileSetForceEnable(true); \ - MicroProfileWebServerStart(); \ MicroProfileOnThreadCreate("MainThread"); \ MicroProfileInit();
diff --git a/premake5_v2.lua b/premake5_v2.lua index 2d4b4c4..21c4554 100644 --- a/premake5_v2.lua +++ b/premake5_v2.lua
@@ -46,7 +46,6 @@ dofile(path.join(dependencies, 'premake5_microprofile.lua')) end - if _OPTIONS['with_rive_scripting'] then local scripting = require(path.join(path.getabsolute('scripting/'), 'premake5')) luau = scripting.luau @@ -130,6 +129,8 @@ defines({ '_USE_MATH_DEFINES' }) end + filter({}) + if _OPTIONS['with_optick'] then includedirs({ optick .. '/src' }) end
diff --git a/src/profiler/profiler.cpp b/src/profiler/profiler.cpp index 0f8d2da..22f306e 100644 --- a/src/profiler/profiler.cpp +++ b/src/profiler/profiler.cpp
@@ -1,8 +1,17 @@ #ifdef RIVE_MICROPROFILE #define MICROPROFILE_IMPL +#define MICROPROFILE_WEBSERVER 0 #if defined(RIVE_WINDOWS) #define MICROPROFILE_GPU_TIMERS_D3D11 1 #define MICROPROFILE_GPU_TIMERS_D3D12 1 #endif +#include "rive/profiler/microprofile_emscripten.h" +#ifdef __EMSCRIPTEN__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat" +#endif #include "microprofile.h" +#ifdef __EMSCRIPTEN__ +#pragma clang diagnostic pop +#endif #endif