mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01:00
backend/x11: remove swapchain
Rely on wlr_output's generic swapchain handling. We still need a renderer for cursor readback, sadly.
This commit is contained in:
parent
68c4f15958
commit
a670ee7940
3 changed files with 4 additions and 124 deletions
|
@ -27,14 +27,12 @@
|
||||||
#include <wlr/interfaces/wlr_input_device.h>
|
#include <wlr/interfaces/wlr_input_device.h>
|
||||||
#include <wlr/interfaces/wlr_keyboard.h>
|
#include <wlr/interfaces/wlr_keyboard.h>
|
||||||
#include <wlr/interfaces/wlr_pointer.h>
|
#include <wlr/interfaces/wlr_pointer.h>
|
||||||
#include <wlr/render/wlr_renderer.h>
|
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
|
||||||
#include "backend/backend.h"
|
#include "backend/backend.h"
|
||||||
#include "backend/x11.h"
|
#include "backend/x11.h"
|
||||||
#include "render/allocator.h"
|
#include "render/allocator.h"
|
||||||
#include "render/drm_format_set.h"
|
#include "render/drm_format_set.h"
|
||||||
#include "render/wlr_renderer.h"
|
|
||||||
#include "types/wlr_buffer.h"
|
#include "types/wlr_buffer.h"
|
||||||
#include "util/signal.h"
|
#include "util/signal.h"
|
||||||
|
|
||||||
|
@ -202,7 +200,6 @@ static void backend_destroy(struct wlr_backend *backend) {
|
||||||
wlr_drm_format_set_finish(&x11->primary_shm_formats);
|
wlr_drm_format_set_finish(&x11->primary_shm_formats);
|
||||||
wlr_drm_format_set_finish(&x11->dri3_formats);
|
wlr_drm_format_set_finish(&x11->dri3_formats);
|
||||||
wlr_drm_format_set_finish(&x11->shm_formats);
|
wlr_drm_format_set_finish(&x11->shm_formats);
|
||||||
free(x11->drm_format);
|
|
||||||
|
|
||||||
#if HAS_XCB_ERRORS
|
#if HAS_XCB_ERRORS
|
||||||
xcb_errors_context_free(x11->errors_context);
|
xcb_errors_context_free(x11->errors_context);
|
||||||
|
@ -620,46 +617,6 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
||||||
goto error_event;
|
goto error_event;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct wlr_drm_format_set *pixmap_formats;
|
|
||||||
if (x11->have_dri3 && (allocator->buffer_caps & WLR_BUFFER_CAP_DMABUF)) {
|
|
||||||
pixmap_formats = &x11->dri3_formats;
|
|
||||||
} else if (x11->have_shm && (allocator->buffer_caps & WLR_BUFFER_CAP_SHM)) {
|
|
||||||
pixmap_formats = &x11->shm_formats;
|
|
||||||
} else {
|
|
||||||
wlr_log(WLR_ERROR,
|
|
||||||
"Failed to create allocator (DRI3 and SHM unavailable)");
|
|
||||||
goto error_event;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 DRM formats from renderer");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const struct wlr_drm_format *render_format =
|
|
||||||
wlr_drm_format_set_get(render_formats, x11->x11_format->drm);
|
|
||||||
if (render_format == NULL) {
|
|
||||||
wlr_log(WLR_ERROR, "Renderer doesn't support DRM format 0x%"PRIX32,
|
|
||||||
x11->x11_format->drm);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct wlr_drm_format *pixmap_format = wlr_drm_format_set_get(
|
|
||||||
pixmap_formats, x11->x11_format->drm);
|
|
||||||
if (pixmap_format == NULL) {
|
|
||||||
wlr_log(WLR_ERROR, "X11 server doesn't support DRM format 0x%"PRIX32,
|
|
||||||
x11->x11_format->drm);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
x11->drm_format = wlr_drm_format_intersect(pixmap_format, render_format);
|
|
||||||
if (x11->drm_format == NULL) {
|
|
||||||
wlr_log(WLR_ERROR, "Failed to intersect X11 and render modifiers for "
|
|
||||||
"format 0x%"PRIX32, x11->x11_format->drm);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Windows can only display buffers with the depth they were created with
|
// Windows can only display buffers with the depth they were created with
|
||||||
// TODO: look into changing the window's depth at runtime
|
// TODO: look into changing the window's depth at runtime
|
||||||
const struct wlr_drm_format *dri3_format =
|
const struct wlr_drm_format *dri3_format =
|
||||||
|
|
|
@ -19,9 +19,7 @@
|
||||||
#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/x11.h"
|
#include "backend/x11.h"
|
||||||
#include "render/swapchain.h"
|
|
||||||
#include "render/wlr_renderer.h"
|
#include "render/wlr_renderer.h"
|
||||||
#include "types/wlr_buffer.h"
|
#include "types/wlr_buffer.h"
|
||||||
#include "util/signal.h"
|
#include "util/signal.h"
|
||||||
|
@ -83,9 +81,7 @@ static void output_destroy(struct wlr_output *wlr_output) {
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_list_remove(&output->link);
|
wl_list_remove(&output->link);
|
||||||
wlr_buffer_unlock(output->back_buffer);
|
|
||||||
wlr_swapchain_destroy(output->swapchain);
|
|
||||||
wlr_swapchain_destroy(output->cursor.swapchain);
|
|
||||||
if (output->cursor.pic != XCB_NONE) {
|
if (output->cursor.pic != XCB_NONE) {
|
||||||
xcb_render_free_picture(x11->xcb, output->cursor.pic);
|
xcb_render_free_picture(x11->xcb, output->cursor.pic);
|
||||||
}
|
}
|
||||||
|
@ -97,26 +93,6 @@ static void output_destroy(struct wlr_output *wlr_output) {
|
||||||
free(output);
|
free(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool output_attach_render(struct wlr_output *wlr_output,
|
|
||||||
int *buffer_age) {
|
|
||||||
struct wlr_x11_output *output = get_x11_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool output_test(struct wlr_output *wlr_output) {
|
static bool output_test(struct wlr_output *wlr_output) {
|
||||||
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_ENABLED) {
|
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_ENABLED) {
|
||||||
wlr_log(WLR_DEBUG, "Cannot disable an X11 output");
|
wlr_log(WLR_DEBUG, "Cannot disable an X11 output");
|
||||||
|
@ -273,24 +249,11 @@ static struct wlr_x11_buffer *get_or_create_x11_buffer(
|
||||||
|
|
||||||
static bool output_commit_buffer(struct wlr_x11_output *output) {
|
static bool output_commit_buffer(struct wlr_x11_output *output) {
|
||||||
struct wlr_x11_backend *x11 = output->x11;
|
struct wlr_x11_backend *x11 = output->x11;
|
||||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(&x11->backend);
|
|
||||||
|
|
||||||
struct wlr_buffer *buffer = NULL;
|
assert(output->wlr_output.pending.buffer_type ==
|
||||||
switch (output->wlr_output.pending.buffer_type) {
|
WLR_OUTPUT_STATE_BUFFER_SCANOUT);
|
||||||
case WLR_OUTPUT_STATE_BUFFER_RENDER:
|
|
||||||
assert(output->back_buffer != NULL);
|
|
||||||
|
|
||||||
wlr_renderer_bind_buffer(renderer, NULL);
|
|
||||||
|
|
||||||
buffer = output->back_buffer;
|
|
||||||
output->back_buffer = NULL;
|
|
||||||
break;
|
|
||||||
case WLR_OUTPUT_STATE_BUFFER_SCANOUT:
|
|
||||||
buffer = wlr_buffer_lock(output->wlr_output.pending.buffer);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
assert(buffer != NULL);
|
|
||||||
|
|
||||||
|
struct wlr_buffer *buffer = output->wlr_output.pending.buffer;
|
||||||
struct wlr_x11_buffer *x11_buffer =
|
struct wlr_x11_buffer *x11_buffer =
|
||||||
get_or_create_x11_buffer(output, buffer);
|
get_or_create_x11_buffer(output, buffer);
|
||||||
if (!x11_buffer) {
|
if (!x11_buffer) {
|
||||||
|
@ -338,15 +301,10 @@ static bool output_commit_buffer(struct wlr_x11_output *output) {
|
||||||
xcb_xfixes_destroy_region(x11->xcb, region);
|
xcb_xfixes_destroy_region(x11->xcb, region);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_buffer_unlock(buffer);
|
|
||||||
|
|
||||||
wlr_swapchain_set_buffer_submitted(output->swapchain, x11_buffer->buffer);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
destroy_x11_buffer(x11_buffer);
|
destroy_x11_buffer(x11_buffer);
|
||||||
wlr_buffer_unlock(buffer);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,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 void update_x11_output_cursor(struct wlr_x11_output *output,
|
static void update_x11_output_cursor(struct wlr_x11_output *output,
|
||||||
int32_t hotspot_x, int32_t hotspot_y) {
|
int32_t hotspot_x, int32_t hotspot_y) {
|
||||||
struct wlr_x11_backend *x11 = output->x11;
|
struct wlr_x11_backend *x11 = output->x11;
|
||||||
|
@ -530,10 +483,8 @@ static const struct wlr_drm_format_set *output_get_primary_formats(
|
||||||
|
|
||||||
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_primary_formats = output_get_primary_formats,
|
.get_primary_formats = output_get_primary_formats,
|
||||||
|
@ -541,7 +492,6 @@ static const struct wlr_output_impl output_impl = {
|
||||||
|
|
||||||
struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
||||||
struct wlr_x11_backend *x11 = get_x11_backend_from_backend(backend);
|
struct wlr_x11_backend *x11 = get_x11_backend_from_backend(backend);
|
||||||
struct wlr_allocator *allocator = backend_get_allocator(backend);
|
|
||||||
|
|
||||||
if (!x11->started) {
|
if (!x11->started) {
|
||||||
++x11->requested_outputs;
|
++x11->requested_outputs;
|
||||||
|
@ -561,14 +511,6 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
||||||
|
|
||||||
wlr_output_update_custom_mode(wlr_output, 1024, 768, 0);
|
wlr_output_update_custom_mode(wlr_output, 1024, 768, 0);
|
||||||
|
|
||||||
output->swapchain = wlr_swapchain_create(allocator,
|
|
||||||
wlr_output->width, wlr_output->height, x11->drm_format);
|
|
||||||
if (!output->swapchain) {
|
|
||||||
wlr_log(WLR_ERROR, "Failed to create swapchain");
|
|
||||||
free(output);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(wlr_output->name, sizeof(wlr_output->name), "X11-%zd",
|
snprintf(wlr_output->name, sizeof(wlr_output->name), "X11-%zd",
|
||||||
++x11->last_output_num);
|
++x11->last_output_num);
|
||||||
parse_xcb_setup(wlr_output, x11->xcb);
|
parse_xcb_setup(wlr_output, x11->xcb);
|
||||||
|
@ -653,8 +595,6 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
||||||
|
|
||||||
void handle_x11_configure_notify(struct wlr_x11_output *output,
|
void handle_x11_configure_notify(struct wlr_x11_output *output,
|
||||||
xcb_configure_notify_event_t *ev) {
|
xcb_configure_notify_event_t *ev) {
|
||||||
struct wlr_allocator *allocator = backend_get_allocator(&output->x11->backend);
|
|
||||||
|
|
||||||
// ignore events that set an invalid size:
|
// ignore events that set an invalid size:
|
||||||
if (ev->width == 0 || ev->height == 0) {
|
if (ev->width == 0 || ev->height == 0) {
|
||||||
wlr_log(WLR_DEBUG,
|
wlr_log(WLR_DEBUG,
|
||||||
|
@ -663,18 +603,6 @@ void handle_x11_configure_notify(struct wlr_x11_output *output,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output->swapchain->width != ev->width ||
|
|
||||||
output->swapchain->height != ev->height) {
|
|
||||||
struct wlr_swapchain *swapchain = wlr_swapchain_create(
|
|
||||||
allocator, ev->width, ev->height,
|
|
||||||
output->x11->drm_format);
|
|
||||||
if (!swapchain) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
wlr_swapchain_destroy(output->swapchain);
|
|
||||||
output->swapchain = swapchain;
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_output_update_custom_mode(&output->wlr_output, ev->width,
|
wlr_output_update_custom_mode(&output->wlr_output, ev->width,
|
||||||
ev->height, 0);
|
ev->height, 0);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include <wlr/interfaces/wlr_pointer.h>
|
#include <wlr/interfaces/wlr_pointer.h>
|
||||||
#include <wlr/interfaces/wlr_touch.h>
|
#include <wlr/interfaces/wlr_touch.h>
|
||||||
#include <wlr/render/drm_format_set.h>
|
#include <wlr/render/drm_format_set.h>
|
||||||
#include <wlr/render/wlr_renderer.h>
|
|
||||||
|
|
||||||
#define XCB_EVENT_RESPONSE_TYPE_MASK 0x7f
|
#define XCB_EVENT_RESPONSE_TYPE_MASK 0x7f
|
||||||
|
|
||||||
|
@ -35,9 +34,6 @@ struct wlr_x11_output {
|
||||||
xcb_window_t win;
|
xcb_window_t win;
|
||||||
xcb_present_event_t present_event_id;
|
xcb_present_event_t present_event_id;
|
||||||
|
|
||||||
struct wlr_swapchain *swapchain;
|
|
||||||
struct wlr_buffer *back_buffer;
|
|
||||||
|
|
||||||
struct wlr_pointer pointer;
|
struct wlr_pointer pointer;
|
||||||
struct wlr_input_device pointer_dev;
|
struct wlr_input_device pointer_dev;
|
||||||
|
|
||||||
|
@ -93,7 +89,6 @@ struct wlr_x11_backend {
|
||||||
const struct wlr_x11_format *x11_format;
|
const struct wlr_x11_format *x11_format;
|
||||||
struct wlr_drm_format_set primary_dri3_formats;
|
struct wlr_drm_format_set primary_dri3_formats;
|
||||||
struct wlr_drm_format_set primary_shm_formats;
|
struct wlr_drm_format_set primary_shm_formats;
|
||||||
struct wlr_drm_format *drm_format;
|
|
||||||
struct wl_event_source *event_source;
|
struct wl_event_source *event_source;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
Loading…
Reference in a new issue