From cfc9e7c94eafa33e7f109099664ec4fb57ac5ca3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 22 Jun 2017 14:52:57 +0200 Subject: hwcontext_d3d11va: add option to enable debug mode Basically copied from VLC (LGPL): http://git.videolan.org/?p=vlc.git;a=blob;f=modules/video_output/win32/direct3d11.c;h=e9fcb83dcabfe778f26e63d19f218caf06a7c3ae;hb=HEAD#l1482 http://git.videolan.org/?p=vlc.git;a=blob;f=modules/codec/avcodec/d3d11va.c;h=85e7d25caebc059a9770da2ef4bb8fe90816d76d;hb=HEAD#l599 Signed-off-by: Luca Barbato --- libavutil/hwcontext_d3d11va.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'libavutil/hwcontext_d3d11va.c') diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index 376c76e5cf..75f78d8669 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" + #include // Include thread.h before redefining _WIN32_WINNT, to get @@ -32,6 +34,10 @@ #include #include +#if HAVE_DXGIDEBUG_H +#include +#endif + #include "avassert.h" #include "common.h" #include "hwcontext.h" @@ -476,8 +482,18 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device, IDXGIAdapter *pAdapter = NULL; ID3D10Multithread *pMultithread; UINT creationFlags = D3D11_CREATE_DEVICE_VIDEO_SUPPORT; + int is_debug = !!av_dict_get(opts, "debug", NULL, 0); int ret; + // (On UWP we can't check this.) +#if HAVE_LOADLIBRARY + if (!LoadLibrary("d3d11_1sdklayers.dll")) + is_debug = 0; +#endif + + if (is_debug) + creationFlags |= D3D11_CREATE_DEVICE_DEBUG; + if ((ret = ff_thread_once(&functions_loaded, load_functions)) != 0) return AVERROR_UNKNOWN; if (!mD3D11CreateDevice || !mCreateDXGIFactory) { @@ -511,6 +527,22 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device, ID3D10Multithread_Release(pMultithread); } +#if HAVE_LOADLIBRARY && HAVE_DXGIDEBUG_H + if (is_debug) { + HANDLE dxgidebug_dll = LoadLibrary("dxgidebug.dll"); + if (dxgidebug_dll) { + HRESULT (WINAPI * pf_DXGIGetDebugInterface)(const GUID *riid, void **ppDebug) + = (void *)GetProcAddress(dxgidebug_dll, "DXGIGetDebugInterface"); + if (pf_DXGIGetDebugInterface) { + IDXGIDebug *dxgi_debug = NULL; + hr = pf_DXGIGetDebugInterface(&IID_IDXGIDebug, (void**)&dxgi_debug); + if (SUCCEEDED(hr) && dxgi_debug) + IDXGIDebug_ReportLiveObjects(dxgi_debug, DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_ALL); + } + } + } +#endif + return 0; } -- cgit v1.2.3