mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 18:09:49 +01:00
backend/drm: implement get_cursor_formats and get_cursor_size
This commit is contained in:
parent
de51df2770
commit
9e9be83a58
3 changed files with 70 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <drm_fourcc.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -238,6 +239,35 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
|
|||
goto error_event;
|
||||
}
|
||||
|
||||
if (drm->parent) {
|
||||
// We'll perform a multi-GPU copy for all submitted buffers, we need
|
||||
// to be able to texture from them
|
||||
struct wlr_renderer *renderer = drm->renderer.wlr_rend;
|
||||
const struct wlr_drm_format_set *texture_formats =
|
||||
wlr_renderer_get_dmabuf_texture_formats(renderer);
|
||||
if (texture_formats == NULL) {
|
||||
wlr_log(WLR_ERROR, "Failed to query renderer texture formats");
|
||||
goto error_event;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < texture_formats->len; i++) {
|
||||
const struct wlr_drm_format *fmt = texture_formats->formats[i];
|
||||
if (fmt->len == 0) {
|
||||
// Modifiers aren't supported. The implicit modifier changes
|
||||
// from a GPU to the other, so we can only accept linear
|
||||
// buffers
|
||||
wlr_drm_format_set_add(&drm->mgpu_formats, fmt->format,
|
||||
DRM_FORMAT_MOD_LINEAR);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (size_t j = 0; j < fmt->len; j++) {
|
||||
wlr_drm_format_set_add(&drm->mgpu_formats, fmt->format,
|
||||
fmt->modifiers[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drm->session_destroy.notify = handle_session_destroy;
|
||||
wl_signal_add(&session->events.destroy, &drm->session_destroy);
|
||||
|
||||
|
|
|
@ -26,9 +26,17 @@
|
|||
#include "backend/drm/util.h"
|
||||
#include "render/pixel_format.h"
|
||||
#include "render/swapchain.h"
|
||||
#include "types/wlr_buffer.h"
|
||||
#include "util/signal.h"
|
||||
|
||||
bool check_drm_features(struct wlr_drm_backend *drm) {
|
||||
if (drmGetCap(drm->fd, DRM_CAP_CURSOR_WIDTH, &drm->cursor_width)) {
|
||||
drm->cursor_width = 64;
|
||||
}
|
||||
if (drmGetCap(drm->fd, DRM_CAP_CURSOR_HEIGHT, &drm->cursor_height)) {
|
||||
drm->cursor_height = 64;
|
||||
}
|
||||
|
||||
uint64_t cap;
|
||||
if (drmGetCap(drm->fd, DRM_CAP_PRIME, &cap) ||
|
||||
!(cap & DRM_PRIME_CAP_IMPORT)) {
|
||||
|
@ -1004,6 +1012,32 @@ static void drm_connector_destroy_output(struct wlr_output *output) {
|
|||
memset(&conn->output, 0, sizeof(struct wlr_output));
|
||||
}
|
||||
|
||||
static const struct wlr_drm_format_set *drm_connector_get_cursor_formats(
|
||||
struct wlr_output *output, uint32_t buffer_caps) {
|
||||
if (!(buffer_caps & WLR_BUFFER_CAP_DMABUF)) {
|
||||
return NULL;
|
||||
}
|
||||
struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
|
||||
if (!conn->crtc) {
|
||||
return false;
|
||||
}
|
||||
struct wlr_drm_plane *plane = conn->crtc->cursor;
|
||||
if (!plane) {
|
||||
return false;
|
||||
}
|
||||
if (conn->backend->parent) {
|
||||
return &conn->backend->mgpu_formats;
|
||||
}
|
||||
return &plane->formats;
|
||||
}
|
||||
|
||||
static void drm_connector_get_cursor_size(struct wlr_output *output,
|
||||
int *width, int *height) {
|
||||
struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend);
|
||||
*width = (int)drm->cursor_width;
|
||||
*height = (int)drm->cursor_height;
|
||||
}
|
||||
|
||||
static const struct wlr_output_impl output_impl = {
|
||||
.set_cursor = drm_connector_set_cursor,
|
||||
.move_cursor = drm_connector_move_cursor,
|
||||
|
@ -1014,6 +1048,8 @@ static const struct wlr_output_impl output_impl = {
|
|||
.rollback_render = drm_connector_rollback_render,
|
||||
.get_gamma_size = drm_connector_get_gamma_size,
|
||||
.export_dmabuf = drm_connector_export_dmabuf,
|
||||
.get_cursor_formats = drm_connector_get_cursor_formats,
|
||||
.get_cursor_size = drm_connector_get_cursor_size,
|
||||
};
|
||||
|
||||
bool wlr_output_is_drm(struct wlr_output *output) {
|
||||
|
|
|
@ -87,6 +87,10 @@ struct wlr_drm_backend {
|
|||
|
||||
struct wlr_drm_renderer renderer;
|
||||
struct wlr_session *session;
|
||||
|
||||
uint64_t cursor_width, cursor_height;
|
||||
|
||||
struct wlr_drm_format_set mgpu_formats;
|
||||
};
|
||||
|
||||
enum wlr_drm_connector_state {
|
||||
|
|
Loading…
Reference in a new issue