st/va: check resource_get_info nullity in vlVaDeriveImage
authorJulien Isorce <jisorce@oblong.com>
Thu, 2 May 2019 22:36:04 +0000 (15:36 -0700)
committerJulien Isorce <julien.isorce@chromium.org>
Fri, 3 May 2019 23:11:55 +0000 (16:11 -0700)
This pipe_screen function is not implemented by all backends.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110443
Signed-off-by: Julien Isorce <jisorce@oblong.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
src/gallium/state_trackers/va/image.c

index 491c2d82858a84ee37ca12a25b4e944f37c4d18d..d4b9ce5596dcf5fd682ec26d48cce57f1a587044 100644 (file)
@@ -251,23 +251,26 @@ vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image)
    }
 
    mtx_lock(&drv->mutex);
-   screen->resource_get_info(screen, surfaces[0]->texture, &stride, &offset);
-   if (!stride)
-      offset = 0;
+   if (screen->resource_get_info) {
+      screen->resource_get_info(screen, surfaces[0]->texture, &stride,
+                                &offset);
+      if (!stride)
+         offset = 0;
+   }
 
    switch (img->format.fourcc) {
    case VA_FOURCC('U','Y','V','Y'):
    case VA_FOURCC('Y','U','Y','V'):
-      assert(stride >= (w * 2));
       img->pitches[0] = stride > 0 ? stride : w * 2;
+      assert(img->pitches[0] >= (w * 2));
       break;
 
    case VA_FOURCC('B','G','R','A'):
    case VA_FOURCC('R','G','B','A'):
    case VA_FOURCC('B','G','R','X'):
    case VA_FOURCC('R','G','B','X'):
-      assert(stride >= (w * 4));
       img->pitches[0] = stride > 0 ? stride : w * 4;
+      assert(img->pitches[0] >= (w * 4));
       break;
 
    default: