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

@ -27,7 +27,6 @@
#include "backend/drm/util.h"
#include "render/pixel_format.h"
#include "render/drm_format_set.h"
#include "render/swapchain.h"
#include "render/wlr_renderer.h"
#include "util/env.h"
#include "config.h"

View file

@ -15,7 +15,6 @@
#include "render/drm_format_set.h"
#include "render/allocator/allocator.h"
#include "render/pixel_format.h"
#include "render/swapchain.h"
#include "render/wlr_renderer.h"
bool init_drm_renderer(struct wlr_drm_backend *drm,
@ -53,24 +52,22 @@ static void finish_drm_surface(struct wlr_drm_surface *surf) {
return;
}
wlr_swapchain_destroy(surf->swapchain);
wlr_swapchain_finish(&surf->swapchain);
memset(surf, 0, sizeof(*surf));
}
bool init_drm_surface(struct wlr_drm_surface *surf,
struct wlr_drm_renderer *renderer, int width, int height,
const struct wlr_drm_format *drm_format) {
if (surf->swapchain != NULL && surf->swapchain->width == width &&
surf->swapchain->height == height) {
if (surf->swapchain.width == width &&
surf->swapchain.height == height) {
return true;
}
finish_drm_surface(surf);
surf->swapchain = wlr_swapchain_create(renderer->allocator, width, height,
drm_format);
if (surf->swapchain == NULL) {
if (!wlr_swapchain_init(&surf->swapchain, renderer->allocator,
width, height, drm_format)) {
wlr_log(WLR_ERROR, "Failed to create swapchain");
return false;
}
@ -84,8 +81,8 @@ struct wlr_buffer *drm_surface_blit(struct wlr_drm_surface *surf,
struct wlr_buffer *buffer) {
struct wlr_renderer *renderer = surf->renderer->wlr_rend;
if (surf->swapchain->width != buffer->width ||
surf->swapchain->height != buffer->height) {
if (surf->swapchain.width != buffer->width ||
surf->swapchain.height != buffer->height) {
wlr_log(WLR_ERROR, "Surface size doesn't match buffer size");
return NULL;
}
@ -96,7 +93,7 @@ struct wlr_buffer *drm_surface_blit(struct wlr_drm_surface *surf,
return NULL;
}
struct wlr_buffer *dst = wlr_swapchain_acquire(surf->swapchain, NULL);
struct wlr_buffer *dst = wlr_swapchain_acquire(&surf->swapchain, NULL);
if (!dst) {
wlr_log(WLR_ERROR, "Failed to acquire multi-GPU swapchain buffer");
wlr_texture_destroy(tex);
@ -105,7 +102,7 @@ struct wlr_buffer *drm_surface_blit(struct wlr_drm_surface *surf,
float mat[9];
wlr_matrix_identity(mat);
wlr_matrix_scale(mat, surf->swapchain->width, surf->swapchain->height);
wlr_matrix_scale(mat, surf->swapchain.width, surf->swapchain.height);
if (!wlr_renderer_begin_with_buffer(renderer, dst)) {
wlr_log(WLR_ERROR, "Failed to bind multi-GPU destination buffer");

View file

@ -18,7 +18,6 @@
#include "backend/wayland.h"
#include "render/pixel_format.h"
#include "render/swapchain.h"
#include "render/wlr_renderer.h"
#include "linux-dmabuf-unstable-v1-client-protocol.h"