gallium: create multimedia contexts as compute-only if graphics is unsupported
authorMarek Olšák <marek.olsak@amd.com>
Thu, 7 Feb 2019 05:13:44 +0000 (00:13 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 29 Jul 2019 21:52:41 +0000 (17:52 -0400)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
src/gallium/auxiliary/util/u_inlines.h
src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
src/gallium/auxiliary/vl/vl_winsys_dri3.c
src/gallium/state_trackers/omx/bellagio/vid_dec.c
src/gallium/state_trackers/omx/bellagio/vid_enc.c
src/gallium/state_trackers/omx/tizonia/h264dprc.c
src/gallium/state_trackers/omx/tizonia/h264eprc.c
src/gallium/state_trackers/va/context.c
src/gallium/state_trackers/vdpau/device.c

index ffd0ea9c7a23f21d467302d506c19a141d9c97c5..1254e3f9e98cb4b702a50fadb977fc787d688690 100644 (file)
@@ -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
index 6e6f0bd4563b760f055f70c5498ea80f64bda1dc..b7ef70f6ced62bb953917cae701ee046833f47bc 100644 (file)
@@ -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;
index 77d1972af2c7916ea0ab9ddb89f06ad5adfc9140..56649654011121cbc5ae96d044a1b3ca9382b0dc 100644 (file)
@@ -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;
 
index 65e612a57fe8fc27917dc4579052bdd18064991d..2eedf937cd97c2c1c508cb2c1715dfc56869a01c 100644 (file)
@@ -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;
 
index 525d2f331d831295c103f0dbf375128e64d98506..9f25be9fafe7983efec345e7e0cad73eda1f1952 100644 (file)
@@ -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;
 
index 09248e64a9231634529ff2544870eb27748651b8..b900c75a57d5d0a0cd12a204d212ef9a19157a84 100644 (file)
@@ -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;
 
index effff378e8ffd510068cd8374ad132b9825cfe47..b6bba151399f693cee98995f982f33074c8001e9 100644 (file)
@@ -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;
 
index 9176b7e8c5d6c9a549fa69d2582a6f733998131e..2cb3a6c92684a54dc3bb4bc2be275485eff7ba96 100644 (file)
@@ -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;
 
index c3f156f0bb4243501232d9eb8003db309f889042..c5a3eeb6b30367199a796c659d0f805c811d1a8b 100644 (file)
@@ -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;