|
|
@ -10,6 +10,7 @@
|
|
|
|
#include <xf86drm.h>
|
|
|
|
#include <xf86drm.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "render/allocator/gbm.h"
|
|
|
|
#include "render/allocator/gbm.h"
|
|
|
|
|
|
|
|
#include "render/drm_format_set.h"
|
|
|
|
|
|
|
|
|
|
|
|
static const struct wlr_buffer_impl buffer_impl;
|
|
|
|
static const struct wlr_buffer_impl buffer_impl;
|
|
|
|
|
|
|
|
|
|
|
@ -89,17 +90,22 @@ static struct wlr_gbm_buffer *create_buffer(struct wlr_gbm_allocator *alloc,
|
|
|
|
int width, int height, const struct wlr_drm_format *format) {
|
|
|
|
int width, int height, const struct wlr_drm_format *format) {
|
|
|
|
struct gbm_device *gbm_device = alloc->gbm_device;
|
|
|
|
struct gbm_device *gbm_device = alloc->gbm_device;
|
|
|
|
|
|
|
|
|
|
|
|
struct gbm_bo *bo = NULL;
|
|
|
|
assert(format->len > 0);
|
|
|
|
|
|
|
|
|
|
|
|
bool has_modifier = true;
|
|
|
|
bool has_modifier = true;
|
|
|
|
if (format->len > 0) {
|
|
|
|
uint64_t fallback_modifier = DRM_FORMAT_MOD_INVALID;
|
|
|
|
bo = gbm_bo_create_with_modifiers(gbm_device, width, height,
|
|
|
|
struct gbm_bo *bo = gbm_bo_create_with_modifiers(gbm_device, width, height,
|
|
|
|
format->format, format->modifiers, format->len);
|
|
|
|
format->format, format->modifiers, format->len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bo == NULL) {
|
|
|
|
if (bo == NULL) {
|
|
|
|
uint32_t usage = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING;
|
|
|
|
uint32_t usage = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING;
|
|
|
|
if (format->len == 1 &&
|
|
|
|
if (format->len == 1 &&
|
|
|
|
format->modifiers[0] == DRM_FORMAT_MOD_LINEAR) {
|
|
|
|
format->modifiers[0] == DRM_FORMAT_MOD_LINEAR) {
|
|
|
|
usage |= GBM_BO_USE_LINEAR;
|
|
|
|
usage |= GBM_BO_USE_LINEAR;
|
|
|
|
|
|
|
|
fallback_modifier = DRM_FORMAT_MOD_LINEAR;
|
|
|
|
|
|
|
|
} else if (!wlr_drm_format_has(format, DRM_FORMAT_MOD_INVALID)) {
|
|
|
|
|
|
|
|
// If the format doesn't accept an implicit modifier, bail out.
|
|
|
|
|
|
|
|
wlr_log(WLR_ERROR, "gbm_bo_create_with_modifiers failed");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bo = gbm_bo_create(gbm_device, width, height, format->format, usage);
|
|
|
|
bo = gbm_bo_create(gbm_device, width, height, format->format, usage);
|
|
|
|
has_modifier = false;
|
|
|
|
has_modifier = false;
|
|
|
@ -128,7 +134,7 @@ static struct wlr_gbm_buffer *create_buffer(struct wlr_gbm_allocator *alloc,
|
|
|
|
// don't populate the modifier field: other parts of the stack may not
|
|
|
|
// don't populate the modifier field: other parts of the stack may not
|
|
|
|
// understand modifiers, and they can't strip the modifier.
|
|
|
|
// understand modifiers, and they can't strip the modifier.
|
|
|
|
if (!has_modifier) {
|
|
|
|
if (!has_modifier) {
|
|
|
|
buffer->dmabuf.modifier = DRM_FORMAT_MOD_INVALID;
|
|
|
|
buffer->dmabuf.modifier = fallback_modifier;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wlr_log(WLR_DEBUG, "Allocated %dx%d GBM buffer (format 0x%"PRIX32", "
|
|
|
|
wlr_log(WLR_DEBUG, "Allocated %dx%d GBM buffer (format 0x%"PRIX32", "
|
|
|
|