diff --git a/src/drm.cpp b/src/drm.cpp index 39c641b7eb..3c29994012 100644 --- a/src/drm.cpp +++ b/src/drm.cpp @@ -272,6 +272,7 @@ static void drm_unlock_fb_internal( struct drm_t *drm, struct fb *fb ); std::atomic g_nCompletedPageFlipCount = { 0u }; +extern void mangoapp_output_update( uint64_t vblanktime ); static void page_flip_handler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, unsigned int crtc_id, void *data) { uint64_t flipcount = (uint64_t)data; @@ -333,6 +334,8 @@ static void page_flip_handler(int fd, unsigned int frame, unsigned int sec, unsi g_DRM.fbids_queued.clear(); g_DRM.flip_lock.unlock(); + + mangoapp_output_update( vblanktime ); } void flip_handler_thread_run(void) diff --git a/src/mangoapp.cpp b/src/mangoapp.cpp index e751e5ff2b..2d0c59f72e 100644 --- a/src/mangoapp.cpp +++ b/src/mangoapp.cpp @@ -52,3 +52,26 @@ void mangoapp_update( uint64_t visible_frametime, uint64_t app_frametime_ns, uin mangoapp_msg_v1.outputHeight = g_nOutputHeight; msgsnd(msgid, &mangoapp_msg_v1, sizeof(mangoapp_msg_v1) - sizeof(mangoapp_msg_v1.hdr.msg_type), IPC_NOWAIT); } + +extern uint64_t g_uCurrentBasePlaneCommitID; +extern bool g_bCurrentBasePlaneIsFifo; +void mangoapp_output_update( uint64_t vblanktime ) +{ + if ( !g_bCurrentBasePlaneIsFifo ) + { + return; + } + + static uint64_t s_uLastBasePlaneCommitID = 0; + if ( s_uLastBasePlaneCommitID != g_uCurrentBasePlaneCommitID ) + { + static uint64_t s_uLastBasePlaneUpdateVBlankTime = vblanktime; + uint64_t last_frametime = s_uLastBasePlaneUpdateVBlankTime; + uint64_t frametime = vblanktime - last_frametime; + s_uLastBasePlaneUpdateVBlankTime = vblanktime; + s_uLastBasePlaneCommitID = g_uCurrentBasePlaneCommitID; + if ( last_frametime > vblanktime ) + return; + mangoapp_update( frametime, uint64_t(~0ull), uint64_t(~0ull) ); + } +} diff --git a/src/rendervulkan.cpp b/src/rendervulkan.cpp index a1805edb60..f18b91fe30 100644 --- a/src/rendervulkan.cpp +++ b/src/rendervulkan.cpp @@ -2581,6 +2581,7 @@ bool acquire_next_image( void ) static std::atomic g_currentPresentWaitId = {0u}; static std::mutex present_wait_lock; +extern void mangoapp_output_update( uint64_t vblanktime ); static void present_wait_thread_func( void ) { uint64_t present_wait_id = 0; @@ -2598,7 +2599,9 @@ static void present_wait_thread_func( void ) if (present_wait_id != 0) { g_device.vk.WaitForPresentKHR( g_device.device(), g_output.swapChain, present_wait_id, 1'000'000'000lu ); - vblank_mark_possible_vblank( get_time_in_nanos() ); + uint64_t vblanktime = get_time_in_nanos(); + vblank_mark_possible_vblank( vblanktime ); + mangoapp_output_update( vblanktime ); } } } diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index c0f749e697..0df145ea26 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp @@ -765,6 +765,7 @@ struct commit_t : public gamescope::IWaitable bool done = false; bool async = false; bool fifo = false; + bool is_steam = false; std::optional feedback = std::nullopt; uint64_t win_seq = 0; @@ -818,11 +819,16 @@ struct commit_t : public gamescope::IWaitable } if ( m_bMangoNudge ) - mangoapp_update( frametime, uint64_t(~0ull), uint64_t(~0ull) ); + mangoapp_update( IsPerfOverlayFIFO() ? uint64_t(~0ull) : frametime, frametime, uint64_t(~0ull) ); nudge_steamcompmgr(); } + bool IsPerfOverlayFIFO() + { + return fifo || is_steam; + } + void CloseFenceInternal() { if ( m_nCommitFence < 0 ) @@ -949,6 +955,9 @@ std::mutex g_SteamCompMgrXWaylandServerMutex; VBlankTimeInfo_t g_SteamCompMgrVBlankTime = {}; +uint64_t g_uCurrentBasePlaneCommitID = 0; +bool g_bCurrentBasePlaneIsFifo = false; + static int g_nSteamCompMgrTargetFPS = 0; static uint64_t g_uDynamicRefreshEqualityTime = 0; static int g_nDynamicRefreshRate[DRM_SCREEN_TYPE_COUNT] = { 0, 0 }; @@ -1429,6 +1438,7 @@ import_commit ( steamcompmgr_win_t *w, struct wlr_surface *surf, struct wlr_buff commit->buf = buf; commit->async = async; commit->fifo = fifo; + commit->is_steam = window_is_steam( w ); commit->presentation_feedbacks = std::move(presentation_feedbacks); if (swapchain_feedback) commit->feedback = *swapchain_feedback; @@ -2392,6 +2402,9 @@ paint_window(steamcompmgr_win_t *w, steamcompmgr_win_t *scaleW, struct FrameInfo g_CachedPlanes[ HELD_COMMIT_BASE ] = basePlane; if ( !(flags & PaintWindowFlag::FadeTarget) ) g_CachedPlanes[ HELD_COMMIT_FADE ] = basePlane; + + g_uCurrentBasePlaneCommitID = lastCommit->commitID; + g_bCurrentBasePlaneIsFifo = lastCommit->IsPerfOverlayFIFO(); } }