Skip to content

Commit

Permalink
mangoapp: Use visible frames for reporting to mangohud if FIFO
Browse files Browse the repository at this point in the history
Report app gpu frametime to a separate place...
  • Loading branch information
misyltoad committed Dec 1, 2023
1 parent f5d1d67 commit 754420f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
16 changes: 13 additions & 3 deletions src/mangoapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) );
}
}
13 changes: 11 additions & 2 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<wlserver_vk_swapchain_feedback> feedback = std::nullopt;

uint64_t win_seq = 0;
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}

Expand Down

0 comments on commit 754420f

Please sign in to comment.