clients/simple-dmabuf-*: Use gbm_bo_create_with_modifiers2
It is used in Mesa. Lets switch to it as well in order to provide good examples and encourage proper API usage. Signed-off-by: Robert Mader <robert.mader@collabora.com>
This commit is contained in:
parent
46a6b5b448
commit
572ad2d8a9
@ -35,6 +35,10 @@ dep_toytoolkit = declare_dependency(
|
||||
link_with: lib_toytoolkit,
|
||||
dependencies: deps_toytoolkit,
|
||||
)
|
||||
dep_gbm = dependency('gbm', required: false)
|
||||
if dep_gbm.found() and dep_gbm.version().version_compare('>= 21.3')
|
||||
config_h.set('HAVE_GBM_BO_CREATE_WITH_MODIFIERS2', '1')
|
||||
endif
|
||||
|
||||
simple_clients_enabled = get_option('simple-clients')
|
||||
simple_build_all = simple_clients_enabled.contains('all')
|
||||
|
@ -343,12 +343,22 @@ create_dmabuf_buffer(struct display *display, struct buffer *buffer,
|
||||
|
||||
#ifdef HAVE_GBM_MODIFIERS
|
||||
if (display->modifiers_count > 0) {
|
||||
#ifdef HAVE_GBM_BO_CREATE_WITH_MODIFIERS2
|
||||
buffer->bo = gbm_bo_create_with_modifiers2(display->gbm.device,
|
||||
buffer->width,
|
||||
buffer->height,
|
||||
buffer->format,
|
||||
display->modifiers,
|
||||
display->modifiers_count,
|
||||
GBM_BO_USE_RENDERING);
|
||||
#else
|
||||
buffer->bo = gbm_bo_create_with_modifiers(display->gbm.device,
|
||||
buffer->width,
|
||||
buffer->height,
|
||||
buffer->format,
|
||||
display->modifiers,
|
||||
display->modifiers_count);
|
||||
#endif
|
||||
if (buffer->bo)
|
||||
buffer->modifier = gbm_bo_get_modifier(buffer->bo);
|
||||
}
|
||||
|
@ -180,6 +180,7 @@ struct window {
|
||||
struct dmabuf_feedback dmabuf_feedback, pending_dmabuf_feedback;
|
||||
int card_fd;
|
||||
struct drm_format format;
|
||||
uint32_t bo_flags;
|
||||
struct buffer buffers[NUM_BUFFERS];
|
||||
};
|
||||
|
||||
@ -461,7 +462,7 @@ buffer_free(struct buffer *buf)
|
||||
static void
|
||||
create_dmabuf_buffer(struct window *window, struct buffer *buf, uint32_t width,
|
||||
uint32_t height, uint32_t format, unsigned int count_modifiers,
|
||||
uint64_t *modifiers);
|
||||
uint64_t *modifiers, uint32_t bo_flags);
|
||||
|
||||
static void
|
||||
buffer_recreate(struct buffer *buf)
|
||||
@ -474,7 +475,7 @@ buffer_recreate(struct buffer *buf)
|
||||
create_dmabuf_buffer(window, buf, width, height,
|
||||
window->format.format,
|
||||
window->format.modifiers.size / sizeof(uint64_t),
|
||||
window->format.modifiers.data);
|
||||
window->format.modifiers.data, window->bo_flags);
|
||||
buf->recreate = false;
|
||||
}
|
||||
|
||||
@ -524,7 +525,7 @@ static const struct zwp_linux_buffer_params_v1_listener params_listener = {
|
||||
static void
|
||||
create_dmabuf_buffer(struct window *window, struct buffer *buf, uint32_t width,
|
||||
uint32_t height, uint32_t format, unsigned int count_modifiers,
|
||||
uint64_t *modifiers)
|
||||
uint64_t *modifiers, uint32_t bo_flags)
|
||||
{
|
||||
struct display *display = window->display;
|
||||
static uint32_t flags = 0;
|
||||
@ -539,10 +540,18 @@ create_dmabuf_buffer(struct window *window, struct buffer *buf, uint32_t width,
|
||||
|
||||
#ifdef HAVE_GBM_MODIFIERS
|
||||
if (count_modifiers > 0) {
|
||||
#ifdef HAVE_GBM_BO_CREATE_WITH_MODIFIERS2
|
||||
buf->bo = gbm_bo_create_with_modifiers2(display->gbm_device,
|
||||
buf->width, buf->height,
|
||||
format, modifiers,
|
||||
count_modifiers,
|
||||
bo_flags);
|
||||
#else
|
||||
buf->bo = gbm_bo_create_with_modifiers(display->gbm_device,
|
||||
buf->width, buf->height,
|
||||
format, modifiers,
|
||||
count_modifiers);
|
||||
#endif
|
||||
if (buf->bo)
|
||||
buf->modifier = gbm_bo_get_modifier(buf->bo);
|
||||
}
|
||||
@ -551,7 +560,7 @@ create_dmabuf_buffer(struct window *window, struct buffer *buf, uint32_t width,
|
||||
if (!buf->bo) {
|
||||
buf->bo = gbm_bo_create(display->gbm_device, buf->width,
|
||||
buf->height, buf->format,
|
||||
GBM_BO_USE_RENDERING);
|
||||
bo_flags);
|
||||
buf->modifier = DRM_FORMAT_MOD_INVALID;
|
||||
}
|
||||
|
||||
@ -938,7 +947,7 @@ create_window(struct display *display)
|
||||
create_dmabuf_buffer(window, &window->buffers[i], width, height,
|
||||
window->format.format,
|
||||
window->format.modifiers.size / sizeof(uint64_t),
|
||||
window->format.modifiers.data);
|
||||
window->format.modifiers.data, window->bo_flags);
|
||||
|
||||
|
||||
window->xdg_surface = xdg_wm_base_get_xdg_surface(display->wm_base,
|
||||
@ -1237,6 +1246,8 @@ pick_initial_format_from_renderer_tranche(struct window *window,
|
||||
window->format.format = fmt->format;
|
||||
wl_array_copy(&window->format.modifiers, &fmt->modifiers);
|
||||
|
||||
window->bo_flags = GBM_BO_USE_RENDERING;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -1267,6 +1278,8 @@ pick_format_from_scanout_tranche(struct window *window,
|
||||
window->format.format = fmt->format;
|
||||
wl_array_copy(&window->format.modifiers, &fmt->modifiers);
|
||||
|
||||
window->bo_flags = GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user