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