summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2013-05-15 15:10:11 +0200
committerChristian König <christian.koenig@amd.com>2013-10-26 12:13:36 +0200
commit80964226e9b8a05c39157f9305c06c0b2861e080 (patch)
treec4f1c11f0f3e82e0b8167b8cba21de6694f2f9d9 /src/gallium
parent3d3a0b9b67982a96a4c4d87f78c21204f3a48776 (diff)
implement NV_vdpau_interop v7
v2: Actually implement interop between the gallium state tracker and the VDPAU backend. v3: Make it also available in non legacy contexts, fix video buffer sharing. v4: deny interop if we don't have the same screen object v5: rebased on upstream changes v6: implemented VDPAUGetSurfaceivNV, improved error handling, unregister all surfaces in VDPAUFiniNV v7: squash merge with Mareks changes Signed-off-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/include/state_tracker/vdpau_interop.h49
-rw-r--r--src/gallium/state_trackers/vdpau/ftab.c31
-rw-r--r--src/gallium/state_trackers/vdpau/output.c11
-rw-r--r--src/gallium/state_trackers/vdpau/surface.c21
-rw-r--r--src/gallium/state_trackers/vdpau/vdpau_private.h6
5 files changed, 110 insertions, 8 deletions
diff --git a/src/gallium/include/state_tracker/vdpau_interop.h b/src/gallium/include/state_tracker/vdpau_interop.h
new file mode 100644
index 00000000000..3ca7c9d4aa6
--- /dev/null
+++ b/src/gallium/include/state_tracker/vdpau_interop.h
@@ -0,0 +1,49 @@
+/**************************************************************************
+ *
+ * Copyright 2013 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@amd.com>
+ *
+ */
+
+#ifndef _VDPAU_INTEROP_H_
+#define _VDPAU_INTEROP_H_
+
+/* driver specific functions for NV_vdpau_interop */
+
+#define VDP_FUNC_ID_BASE_DRIVER 0x2000
+#define VDP_FUNC_ID_VIDEO_SURFACE_GALLIUM (VDP_FUNC_ID_BASE_DRIVER + 0)
+#define VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM (VDP_FUNC_ID_BASE_DRIVER + 1)
+
+struct pipe_resource;
+struct pipe_video_buffer;
+
+typedef struct pipe_video_buffer *VdpVideoSurfaceGallium(uint32_t surface);
+typedef struct pipe_resource *VdpOutputSurfaceGallium(uint32_t surface);
+
+#endif /* _VDPAU_INTEROP_H_ */
diff --git a/src/gallium/state_trackers/vdpau/ftab.c b/src/gallium/state_trackers/vdpau/ftab.c
index 81d16ec306a..2c84554cf83 100644
--- a/src/gallium/state_trackers/vdpau/ftab.c
+++ b/src/gallium/state_trackers/vdpau/ftab.c
@@ -26,6 +26,9 @@
**************************************************************************/
#include <assert.h>
+
+#include "util/u_memory.h"
+
#include "vdpau_private.h"
static void* ftab[67] =
@@ -104,19 +107,31 @@ static void* ftab_winsys[1] =
&vlVdpPresentationQueueTargetCreateX11 /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 */
};
+static void* ftab_driver[2] =
+{
+ &vlVdpVideoSurfaceGallium, /* VDP_FUNC_ID_SURFACE_GALLIUM */
+ &vlVdpOutputSurfaceGallium /* VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM */
+};
+
boolean vlGetFuncFTAB(VdpFuncId function_id, void **func)
{
assert(func);
+ *func = NULL;
+
if (function_id < VDP_FUNC_ID_BASE_WINSYS) {
- if (function_id > 66)
- return FALSE;
- *func = ftab[function_id];
- }
- else {
+ if (function_id < Elements(ftab))
+ *func = ftab[function_id];
+
+ } else if (function_id < VDP_FUNC_ID_BASE_DRIVER) {
function_id -= VDP_FUNC_ID_BASE_WINSYS;
- if (function_id > 0)
- return FALSE;
- *func = ftab_winsys[function_id];
+ if (function_id < Elements(ftab_winsys))
+ *func = ftab_winsys[function_id];
+
+ } else {
+ function_id -= VDP_FUNC_ID_BASE_DRIVER;
+ if (function_id < Elements(ftab_driver))
+ *func = ftab_driver[function_id];
}
+
return *func != NULL;
}
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
index cf77b532485..def01c89d2a 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -725,3 +725,14 @@ vlVdpOutputSurfaceRenderBitmapSurface(VdpOutputSurface destination_surface,
return VDP_STATUS_OK;
}
+
+struct pipe_resource *vlVdpOutputSurfaceGallium(VdpOutputSurface surface)
+{
+ vlVdpOutputSurface *vlsurface;
+
+ vlsurface = vlGetDataHTAB(surface);
+ if (!vlsurface || !vlsurface->surface)
+ return NULL;
+
+ return vlsurface->surface->texture;
+}
diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c
index 074363bdafb..cd798a21a32 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -469,3 +469,24 @@ vlVdpVideoSurfaceClear(vlVdpSurface *vlsurf)
}
pipe->flush(pipe, NULL, 0);
}
+
+/**
+ * Interop to mesa state tracker
+ */
+struct pipe_video_buffer *vlVdpVideoSurfaceGallium(VdpVideoSurface surface)
+{
+ vlVdpSurface *p_surf = vlGetDataHTAB(surface);
+ if (!p_surf)
+ return NULL;
+
+ pipe_mutex_lock(p_surf->device->mutex);
+ if (p_surf->video_buffer == NULL) {
+ struct pipe_context *pipe = p_surf->device->context;
+
+ /* try to create a video buffer if we don't already have one */
+ p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat);
+ }
+ pipe_mutex_unlock(p_surf->device->mutex);
+
+ return p_surf->video_buffer;
+}
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index bb91de13103..60196acee6d 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -36,6 +36,8 @@
#include "pipe/p_compiler.h"
#include "pipe/p_video_codec.h"
+#include "state_tracker/vdpau_interop.h"
+
#include "util/u_debug.h"
#include "util/u_rect.h"
#include "os/os_thread.h"
@@ -498,6 +500,10 @@ VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues;
VdpVideoMixerDestroy vlVdpVideoMixerDestroy;
VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix;
+/* interop to mesa state tracker */
+VdpVideoSurfaceGallium vlVdpVideoSurfaceGallium;
+VdpOutputSurfaceGallium vlVdpOutputSurfaceGallium;
+
#define VDPAU_OUT 0
#define VDPAU_ERR 1
#define VDPAU_WARN 2