gallium: dmabuf support for yuv formats that are not natively supported
[mesa.git] / src / gallium / state_trackers / dri / dri2.c
index 82c57b78d9989b661b76501a10b3a2cedf867f38..05ebb4ef1d7198606407b5c46745523635d52287 100644 (file)
@@ -755,15 +755,7 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
        * add sampler view usage.
        */
       use_lowered = true;
-      for (i = 0; i < map->nplanes; i++) {
-          if (!pscreen->is_format_supported(pscreen,
-                                            dri2_get_pipe_format_for_dri_format(map->planes[i].dri_format),
-                                            screen->target, 0, 0,
-                                            PIPE_BIND_SAMPLER_VIEW))
-             break;
-      }
-
-      if (i == map->nplanes)
+      if (dri2_yuv_dma_buf_supported(screen, map))
          tex_usage |= PIPE_BIND_SAMPLER_VIEW;
    }
 
@@ -1407,6 +1399,11 @@ dri2_query_dma_buf_modifiers(__DRIscreen *_screen, int fourcc, int max,
       pscreen->query_dmabuf_modifiers(pscreen, format, max, modifiers,
                                       external_only, count);
       return true;
+   } else if (dri2_yuv_dma_buf_supported(screen, map)) {
+      *count = 1;
+      if (modifiers)
+         modifiers[0] = DRM_FORMAT_MOD_NONE;
+      return true;
    }
    return false;
 }