From a16040528459844d304d39c7d567ced86565ae06 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 25 Jan 2016 16:42:54 +0100 Subject: vdpau: force driver to report preemption early Another fix for the crazy and insane nvidia preemption behavior. This time, the situation is that we are using vo_opengl with vdpau interop, and that vdpau got preempted in the background while mpv was sitting idly. This can be e.g. reproduced by using: --force-window=immediate --idle --hwdec=vdpau and switching VTs. Then after switching back, load a video file. This will not let mp_vdpau_handle_preemption() perform preemption recovery, simply because it will do so only once vdp_decoder_create() has been called. There are some other API calls which trigger preemption, but many don't. Due to the way the libavcodec API works, vdp_decoder_create() is way too late. It does so when get_format returns. It notices creating the decoder fails, and continues calling get_format without the vdpau format. We could perhaps force it to reinit again (by adding a call to vdpau.c, that checks for preemption, and sets hwdec_request_reinit), but this seems too much of a mess. Solve it by calling API in mp_vdpau_handle_preemption() that empirically does trigger preemption: output_surface_put_bits_native(). This call is useless, and in fact should be doing nothing (empty update VdpRect). There's the slight chance that in theory it will slow down operation, but in practice it's bound to be harmless. It's the likely cheapest and simplest API call I've found that can trigger the fallback this way. (The driver is closed source, so it was up to trial & error.) Also, when initializing decoding, allow initial preemption recovery, which is needed to pass the test mention above. --- video/vdpau.h | 1 + 1 file changed, 1 insertion(+) (limited to 'video/vdpau.h') diff --git a/video/vdpau.h b/video/vdpau.h index 2e9269a420..db73a87dd7 100644 --- a/video/vdpau.h +++ b/video/vdpau.h @@ -59,6 +59,7 @@ struct mp_vdpau_ctx { uint64_t preemption_counter; // incremented after _restoring_ bool preemption_user_notified; double last_preemption_retry_fail; + VdpOutputSurface preemption_obj; // dummy for reliable preempt. check // Surface pool pthread_mutex_t pool_lock; -- cgit v1.2.3