aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/vdpau/output.c
diff options
context:
space:
mode:
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 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;
+}