mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-21 06:46:46 -04:00
Merge branch 'frame-scheduler-helper' into 'master'
Draft: render: add frame scheduler helper See merge request wlroots/wlroots!3783
This commit is contained in:
commit
e7737537ef
13 changed files with 479 additions and 7 deletions
|
|
@ -48,6 +48,8 @@ struct wlr_renderer_impl {
|
|||
uint32_t (*get_render_buffer_caps)(struct wlr_renderer *renderer);
|
||||
struct wlr_texture *(*texture_from_buffer)(struct wlr_renderer *renderer,
|
||||
struct wlr_buffer *buffer);
|
||||
bool (*get_time)(struct wlr_renderer *r, struct timespec *t);
|
||||
struct wlr_render_timestamp *(*create_timestamp)(struct wlr_renderer *r);
|
||||
};
|
||||
|
||||
void wlr_renderer_init(struct wlr_renderer *renderer,
|
||||
|
|
@ -62,4 +64,17 @@ struct wlr_texture_impl {
|
|||
void wlr_texture_init(struct wlr_texture *texture,
|
||||
const struct wlr_texture_impl *impl, uint32_t width, uint32_t height);
|
||||
|
||||
struct wlr_render_timestamp {
|
||||
const struct wlr_render_timestamp_impl *impl;
|
||||
};
|
||||
|
||||
struct wlr_render_timestamp_impl {
|
||||
void (*destroy)(struct wlr_render_timestamp *timestamp);
|
||||
bool (*get_time)(struct wlr_render_timestamp *timestamp,
|
||||
struct timespec *t);
|
||||
};
|
||||
|
||||
void wlr_render_timestamp_init(struct wlr_render_timestamp *timestamp,
|
||||
const struct wlr_render_timestamp_impl *impl);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
#include <wlr/backend.h>
|
||||
#include <wlr/render/wlr_texture.h>
|
||||
|
||||
struct timespec;
|
||||
|
||||
struct wlr_renderer_impl;
|
||||
struct wlr_drm_format_set;
|
||||
struct wlr_buffer;
|
||||
|
|
@ -112,6 +114,20 @@ bool wlr_renderer_init_wl_shm(struct wlr_renderer *r,
|
|||
*/
|
||||
int wlr_renderer_get_drm_fd(struct wlr_renderer *r);
|
||||
|
||||
/**
|
||||
* Get the current GPU time.
|
||||
*/
|
||||
bool wlr_renderer_get_time(struct wlr_renderer *r, struct timespec *t);
|
||||
|
||||
struct wlr_render_timestamp;
|
||||
|
||||
struct wlr_render_timestamp *wlr_renderer_create_timestamp(struct wlr_renderer *r);
|
||||
|
||||
bool wlr_render_timestamp_get_time(struct wlr_render_timestamp *timestamp,
|
||||
struct timespec *t);
|
||||
|
||||
void wlr_render_timestamp_destroy(struct wlr_render_timestamp *timestamp);
|
||||
|
||||
/**
|
||||
* Destroys the renderer.
|
||||
*
|
||||
|
|
|
|||
55
include/wlr/types/wlr_frame_scheduler.h
Normal file
55
include/wlr/types/wlr_frame_scheduler.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* This an unstable interface of wlroots. No guarantees are made regarding the
|
||||
* future consistency of this API.
|
||||
*/
|
||||
#ifndef WLR_USE_UNSTABLE
|
||||
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
||||
#endif
|
||||
|
||||
#ifndef WLR_TYPES_WLR_FRAME_SCHEDULER_H
|
||||
#define WLR_TYPES_WLR_FRAME_SCHEDULER_H
|
||||
|
||||
#include <wayland-server-core.h>
|
||||
#include <time.h>
|
||||
|
||||
struct wlr_renderer;
|
||||
struct wlr_render_timestamp;
|
||||
|
||||
#define WLR_FRAME_SCHEDULER_HISTOGRAM_LEN 128
|
||||
|
||||
struct wlr_frame_scheduler_bucket {
|
||||
int64_t cpu_duration_ns, gpu_duration_ns;
|
||||
};
|
||||
|
||||
struct wlr_frame_scheduler {
|
||||
struct wlr_output *output;
|
||||
clockid_t presentation_clock;
|
||||
|
||||
struct {
|
||||
struct wl_signal frame;
|
||||
} events;
|
||||
|
||||
// private state
|
||||
|
||||
struct wl_event_source *timer;
|
||||
|
||||
struct wlr_frame_scheduler_bucket histogram[WLR_FRAME_SCHEDULER_HISTOGRAM_LEN];
|
||||
size_t histogram_cur;
|
||||
|
||||
struct wl_listener output_present;
|
||||
|
||||
struct {
|
||||
uint32_t commit_seq;
|
||||
struct timespec frame_emitted, frame_submitted; // CPU time
|
||||
struct timespec render_submitted; // GPU time
|
||||
struct wlr_render_timestamp *render_complete;
|
||||
} queued;
|
||||
};
|
||||
|
||||
bool wlr_frame_scheduler_init(struct wlr_frame_scheduler *scheduler,
|
||||
struct wlr_output *output);
|
||||
void wlr_frame_scheduler_finish(struct wlr_frame_scheduler *scheduler);
|
||||
void wlr_frame_scheduler_mark_render_submitted(
|
||||
struct wlr_frame_scheduler *scheduler, struct wlr_renderer *renderer);
|
||||
|
||||
#endif
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
#include <wayland-server-core.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_damage_ring.h>
|
||||
#include <wlr/types/wlr_frame_scheduler.h>
|
||||
|
||||
struct wlr_output;
|
||||
struct wlr_output_layout;
|
||||
|
|
@ -166,6 +167,7 @@ struct wlr_scene_output {
|
|||
struct wlr_addon addon;
|
||||
|
||||
struct wlr_damage_ring damage_ring;
|
||||
struct wlr_frame_scheduler frame_scheduler;
|
||||
|
||||
int x, y;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue