diff options
author | Jan Ekström <jeebjp@gmail.com> | 2019-09-29 13:08:14 +0300 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2019-09-29 19:39:26 +0300 |
commit | bca6e14702998220b5744546f17da5e3e75d2f06 (patch) | |
tree | 77fda4fde24f06c633cc7582a74a338692a5baab /video | |
parent | b7438d3aff285a1b8368fec113e11f32cc81796d (diff) | |
download | mpv-bca6e14702998220b5744546f17da5e3e75d2f06.tar.bz2 mpv-bca6e14702998220b5744546f17da5e3e75d2f06.tar.xz |
vo_gpu/d3d11: refactor pthread_once d3d11 loading to function
Lets us reuse this in the future.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/gpu/d3d11_helpers.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/video/out/gpu/d3d11_helpers.c b/video/out/gpu/d3d11_helpers.c index b2f6e76989..cfabfbe3ab 100644 --- a/video/out/gpu/d3d11_helpers.c +++ b/video/out/gpu/d3d11_helpers.c @@ -47,6 +47,20 @@ static void d3d11_load(void) GetProcAddress(dxgilib, "CreateDXGIFactory1"); } +static bool load_d3d11_functions(struct mp_log *log) +{ + pthread_once(&d3d11_once, d3d11_load); + if (!pD3D11CreateDevice || !pCreateDXGIFactory1) { + mp_fatal(log, "Failed to load base d3d11 functionality: " + "CreateDevice: %s, CreateDXGIFactory1: %s\n", + pD3D11CreateDevice ? "success" : "failure", + pCreateDXGIFactory1 ? "success": "failure"); + return false; + } + + return true; +} + // Get a const array of D3D_FEATURE_LEVELs from max_fl to min_fl (inclusive) static int get_feature_levels(int max_fl, int min_fl, const D3D_FEATURE_LEVEL **out) @@ -171,12 +185,7 @@ bool mp_d3d11_create_present_device(struct mp_log *log, bool success = false; HRESULT hr; - pthread_once(&d3d11_once, d3d11_load); - if (!pD3D11CreateDevice || !pCreateDXGIFactory1) { - mp_fatal(log, "Failed to load base d3d11 functionality: " - "CreateDevice: %s, CreateDXGIFactory1: %s\n", - pD3D11CreateDevice ? "success" : "failure", - pCreateDXGIFactory1 ? "success": "failure"); + if (!load_d3d11_functions(log)) { goto done; } |