The open source OpenXR runtime
0
fork

Configure Feed

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

u/pacing: Refactor out tracing writing to own function

+124 -111
+124 -111
src/xrt/auxiliary/util/u_pacing_compositor.c
··· 395 395 396 396 /* 397 397 * 398 + * Metrics and tracing. 399 + * 400 + */ 401 + 402 + static void 403 + do_tracing(struct pacing_compositor *pc, struct frame *f) 404 + { 405 + if (!U_TRACE_CATEGORY_IS_ENABLED(timing)) { 406 + return; 407 + } 408 + 409 + #define TE_BEG(TRACK, TIME, NAME) U_TRACE_EVENT_BEGIN_ON_TRACK_DATA(timing, TRACK, TIME, NAME, PERCETTO_I(f->frame_id)) 410 + #define TE_END(TRACK, TIME) U_TRACE_EVENT_END_ON_TRACK(timing, TRACK, TIME) 411 + 412 + 413 + /* 414 + * 415 + * CPU 416 + * 417 + */ 418 + 419 + TE_BEG(pc_cpu, f->when_predict_ns, "sleep"); 420 + TE_END(pc_cpu, f->wake_up_time_ns); 421 + 422 + uint64_t oversleep_start_ns = f->wake_up_time_ns + 1; 423 + if (f->when_woke_ns > oversleep_start_ns) { 424 + TE_BEG(pc_cpu, oversleep_start_ns, "oversleep"); 425 + TE_END(pc_cpu, f->when_woke_ns); 426 + } 427 + 428 + 429 + /* 430 + * 431 + * GPU 432 + * 433 + */ 434 + 435 + uint64_t gpu_end_ns = f->actual_present_time_ns - f->present_margin_ns; 436 + if (gpu_end_ns > f->when_submitted_ns) { 437 + TE_BEG(pc_gpu, f->when_submitted_ns, "gpu"); 438 + TE_END(pc_gpu, gpu_end_ns); 439 + } else { 440 + TE_BEG(pc_gpu, gpu_end_ns, "gpu-time-travel"); 441 + TE_END(pc_gpu, f->when_submitted_ns); 442 + } 443 + 444 + 445 + /* 446 + * 447 + * Margin 448 + * 449 + */ 450 + 451 + if (gpu_end_ns < f->desired_present_time_ns) { 452 + TE_BEG(pc_margin, gpu_end_ns, "margin"); 453 + TE_END(pc_margin, f->desired_present_time_ns); 454 + } 455 + 456 + 457 + /* 458 + * 459 + * ERROR 460 + * 461 + */ 462 + 463 + if (!is_within_half_ms(f->actual_present_time_ns, f->desired_present_time_ns)) { 464 + if (f->actual_present_time_ns > f->desired_present_time_ns) { 465 + TE_BEG(pc_error, f->desired_present_time_ns, "slippage"); 466 + TE_END(pc_error, f->actual_present_time_ns); 467 + } else { 468 + TE_BEG(pc_error, f->actual_present_time_ns, "run-ahead"); 469 + TE_END(pc_error, f->desired_present_time_ns); 470 + } 471 + } 472 + 473 + 474 + /* 475 + * 476 + * Info 477 + * 478 + */ 479 + 480 + if (f->when_infoed_ns >= f->actual_present_time_ns) { 481 + TE_BEG(pc_info, f->actual_present_time_ns, "info"); 482 + TE_END(pc_info, f->when_infoed_ns); 483 + } else { 484 + TE_BEG(pc_info, f->when_infoed_ns, "info_before"); 485 + TE_END(pc_info, f->actual_present_time_ns); 486 + } 487 + 488 + 489 + /* 490 + * 491 + * Present 492 + * 493 + */ 494 + 495 + if (f->actual_present_time_ns != f->earliest_present_time_ns) { 496 + U_TRACE_INSTANT_ON_TRACK(timing, pc_present, f->earliest_present_time_ns, "earliest"); 497 + } 498 + if (!is_within_half_ms(f->desired_present_time_ns, f->earliest_present_time_ns)) { 499 + U_TRACE_INSTANT_ON_TRACK(timing, pc_present, f->desired_present_time_ns, "predicted"); 500 + } 501 + U_TRACE_INSTANT_ON_TRACK(timing, pc_present, f->actual_present_time_ns, "vsync"); 502 + 503 + 504 + /* 505 + * 506 + * Compositor time 507 + * 508 + */ 509 + 510 + TE_BEG(pc_allotted, f->wake_up_time_ns, "allotted"); 511 + TE_END(pc_allotted, f->wake_up_time_ns + f->current_comp_time_ns); 512 + 513 + #undef TE_BEG 514 + #undef TE_END 515 + } 516 + 517 + 518 + /* 519 + * 398 520 * Member functions. 399 521 * 400 522 */ ··· 533 655 f->present_margin_ns, // 534 656 present_margin_ms); // 535 657 536 - 537 - if (!U_TRACE_CATEGORY_IS_ENABLED(timing)) { 538 - return; 539 - } 540 - 541 - #define TE_BEG(TRACK, TIME, NAME) U_TRACE_EVENT_BEGIN_ON_TRACK_DATA(timing, TRACK, TIME, NAME, PERCETTO_I(f->frame_id)) 542 - #define TE_END(TRACK, TIME) U_TRACE_EVENT_END_ON_TRACK(timing, TRACK, TIME) 543 - 544 - 545 - /* 546 - * 547 - * CPU 548 - * 549 - */ 550 - 551 - TE_BEG(pc_cpu, f->when_predict_ns, "sleep"); 552 - TE_END(pc_cpu, f->wake_up_time_ns); 553 - 554 - uint64_t oversleep_start_ns = f->wake_up_time_ns + 1; 555 - if (f->when_woke_ns > oversleep_start_ns) { 556 - TE_BEG(pc_cpu, oversleep_start_ns, "oversleep"); 557 - TE_END(pc_cpu, f->when_woke_ns); 558 - } 559 - 560 - 561 - /* 562 - * 563 - * GPU 564 - * 565 - */ 566 - 567 - uint64_t gpu_end_ns = f->actual_present_time_ns - f->present_margin_ns; 568 - if (gpu_end_ns > f->when_submitted_ns) { 569 - TE_BEG(pc_gpu, f->when_submitted_ns, "gpu"); 570 - TE_END(pc_gpu, gpu_end_ns); 571 - } else { 572 - TE_BEG(pc_gpu, gpu_end_ns, "gpu-time-travel"); 573 - TE_END(pc_gpu, f->when_submitted_ns); 574 - } 575 - 576 - 577 - /* 578 - * 579 - * Margin 580 - * 581 - */ 582 - 583 - if (gpu_end_ns < f->desired_present_time_ns) { 584 - TE_BEG(pc_margin, gpu_end_ns, "margin"); 585 - TE_END(pc_margin, f->desired_present_time_ns); 586 - } 587 - 588 - 589 - /* 590 - * 591 - * ERROR 592 - * 593 - */ 594 - 595 - if (!is_within_half_ms(f->actual_present_time_ns, f->desired_present_time_ns)) { 596 - if (f->actual_present_time_ns > f->desired_present_time_ns) { 597 - TE_BEG(pc_error, f->desired_present_time_ns, "slippage"); 598 - TE_END(pc_error, f->actual_present_time_ns); 599 - } else { 600 - TE_BEG(pc_error, f->actual_present_time_ns, "run-ahead"); 601 - TE_END(pc_error, f->desired_present_time_ns); 602 - } 603 - } 604 - 605 - 606 - /* 607 - * 608 - * Info 609 - * 610 - */ 611 - 612 - if (f->when_infoed_ns >= f->actual_present_time_ns) { 613 - TE_BEG(pc_info, f->actual_present_time_ns, "info"); 614 - TE_END(pc_info, f->when_infoed_ns); 615 - } else { 616 - TE_BEG(pc_info, f->when_infoed_ns, "info_before"); 617 - TE_END(pc_info, f->actual_present_time_ns); 618 - } 619 - 620 - 621 - /* 622 - * 623 - * Present 624 - * 625 - */ 626 - 627 - if (f->actual_present_time_ns != f->earliest_present_time_ns) { 628 - U_TRACE_INSTANT_ON_TRACK(timing, pc_present, f->earliest_present_time_ns, "earliest"); 629 - } 630 - if (!is_within_half_ms(f->desired_present_time_ns, f->earliest_present_time_ns)) { 631 - U_TRACE_INSTANT_ON_TRACK(timing, pc_present, f->desired_present_time_ns, "predicted"); 632 - } 633 - U_TRACE_INSTANT_ON_TRACK(timing, pc_present, f->actual_present_time_ns, "vsync"); 634 - 635 - 636 - /* 637 - * 638 - * Compositor time 639 - * 640 - */ 641 - 642 - TE_BEG(pc_allotted, f->wake_up_time_ns, "allotted"); 643 - TE_END(pc_allotted, f->wake_up_time_ns + f->current_comp_time_ns); 644 - 645 - #undef TE_BEG 646 - #undef TE_END 658 + // Write out tracing data. 659 + do_tracing(pc, f); 647 660 } 648 661 649 662 static void