mirror of
https://github.com/labwc/labwc.git
synced 2026-04-12 08:21:13 -04:00
src/output-state.c: add a FPS debug option
Logs the FPS per output every $timeout ms via wlr_log() if enabled. By default this patch does nothing unless the FPS_TIMEOUT define has been set, for example via `meson configure build -DFPS_TIMEOUT=5000`.
This commit is contained in:
parent
3be8fe25f3
commit
7a35b1e67c
3 changed files with 33 additions and 0 deletions
|
|
@ -371,6 +371,7 @@ struct output {
|
||||||
struct server *server;
|
struct server *server;
|
||||||
struct wlr_output *wlr_output;
|
struct wlr_output *wlr_output;
|
||||||
struct wlr_output_state pending;
|
struct wlr_output_state pending;
|
||||||
|
struct wl_event_source *fps_timer;
|
||||||
struct wlr_scene_output *scene_output;
|
struct wlr_scene_output *scene_output;
|
||||||
struct wlr_scene_tree *layer_tree[LAB_NR_LAYERS];
|
struct wlr_scene_tree *layer_tree[LAB_NR_LAYERS];
|
||||||
struct wlr_scene_tree *layer_popup_tree;
|
struct wlr_scene_tree *layer_popup_tree;
|
||||||
|
|
@ -389,6 +390,7 @@ struct output {
|
||||||
|
|
||||||
bool leased;
|
bool leased;
|
||||||
bool gamma_lut_changed;
|
bool gamma_lut_changed;
|
||||||
|
uint32_t frames;
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef LAB_NR_LAYERS
|
#undef LAB_NR_LAYERS
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,25 @@
|
||||||
|
|
||||||
#include <wlr/types/wlr_output.h>
|
#include <wlr/types/wlr_output.h>
|
||||||
#include <wlr/types/wlr_output_management_v1.h>
|
#include <wlr/types/wlr_output_management_v1.h>
|
||||||
|
#include <wlr/util/log.h>
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "output-state.h"
|
#include "output-state.h"
|
||||||
|
|
||||||
|
//#define FPS_TIMEOUT (2 * 1000)
|
||||||
|
|
||||||
|
#ifdef FPS_TIMEOUT
|
||||||
|
static int
|
||||||
|
handle_fps_timer(void *data)
|
||||||
|
{
|
||||||
|
struct output *output = data;
|
||||||
|
wlr_log(WLR_DEBUG, "%s commit: avg %.2f fps",
|
||||||
|
output->wlr_output->name, (double)output->frames / (FPS_TIMEOUT / 1000));
|
||||||
|
wl_event_source_timer_update(output->fps_timer, FPS_TIMEOUT);
|
||||||
|
output->frames = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
output_state_init(struct output *output)
|
output_state_init(struct output *output)
|
||||||
{
|
{
|
||||||
|
|
@ -37,8 +53,18 @@ bool
|
||||||
wlr_output_commit(struct wlr_output *wlr_output)
|
wlr_output_commit(struct wlr_output *wlr_output)
|
||||||
{
|
{
|
||||||
struct output *output = wlr_output->data;
|
struct output *output = wlr_output->data;
|
||||||
|
#ifdef FPS_TIMEOUT
|
||||||
|
if (!output->fps_timer) {
|
||||||
|
output->fps_timer = wl_event_loop_add_timer(
|
||||||
|
output->server->wl_event_loop, handle_fps_timer, output);
|
||||||
|
wl_event_source_timer_update(output->fps_timer, FPS_TIMEOUT);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
bool committed = wlr_output_commit_state(wlr_output, &output->pending);
|
bool committed = wlr_output_commit_state(wlr_output, &output->pending);
|
||||||
if (committed) {
|
if (committed) {
|
||||||
|
#ifdef FPS_TIMEOUT
|
||||||
|
output->frames++;
|
||||||
|
#endif
|
||||||
wlr_output_state_finish(&output->pending);
|
wlr_output_state_finish(&output->pending);
|
||||||
wlr_output_state_init(&output->pending);
|
wlr_output_state_init(&output->pending);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,11 @@ output_destroy_notify(struct wl_listener *listener, void *data)
|
||||||
*/
|
*/
|
||||||
output->wlr_output->data = NULL;
|
output->wlr_output->data = NULL;
|
||||||
|
|
||||||
|
if (output->fps_timer) {
|
||||||
|
wl_event_source_remove(output->fps_timer);
|
||||||
|
output->fps_timer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* output->scene_output (if still around at this point) is
|
* output->scene_output (if still around at this point) is
|
||||||
* destroyed automatically when the wlr_output is destroyed
|
* destroyed automatically when the wlr_output is destroyed
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue