|
35 | 35 | #include "egl_utils.h"
|
36 | 36 | #include "wayland_display.h"
|
37 | 37 |
|
| 38 | +#include <unistd.h> |
| 39 | +#include <sys/syscall.h> |
| 40 | + |
| 41 | +#define DBG_TIMING(x) |
| 42 | + |
| 43 | +DBG_TIMING( |
| 44 | +#define gettid() syscall(SYS_gettid) |
| 45 | +static uint64_t t00; |
| 46 | +) |
| 47 | + |
38 | 48 | namespace flutter {
|
39 | 49 |
|
40 | 50 | static double get_pixel_ratio(int32_t physical_width, int32_t physical_height, int32_t pixels_width, int32_t pixels_height) {
|
@@ -344,6 +354,14 @@ const struct wp_presentation_feedback_listener WaylandDisplay::kPresentationFeed
|
344 | 354 | }
|
345 | 355 | }
|
346 | 356 |
|
| 357 | + DBG_TIMING({ |
| 358 | + static auto t0 = FlutterEngineGetCurrentTime(); |
| 359 | + const auto t1 = FlutterEngineGetCurrentTime(); |
| 360 | + // dbgI("[%09.4f][%ld] presented: %09lldns flags:%08x p2p-diff:%5lldus rerfresh:%u\n", (t1-t00)/1e9, gettid(), (new_last_frame_ns-t00), flags, (new_last_frame_ns - wd->vsync.last_frame_)/1000, refresh); |
| 361 | + dbgI("[%09.4f][%ld] presented %09.4f f:%08x dc:%.5f df:%.5f r:%u\n", (t1-t00)/1e9, gettid(), (new_last_frame_ns-t00)/1e9, flags, (t1 - t0)/1e9, (new_last_frame_ns - wd->vsync.last_frame_)/1e9, refresh); |
| 362 | + t0 = t1; |
| 363 | + }) |
| 364 | + |
347 | 365 | wd->vsync.last_frame_ = new_last_frame_ns;
|
348 | 366 | },
|
349 | 367 | .discarded =
|
@@ -499,6 +517,7 @@ WaylandDisplay::WaylandDisplay(size_t width, size_t height, const std::string &b
|
499 | 517 | return;
|
500 | 518 | }
|
501 | 519 |
|
| 520 | + DBG_TIMING({t00 = FlutterEngineGetCurrentTime();}); |
502 | 521 | valid_ = true;
|
503 | 522 | }
|
504 | 523 |
|
@@ -531,12 +550,24 @@ bool WaylandDisplay::SetupEngine(const std::string &bundle_path, const std::vect
|
531 | 550 | config.open_gl.present = [](void *data) -> bool {
|
532 | 551 | WaylandDisplay *const wd = get_wayland_display(data);
|
533 | 552 |
|
| 553 | + DBG_TIMING( |
| 554 | + static auto tprev = FlutterEngineGetCurrentTime(); |
| 555 | + auto tb = FlutterEngineGetCurrentTime(); |
| 556 | + dbgI("[%09.4f][%ld] >>> swap buffer [%09.4f]\n", (tb-t00)/1e9, gettid(), (tb-tprev)/1e9); |
| 557 | + ); |
| 558 | + |
534 | 559 | if (eglSwapBuffers(wd->egl_display_, wd->egl_surface_) != EGL_TRUE) {
|
535 | 560 | LogLastEGLError();
|
536 | 561 | dbgE("Could not swap the EGL buffer\n");
|
537 | 562 | return false;
|
538 | 563 | }
|
539 | 564 |
|
| 565 | + DBG_TIMING( |
| 566 | + auto ta = FlutterEngineGetCurrentTime(); |
| 567 | + dbgI("[%09.4f][%ld] <<< swap buffer [dur:%09.4f]\n", (ta-t00)/1e9, gettid(), (ta-tb)/1e9); |
| 568 | + tprev = tb; |
| 569 | + ); |
| 570 | + |
540 | 571 | return true;
|
541 | 572 | };
|
542 | 573 | config.open_gl.fbo_callback = [](void *data) -> uint32_t { return 0; };
|
@@ -591,6 +622,11 @@ bool WaylandDisplay::SetupEngine(const std::string &bundle_path, const std::vect
|
591 | 622 | .vsync_callback = [](void *data, intptr_t baton) -> void {
|
592 | 623 | WaylandDisplay *const wd = get_wayland_display(data);
|
593 | 624 |
|
| 625 | + DBG_TIMING({ |
| 626 | + auto tx = FlutterEngineGetCurrentTime(); |
| 627 | + dbgI("[%09.4f][%ld] vsync callback [%jx]\n", (tx-t00)/1e9, gettid(), static_cast<uintmax_t>(baton)); |
| 628 | + }); |
| 629 | + |
594 | 630 | if (wd->vsync.baton_ != 0) {
|
595 | 631 | dbgE("vsync.wait: New baton arrived, but old was not sent\n");
|
596 | 632 | exit(1);
|
@@ -773,6 +809,13 @@ ssize_t WaylandDisplay::vSyncHandler() {
|
773 | 809 | const uint64_t finish_time_ns = current_ns + vsync.vblank_time_ns_;
|
774 | 810 | intptr_t baton = std::atomic_exchange(&vsync.baton_, 0);
|
775 | 811 |
|
| 812 | + DBG_TIMING({ |
| 813 | + auto tx = FlutterEngineGetCurrentTime(); |
| 814 | + dbgI("[%09.4f][%ld] flutterEngineOnVsync [%jx] (t:%09.4f d:%09.4f vb:%09.4f c:%09.4f f:%09.4f)\n", |
| 815 | + (tx-t00)/1e9, gettid(), static_cast<uintmax_t>(baton), (t_now_ns-t00)/1e9, (t_now_ns-vsync.last_frame_)/1e9, |
| 816 | + vsync.vblank_time_ns_/1e9, (current_ns-t00)/1e9, (finish_time_ns-t00)/1e9); |
| 817 | + }); |
| 818 | + |
776 | 819 | const auto status = FlutterEngineOnVsync(engine_, baton, current_ns, finish_time_ns);
|
777 | 820 |
|
778 | 821 | if (status != kSuccess) {
|
@@ -901,6 +944,10 @@ bool WaylandDisplay::Run() {
|
901 | 944 | }
|
902 | 945 |
|
903 | 946 | if (vsync.presentation_clk_id_ != UINT32_MAX && presentation_ != nullptr) {
|
| 947 | + DBG_TIMING({ |
| 948 | + auto tx = FlutterEngineGetCurrentTime(); |
| 949 | + dbgI("[%09.4f][%ld] add listener\n", (tx-t00)/1e9, gettid()); |
| 950 | + }); |
904 | 951 | wp_presentation_feedback_add_listener(::wp_presentation_feedback(presentation_, surface_), &kPresentationFeedbackListener, this);
|
905 | 952 | wl_display_dispatch_pending(display_);
|
906 | 953 | }
|
|
0 commit comments