summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/vdpau
diff options
context:
space:
mode:
authorChristian König <[email protected]>2013-05-15 15:10:11 +0200
committerChristian König <[email protected]>2013-10-26 12:13:36 +0200
commit80964226e9b8a05c39157f9305c06c0b2861e080 (patch)
treec4f1c11f0f3e82e0b8167b8cba21de6694f2f9d9 /src/gallium/state_trackers/vdpau
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 <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/vdpau')
-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
4 files changed, 61 insertions, 8 deletions
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