From 754420f8a1bc5a01b30b5c2feb3c1080bc8af209 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Fri, 1 Dec 2023 06:20:35 +0000 Subject: [PATCH] mangoapp: Use visible frames for reporting to mangohud if FIFO Report app gpu frametime to a separate place... --- src/mangoapp.cpp | 16 +++++++++++++--- src/steamcompmgr.cpp | 13 +++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/mangoapp.cpp b/src/mangoapp.cpp index c8cedc0814..2d0c59f72e 100644 --- a/src/mangoapp.cpp +++ b/src/mangoapp.cpp @@ -54,14 +54,24 @@ void mangoapp_update( uint64_t visible_frametime, uint64_t app_frametime_ns, uin } 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 - 16'666'666; - mangoapp_update( s_uLastBasePlaneUpdateVBlankTime - vblanktime, uint64_t(~0ull), uint64_t(~0ull) ); - 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/steamcompmgr.cpp b/src/steamcompmgr.cpp index 97049ac4d1..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; @@ -817,12 +818,17 @@ struct commit_t : public gamescope::IWaitable } ); } - //if ( m_bMangoNudge ) - // mangoapp_update( frametime, uint64_t(~0ull), uint64_t(~0ull) ); + if ( m_bMangoNudge ) + 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 ) @@ -950,6 +956,7 @@ 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; @@ -1431,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; @@ -2396,6 +2404,7 @@ paint_window(steamcompmgr_win_t *w, steamcompmgr_win_t *scaleW, struct FrameInfo g_CachedPlanes[ HELD_COMMIT_FADE ] = basePlane; g_uCurrentBasePlaneCommitID = lastCommit->commitID; + g_bCurrentBasePlaneIsFifo = lastCommit->IsPerfOverlayFIFO(); } }