vo_gpu: d3d11_helpers: don't try BGRA_SUPPORT

The D3D11_CREATE_DEVICE_BGRA_SUPPORT flag doesn't enable support for
BGRA textures. BGRA textures will be supported whether or not the flag
is passed. The flag just fails device creation if they are not supported
as an API convenience for programs that need BGRA textures, such as
programs that use D2D or D3D9 interop. We can handle devices without
BGRA support fine, so don't bother with the flag.
This commit is contained in:
James Ross-Gowan 2017-11-19 21:37:08 +11:00
parent 021fe791e1
commit b9c742df10
1 changed files with 4 additions and 20 deletions

View File

@ -72,9 +72,8 @@ static int get_feature_levels(int max_fl, int min_fl,
return len; return len;
} }
static HRESULT create_device(struct mp_log *log, bool warp, bool bgra, static HRESULT create_device(struct mp_log *log, bool warp, bool debug,
bool debug, int max_fl, int min_fl, int max_fl, int min_fl, ID3D11Device **dev)
ID3D11Device **dev)
{ {
const D3D_FEATURE_LEVEL *levels; const D3D_FEATURE_LEVEL *levels;
int levels_len = get_feature_levels(max_fl, min_fl, &levels); int levels_len = get_feature_levels(max_fl, min_fl, &levels);
@ -85,11 +84,7 @@ static HRESULT create_device(struct mp_log *log, bool warp, bool bgra,
D3D_DRIVER_TYPE type = warp ? D3D_DRIVER_TYPE_WARP D3D_DRIVER_TYPE type = warp ? D3D_DRIVER_TYPE_WARP
: D3D_DRIVER_TYPE_HARDWARE; : D3D_DRIVER_TYPE_HARDWARE;
UINT flags = 0; UINT flags = debug ? D3D11_CREATE_DEVICE_DEBUG : 0;
if (bgra)
flags |= D3D11_CREATE_DEVICE_BGRA_SUPPORT;
if (debug)
flags |= D3D11_CREATE_DEVICE_DEBUG;
return pD3D11CreateDevice(NULL, type, NULL, flags, levels, levels_len, return pD3D11CreateDevice(NULL, type, NULL, flags, levels, levels_len,
D3D11_SDK_VERSION, dev, NULL, NULL); D3D11_SDK_VERSION, dev, NULL, NULL);
} }
@ -102,7 +97,6 @@ bool mp_d3d11_create_present_device(struct mp_log *log,
ID3D11Device **dev_out) ID3D11Device **dev_out)
{ {
bool warp = opts->force_warp; bool warp = opts->force_warp;
bool bgra = true;
int max_fl = opts->max_feature_level; int max_fl = opts->max_feature_level;
int min_fl = opts->min_feature_level; int min_fl = opts->min_feature_level;
ID3D11Device *dev = NULL; ID3D11Device *dev = NULL;
@ -123,17 +117,10 @@ bool mp_d3d11_create_present_device(struct mp_log *log,
max_fl = max_fl ? max_fl : D3D_FEATURE_LEVEL_11_0; max_fl = max_fl ? max_fl : D3D_FEATURE_LEVEL_11_0;
min_fl = min_fl ? min_fl : D3D_FEATURE_LEVEL_9_1; min_fl = min_fl ? min_fl : D3D_FEATURE_LEVEL_9_1;
hr = create_device(log, warp, bgra, opts->debug, max_fl, min_fl, &dev); hr = create_device(log, warp, opts->debug, max_fl, min_fl, &dev);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
break; break;
// BGRA is recommended, but FL 10_0 hardware may not support it
if (bgra) {
mp_dbg(log, "Failed to create D3D device with BGRA support\n");
bgra = false;
continue;
}
// Trying to create a D3D_FEATURE_LEVEL_12_0 device on Windows 8.1 or // Trying to create a D3D_FEATURE_LEVEL_12_0 device on Windows 8.1 or
// below will not succeed. Try an 11_1 device. // below will not succeed. Try an 11_1 device.
if (max_fl >= D3D_FEATURE_LEVEL_12_0 && if (max_fl >= D3D_FEATURE_LEVEL_12_0 &&
@ -141,7 +128,6 @@ bool mp_d3d11_create_present_device(struct mp_log *log,
{ {
mp_dbg(log, "Failed to create 12_0+ device, trying 11_1\n"); mp_dbg(log, "Failed to create 12_0+ device, trying 11_1\n");
max_fl = D3D_FEATURE_LEVEL_11_1; max_fl = D3D_FEATURE_LEVEL_11_1;
bgra = true;
continue; continue;
} }
@ -152,7 +138,6 @@ bool mp_d3d11_create_present_device(struct mp_log *log,
{ {
mp_dbg(log, "Failed to create 11_1+ device, trying 11_0\n"); mp_dbg(log, "Failed to create 11_1+ device, trying 11_0\n");
max_fl = D3D_FEATURE_LEVEL_11_0; max_fl = D3D_FEATURE_LEVEL_11_0;
bgra = true;
continue; continue;
} }
@ -162,7 +147,6 @@ bool mp_d3d11_create_present_device(struct mp_log *log,
warp = true; warp = true;
max_fl = opts->max_feature_level; max_fl = opts->max_feature_level;
min_fl = opts->min_feature_level; min_fl = opts->min_feature_level;
bgra = true;
continue; continue;
} }