mirror of
https://github.com/brl/mutter.git
synced 2024-12-26 04:42:14 +00:00
cogl/renderer: Add 'is_dma_buf_supported()' vfunc
Returns TRUE if the active renderer backend can allocate DMA buffers. This is the case hardware accelerated GBM backends, but FALSE for surfaceless (i.e. no render node) and EGLDevice (legacy NVIDIA paths). While software based gbm devices can allocate DMA buffers, we don't want to allocate them for offscreen rendering, as we really only use these for inter process transfers, and as buffers allocated for scanout doesn't use the relevant API, making it return FALSE for these solves that. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1939>
This commit is contained in:
parent
d838460fe9
commit
49ac60e346
@ -773,6 +773,17 @@ cogl_renderer_create_dma_buf (CoglRenderer *renderer,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cogl_renderer_is_dma_buf_supported (CoglRenderer *renderer)
|
||||
{
|
||||
const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer);
|
||||
|
||||
if (winsys->renderer_is_dma_buf_supported)
|
||||
return winsys->renderer_is_dma_buf_supported (renderer);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_renderer_bind_api (CoglRenderer *renderer)
|
||||
{
|
||||
|
@ -419,6 +419,16 @@ cogl_renderer_create_dma_buf (CoglRenderer *renderer,
|
||||
int height,
|
||||
GError **error);
|
||||
|
||||
|
||||
/**
|
||||
* cogl_renderer_is_dma_buf_supported: (skip)
|
||||
* @renderer: A #CoglRenderer
|
||||
*
|
||||
* Returns: %TRUE if DMA buffers can be allocated
|
||||
*/
|
||||
COGL_EXPORT gboolean
|
||||
cogl_renderer_is_dma_buf_supported (CoglRenderer *renderer);
|
||||
|
||||
/**
|
||||
* cogl_renderer_bind_api: (skip)
|
||||
*/
|
||||
|
@ -73,11 +73,12 @@ typedef struct _CoglWinsysVtable
|
||||
|
||||
GCallback
|
||||
(*renderer_get_proc_address) (CoglRenderer *renderer,
|
||||
const char *name,
|
||||
gboolean in_core);
|
||||
const char *name,
|
||||
gboolean in_core);
|
||||
|
||||
gboolean
|
||||
(*renderer_connect) (CoglRenderer *renderer, GError **error);
|
||||
(*renderer_connect) (CoglRenderer *renderer,
|
||||
GError **error);
|
||||
|
||||
void
|
||||
(*renderer_disconnect) (CoglRenderer *renderer);
|
||||
@ -86,7 +87,8 @@ typedef struct _CoglWinsysVtable
|
||||
(*renderer_outputs_changed) (CoglRenderer *renderer);
|
||||
|
||||
gboolean
|
||||
(*display_setup) (CoglDisplay *display, GError **error);
|
||||
(*display_setup) (CoglDisplay *display,
|
||||
GError **error);
|
||||
|
||||
void
|
||||
(*display_destroy) (CoglDisplay *display);
|
||||
@ -97,11 +99,15 @@ typedef struct _CoglWinsysVtable
|
||||
int height,
|
||||
GError **error);
|
||||
|
||||
gboolean
|
||||
(*renderer_is_dma_buf_supported) (CoglRenderer *renderer);
|
||||
|
||||
void
|
||||
(*renderer_bind_api) (CoglRenderer *renderer);
|
||||
|
||||
gboolean
|
||||
(*context_init) (CoglContext *context, GError **error);
|
||||
(*context_init) (CoglContext *context,
|
||||
GError **error);
|
||||
|
||||
void
|
||||
(*context_deinit) (CoglContext *context);
|
||||
@ -115,15 +121,15 @@ typedef struct _CoglWinsysVtable
|
||||
(*texture_pixmap_x11_free) (CoglTexturePixmapX11 *tex_pixmap);
|
||||
|
||||
gboolean
|
||||
(*texture_pixmap_x11_update) (CoglTexturePixmapX11 *tex_pixmap,
|
||||
(*texture_pixmap_x11_update) (CoglTexturePixmapX11 *tex_pixmap,
|
||||
CoglTexturePixmapStereoMode stereo_mode,
|
||||
gboolean needs_mipmap);
|
||||
gboolean needs_mipmap);
|
||||
|
||||
void
|
||||
(*texture_pixmap_x11_damage_notify) (CoglTexturePixmapX11 *tex_pixmap);
|
||||
|
||||
CoglTexture *
|
||||
(*texture_pixmap_x11_get_texture) (CoglTexturePixmapX11 *tex_pixmap,
|
||||
(*texture_pixmap_x11_get_texture) (CoglTexturePixmapX11 *tex_pixmap,
|
||||
CoglTexturePixmapStereoMode stereo_mode);
|
||||
#endif
|
||||
|
||||
@ -131,10 +137,12 @@ typedef struct _CoglWinsysVtable
|
||||
(*fence_add) (CoglContext *ctx);
|
||||
|
||||
gboolean
|
||||
(*fence_is_complete) (CoglContext *ctx, void *fence);
|
||||
(*fence_is_complete) (CoglContext *ctx,
|
||||
void *fence);
|
||||
|
||||
void
|
||||
(*fence_destroy) (CoglContext *ctx, void *fence);
|
||||
(*fence_destroy) (CoglContext *ctx,
|
||||
void *fence);
|
||||
|
||||
} CoglWinsysVtable;
|
||||
|
||||
|
@ -970,6 +970,27 @@ meta_renderer_native_create_dma_buf (CoglRenderer *cogl_renderer,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_renderer_native_is_dma_buf_supported (CoglRenderer *cogl_renderer)
|
||||
{
|
||||
CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
|
||||
MetaRendererNativeGpuData *renderer_gpu_data = cogl_renderer_egl->platform;
|
||||
MetaRenderDevice *render_device = renderer_gpu_data->render_device;
|
||||
|
||||
switch (renderer_gpu_data->mode)
|
||||
{
|
||||
case META_RENDERER_NATIVE_MODE_GBM:
|
||||
return meta_render_device_is_hardware_accelerated (render_device);
|
||||
case META_RENDERER_NATIVE_MODE_SURFACELESS:
|
||||
#ifdef HAVE_EGL_DEVICE
|
||||
case META_RENDERER_NATIVE_MODE_EGL_DEVICE:
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_renderer_native_init_egl_context (CoglContext *cogl_context,
|
||||
GError **error)
|
||||
@ -1114,6 +1135,8 @@ get_native_cogl_winsys_vtable (CoglRenderer *cogl_renderer)
|
||||
vtable.renderer_connect = meta_renderer_native_connect;
|
||||
vtable.renderer_disconnect = meta_renderer_native_disconnect;
|
||||
vtable.renderer_create_dma_buf = meta_renderer_native_create_dma_buf;
|
||||
vtable.renderer_is_dma_buf_supported =
|
||||
meta_renderer_native_is_dma_buf_supported;
|
||||
|
||||
vtable_inited = TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user