mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
render-device: Update DMA-BUF allocation API to allow modifiers
meta_render_device_gbm_allocate_dma_buf() function is updated to take a list of modifiers. If no modifiers are specified, the modifier is selected by the allocator, and implicit modifiers are used to import the created DMA-BUF. Co-authored-by: Jonas Ådahl <jadahl@gmail.com> Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3537>
This commit is contained in:
parent
ab1322781d
commit
34d00d769e
@ -758,6 +758,8 @@ cogl_renderer_foreach_output (CoglRenderer *renderer,
|
||||
CoglDmaBufHandle *
|
||||
cogl_renderer_create_dma_buf (CoglRenderer *renderer,
|
||||
CoglPixelFormat format,
|
||||
uint64_t *modifiers,
|
||||
int n_modifiers,
|
||||
int width,
|
||||
int height,
|
||||
GError **error)
|
||||
@ -765,7 +767,9 @@ cogl_renderer_create_dma_buf (CoglRenderer *renderer,
|
||||
const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer);
|
||||
|
||||
if (winsys->renderer_create_dma_buf)
|
||||
return winsys->renderer_create_dma_buf (renderer, format,
|
||||
return winsys->renderer_create_dma_buf (renderer,
|
||||
format,
|
||||
modifiers, n_modifiers,
|
||||
width, height,
|
||||
error);
|
||||
|
||||
|
@ -347,6 +347,8 @@ cogl_renderer_foreach_output (CoglRenderer *renderer,
|
||||
* cogl_renderer_create_dma_buf: (skip)
|
||||
* @renderer: A #CoglRenderer
|
||||
* @format: A #CoglPixelFormat
|
||||
* @modifiers: array of DRM format modifiers
|
||||
* @n_modifiers: length of modifiers array
|
||||
* @width: width of the new
|
||||
* @height: height of the new
|
||||
* @error: (nullable): return location for a #GError
|
||||
@ -355,6 +357,9 @@ cogl_renderer_foreach_output (CoglRenderer *renderer,
|
||||
* format @format, and exports the new framebuffer's DMA buffer
|
||||
* handle.
|
||||
*
|
||||
* Passing an empty modifier array (passing a 0 n_modifiers) means implicit
|
||||
* modifiers will be used.
|
||||
*
|
||||
* Returns: (nullable)(transfer full): a #CoglDmaBufHandle. The
|
||||
* return result must be released with cogl_dma_buf_handle_free()
|
||||
* after use.
|
||||
@ -362,6 +367,8 @@ cogl_renderer_foreach_output (CoglRenderer *renderer,
|
||||
COGL_EXPORT CoglDmaBufHandle *
|
||||
cogl_renderer_create_dma_buf (CoglRenderer *renderer,
|
||||
CoglPixelFormat format,
|
||||
uint64_t *modifiers,
|
||||
int n_modifiers,
|
||||
int width,
|
||||
int height,
|
||||
GError **error);
|
||||
|
@ -91,6 +91,8 @@ typedef struct _CoglWinsysVtable
|
||||
CoglDmaBufHandle *
|
||||
(*renderer_create_dma_buf) (CoglRenderer *renderer,
|
||||
CoglPixelFormat format,
|
||||
uint64_t *modifiers,
|
||||
int n_modifiers,
|
||||
int width,
|
||||
int height,
|
||||
GError **error);
|
||||
|
@ -129,6 +129,7 @@ meta_screen_cast_create_dma_buf_handle (MetaScreenCast *screen_cast,
|
||||
|
||||
dmabuf_handle = cogl_renderer_create_dma_buf (cogl_renderer,
|
||||
format,
|
||||
NULL, 0,
|
||||
width, height,
|
||||
&error);
|
||||
if (!dmabuf_handle)
|
||||
|
@ -186,6 +186,7 @@ maybe_disable_screen_cast_dma_bufs (MetaBackendNative *native)
|
||||
|
||||
dmabuf_handle = cogl_renderer_create_dma_buf (cogl_renderer,
|
||||
COGL_PIXEL_FORMAT_BGRX_8888,
|
||||
NULL, 0,
|
||||
1, 1,
|
||||
&error);
|
||||
if (!dmabuf_handle)
|
||||
|
@ -941,6 +941,7 @@ copy_shared_framebuffer_primary_gpu (CoglOnscreen *onscre
|
||||
int dmabuf_fd;
|
||||
g_autoptr (GError) error = NULL;
|
||||
const MetaFormatInfo *format_info;
|
||||
uint64_t modifier;
|
||||
|
||||
COGL_TRACE_BEGIN_SCOPED (CopySharedFramebufferPrimaryGpu,
|
||||
"copy_shared_framebuffer_primary_gpu()");
|
||||
@ -977,13 +978,14 @@ copy_shared_framebuffer_primary_gpu (CoglOnscreen *onscre
|
||||
return NULL;
|
||||
}
|
||||
|
||||
modifier = DRM_FORMAT_MOD_LINEAR;
|
||||
dmabuf_fb =
|
||||
meta_renderer_native_create_dma_buf_framebuffer (renderer_native,
|
||||
dmabuf_fd,
|
||||
width,
|
||||
height,
|
||||
stride,
|
||||
0, DRM_FORMAT_MOD_LINEAR,
|
||||
0, &modifier,
|
||||
drm_format,
|
||||
&error);
|
||||
|
||||
|
@ -150,6 +150,8 @@ meta_render_device_gbm_allocate_dma_buf (MetaRenderDevice *render_device,
|
||||
int width,
|
||||
int height,
|
||||
uint32_t format,
|
||||
uint64_t *modifiers,
|
||||
int n_modifiers,
|
||||
MetaDrmBufferFlags flags,
|
||||
GError **error)
|
||||
{
|
||||
@ -159,9 +161,21 @@ meta_render_device_gbm_allocate_dma_buf (MetaRenderDevice *render_device,
|
||||
struct gbm_bo *gbm_bo;
|
||||
MetaDrmBufferGbm *buffer_gbm;
|
||||
|
||||
gbm_bo = gbm_bo_create (render_device_gbm->gbm_device,
|
||||
width, height, format,
|
||||
GBM_BO_USE_RENDERING | GBM_BO_USE_LINEAR);
|
||||
if (n_modifiers == 0)
|
||||
{
|
||||
gbm_bo = gbm_bo_create (render_device_gbm->gbm_device,
|
||||
width, height, format,
|
||||
GBM_BO_USE_RENDERING);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warn_if_fail (!(flags & META_DRM_BUFFER_FLAG_DISABLE_MODIFIERS));
|
||||
gbm_bo = gbm_bo_create_with_modifiers2 (render_device_gbm->gbm_device,
|
||||
width, height, format,
|
||||
modifiers, n_modifiers,
|
||||
GBM_BO_USE_RENDERING);
|
||||
}
|
||||
|
||||
if (!gbm_bo)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
|
@ -37,6 +37,8 @@ struct _MetaRenderDeviceClass
|
||||
int width,
|
||||
int height,
|
||||
uint32_t format,
|
||||
uint64_t *modifiers,
|
||||
int n_modifiers,
|
||||
MetaDrmBufferFlags flags,
|
||||
GError **error);
|
||||
MetaDrmBuffer * (* import_dma_buf) (MetaRenderDevice *render_device,
|
||||
|
@ -345,6 +345,8 @@ meta_render_device_allocate_dma_buf (MetaRenderDevice *render_device,
|
||||
int width,
|
||||
int height,
|
||||
uint32_t format,
|
||||
uint64_t *modifiers,
|
||||
int n_modifiers,
|
||||
MetaDrmBufferFlags flags,
|
||||
GError **error)
|
||||
{
|
||||
@ -353,7 +355,9 @@ meta_render_device_allocate_dma_buf (MetaRenderDevice *render_device,
|
||||
if (klass->allocate_dma_buf)
|
||||
{
|
||||
return klass->allocate_dma_buf (render_device,
|
||||
width, height, format,
|
||||
width, height,
|
||||
format,
|
||||
modifiers, n_modifiers,
|
||||
flags,
|
||||
error);
|
||||
}
|
||||
|
@ -42,6 +42,8 @@ MetaDrmBuffer * meta_render_device_allocate_dma_buf (MetaRenderDevice *render
|
||||
int width,
|
||||
int height,
|
||||
uint32_t format,
|
||||
uint64_t *modifiers,
|
||||
int n_modifiers,
|
||||
MetaDrmBufferFlags flags,
|
||||
GError **error);
|
||||
|
||||
|
@ -97,7 +97,7 @@ CoglFramebuffer * meta_renderer_native_create_dma_buf_framebuffer (MetaRendererN
|
||||
uint32_t height,
|
||||
uint32_t stride,
|
||||
uint32_t offset,
|
||||
uint64_t modifier,
|
||||
uint64_t *modifier,
|
||||
uint32_t drm_format,
|
||||
GError **error);
|
||||
|
||||
|
@ -633,7 +633,7 @@ meta_renderer_native_create_dma_buf_framebuffer (MetaRendererNative *renderer_n
|
||||
uint32_t height,
|
||||
uint32_t stride,
|
||||
uint32_t offset,
|
||||
uint64_t modifier,
|
||||
uint64_t *modifier,
|
||||
uint32_t drm_format,
|
||||
GError **error)
|
||||
{
|
||||
@ -647,7 +647,6 @@ meta_renderer_native_create_dma_buf_framebuffer (MetaRendererNative *renderer_n
|
||||
EGLImageKHR egl_image;
|
||||
uint32_t strides[1];
|
||||
uint32_t offsets[1];
|
||||
uint64_t modifiers[1];
|
||||
CoglPixelFormat cogl_format;
|
||||
CoglEglImageFlags flags;
|
||||
CoglTexture *cogl_tex;
|
||||
@ -660,7 +659,6 @@ meta_renderer_native_create_dma_buf_framebuffer (MetaRendererNative *renderer_n
|
||||
|
||||
strides[0] = stride;
|
||||
offsets[0] = offset;
|
||||
modifiers[0] = modifier;
|
||||
egl_image = meta_egl_create_dmabuf_image (egl,
|
||||
egl_display,
|
||||
width,
|
||||
@ -670,7 +668,7 @@ meta_renderer_native_create_dma_buf_framebuffer (MetaRendererNative *renderer_n
|
||||
&dmabuf_fd,
|
||||
strides,
|
||||
offsets,
|
||||
modifiers,
|
||||
modifier,
|
||||
error);
|
||||
if (egl_image == EGL_NO_IMAGE_KHR)
|
||||
return NULL;
|
||||
@ -945,6 +943,8 @@ meta_renderer_native_queue_mode_set_update (MetaRendererNative *renderer_native,
|
||||
static CoglDmaBufHandle *
|
||||
meta_renderer_native_create_dma_buf (CoglRenderer *cogl_renderer,
|
||||
CoglPixelFormat format,
|
||||
uint64_t *modifiers,
|
||||
int n_modifiers,
|
||||
int width,
|
||||
int height,
|
||||
GError **error)
|
||||
@ -964,7 +964,6 @@ meta_renderer_native_create_dma_buf (CoglRenderer *cogl_renderer,
|
||||
uint32_t stride;
|
||||
uint32_t offset;
|
||||
uint32_t bpp;
|
||||
uint64_t modifier;
|
||||
uint32_t drm_format;
|
||||
CoglFramebuffer *dmabuf_fb;
|
||||
CoglDmaBufHandle *dmabuf_handle;
|
||||
@ -985,6 +984,7 @@ meta_renderer_native_create_dma_buf (CoglRenderer *cogl_renderer,
|
||||
buffer = meta_render_device_allocate_dma_buf (render_device,
|
||||
width, height,
|
||||
drm_format,
|
||||
modifiers, n_modifiers,
|
||||
flags,
|
||||
error);
|
||||
if (!buffer)
|
||||
@ -997,17 +997,32 @@ meta_renderer_native_create_dma_buf (CoglRenderer *cogl_renderer,
|
||||
stride = meta_drm_buffer_get_stride (buffer);
|
||||
offset = meta_drm_buffer_get_offset (buffer, 0);
|
||||
bpp = meta_drm_buffer_get_bpp (buffer);
|
||||
modifier = meta_drm_buffer_get_modifier (buffer);
|
||||
if (n_modifiers)
|
||||
{
|
||||
uint64_t modifier = meta_drm_buffer_get_modifier (buffer);
|
||||
|
||||
dmabuf_fb =
|
||||
meta_renderer_native_create_dma_buf_framebuffer (renderer_native,
|
||||
dmabuf_fd,
|
||||
width, height,
|
||||
stride,
|
||||
offset,
|
||||
modifier,
|
||||
drm_format,
|
||||
error);
|
||||
dmabuf_fb =
|
||||
meta_renderer_native_create_dma_buf_framebuffer (renderer_native,
|
||||
dmabuf_fd,
|
||||
width, height,
|
||||
stride,
|
||||
offset,
|
||||
&modifier,
|
||||
drm_format,
|
||||
error);
|
||||
}
|
||||
else
|
||||
{
|
||||
dmabuf_fb =
|
||||
meta_renderer_native_create_dma_buf_framebuffer (renderer_native,
|
||||
dmabuf_fd,
|
||||
width, height,
|
||||
stride,
|
||||
offset,
|
||||
NULL,
|
||||
drm_format,
|
||||
error);
|
||||
}
|
||||
|
||||
if (!dmabuf_fb)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user