Merge branch 'swapchain-stack' into 'master'

Draft: render/swapchain: switch to init()/finish()

See merge request wlroots/wlroots!4024
This commit is contained in:
Simon Ser 2023-02-21 16:13:56 +00:00
commit a2c4492bd2
10 changed files with 66 additions and 77 deletions

View file

@ -0,0 +1,50 @@
#ifndef WLR_RENDER_SWAPCHAIN_H
#define WLR_RENDER_SWAPCHAIN_H
#include <stdbool.h>
#include <wayland-server-core.h>
#include <wlr/render/drm_format_set.h>
#define WLR_SWAPCHAIN_CAP 4
struct wlr_swapchain_slot {
struct wlr_buffer *buffer;
bool acquired; // waiting for release
int age;
struct wl_listener release;
};
struct wlr_swapchain {
struct wlr_allocator *allocator; // NULL if destroyed
int width, height;
struct wlr_drm_format *format;
struct wlr_swapchain_slot slots[WLR_SWAPCHAIN_CAP];
struct wl_listener allocator_destroy;
};
bool wlr_swapchain_init(struct wlr_swapchain *swapchain,
struct wlr_allocator *alloc, int width, int height,
const struct wlr_drm_format *format);
void wlr_swapchain_finish(struct wlr_swapchain *swapchain);
/**
* Acquire a buffer from the swap chain.
*
* The returned buffer is locked. When the caller is done with it, they must
* unlock it by calling wlr_buffer_unlock.
*/
struct wlr_buffer *wlr_swapchain_acquire(struct wlr_swapchain *swapchain,
int *age);
/**
* Mark the buffer as submitted for presentation. This needs to be called by
* swap chain users on frame boundaries.
*
* If the buffer hasn't been created via the swap chain, the call is ignored.
*/
void wlr_swapchain_set_buffer_submitted(struct wlr_swapchain *swapchain,
struct wlr_buffer *buffer);
#endif

View file

@ -14,6 +14,7 @@
#include <time.h>
#include <wayland-server-protocol.h>
#include <wayland-util.h>
#include <wlr/render/swapchain.h>
#include <wlr/types/wlr_buffer.h>
#include <wlr/util/addon.h>
@ -192,7 +193,7 @@ struct wlr_output {
struct wl_list cursors; // wlr_output_cursor::link
struct wlr_output_cursor *hardware_cursor;
struct wlr_swapchain *cursor_swapchain;
struct wlr_swapchain cursor_swapchain;
struct wlr_buffer *cursor_front_buffer;
int software_cursor_locks; // number of locks forcing software cursors
@ -200,7 +201,7 @@ struct wlr_output {
struct wlr_allocator *allocator;
struct wlr_renderer *renderer;
struct wlr_swapchain *swapchain;
struct wlr_swapchain swapchain;
struct wlr_buffer *back_buffer;
struct wl_listener display_destroy;