[Mesa-dev] [PATCH 1/2] st/vdpau: split the VdpFormatRGBAToPipe helper in two

Emil Velikov emil.l.velikov at gmail.com
Fri Apr 21 12:11:05 UTC 2017


Split the helper in two:
 - an "official" VDP format to pipe
 - and a custom VDP format to pipe

The latter is DMAbuf specific and does not belong with the rest.
That is, until not until the VDP_RGBA_FORMAT_R8{,G8} formats become part
of libvdpau.

With this commit we effectively revert "st/vdpau: move FormatRGBAToPipe
into the interop"

Cc: Christian König <christian.koenig at amd.com>
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/gallium/include/state_tracker/vdpau_dmabuf.h | 18 ++++++-
 src/gallium/include/state_tracker/vdpau_funcs.h  | 65 ------------------------
 src/gallium/state_trackers/vdpau/bitmap.c        |  2 +-
 src/gallium/state_trackers/vdpau/output.c        |  2 +-
 src/gallium/state_trackers/vdpau/query.c         | 10 ++--
 src/gallium/state_trackers/vdpau/vdpau_private.h | 22 +++++++-
 src/mesa/state_tracker/st_vdpau.c                |  3 +-
 7 files changed, 46 insertions(+), 76 deletions(-)
 delete mode 100644 src/gallium/include/state_tracker/vdpau_funcs.h

diff --git a/src/gallium/include/state_tracker/vdpau_dmabuf.h b/src/gallium/include/state_tracker/vdpau_dmabuf.h
index f838c925f30..47c20b48ae6 100644
--- a/src/gallium/include/state_tracker/vdpau_dmabuf.h
+++ b/src/gallium/include/state_tracker/vdpau_dmabuf.h
@@ -35,6 +35,7 @@
 #define _VDPAU_DMABUF_H_
 
 #include <vdpau/vdpau.h>
+#include "pipe/p_format.h"
 
 /* driver specific functions for NV_vdpau_interop */
 #ifndef VDP_FUNC_ID_BASE_DRIVER
@@ -51,6 +52,21 @@
 #define VDP_RGBA_FORMAT_R8          (-1)
 #define VDP_RGBA_FORMAT_R8G8        (-2)
 
+static inline enum pipe_format
+VdpCustomFormatRGBAToPipe(uint32_t vdpau_format)
+{
+   switch (vdpau_format) {
+   case VDP_RGBA_FORMAT_R8:
+      return PIPE_FORMAT_R8_UNORM;
+   case VDP_RGBA_FORMAT_R8G8:
+      return PIPE_FORMAT_R8G8_UNORM;
+   default:
+      assert(0);
+   }
+
+   return PIPE_FORMAT_NONE;
+}
+
 struct VdpSurfaceDMABufDesc {
    /* DMA-buf file descriptor */
    uint32_t handle;
@@ -62,7 +78,7 @@ struct VdpSurfaceDMABufDesc {
    uint32_t offset;
    /* Stride in bytes */
    uint32_t stride;
-   /* VDP_RGBA_FORMAT_* as defined in the VDPAU spec and above. */
+   /* VDP_RGBA_FORMAT_* as defined above. */
    uint32_t format;
 };
 
diff --git a/src/gallium/include/state_tracker/vdpau_funcs.h b/src/gallium/include/state_tracker/vdpau_funcs.h
deleted file mode 100644
index 66e3c23ede4..00000000000
--- a/src/gallium/include/state_tracker/vdpau_funcs.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2016 Advanced Micro Devices, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/*
- * Authors:
- *      Christian König <christian.koenig at amd.com>
- *
- */
-
-#ifndef _VDPAU_FUNCS_H_
-#define _VDPAU_FUNCS_H_
-
-#include "vdpau_dmabuf.h"
-
-/* Used for implementing NV_vdpau_interop */
-static inline enum pipe_format
-VdpFormatRGBAToPipe(uint32_t vdpau_format)
-{
-   switch (vdpau_format) {
-   case VDP_RGBA_FORMAT_R8:
-      return PIPE_FORMAT_R8_UNORM;
-   case VDP_RGBA_FORMAT_R8G8:
-      return PIPE_FORMAT_R8G8_UNORM;
-   case VDP_RGBA_FORMAT_A8:
-      return PIPE_FORMAT_A8_UNORM;
-   case VDP_RGBA_FORMAT_B10G10R10A2:
-      return PIPE_FORMAT_B10G10R10A2_UNORM;
-   case VDP_RGBA_FORMAT_B8G8R8A8:
-      return PIPE_FORMAT_B8G8R8A8_UNORM;
-   case VDP_RGBA_FORMAT_R10G10B10A2:
-      return PIPE_FORMAT_R10G10B10A2_UNORM;
-   case VDP_RGBA_FORMAT_R8G8B8A8:
-      return PIPE_FORMAT_R8G8B8A8_UNORM;
-   default:
-      assert(0);
-   }
-
-   return PIPE_FORMAT_NONE;
-}
-
-#endif /* _VDPAU_FUNCS_H_ */
diff --git a/src/gallium/state_trackers/vdpau/bitmap.c b/src/gallium/state_trackers/vdpau/bitmap.c
index 643be75e618..c69fe2e709e 100644
--- a/src/gallium/state_trackers/vdpau/bitmap.c
+++ b/src/gallium/state_trackers/vdpau/bitmap.c
@@ -71,7 +71,7 @@ vlVdpBitmapSurfaceCreate(VdpDevice device,
 
    memset(&res_tmpl, 0, sizeof(res_tmpl));
    res_tmpl.target = PIPE_TEXTURE_2D;
-   res_tmpl.format = VdpFormatRGBAToPipe(rgba_format);
+   res_tmpl.format = FormatRGBAToPipe(rgba_format);
    res_tmpl.width0 = width;
    res_tmpl.height0 = height;
    res_tmpl.depth0 = 1;
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
index 8ef826836c1..72a81adb070 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -83,7 +83,7 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
    vlsurface->send_to_X = rgba_format == VDP_RGBA_FORMAT_B8G8R8A8;
 
    res_tmpl.target = PIPE_TEXTURE_2D;
-   res_tmpl.format = VdpFormatRGBAToPipe(rgba_format);
+   res_tmpl.format = FormatRGBAToPipe(rgba_format);
    res_tmpl.width0 = width;
    res_tmpl.height0 = height;
    res_tmpl.depth0 = 1;
diff --git a/src/gallium/state_trackers/vdpau/query.c b/src/gallium/state_trackers/vdpau/query.c
index 6b8b5a6b5d3..5e192a02ae6 100644
--- a/src/gallium/state_trackers/vdpau/query.c
+++ b/src/gallium/state_trackers/vdpau/query.c
@@ -237,7 +237,7 @@ vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba
    if (!pscreen)
       return VDP_STATUS_RESOURCES;
 
-   format = VdpFormatRGBAToPipe(surface_rgba_format);
+   format = FormatRGBAToPipe(surface_rgba_format);
    if (format == PIPE_FORMAT_NONE || format == PIPE_FORMAT_A8_UNORM)
       return VDP_STATUS_INVALID_RGBA_FORMAT;
 
@@ -289,7 +289,7 @@ vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device, VdpRGBAFor
    if (!pscreen)
       return VDP_STATUS_ERROR;
 
-   format = VdpFormatRGBAToPipe(surface_rgba_format);
+   format = FormatRGBAToPipe(surface_rgba_format);
    if (format == PIPE_FORMAT_NONE || format == PIPE_FORMAT_A8_UNORM)
       return VDP_STATUS_INVALID_RGBA_FORMAT;
 
@@ -330,7 +330,7 @@ vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities(VdpDevice device,
    if (!pscreen)
       return VDP_STATUS_ERROR;
 
-   rgba_format = VdpFormatRGBAToPipe(surface_rgba_format);
+   rgba_format = FormatRGBAToPipe(surface_rgba_format);
    if (rgba_format == PIPE_FORMAT_NONE || rgba_format == PIPE_FORMAT_A8_UNORM)
       return VDP_STATUS_INVALID_RGBA_FORMAT;
 
@@ -389,7 +389,7 @@ vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device, VdpRGBAFormat
    if (!pscreen)
       return VDP_STATUS_ERROR;
 
-   rgba_format = VdpFormatRGBAToPipe(surface_rgba_format);
+   rgba_format = FormatRGBAToPipe(surface_rgba_format);
    if (rgba_format == PIPE_FORMAT_NONE || rgba_format == PIPE_FORMAT_A8_UNORM)
       return VDP_STATUS_INVALID_RGBA_FORMAT;
 
@@ -437,7 +437,7 @@ vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba
    if (!pscreen)
       return VDP_STATUS_RESOURCES;
 
-   format = VdpFormatRGBAToPipe(surface_rgba_format);
+   format = FormatRGBAToPipe(surface_rgba_format);
    if (format == PIPE_FORMAT_NONE)
       return VDP_STATUS_INVALID_RGBA_FORMAT;
 
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index b36c0c4aec2..1cf8c059ba9 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -38,7 +38,6 @@
 
 #include "state_tracker/vdpau_interop.h"
 #include "state_tracker/vdpau_dmabuf.h"
-#include "state_tracker/vdpau_funcs.h"
 
 #include "util/u_debug.h"
 #include "util/u_rect.h"
@@ -164,6 +163,27 @@ PipeToFormatYCBCR(enum pipe_format p_format)
    return -1;
 }
 
+static inline enum pipe_format
+FormatRGBAToPipe(VdpRGBAFormat vdpau_format)
+{
+   switch (vdpau_format) {
+      case VDP_RGBA_FORMAT_A8:
+         return PIPE_FORMAT_A8_UNORM;
+      case VDP_RGBA_FORMAT_B10G10R10A2:
+         return PIPE_FORMAT_B10G10R10A2_UNORM;
+      case VDP_RGBA_FORMAT_B8G8R8A8:
+         return PIPE_FORMAT_B8G8R8A8_UNORM;
+      case VDP_RGBA_FORMAT_R10G10B10A2:
+         return PIPE_FORMAT_R10G10B10A2_UNORM;
+      case VDP_RGBA_FORMAT_R8G8B8A8:
+         return PIPE_FORMAT_R8G8B8A8_UNORM;
+      default:
+         assert(0);
+   }
+
+   return PIPE_FORMAT_NONE;
+}
+
 static inline VdpRGBAFormat
 PipeToFormatRGBA(enum pipe_format p_format)
 {
diff --git a/src/mesa/state_tracker/st_vdpau.c b/src/mesa/state_tracker/st_vdpau.c
index 02738153085..57d02395fee 100644
--- a/src/mesa/state_tracker/st_vdpau.c
+++ b/src/mesa/state_tracker/st_vdpau.c
@@ -52,7 +52,6 @@
 
 #include "state_tracker/vdpau_interop.h"
 #include "state_tracker/vdpau_dmabuf.h"
-#include "state_tracker/vdpau_funcs.h"
 #include "state_tracker/drm_driver.h"
 
 static struct pipe_resource *
@@ -122,7 +121,7 @@ st_vdpau_resource_from_description(struct gl_context *ctx,
    templ.array_size = 1;
    templ.width0 = desc->width;
    templ.height0 = desc->height;
-   templ.format = VdpFormatRGBAToPipe(desc->format);
+   templ.format = VdpCustomFormatRGBAToPipe(desc->format);
    templ.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
    templ.usage = PIPE_USAGE_DEFAULT;
 
-- 
2.12.2



More information about the mesa-dev mailing list