[Mesa-dev] [PATCH 4/7] st/vdpau: add support for 16bit interop

Christian König deathsimple at vodafone.de
Wed Jan 25 14:41:57 UTC 2017


From: Christian König <christian.koenig at amd.com>

That should make it possible to use the 16bit surfaces in OpenGL as well.

Signed-off-by: Christian König <christian.koenig at amd.com>
---
 src/gallium/include/state_tracker/vdpau_dmabuf.h |  2 ++
 src/gallium/include/state_tracker/vdpau_funcs.h  |  4 ++++
 src/gallium/state_trackers/vdpau/surface.c       | 18 ++++++++++++------
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/gallium/include/state_tracker/vdpau_dmabuf.h b/src/gallium/include/state_tracker/vdpau_dmabuf.h
index f838c92..1f770c1 100644
--- a/src/gallium/include/state_tracker/vdpau_dmabuf.h
+++ b/src/gallium/include/state_tracker/vdpau_dmabuf.h
@@ -50,6 +50,8 @@
  */
 #define VDP_RGBA_FORMAT_R8          (-1)
 #define VDP_RGBA_FORMAT_R8G8        (-2)
+#define VDP_RGBA_FORMAT_R16         (-3)
+#define VDP_RGBA_FORMAT_R16G16      (-4)
 
 struct VdpSurfaceDMABufDesc {
    /* DMA-buf file descriptor */
diff --git a/src/gallium/include/state_tracker/vdpau_funcs.h b/src/gallium/include/state_tracker/vdpau_funcs.h
index 66e3c23..9c7a4fa 100644
--- a/src/gallium/include/state_tracker/vdpau_funcs.h
+++ b/src/gallium/include/state_tracker/vdpau_funcs.h
@@ -45,6 +45,10 @@ VdpFormatRGBAToPipe(uint32_t vdpau_format)
       return PIPE_FORMAT_R8_UNORM;
    case VDP_RGBA_FORMAT_R8G8:
       return PIPE_FORMAT_R8G8_UNORM;
+   case VDP_RGBA_FORMAT_R16:
+      return PIPE_FORMAT_R16_UNORM;
+   case VDP_RGBA_FORMAT_R16G16:
+      return PIPE_FORMAT_R16G16_UNORM;
    case VDP_RGBA_FORMAT_A8:
       return PIPE_FORMAT_A8_UNORM;
    case VDP_RGBA_FORMAT_B10G10R10A2:
diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c
index 9a80605..d087dde 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -454,7 +454,8 @@ VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
 
    /* Check if surface match interop requirements */
    if (p_surf->video_buffer == NULL || !p_surf->video_buffer->interlaced ||
-       p_surf->video_buffer->buffer_format != PIPE_FORMAT_NV12) {
+       (p_surf->video_buffer->buffer_format != PIPE_FORMAT_NV12 &&
+        p_surf->video_buffer->buffer_format != PIPE_FORMAT_P016)) {
       pipe_mutex_unlock(p_surf->device->mutex);
       return VDP_STATUS_NO_IMPLEMENTATION;
    }
@@ -465,6 +466,16 @@ VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
       return VDP_STATUS_RESOURCES;
    }
 
+   switch (surf->format) {
+   case PIPE_FORMAT_R8_UNORM: result->format = VDP_RGBA_FORMAT_R8; break;
+   case PIPE_FORMAT_R8G8_UNORM: result->format = VDP_RGBA_FORMAT_R8G8; break;
+   case PIPE_FORMAT_R16_UNORM: result->format = VDP_RGBA_FORMAT_R16; break;
+   case PIPE_FORMAT_R16G16_UNORM: result->format = VDP_RGBA_FORMAT_R16G16; break;
+   default:
+      pipe_mutex_unlock(p_surf->device->mutex);
+      return VDP_STATUS_NO_IMPLEMENTATION;
+   }
+
    memset(&whandle, 0, sizeof(struct winsys_handle));
    whandle.type = DRM_API_HANDLE_TYPE_FD;
    whandle.layer = surf->u.tex.first_layer;
@@ -485,10 +496,5 @@ VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
    result->offset = whandle.offset;
    result->stride = whandle.stride;
 
-   if (surf->format == PIPE_FORMAT_R8_UNORM)
-      result->format = VDP_RGBA_FORMAT_R8;
-   else
-      result->format = VDP_RGBA_FORMAT_R8G8;
-
    return VDP_STATUS_OK;
 }
-- 
2.7.4



More information about the mesa-dev mailing list