mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-29 10:10:09 +01:00
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 <pierre-eric.pelloux-prayer@amd.com> # v1 Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
parent
7499e7362d
commit
22c7738520
1 changed files with 18 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue