mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
renderer-native: Implement DMA buffer creation
Create a new gbm_bo using the same given geometry, and export the new bo's DMA buffer fd. The new bo lives as long as necessary to be used, and reused, by PipeWire. Unfortunately, PipeWire doesn't support modifiers properly, so use the linear format for now. For now, a hardcoded format of DRM_FORMAT_XRGB8888 is set, so we don't need to negotiate the format with PipeWire early. https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
This commit is contained in:
parent
7fbb47b2bb
commit
d366fb335d
@ -2132,6 +2132,73 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
|||||||
COGL_TRACE_END (MetaRendererNativePostKmsUpdate);
|
COGL_TRACE_END (MetaRendererNativePostKmsUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CoglDmaBufHandle *
|
||||||
|
meta_renderer_native_create_dma_buf (CoglRenderer *cogl_renderer,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
|
||||||
|
MetaRendererNativeGpuData *renderer_gpu_data = cogl_renderer_egl->platform;
|
||||||
|
MetaRendererNative *renderer_native = renderer_gpu_data->renderer_native;
|
||||||
|
|
||||||
|
switch (renderer_gpu_data->mode)
|
||||||
|
{
|
||||||
|
case META_RENDERER_NATIVE_MODE_GBM:
|
||||||
|
{
|
||||||
|
CoglFramebuffer *dmabuf_fb;
|
||||||
|
struct gbm_bo *new_bo;
|
||||||
|
int dmabuf_fd = -1;
|
||||||
|
|
||||||
|
new_bo = gbm_bo_create (renderer_gpu_data->gbm.device,
|
||||||
|
width, height, DRM_FORMAT_XRGB8888,
|
||||||
|
GBM_BO_USE_RENDERING | GBM_BO_USE_LINEAR);
|
||||||
|
|
||||||
|
if (!new_bo)
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"Failed to allocate buffer");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dmabuf_fd = gbm_bo_get_fd (new_bo);
|
||||||
|
|
||||||
|
if (dmabuf_fd == -1)
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS,
|
||||||
|
"Failed to export buffer's DMA fd: %s",
|
||||||
|
g_strerror (errno));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dmabuf_fb = create_dma_buf_framebuffer (renderer_native,
|
||||||
|
dmabuf_fd,
|
||||||
|
width, height,
|
||||||
|
gbm_bo_get_stride (new_bo),
|
||||||
|
gbm_bo_get_offset (new_bo, 0),
|
||||||
|
DRM_FORMAT_MOD_LINEAR,
|
||||||
|
DRM_FORMAT_XRGB8888,
|
||||||
|
error);
|
||||||
|
|
||||||
|
if (!dmabuf_fb)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return cogl_dma_buf_handle_new (dmabuf_fb, dmabuf_fd, new_bo,
|
||||||
|
(GDestroyNotify) gbm_bo_destroy);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#ifdef HAVE_EGL_DEVICE
|
||||||
|
case META_RENDERER_NATIVE_MODE_EGL_DEVICE:
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_UNKNOWN,
|
||||||
|
"Current mode does not support exporting DMA buffers");
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_renderer_native_init_egl_context (CoglContext *cogl_context,
|
meta_renderer_native_init_egl_context (CoglContext *cogl_context,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -2874,6 +2941,7 @@ get_native_cogl_winsys_vtable (CoglRenderer *cogl_renderer)
|
|||||||
|
|
||||||
vtable.renderer_connect = meta_renderer_native_connect;
|
vtable.renderer_connect = meta_renderer_native_connect;
|
||||||
vtable.renderer_disconnect = meta_renderer_native_disconnect;
|
vtable.renderer_disconnect = meta_renderer_native_disconnect;
|
||||||
|
vtable.renderer_create_dma_buf = meta_renderer_native_create_dma_buf;
|
||||||
|
|
||||||
vtable.onscreen_init = meta_renderer_native_init_onscreen;
|
vtable.onscreen_init = meta_renderer_native_init_onscreen;
|
||||||
vtable.onscreen_deinit = meta_renderer_native_release_onscreen;
|
vtable.onscreen_deinit = meta_renderer_native_release_onscreen;
|
||||||
|
Loading…
Reference in New Issue
Block a user