From a1b3af5df32558ddcf67432a706a7280f81c5f2d Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 14 Mar 2015 22:36:59 +0100 Subject: vo_opengl: silence vdpau hwdec warnings with smoothmotion Since the gl_rework merge, this started to print some OpenGL errors when using vdpau hardware decoding with vo_opengl smoothmotion. This happens because some hwdec unmap_image call were not paired with a map_image call. Unlike the old vo_opengl, the new code does not do this out of convenience (it would be a pain to track this exactly). It was triggered by smoothmotion, because not every rendered frame has actually a new input video frame (i.e. no map_image call, but it called unmap_image anyway). Solve this by handling unmapping differently in the vdpau code. The next commit will remove the unmap_image callback completely. Fixes #1687. --- video/out/gl_hwdec_vdpau.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/video/out/gl_hwdec_vdpau.c b/video/out/gl_hwdec_vdpau.c index f0086b35a5..fc341b1637 100644 --- a/video/out/gl_hwdec_vdpau.c +++ b/video/out/gl_hwdec_vdpau.c @@ -40,6 +40,7 @@ struct priv { GLvdpauSurfaceNV vdpgl_surface; VdpOutputSurface vdp_surface; struct mp_vdpau_mixer *mixer; + bool mapped; }; static void mark_vdpau_objects_uninitialized(struct gl_hwdec *hw) @@ -48,6 +49,7 @@ static void mark_vdpau_objects_uninitialized(struct gl_hwdec *hw) p->vdp_surface = VDP_INVALID_HANDLE; p->mixer->video_mixer = VDP_INVALID_HANDLE; + p->mapped = false; } static void destroy_objects(struct gl_hwdec *hw) @@ -57,6 +59,10 @@ static void destroy_objects(struct gl_hwdec *hw) struct vdp_functions *vdp = &p->ctx->vdp; VdpStatus vdp_st; + if (p->mapped) + gl->VDPAUUnmapSurfacesNV(1, &p->vdpgl_surface); + p->mapped = false; + if (p->vdpgl_surface) gl->VDPAUUnregisterSurfaceNV(p->vdpgl_surface); p->vdpgl_surface = 0; @@ -182,19 +188,19 @@ static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image, if (!p->vdpgl_surface) return -1; + if (p->mapped) + gl->VDPAUUnmapSurfacesNV(1, &p->vdpgl_surface); + mp_vdpau_mixer_render(p->mixer, NULL, p->vdp_surface, NULL, hw_image, NULL); gl->VDPAUMapSurfacesNV(1, &p->vdpgl_surface); + p->mapped = true; out_textures[0] = p->gl_texture; return 0; } static void unmap_image(struct gl_hwdec *hw) { - struct priv *p = hw->priv; - GL *gl = hw->gl; - - gl->VDPAUUnmapSurfacesNV(1, &p->vdpgl_surface); } const struct gl_hwdec_driver gl_hwdec_vdpau = { -- cgit v1.2.3