The open source OpenXR runtime
0
fork

Configure Feed

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

u/pacing: Add metrics output

authored by

Jakob Bornecrantz and committed by
Moses Turner
37da46b7 87fdedeb

+113 -5
+45 -3
src/xrt/auxiliary/util/u_pacing_app.c
··· 13 13 #include "util/u_misc.h" 14 14 #include "util/u_debug.h" 15 15 #include "util/u_pacing.h" 16 + #include "util/u_metrics.h" 16 17 #include "util/u_logging.h" 17 18 #include "util/u_trace_marker.h" 18 19 ··· 254 255 */ 255 256 256 257 static void 258 + do_metrics(struct pacing_app *pa, struct u_pa_frame *f, bool discarded) 259 + { 260 + if (!u_metrics_is_active()) { 261 + return; 262 + } 263 + 264 + struct u_metrics_session_frame umsf = { 265 + .session_id = pa->session_id, 266 + .frame_id = f->frame_id, 267 + .predicted_frame_time_ns = f->predicted_frame_time_ns, 268 + .predicted_wake_up_time_ns = f->predicted_wake_up_time_ns, 269 + .predicted_gpu_done_time_ns = f->predicted_gpu_done_time_ns, 270 + .predicted_display_time_ns = f->predicted_display_time_ns, 271 + .predicted_display_period_ns = f->predicted_display_period_ns, 272 + .display_time_ns = f->display_time_ns, 273 + .when_predicted_ns = f->when.predicted_ns, 274 + .when_wait_woke_ns = f->when.wait_woke_ns, 275 + .when_begin_ns = f->when.begin_ns, 276 + .when_delivered_ns = f->when.delivered_ns, 277 + .when_gpu_done_ns = f->when.gpu_done_ns, 278 + .discarded = discarded, 279 + }; 280 + 281 + u_metrics_write_session_frame(&umsf); 282 + } 283 + 284 + static void 257 285 do_tracing(struct pacing_app *pa, struct u_pa_frame *f) 258 286 { 259 287 if (!U_TRACE_CATEGORY_IS_ENABLED(timing)) { ··· 406 434 // Update all data. 407 435 f->when.delivered_ns = when_ns; 408 436 437 + // Write out metrics data. 438 + do_metrics(pa, f, true); 439 + 409 440 // Reset the frame. 441 + U_ZERO(f); // Zero for metrics 410 442 f->state = U_PA_READY; 411 443 f->frame_id = -1; 412 444 } ··· 477 509 do_iir_filter(&pa->app.draw_time_ns, IIR_ALPHA_LT, IIR_ALPHA_GT, diff_draw_ns); 478 510 do_iir_filter(&pa->app.wait_time_ns, IIR_ALPHA_LT, IIR_ALPHA_GT, diff_wait_ns); 479 511 480 - // Write out tracing data. 512 + // Write out metrics and tracing data. 513 + do_metrics(pa, f, false); 481 514 do_tracing(pa, f); 482 515 483 516 #ifndef VALIDATE_LATCHED_AND_RETIRED 484 517 // Reset the frame. 485 - U_ZERO(f); 518 + U_ZERO(f); // Zero for metrics 486 519 f->state = U_PA_READY; 487 520 f->frame_id = -1; 488 521 #endif ··· 501 534 #else 502 535 (void)pa; 503 536 #endif 537 + 538 + struct u_metrics_used umu = { 539 + .session_id = pa->session_id, 540 + .session_frame_id = frame_id, 541 + .system_frame_id = system_frame_id, 542 + .when_ns = when_ns, 543 + }; 544 + 545 + u_metrics_write_used(&umu); 504 546 } 505 547 506 548 static void ··· 515 557 assert(f->state == U_RT_GPU_DONE || f->state == U_RT_DELIVERED); 516 558 517 559 // Reset the frame. 518 - U_ZERO(f); 560 + U_ZERO(f); // Zero for metrics 519 561 f->state = U_PA_READY; 520 562 f->frame_id = -1; 521 563 #else
+41 -2
src/xrt/auxiliary/util/u_pacing_compositor.c
··· 13 13 #include "util/u_misc.h" 14 14 #include "util/u_debug.h" 15 15 #include "util/u_pacing.h" 16 + #include "util/u_metrics.h" 16 17 #include "util/u_logging.h" 17 18 #include "util/u_trace_marker.h" 18 19 ··· 400 401 */ 401 402 402 403 static void 404 + do_metrics(struct pacing_compositor *pc, struct frame *f) 405 + { 406 + if (!u_metrics_is_active()) { 407 + return; 408 + } 409 + 410 + struct u_metrics_system_present_info umpi = { 411 + .frame_id = f->frame_id, 412 + .expected_comp_time_ns = f->current_comp_time_ns, 413 + .predicted_wake_up_time_ns = f->wake_up_time_ns, 414 + .predicted_done_time_ns = f->expected_done_time_ns, 415 + .predicted_display_time_ns = f->predicted_display_time_ns, 416 + .when_predict_ns = f->when_predict_ns, 417 + .when_woke_ns = f->when_woke_ns, 418 + .when_began_ns = f->when_began_ns, 419 + .when_submitted_ns = f->when_submitted_ns, 420 + .when_infoed_ns = f->when_infoed_ns, 421 + .desired_present_time_ns = f->desired_present_time_ns, 422 + .present_slop_ns = PRESENT_SLOP_NS, 423 + .present_margin_ns = f->present_margin_ns, 424 + .actual_present_time_ns = f->actual_present_time_ns, 425 + .earliest_present_time_ns = f->earliest_present_time_ns, 426 + }; 427 + 428 + u_metrics_write_system_present_info(&umpi); 429 + } 430 + 431 + static void 403 432 do_tracing(struct pacing_compositor *pc, struct frame *f) 404 433 { 405 434 #ifdef U_TRACE_PERCETTO // Uses Percetto specific things. ··· 657 686 f->present_margin_ns, // 658 687 present_margin_ms); // 659 688 660 - // Write out tracing data. 689 + // Write out metrics and tracing data. 690 + do_metrics(pc, f); 661 691 do_tracing(pc, f); 662 692 } 663 693 ··· 665 695 pc_info_gpu( 666 696 struct u_pacing_compositor *upc, int64_t frame_id, uint64_t gpu_start_ns, uint64_t gpu_end_ns, uint64_t when_ns) 667 697 { 668 - // No-op 698 + if (u_metrics_is_active()) { 699 + struct u_metrics_system_gpu_info umgi = { 700 + .frame_id = frame_id, 701 + .gpu_start_ns = gpu_start_ns, 702 + .gpu_end_ns = gpu_end_ns, 703 + .when_ns = when_ns, 704 + }; 705 + 706 + u_metrics_write_system_gpu_info(&umgi); 707 + } 669 708 } 670 709 671 710 static void
+27
src/xrt/auxiliary/util/u_pacing_compositor_fake.c
··· 13 13 #include "util/u_misc.h" 14 14 #include "util/u_debug.h" 15 15 #include "util/u_pacing.h" 16 + #include "util/u_metrics.h" 16 17 #include "util/u_logging.h" 17 18 #include "util/u_trace_marker.h" 18 19 ··· 123 124 *out_predicted_display_time_ns = predicted_display_time_ns; 124 125 *out_predicted_display_period_ns = predicted_display_period_ns; 125 126 *out_min_display_period_ns = min_display_period_ns; 127 + 128 + if (!u_metrics_is_active()) { 129 + return; 130 + } 131 + 132 + struct u_metrics_system_frame umsf = { 133 + .frame_id = frame_id, 134 + .predicted_display_time_ns = predicted_display_time_ns, 135 + .predicted_display_period_ns = predicted_display_period_ns, 136 + .desired_present_time_ns = desired_present_time_ns, 137 + .wake_up_time_ns = wake_up_time_ns, 138 + .present_slop_ns = present_slop_ns, 139 + }; 140 + 141 + u_metrics_write_system_frame(&umsf); 126 142 } 127 143 128 144 static void ··· 156 172 pc_info_gpu( 157 173 struct u_pacing_compositor *upc, int64_t frame_id, uint64_t gpu_start_ns, uint64_t gpu_end_ns, uint64_t when_ns) 158 174 { 175 + if (u_metrics_is_active()) { 176 + struct u_metrics_system_gpu_info umgi = { 177 + .frame_id = frame_id, 178 + .gpu_start_ns = gpu_start_ns, 179 + .gpu_end_ns = gpu_end_ns, 180 + .when_ns = when_ns, 181 + }; 182 + 183 + u_metrics_write_system_gpu_info(&umgi); 184 + } 185 + 159 186 #ifdef U_TRACE_PERCETTO // Uses Percetto specific things. 160 187 if (U_TRACE_CATEGORY_IS_ENABLED(timing)) { 161 188 #define TE_BEG(TRACK, TIME, NAME) U_TRACE_EVENT_BEGIN_ON_TRACK_DATA(timing, TRACK, TIME, NAME, PERCETTO_I(frame_id))