steamcompmgr: Add tuneables for vblank red zone + decay rate

This commit is contained in:
Joshua Ashton 2022-01-28 23:44:21 +00:00 committed by Joshie
parent 797ee59cbb
commit 0bc3a2493d
4 changed files with 25 additions and 3 deletions

View file

@ -3477,6 +3477,14 @@ handle_property_notify(xwayland_ctx_t *ctx, XPropertyEvent *ev)
}
}
}
if ( ev->atom == ctx->atoms.gamescopeTuneableVBlankRedZone )
{
g_uVblankDrawBufferRedZoneNS = (uint64_t)get_prop( ctx, ctx->root, ctx->atoms.gamescopeTuneableVBlankRedZone, g_uDefaultVBlankRedZone );
}
if ( ev->atom == ctx->atoms.gamescopeTuneableRateOfDecay )
{
g_uVBlankRateOfDecayPercentage = (uint64_t)get_prop( ctx, ctx->root, ctx->atoms.gamescopeTuneableRateOfDecay, g_uDefaultVBlankRateOfDecayPercentage );
}
}
static int
@ -4316,6 +4324,10 @@ void init_xwayland_ctx(gamescope_xwayland_server_t *xwayland_server)
ctx->atoms.gamescopeMouseFocusDisplay = XInternAtom(ctx->dpy, "GAMESCOPE_MOUSE_FOCUS_DISPLAY", false);
ctx->atoms.gamescopeKeyboardFocusDisplay = XInternAtom( ctx->dpy, "GAMESCOPE_KEYBOARD_FOCUS_DISPLAY", false );
// In nanoseconds...
ctx->atoms.gamescopeTuneableVBlankRedZone = XInternAtom( ctx->dpy, "GAMESCOPE_TUNEABLE_VBLANK_REDZONE", false );
ctx->atoms.gamescopeTuneableRateOfDecay = XInternAtom( ctx->dpy, "GAMESCOPE_TUNEABLE_VBLANK_RATE_OF_DECAY_PERCENTAGE", false );
ctx->root_width = DisplayWidth(ctx->dpy, ctx->scr);
ctx->root_height = DisplayHeight(ctx->dpy, ctx->scr);

View file

@ -27,17 +27,18 @@ const uint64_t g_uStartingDrawTime = 3'000'000;
std::atomic<uint64_t> g_uVblankDrawTimeNS = { g_uStartingDrawTime };
// Tuneable
// 2.0ms
// 2.0ms by default. (g_DefaultVBlankRedZone)
// This is the leeway we always apply to our buffer.
// This also accounts for some time we cannot account for (which (I think) is the drm_commit -> triggering the pageflip)
// It would be nice to make this lower if we can find a way to track that effectively
// Perhaps the missing time is spent elsewhere, but given we track from the pipe write
// to after the return from `drm_commit` -- I am very doubtful.
uint64_t g_uVblankDrawBufferRedZoneNS = 2'000'000;
uint64_t g_uVblankDrawBufferRedZoneNS = g_uDefaultVBlankRedZone;
// Tuneable
// 93% by default. (g_uVBlankRateOfDecayPercentage)
// The rate of decay (as a percentage) of the rolling average -> current draw time
uint64_t g_uVBlankRateOfDecayPercentage = 93;
uint64_t g_uVBlankRateOfDecayPercentage = g_uDefaultVBlankRateOfDecayPercentage;
const uint64_t g_uVBlankRateOfDecayMax = 100;

View file

@ -5,3 +5,9 @@ int vblank_init( void );
void vblank_mark_possible_vblank( uint64_t nanos );
extern std::atomic<uint64_t> g_uVblankDrawTimeNS;
const unsigned int g_uDefaultVBlankRedZone = 2'000'000;
const unsigned int g_uDefaultVBlankRateOfDecayPercentage = 93;
extern uint64_t g_uVblankDrawBufferRedZoneNS;
extern uint64_t g_uVBlankRateOfDecayPercentage;

View file

@ -109,5 +109,8 @@ struct xwayland_ctx_t
Atom gamescopeFocusDisplay;
Atom gamescopeMouseFocusDisplay;
Atom gamescopeKeyboardFocusDisplay;
Atom gamescopeTuneableVBlankRedZone;
Atom gamescopeTuneableRateOfDecay;
} atoms;
};