diff options
Diffstat (limited to 'src/core/core_timing.cpp')
| -rw-r--r-- | src/core/core_timing.cpp | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index aba22cdd1..5220b55ea 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp | |||
| @@ -6,11 +6,9 @@ | |||
| 6 | #include <cinttypes> | 6 | #include <cinttypes> |
| 7 | #include <mutex> | 7 | #include <mutex> |
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | |||
| 10 | #include "common/chunk_file.h" | 9 | #include "common/chunk_file.h" |
| 11 | #include "common/logging/log.h" | 10 | #include "common/logging/log.h" |
| 12 | #include "common/string_util.h" | 11 | #include "common/string_util.h" |
| 13 | |||
| 14 | #include "core/arm/arm_interface.h" | 12 | #include "core/arm/arm_interface.h" |
| 15 | #include "core/core.h" | 13 | #include "core/core.h" |
| 16 | #include "core/core_timing.h" | 14 | #include "core/core_timing.h" |
| @@ -21,14 +19,11 @@ int g_clock_rate_arm11 = 268123480; | |||
| 21 | #define INITIAL_SLICE_LENGTH 20000 | 19 | #define INITIAL_SLICE_LENGTH 20000 |
| 22 | #define MAX_SLICE_LENGTH 100000000 | 20 | #define MAX_SLICE_LENGTH 100000000 |
| 23 | 21 | ||
| 24 | namespace CoreTiming | 22 | namespace CoreTiming { |
| 25 | { | 23 | struct EventType { |
| 26 | struct EventType | ||
| 27 | { | ||
| 28 | EventType() {} | 24 | EventType() {} |
| 29 | 25 | ||
| 30 | EventType(TimedCallback cb, const char* n) | 26 | EventType(TimedCallback cb, const char* n) : callback(cb), name(n) {} |
| 31 | : callback(cb), name(n) {} | ||
| 32 | 27 | ||
| 33 | TimedCallback callback; | 28 | TimedCallback callback; |
| 34 | const char* name; | 29 | const char* name; |
| @@ -36,8 +31,7 @@ struct EventType | |||
| 36 | 31 | ||
| 37 | static std::vector<EventType> event_types; | 32 | static std::vector<EventType> event_types; |
| 38 | 33 | ||
| 39 | struct BaseEvent | 34 | struct BaseEvent { |
| 40 | { | ||
| 41 | s64 time; | 35 | s64 time; |
| 42 | u64 userdata; | 36 | u64 userdata; |
| 43 | int type; | 37 | int type; |
| @@ -200,7 +194,6 @@ u64 GetIdleTicks() { | |||
| 200 | return (u64)idled_cycles; | 194 | return (u64)idled_cycles; |
| 201 | } | 195 | } |
| 202 | 196 | ||
| 203 | |||
| 204 | // This is to be called when outside threads, such as the graphics thread, wants to | 197 | // This is to be called when outside threads, such as the graphics thread, wants to |
| 205 | // schedule things to be executed on the main thread. | 198 | // schedule things to be executed on the main thread. |
| 206 | void ScheduleEvent_Threadsafe(s64 cycles_into_future, int event_type, u64 userdata) { | 199 | void ScheduleEvent_Threadsafe(s64 cycles_into_future, int event_type, u64 userdata) { |
| @@ -222,12 +215,11 @@ void ScheduleEvent_Threadsafe(s64 cycles_into_future, int event_type, u64 userda | |||
| 222 | // Same as ScheduleEvent_Threadsafe(0, ...) EXCEPT if we are already on the CPU thread | 215 | // Same as ScheduleEvent_Threadsafe(0, ...) EXCEPT if we are already on the CPU thread |
| 223 | // in which case the event will get handled immediately, before returning. | 216 | // in which case the event will get handled immediately, before returning. |
| 224 | void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata) { | 217 | void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata) { |
| 225 | if (false) //Core::IsCPUThread()) | 218 | if (false) // Core::IsCPUThread()) |
| 226 | { | 219 | { |
| 227 | std::lock_guard<std::recursive_mutex> lock(external_event_section); | 220 | std::lock_guard<std::recursive_mutex> lock(external_event_section); |
| 228 | event_types[event_type].callback(userdata, 0); | 221 | event_types[event_type].callback(userdata, 0); |
| 229 | } | 222 | } else |
| 230 | else | ||
| 231 | ScheduleEvent_Threadsafe(0, event_type, userdata); | 223 | ScheduleEvent_Threadsafe(0, event_type, userdata); |
| 232 | } | 224 | } |
| 233 | 225 | ||
| @@ -317,8 +309,7 @@ s64 UnscheduleThreadsafeEvent(int event_type, u64 userdata) { | |||
| 317 | } | 309 | } |
| 318 | } | 310 | } |
| 319 | 311 | ||
| 320 | if (!ts_first) | 312 | if (!ts_first) { |
| 321 | { | ||
| 322 | ts_last = nullptr; | 313 | ts_last = nullptr; |
| 323 | return result; | 314 | return result; |
| 324 | } | 315 | } |
| @@ -369,7 +360,7 @@ void RemoveEvent(int event_type) { | |||
| 369 | return; | 360 | return; |
| 370 | while (first) { | 361 | while (first) { |
| 371 | if (first->type == event_type) { | 362 | if (first->type == event_type) { |
| 372 | Event *next = first->next; | 363 | Event* next = first->next; |
| 373 | FreeEvent(first); | 364 | FreeEvent(first); |
| 374 | first = next; | 365 | first = next; |
| 375 | } else { | 366 | } else { |
| @@ -509,7 +500,8 @@ void Advance() { | |||
| 509 | void LogPendingEvents() { | 500 | void LogPendingEvents() { |
| 510 | Event* event = first; | 501 | Event* event = first; |
| 511 | while (event) { | 502 | while (event) { |
| 512 | //LOG_TRACE(Core_Timing, "PENDING: Now: %lld Pending: %lld Type: %d", globalTimer, next->time, next->type); | 503 | // LOG_TRACE(Core_Timing, "PENDING: Now: %lld Pending: %lld Type: %d", globalTimer, |
| 504 | // next->time, next->type); | ||
| 513 | event = event->next; | 505 | event = event->next; |
| 514 | } | 506 | } |
| 515 | } | 507 | } |
| @@ -531,7 +523,8 @@ void Idle(int max_idle) { | |||
| 531 | } | 523 | } |
| 532 | } | 524 | } |
| 533 | 525 | ||
| 534 | LOG_TRACE(Core_Timing, "Idle for %" PRId64 " cycles! (%f ms)", cycles_down, cycles_down / (float)(g_clock_rate_arm11 * 0.001f)); | 526 | LOG_TRACE(Core_Timing, "Idle for %" PRId64 " cycles! (%f ms)", cycles_down, |
| 527 | cycles_down / (float)(g_clock_rate_arm11 * 0.001f)); | ||
| 535 | 528 | ||
| 536 | idled_cycles += cycles_down; | 529 | idled_cycles += cycles_down; |
| 537 | Core::g_app_core->down_count -= cycles_down; | 530 | Core::g_app_core->down_count -= cycles_down; |
| @@ -551,7 +544,7 @@ std::string GetScheduledEventsSummary() { | |||
| 551 | if (!name) | 544 | if (!name) |
| 552 | name = "[unknown]"; | 545 | name = "[unknown]"; |
| 553 | text += Common::StringFromFormat("%s : %i %08x%08x\n", name, (int)event->time, | 546 | text += Common::StringFromFormat("%s : %i %08x%08x\n", name, (int)event->time, |
| 554 | (u32)(event->userdata >> 32), (u32)(event->userdata)); | 547 | (u32)(event->userdata >> 32), (u32)(event->userdata)); |
| 555 | event = event->next; | 548 | event = event->next; |
| 556 | } | 549 | } |
| 557 | return text; | 550 | return text; |