summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/state_trackers/vdpau/ftab.c6
-rw-r--r--src/gallium/state_trackers/vdpau/output.c41
-rw-r--r--src/gallium/state_trackers/vdpau/surface.c69
-rw-r--r--src/gallium/state_trackers/vdpau/vdpau_private.h3
4 files changed, 116 insertions, 3 deletions
diff --git a/src/gallium/state_trackers/vdpau/ftab.c b/src/gallium/state_trackers/vdpau/ftab.c
index add465983e5..901a444f1c7 100644
--- a/src/gallium/state_trackers/vdpau/ftab.c
+++ b/src/gallium/state_trackers/vdpau/ftab.c
@@ -107,10 +107,12 @@ static void* ftab_winsys[1] =
&vlVdpPresentationQueueTargetCreateX11 /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 */
};
-static void* ftab_driver[2] =
+static void* ftab_driver[4] =
{
&vlVdpVideoSurfaceGallium, /* VDP_FUNC_ID_SURFACE_GALLIUM */
- &vlVdpOutputSurfaceGallium /* VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM */
+ &vlVdpOutputSurfaceGallium, /* VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM */
+ &vlVdpVideoSurfaceDMABuf, /* VDP_FUNC_ID_VIDEO_SURFACE_DMA_BUF */
+ &vlVdpOutputSurfaceDMABuf /* VDP_FUNC_ID_OUTPUT_SURFACE_DMA_BUF */
};
boolean vlGetFuncFTAB(VdpFuncId function_id, void **func)
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
index 738e7c74f6b..c644cc8ba85 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -36,6 +36,8 @@
#include "vl/vl_csc.h"
+#include "state_tracker/drm_driver.h"
+
#include "vdpau_private.h"
/**
@@ -80,7 +82,7 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
res_tmpl.depth0 = 1;
res_tmpl.array_size = 1;
res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET |
- PIPE_BIND_LINEAR;
+ PIPE_BIND_LINEAR | PIPE_BIND_SHARED;
res_tmpl.usage = PIPE_USAGE_DEFAULT;
pipe_mutex_lock(dev->mutex);
@@ -764,3 +766,40 @@ struct pipe_resource *vlVdpOutputSurfaceGallium(VdpOutputSurface surface)
return vlsurface->surface->texture;
}
+
+VdpStatus vlVdpOutputSurfaceDMABuf(VdpVideoSurface surface,
+ struct VdpSurfaceDMABufDesc *result)
+{
+ vlVdpOutputSurface *vlsurface;
+ struct pipe_screen *pscreen;
+ struct winsys_handle whandle;
+
+ memset(result, 0, sizeof(*result));
+ result->handle = -1;
+
+ vlsurface = vlGetDataHTAB(surface);
+ if (!vlsurface || !vlsurface->surface)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ pipe_mutex_lock(vlsurface->device->mutex);
+ vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
+ vlsurface->device->context->flush(vlsurface->device->context, NULL, 0);
+ pipe_mutex_unlock(vlsurface->device->mutex);
+
+ memset(&whandle, 0, sizeof(struct winsys_handle));
+ whandle.type = DRM_API_HANDLE_TYPE_FD;
+
+ pscreen = vlsurface->surface->texture->screen;
+ if (!pscreen->resource_get_handle(pscreen, vlsurface->surface->texture, &whandle,
+ PIPE_HANDLE_USAGE_READ_WRITE))
+ return VDP_STATUS_NO_IMPLEMENTATION;
+
+ result->handle = whandle.handle;
+ result->width = vlsurface->surface->width;
+ result->height = vlsurface->surface->height;
+ result->offset = whandle.offset;
+ result->stride = whandle.stride;
+ result->format = PipeToFormatRGBA(vlsurface->surface->format);
+
+ return VDP_STATUS_OK;
+}
diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c
index ffcedc12de6..0550141b597 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -37,6 +37,8 @@
#include "util/u_video.h"
#include "vl/vl_defines.h"
+#include "state_tracker/drm_driver.h"
+
#include "vdpau_private.h"
enum getbits_conversion {
@@ -412,3 +414,70 @@ struct pipe_video_buffer *vlVdpVideoSurfaceGallium(VdpVideoSurface surface)
return p_surf->video_buffer;
}
+
+VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
+ VdpVideoSurfacePlane plane,
+ struct VdpSurfaceDMABufDesc *result)
+{
+ vlVdpSurface *p_surf = vlGetDataHTAB(surface);
+
+ struct pipe_screen *pscreen;
+ struct winsys_handle whandle;
+
+ struct pipe_surface *surf;
+
+ memset(result, 0, sizeof(*result));
+ result->handle = -1;
+
+ if (!p_surf)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ if (plane > 3)
+ return VDP_STATUS_INVALID_VALUE;
+
+ if (result)
+ return VDP_STATUS_INVALID_POINTER;
+
+ 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);
+ }
+
+ /* 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) {
+ pipe_mutex_unlock(p_surf->device->mutex);
+ return VDP_STATUS_NO_IMPLEMENTATION;
+ }
+
+ surf = p_surf->video_buffer->get_surfaces(p_surf->video_buffer)[plane];
+ pipe_mutex_unlock(p_surf->device->mutex);
+
+ if (!surf)
+ return VDP_STATUS_RESOURCES;
+
+ memset(&whandle, 0, sizeof(struct winsys_handle));
+ whandle.type = DRM_API_HANDLE_TYPE_FD;
+ whandle.layer = surf->u.tex.first_layer;
+
+ pscreen = surf->texture->screen;
+ if (!pscreen->resource_get_handle(pscreen, surf->texture, &whandle,
+ PIPE_HANDLE_USAGE_READ_WRITE))
+ return VDP_STATUS_NO_IMPLEMENTATION;
+
+ result->handle = whandle.handle;
+ result->width = surf->width;
+ result->height = surf->height;
+ 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;
+}
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index 0d9c1e9f3d0..3b6647e9975 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -37,6 +37,7 @@
#include "pipe/p_video_codec.h"
#include "state_tracker/vdpau_interop.h"
+#include "state_tracker/vdpau_dmabuf.h"
#include "state_tracker/vdpau_funcs.h"
#include "util/u_debug.h"
@@ -522,6 +523,8 @@ VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11;
/* interop to mesa state tracker */
VdpVideoSurfaceGallium vlVdpVideoSurfaceGallium;
VdpOutputSurfaceGallium vlVdpOutputSurfaceGallium;
+VdpVideoSurfaceDMABuf vlVdpVideoSurfaceDMABuf;
+VdpOutputSurfaceDMABuf vlVdpOutputSurfaceDMABuf;
#define VDPAU_OUT 0
#define VDPAU_ERR 1