backend/wayland: remove swapchain
Rely on wlr_output's generic swapchain handling.
This commit is contained in:
parent
5f8092b045
commit
543f5b35d0
|
@ -452,48 +452,6 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
||||||
goto error_drm_fd;
|
goto error_drm_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct wlr_drm_format_set *remote_formats;
|
|
||||||
if ((allocator->buffer_caps & WLR_BUFFER_CAP_DMABUF) && wl->zwp_linux_dmabuf_v1) {
|
|
||||||
remote_formats = &wl->linux_dmabuf_v1_formats;
|
|
||||||
} else if ((allocator->buffer_caps & WLR_BUFFER_CAP_SHM) && wl->shm) {
|
|
||||||
remote_formats = &wl->shm_formats;
|
|
||||||
} else {
|
|
||||||
wlr_log(WLR_ERROR,
|
|
||||||
"Failed to get remote formats (DRI3 and SHM unavailable)");
|
|
||||||
goto error_drm_fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct wlr_drm_format_set *render_formats =
|
|
||||||
wlr_renderer_get_render_formats(renderer);
|
|
||||||
if (render_formats == NULL) {
|
|
||||||
wlr_log(WLR_ERROR, "Failed to get available render-capable formats");
|
|
||||||
goto error_drm_fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t fmt = DRM_FORMAT_ARGB8888;
|
|
||||||
|
|
||||||
const struct wlr_drm_format *remote_format =
|
|
||||||
wlr_drm_format_set_get(remote_formats, fmt);
|
|
||||||
if (remote_format == NULL) {
|
|
||||||
wlr_log(WLR_ERROR, "Remote compositor doesn't support DRM format "
|
|
||||||
"0x%"PRIX32, fmt);
|
|
||||||
goto error_drm_fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct wlr_drm_format *render_format =
|
|
||||||
wlr_drm_format_set_get(render_formats, fmt);
|
|
||||||
if (render_format == NULL) {
|
|
||||||
wlr_log(WLR_ERROR, "Renderer doesn't support DRM format 0x%"PRIX32, fmt);
|
|
||||||
goto error_drm_fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
wl->format = wlr_drm_format_intersect(remote_format, render_format);
|
|
||||||
if (wl->format == NULL) {
|
|
||||||
wlr_log(WLR_ERROR, "Failed to intersect remote and render modifiers "
|
|
||||||
"for format 0x%"PRIX32, fmt);
|
|
||||||
goto error_drm_fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
wl->local_display_destroy.notify = handle_display_destroy;
|
wl->local_display_destroy.notify = handle_display_destroy;
|
||||||
wl_display_add_destroy_listener(display, &wl->local_display_destroy);
|
wl_display_add_destroy_listener(display, &wl->local_display_destroy);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include <wlr/types/wlr_matrix.h>
|
#include <wlr/types/wlr_matrix.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
|
||||||
#include "backend/backend.h"
|
|
||||||
#include "backend/wayland.h"
|
#include "backend/wayland.h"
|
||||||
#include "render/pixel_format.h"
|
#include "render/pixel_format.h"
|
||||||
#include "render/swapchain.h"
|
#include "render/swapchain.h"
|
||||||
|
@ -100,40 +99,7 @@ static const struct wp_presentation_feedback_listener
|
||||||
|
|
||||||
static bool output_set_custom_mode(struct wlr_output *wlr_output,
|
static bool output_set_custom_mode(struct wlr_output *wlr_output,
|
||||||
int32_t width, int32_t height, int32_t refresh) {
|
int32_t width, int32_t height, int32_t refresh) {
|
||||||
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
wlr_output_update_custom_mode(wlr_output, width, height, 0);
|
||||||
struct wlr_allocator *allocator = backend_get_allocator(wlr_output->backend);
|
|
||||||
|
|
||||||
if (wlr_output->width != width || wlr_output->height != height) {
|
|
||||||
struct wlr_swapchain *swapchain = wlr_swapchain_create(allocator,
|
|
||||||
width, height, output->backend->format);
|
|
||||||
if (swapchain == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
wlr_swapchain_destroy(output->swapchain);
|
|
||||||
output->swapchain = swapchain;
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_output_update_custom_mode(&output->wlr_output, width, height, 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool output_attach_render(struct wlr_output *wlr_output,
|
|
||||||
int *buffer_age) {
|
|
||||||
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
|
||||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
|
|
||||||
|
|
||||||
wlr_buffer_unlock(output->back_buffer);
|
|
||||||
output->back_buffer = wlr_swapchain_acquire(output->swapchain, buffer_age);
|
|
||||||
if (!output->back_buffer) {
|
|
||||||
wlr_log(WLR_ERROR, "Failed to acquire swapchain buffer");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!wlr_renderer_bind_buffer(renderer, output->back_buffer)) {
|
|
||||||
wlr_log(WLR_ERROR, "Failed to bind buffer to renderer");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +265,6 @@ static bool output_test(struct wlr_output *wlr_output) {
|
||||||
static bool output_commit(struct wlr_output *wlr_output) {
|
static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
struct wlr_wl_output *output =
|
struct wlr_wl_output *output =
|
||||||
get_wl_output_from_output(wlr_output);
|
get_wl_output_from_output(wlr_output);
|
||||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
|
|
||||||
|
|
||||||
if (!output_test(wlr_output)) {
|
if (!output_test(wlr_output)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -315,6 +280,9 @@ static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
|
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
|
||||||
|
assert(wlr_output->pending.buffer_type ==
|
||||||
|
WLR_OUTPUT_STATE_BUFFER_SCANOUT);
|
||||||
|
|
||||||
struct wp_presentation_feedback *wp_feedback = NULL;
|
struct wp_presentation_feedback *wp_feedback = NULL;
|
||||||
if (output->backend->presentation != NULL) {
|
if (output->backend->presentation != NULL) {
|
||||||
wp_feedback = wp_presentation_feedback(output->backend->presentation,
|
wp_feedback = wp_presentation_feedback(output->backend->presentation,
|
||||||
|
@ -334,19 +302,7 @@ static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
output->frame_callback = wl_surface_frame(output->surface);
|
output->frame_callback = wl_surface_frame(output->surface);
|
||||||
wl_callback_add_listener(output->frame_callback, &frame_listener, output);
|
wl_callback_add_listener(output->frame_callback, &frame_listener, output);
|
||||||
|
|
||||||
struct wlr_buffer *wlr_buffer = NULL;
|
struct wlr_buffer *wlr_buffer = wlr_output->pending.buffer;
|
||||||
switch (wlr_output->pending.buffer_type) {
|
|
||||||
case WLR_OUTPUT_STATE_BUFFER_RENDER:
|
|
||||||
assert(output->back_buffer != NULL);
|
|
||||||
wlr_buffer = output->back_buffer;
|
|
||||||
|
|
||||||
wlr_renderer_bind_buffer(renderer, NULL);
|
|
||||||
break;
|
|
||||||
case WLR_OUTPUT_STATE_BUFFER_SCANOUT:;
|
|
||||||
wlr_buffer = wlr_output->pending.buffer;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_wl_buffer *buffer =
|
struct wlr_wl_buffer *buffer =
|
||||||
get_or_create_wl_buffer(output->backend, wlr_buffer);
|
get_or_create_wl_buffer(output->backend, wlr_buffer);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
|
@ -371,11 +327,6 @@ static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
|
|
||||||
wl_surface_commit(output->surface);
|
wl_surface_commit(output->surface);
|
||||||
|
|
||||||
wlr_buffer_unlock(output->back_buffer);
|
|
||||||
output->back_buffer = NULL;
|
|
||||||
|
|
||||||
wlr_swapchain_set_buffer_submitted(output->swapchain, wlr_buffer);
|
|
||||||
|
|
||||||
if (wp_feedback != NULL) {
|
if (wp_feedback != NULL) {
|
||||||
struct wlr_wl_presentation_feedback *feedback =
|
struct wlr_wl_presentation_feedback *feedback =
|
||||||
calloc(1, sizeof(*feedback));
|
calloc(1, sizeof(*feedback));
|
||||||
|
@ -400,11 +351,6 @@ static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void output_rollback_render(struct wlr_output *wlr_output) {
|
|
||||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
|
|
||||||
wlr_renderer_bind_buffer(renderer, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool output_set_cursor(struct wlr_output *wlr_output,
|
static bool output_set_cursor(struct wlr_output *wlr_output,
|
||||||
struct wlr_buffer *wlr_buffer, int hotspot_x, int hotspot_y) {
|
struct wlr_buffer *wlr_buffer, int hotspot_x, int hotspot_y) {
|
||||||
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
||||||
|
@ -472,8 +418,6 @@ static void output_destroy(struct wlr_output *wlr_output) {
|
||||||
presentation_feedback_destroy(feedback);
|
presentation_feedback_destroy(feedback);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_buffer_unlock(output->back_buffer);
|
|
||||||
wlr_swapchain_destroy(output->swapchain);
|
|
||||||
if (output->zxdg_toplevel_decoration_v1) {
|
if (output->zxdg_toplevel_decoration_v1) {
|
||||||
zxdg_toplevel_decoration_v1_destroy(output->zxdg_toplevel_decoration_v1);
|
zxdg_toplevel_decoration_v1_destroy(output->zxdg_toplevel_decoration_v1);
|
||||||
}
|
}
|
||||||
|
@ -502,10 +446,8 @@ static bool output_move_cursor(struct wlr_output *_output, int x, int y) {
|
||||||
|
|
||||||
static const struct wlr_output_impl output_impl = {
|
static const struct wlr_output_impl output_impl = {
|
||||||
.destroy = output_destroy,
|
.destroy = output_destroy,
|
||||||
.attach_render = output_attach_render,
|
|
||||||
.test = output_test,
|
.test = output_test,
|
||||||
.commit = output_commit,
|
.commit = output_commit,
|
||||||
.rollback_render = output_rollback_render,
|
|
||||||
.set_cursor = output_set_cursor,
|
.set_cursor = output_set_cursor,
|
||||||
.move_cursor = output_move_cursor,
|
.move_cursor = output_move_cursor,
|
||||||
.get_cursor_formats = output_get_formats,
|
.get_cursor_formats = output_get_formats,
|
||||||
|
@ -626,13 +568,6 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *wlr_backend) {
|
||||||
&xdg_toplevel_listener, output);
|
&xdg_toplevel_listener, output);
|
||||||
wl_surface_commit(output->surface);
|
wl_surface_commit(output->surface);
|
||||||
|
|
||||||
struct wlr_allocator *allocator = backend_get_allocator(&backend->backend);
|
|
||||||
output->swapchain = wlr_swapchain_create(allocator,
|
|
||||||
wlr_output->width, wlr_output->height, output->backend->format);
|
|
||||||
if (output->swapchain == NULL) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_display_roundtrip(output->backend->remote_display);
|
wl_display_roundtrip(output->backend->remote_display);
|
||||||
|
|
||||||
wl_list_insert(&backend->outputs, &output->link);
|
wl_list_insert(&backend->outputs, &output->link);
|
||||||
|
|
|
@ -21,7 +21,6 @@ struct wlr_wl_backend {
|
||||||
struct wl_list devices;
|
struct wl_list devices;
|
||||||
struct wl_list outputs;
|
struct wl_list outputs;
|
||||||
int drm_fd;
|
int drm_fd;
|
||||||
struct wlr_drm_format *format;
|
|
||||||
struct wl_list buffers; // wlr_wl_buffer.link
|
struct wl_list buffers; // wlr_wl_buffer.link
|
||||||
size_t requested_outputs;
|
size_t requested_outputs;
|
||||||
size_t last_output_num;
|
size_t last_output_num;
|
||||||
|
@ -75,9 +74,6 @@ struct wlr_wl_output {
|
||||||
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1;
|
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1;
|
||||||
struct wl_list presentation_feedbacks;
|
struct wl_list presentation_feedbacks;
|
||||||
|
|
||||||
struct wlr_swapchain *swapchain;
|
|
||||||
struct wlr_buffer *back_buffer;
|
|
||||||
|
|
||||||
uint32_t enter_serial;
|
uint32_t enter_serial;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
Loading…
Reference in New Issue