summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/vdpau/output.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2016-01-14 16:45:29 +0100
committerChristian König <christian.koenig@amd.com>2016-03-29 17:29:18 +0200
commitbdeb22b7b6204cf7a0eaab123118e2522a9abcd7 (patch)
treee5a7671fd8f95ac6648795cc69ed3d361a2c88ec /src/gallium/state_trackers/vdpau/output.c
parent0042aa508e19bb920d0ab385894cd3e03b9eafde (diff)
downloadexternal_mesa3d-bdeb22b7b6204cf7a0eaab123118e2522a9abcd7.zip
external_mesa3d-bdeb22b7b6204cf7a0eaab123118e2522a9abcd7.tar.gz
external_mesa3d-bdeb22b7b6204cf7a0eaab123118e2522a9abcd7.tar.bz2
st/vdpau: implement the new DMA-buf based interop v2
That should allow us to get away from passing internal structures around. v2: rebased Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Leo Liu <leo.liu@amd.com>
Diffstat (limited to 'src/gallium/state_trackers/vdpau/output.c')
-rw-r--r--src/gallium/state_trackers/vdpau/output.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
index 738e7c7..c644cc8 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;
+}