mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 19:16:21 +00:00
u/pacing: Add minimum app time option
This commit is contained in:
parent
fd55a0f1ef
commit
f5e33e59c8
|
@ -22,6 +22,7 @@
|
|||
#include <inttypes.h>
|
||||
|
||||
DEBUG_GET_ONCE_LOG_OPTION(log_level, "U_PACING_APP_LOG", U_LOGGING_WARN)
|
||||
DEBUG_GET_ONCE_FLOAT_OPTION(min_app_time_ms, "U_PACING_APP_MIN_TIME_MS", 1.0f)
|
||||
|
||||
#define UPA_LOG_T(...) U_LOG_IFL_T(debug_get_log_option_log_level(), __VA_ARGS__)
|
||||
#define UPA_LOG_D(...) U_LOG_IFL_D(debug_get_log_option_log_level(), __VA_ARGS__)
|
||||
|
@ -111,6 +112,9 @@ struct pacing_app
|
|||
|
||||
int64_t frame_counter;
|
||||
|
||||
// Minimum calculated frame (total app time).
|
||||
double min_app_time_ms;
|
||||
|
||||
struct
|
||||
{
|
||||
//! App time between wait returning and begin being called.
|
||||
|
@ -200,6 +204,12 @@ min_period(const struct pacing_app *pa)
|
|||
return pa->last_input.predicted_display_period_ns;
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
min_app_time(const struct pacing_app *pa)
|
||||
{
|
||||
return (uint64_t)(pa->min_app_time_ms * (double)U_TIME_1MS_IN_NS);
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
last_sample_displayed(const struct pacing_app *pa)
|
||||
{
|
||||
|
@ -215,7 +225,14 @@ last_return_predicted_display(const struct pacing_app *pa)
|
|||
static uint64_t
|
||||
total_app_time_ns(const struct pacing_app *pa)
|
||||
{
|
||||
return pa->app.cpu_time_ns + pa->app.draw_time_ns + pa->app.wait_time_ns;
|
||||
uint64_t total_ns = pa->app.cpu_time_ns + pa->app.draw_time_ns + pa->app.wait_time_ns;
|
||||
uint64_t min_ns = min_app_time(pa);
|
||||
|
||||
if (total_ns < min_ns) {
|
||||
total_ns = min_ns;
|
||||
}
|
||||
|
||||
return total_ns;
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
|
@ -650,6 +667,7 @@ pa_create(int64_t session_id, struct u_pacing_app **out_upa)
|
|||
pa->app.cpu_time_ns = U_TIME_1MS_IN_NS * 2;
|
||||
pa->app.draw_time_ns = U_TIME_1MS_IN_NS * 2;
|
||||
pa->app.margin_ns = U_TIME_1MS_IN_NS * 2;
|
||||
pa->min_app_time_ms = debug_get_float_option_min_app_time_ms();
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(pa->frames); i++) {
|
||||
pa->frames[i].state = U_PA_READY;
|
||||
|
|
Loading…
Reference in a new issue