mirror of https://github.com/mpv-player/mpv
vo_gpu/d3d11: refactor pthread_once d3d11 loading to function
Lets us reuse this in the future.
This commit is contained in:
parent
b7438d3aff
commit
bca6e14702
|
@ -47,6 +47,20 @@ static void d3d11_load(void)
|
||||||
GetProcAddress(dxgilib, "CreateDXGIFactory1");
|
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)
|
// 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,
|
static int get_feature_levels(int max_fl, int min_fl,
|
||||||
const D3D_FEATURE_LEVEL **out)
|
const D3D_FEATURE_LEVEL **out)
|
||||||
|
@ -171,12 +185,7 @@ bool mp_d3d11_create_present_device(struct mp_log *log,
|
||||||
bool success = false;
|
bool success = false;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
pthread_once(&d3d11_once, d3d11_load);
|
if (!load_d3d11_functions(log)) {
|
||||||
if (!pD3D11CreateDevice || !pCreateDXGIFactory1) {
|
|
||||||
mp_fatal(log, "Failed to load base d3d11 functionality: "
|
|
||||||
"CreateDevice: %s, CreateDXGIFactory1: %s\n",
|
|
||||||
pD3D11CreateDevice ? "success" : "failure",
|
|
||||||
pCreateDXGIFactory1 ? "success": "failure");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue