summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_vdpau.c
diff options
context:
space:
mode:
authorMichel Dänzer <[email protected]>2019-07-17 12:18:11 +0200
committerMichel Dänzer <[email protected]>2019-07-23 16:28:02 +0200
commit22c7738520e2642a7f297d9b85f3dbfba37ca862 (patch)
treeba28be0b1ce16f9b25857156a245a2b82e1cc24e /src/mesa/state_tracker/st_vdpau.c
parent7499e7362d70c315399731eb20b89478ba794846 (diff)
st/mesa: Try re-importing resource if necessary in st_vdpau_map_surface
This can be the case if the resource was obtained from st_vdpau_output/video_surface_gallium. st_vdpau_output/video_surface_dma_buf do a similar dance internally. v2: * Pass PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE instead of 0 for usage. Bugzilla: https://bugs.freedesktop.org/111099 Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]> # v1 Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_vdpau.c')
-rw-r--r--src/mesa/state_tracker/st_vdpau.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/mesa/state_tracker/st_vdpau.c b/src/mesa/state_tracker/st_vdpau.c
index bfc6adf7f77..6a439b89d59 100644
--- a/src/mesa/state_tracker/st_vdpau.c
+++ b/src/mesa/state_tracker/st_vdpau.c
@@ -185,6 +185,7 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access,
const void *vdpSurface, GLuint index)
{
struct st_context *st = st_context(ctx);
+ struct pipe_screen *screen = st->pipe->screen;
struct st_texture_object *stObj = st_texture_object(texObj);
struct st_texture_image *stImage = st_texture_image(texImage);
@@ -207,15 +208,26 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access,
}
}
- if (!res) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUMapSurfacesNV");
- return;
+ /* If the resource is from a different screen, try re-importing it */
+ if (res && res->screen != screen) {
+ struct pipe_resource *new_res = NULL;
+ struct winsys_handle whandle = { .type = WINSYS_HANDLE_TYPE_FD };
+ unsigned usage = PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE;
+
+ if (screen->get_param(screen, PIPE_CAP_DMABUF) &&
+ res->screen->get_param(res->screen, PIPE_CAP_DMABUF) &&
+ res->screen->resource_get_handle(res->screen, NULL, res, &whandle,
+ usage)) {
+ new_res = screen->resource_from_handle(screen, res, &whandle, usage);
+ close(whandle.handle);
+ }
+
+ pipe_resource_reference(&res, NULL);
+ res = new_res;
}
- /* do we have different screen objects ? */
- if (res->screen != st->pipe->screen) {
+ if (!res) {
_mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUMapSurfacesNV");
- pipe_resource_reference(&res, NULL);
return;
}