From 187cc07d0561311114fc4b3e1fc9951ff311735b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 7 Feb 2019 00:13:44 -0500 Subject: [PATCH] gallium: create multimedia contexts as compute-only if graphics is unsupported Reviewed-by: Alex Deucher Reviewed-by: Pierre-Eric Pelloux-Prayer --- src/gallium/auxiliary/util/u_inlines.h | 11 +++++++++++ src/gallium/auxiliary/vl/vl_mpeg12_decoder.c | 2 +- src/gallium/auxiliary/vl/vl_winsys_dri3.c | 3 +-- src/gallium/state_trackers/omx/bellagio/vid_dec.c | 2 +- src/gallium/state_trackers/omx/bellagio/vid_enc.c | 4 ++-- src/gallium/state_trackers/omx/tizonia/h264dprc.c | 2 +- src/gallium/state_trackers/omx/tizonia/h264eprc.c | 4 ++-- src/gallium/state_trackers/va/context.c | 3 +-- src/gallium/state_trackers/vdpau/device.c | 2 +- 9 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index ffd0ea9..1254e3f 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -731,6 +731,17 @@ util_texrange_covers_whole_level(const struct pipe_resource *tex, depth == util_num_layers(tex, level); } +static inline struct pipe_context * +pipe_create_multimedia_context(struct pipe_screen *screen) +{ + unsigned flags = 0; + + if (!screen->get_param(screen, PIPE_CAP_GRAPHICS)) + flags |= PIPE_CONTEXT_COMPUTE_ONLY; + + return screen->context_create(screen, NULL, flags); +} + #ifdef __cplusplus } #endif diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c index 6e6f0bd..b7ef70f 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c @@ -1120,7 +1120,7 @@ vl_create_mpeg12_decoder(struct pipe_context *context, dec->base = *templat; dec->base.context = context; - dec->context = context->screen->context_create(context->screen, NULL, 0); + dec->context = pipe_create_multimedia_context(context->screen); dec->base.destroy = vl_mpeg12_destroy; dec->base.begin_frame = vl_mpeg12_begin_frame; diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/src/gallium/auxiliary/vl/vl_winsys_dri3.c index 77d1972..5664965 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c +++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c @@ -832,8 +832,7 @@ vl_dri3_screen_create(Display *display, int screen) if (!scrn->base.pscreen) goto release_pipe; - scrn->pipe = scrn->base.pscreen->context_create(scrn->base.pscreen, - NULL, 0); + scrn->pipe = pipe_create_multimedia_context(scrn->base.pscreen); if (!scrn->pipe) goto no_context; diff --git a/src/gallium/state_trackers/omx/bellagio/vid_dec.c b/src/gallium/state_trackers/omx/bellagio/vid_dec.c index 65e612a..2eedf93 100644 --- a/src/gallium/state_trackers/omx/bellagio/vid_dec.c +++ b/src/gallium/state_trackers/omx/bellagio/vid_dec.c @@ -180,7 +180,7 @@ static OMX_ERRORTYPE vid_dec_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING nam return OMX_ErrorInsufficientResources; screen = priv->screen->pscreen; - priv->pipe = screen->context_create(screen, NULL, 0); + priv->pipe = pipe_create_multimedia_context(screen); if (!priv->pipe) return OMX_ErrorInsufficientResources; diff --git a/src/gallium/state_trackers/omx/bellagio/vid_enc.c b/src/gallium/state_trackers/omx/bellagio/vid_enc.c index 525d2f3..9f25be9 100644 --- a/src/gallium/state_trackers/omx/bellagio/vid_enc.c +++ b/src/gallium/state_trackers/omx/bellagio/vid_enc.c @@ -157,7 +157,7 @@ static OMX_ERRORTYPE vid_enc_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING nam PIPE_VIDEO_ENTRYPOINT_ENCODE, PIPE_VIDEO_CAP_SUPPORTED)) return OMX_ErrorBadParameter; - priv->s_pipe = screen->context_create(screen, NULL, 0); + priv->s_pipe = pipe_create_multimedia_context(screen); if (!priv->s_pipe) return OMX_ErrorInsufficientResources; @@ -176,7 +176,7 @@ static OMX_ERRORTYPE vid_enc_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING nam return OMX_ErrorInsufficientResources; } - priv->t_pipe = screen->context_create(screen, NULL, 0); + priv->t_pipe = pipe_create_multimedia_context(screen); if (!priv->t_pipe) return OMX_ErrorInsufficientResources; diff --git a/src/gallium/state_trackers/omx/tizonia/h264dprc.c b/src/gallium/state_trackers/omx/tizonia/h264dprc.c index 09248e6..b900c75 100644 --- a/src/gallium/state_trackers/omx/tizonia/h264dprc.c +++ b/src/gallium/state_trackers/omx/tizonia/h264dprc.c @@ -407,7 +407,7 @@ static OMX_ERRORTYPE h264d_prc_allocate_resources(void *ap_obj, OMX_U32 a_pid) return OMX_ErrorInsufficientResources; screen = priv->screen->pscreen; - priv->pipe = screen->context_create(screen, priv->screen, 0); + priv->pipe = pipe_create_multimedia_context(screen); if (!priv->pipe) return OMX_ErrorInsufficientResources; diff --git a/src/gallium/state_trackers/omx/tizonia/h264eprc.c b/src/gallium/state_trackers/omx/tizonia/h264eprc.c index effff37..b6bba15 100644 --- a/src/gallium/state_trackers/omx/tizonia/h264eprc.c +++ b/src/gallium/state_trackers/omx/tizonia/h264eprc.c @@ -403,7 +403,7 @@ static OMX_ERRORTYPE h264e_prc_create_encoder(void *ap_obj) PIPE_VIDEO_ENTRYPOINT_ENCODE, PIPE_VIDEO_CAP_SUPPORTED)) return OMX_ErrorBadParameter; - priv->s_pipe = screen->context_create(screen, NULL, 0); + priv->s_pipe = pipe_create_multimedia_context(screen); if (!priv->s_pipe) return OMX_ErrorInsufficientResources; @@ -422,7 +422,7 @@ static OMX_ERRORTYPE h264e_prc_create_encoder(void *ap_obj) return OMX_ErrorInsufficientResources; } - priv->t_pipe = screen->context_create(screen, NULL, 0); + priv->t_pipe = pipe_create_multimedia_context(screen); if (!priv->t_pipe) return OMX_ErrorInsufficientResources; diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 9176b7e..2cb3a6c 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -151,8 +151,7 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) if (!drv->vscreen) goto error_screen; - drv->pipe = drv->vscreen->pscreen->context_create(drv->vscreen->pscreen, - NULL, 0); + drv->pipe = pipe_create_multimedia_context(drv->vscreen->pscreen); if (!drv->pipe) goto error_pipe; diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c index c3f156f..c5a3eeb 100644 --- a/src/gallium/state_trackers/vdpau/device.c +++ b/src/gallium/state_trackers/vdpau/device.c @@ -72,7 +72,7 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, } pscreen = dev->vscreen->pscreen; - dev->context = pscreen->context_create(pscreen, NULL, 0); + dev->context = pipe_create_multimedia_context(pscreen); if (!dev->context) { ret = VDP_STATUS_RESOURCES; goto no_context; -- 2.7.4