The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

u/pacing: Improve debug printing in app pacer

+43 -10
+43 -10
src/xrt/auxiliary/util/u_pacing_app.c
··· 149 149 return (struct pacing_app *)upa; 150 150 } 151 151 152 - #define DEBUG_PRINT_FRAME_ID() UPA_LOG_T("%" PRIi64, frame_id) 152 + static inline const char * 153 + state_to_str(enum u_pa_state state) 154 + { 155 + switch (state) { 156 + case U_PA_READY: return "U_PA_READY"; 157 + case U_RT_WAIT_LEFT: return "U_RT_WAIT_LEFT"; 158 + case U_RT_PREDICTED: return "U_RT_PREDICTED"; 159 + case U_RT_BEGUN: return "U_RT_BEGUN"; 160 + case U_RT_DELIVERED: return "U_RT_DELIVERED"; 161 + case U_RT_GPU_DONE: return "U_RT_GPU_DONE"; 162 + default: return "UNKNOWN"; 163 + } 164 + } 165 + 166 + static inline const char * 167 + point_to_str(enum u_timing_point point) 168 + { 169 + switch (point) { 170 + case U_TIMING_POINT_WAKE_UP: return "U_TIMING_POINT_WAKE_UP"; 171 + case U_TIMING_POINT_BEGIN: return "U_TIMING_POINT_BEGIN"; 172 + case U_TIMING_POINT_SUBMIT: return "U_TIMING_POINT_SUBMIT"; 173 + default: return "UNKNOWN"; 174 + } 175 + } 176 + 177 + #define DEBUG_PRINT_ID(ID) UPA_LOG_T("%" PRIi64, ID) 178 + #define DEBUG_PRINT_ID_FRAME(ID, F) UPA_LOG_T("%" PRIi64 " (%" PRIi64 ", %s)", ID, F->frame_id, state_to_str(F->state)) 179 + #define DEBUG_PRINT_ID_FRAME_POINT(ID, F, P) \ 180 + UPA_LOG_T("%" PRIi64 " (%" PRIi64 ", %s) %s", frame_id, F->frame_id, state_to_str(F->state), point_to_str(P)); 181 + 153 182 #define GET_INDEX_FROM_ID(RT, ID) ((uint64_t)(ID) % FRAME_COUNT) 154 183 155 184 #define IIR_ALPHA_LT 0.8 ··· 370 399 int64_t frame_id = ++pa->frame_counter; 371 400 *out_frame_id = frame_id; 372 401 373 - DEBUG_PRINT_FRAME_ID(); 402 + DEBUG_PRINT_ID(frame_id); 374 403 375 404 uint64_t period_ns = calc_period(pa); 376 405 uint64_t predict_ns = predict_display_time(pa, now_ns, period_ns); ··· 411 440 { 412 441 struct pacing_app *pa = pacing_app(upa); 413 442 414 - UPA_LOG_T("%" PRIi64 " (%u)", frame_id, point); 415 - 416 443 size_t index = GET_INDEX_FROM_ID(pa, frame_id); 417 444 struct u_pa_frame *f = &pa->frames[index]; 445 + 446 + DEBUG_PRINT_ID_FRAME_POINT(frame_id, f, point); 447 + 418 448 assert(f->frame_id == frame_id); 419 449 420 450 switch (point) { ··· 440 470 { 441 471 struct pacing_app *pa = pacing_app(upa); 442 472 443 - DEBUG_PRINT_FRAME_ID(); 444 - 445 473 size_t index = GET_INDEX_FROM_ID(pa, frame_id); 446 474 struct u_pa_frame *f = &pa->frames[index]; 475 + 476 + DEBUG_PRINT_ID_FRAME(frame_id, f); 477 + 447 478 assert(f->frame_id == frame_id); 448 479 assert(f->state == U_RT_WAIT_LEFT || f->state == U_RT_BEGUN); 449 480 ··· 464 495 { 465 496 struct pacing_app *pa = pacing_app(upa); 466 497 467 - DEBUG_PRINT_FRAME_ID(); 468 - 469 498 size_t index = GET_INDEX_FROM_ID(pa, frame_id); 470 499 struct u_pa_frame *f = &pa->frames[index]; 500 + 501 + DEBUG_PRINT_ID_FRAME(frame_id, f); 502 + 471 503 assert(f->frame_id == frame_id); 472 504 assert(f->state == U_RT_BEGUN); 473 505 ··· 482 514 { 483 515 struct pacing_app *pa = pacing_app(upa); 484 516 485 - DEBUG_PRINT_FRAME_ID(); 486 - 487 517 size_t index = GET_INDEX_FROM_ID(pa, frame_id); 488 518 struct u_pa_frame *f = &pa->frames[index]; 519 + 520 + DEBUG_PRINT_ID_FRAME(frame_id, f); 521 + 489 522 assert(f->frame_id == frame_id); 490 523 assert(f->state == U_RT_DELIVERED); 491 524