diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2023-11-08 00:01:47 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2023-11-22 11:43:20 +0100 |
commit | 66e3b53eb930e1dba7d10c9dc52f45af06932e88 (patch) | |
tree | abb409d390bdfb039efb9a7fcb7d86a35d27fb62 /video/out | |
parent | eb7ba44acf07f3358a49bafa61c9581c9b16ab85 (diff) | |
download | mpv-66e3b53eb930e1dba7d10c9dc52f45af06932e88.tar.bz2 mpv-66e3b53eb930e1dba7d10c9dc52f45af06932e88.tar.xz |
d3d11: expose mp_get_dxgi_adapter and mp_dxgi_validate_adapter
To be able to reuse them in other parts of code.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/d3d11/context.c | 37 | ||||
-rw-r--r-- | video/out/gpu/d3d11_helpers.c | 41 | ||||
-rw-r--r-- | video/out/gpu/d3d11_helpers.h | 8 |
3 files changed, 45 insertions, 41 deletions
diff --git a/video/out/d3d11/context.c b/video/out/d3d11/context.c index faf2a712fd..96d37ff5d5 100644 --- a/video/out/d3d11/context.c +++ b/video/out/d3d11/context.c @@ -27,10 +27,6 @@ #include "context.h" #include "ra_d3d11.h" -static int dxgi_validate_adapter(struct mp_log *log, - const struct m_option *opt, - struct bstr name, const char **value); - struct d3d11_opts { int feature_level; int warp; @@ -62,7 +58,7 @@ const struct m_sub_options d3d11_conf = { {"d3d11-flip", OPT_BOOL(flip)}, {"d3d11-sync-interval", OPT_INT(sync_interval), M_RANGE(0, 4)}, {"d3d11-adapter", OPT_STRING_VALIDATE(adapter_name, - dxgi_validate_adapter)}, + mp_dxgi_validate_adapter)}, {"d3d11-output-format", OPT_CHOICE(output_format, {"auto", DXGI_FORMAT_UNKNOWN}, {"rgba8", DXGI_FORMAT_R8G8B8A8_UNORM}, @@ -109,37 +105,6 @@ struct priv { int64_t last_submit_qpc; }; -static int dxgi_validate_adapter(struct mp_log *log, - const struct m_option *opt, - struct bstr name, const char **value) -{ - struct bstr param = bstr0(*value); - bool help = bstr_equals0(param, "help"); - bool adapter_matched = false; - struct bstr listing = { 0 }; - - if (bstr_equals0(param, "")) { - return 0; - } - - adapter_matched = mp_dxgi_list_or_verify_adapters(log, - help ? bstr0(NULL) : param, - help ? &listing : NULL); - - if (help) { - mp_info(log, "Available DXGI adapters:\n%.*s", - BSTR_P(listing)); - talloc_free(listing.start); - return M_OPT_EXIT; - } - - if (!adapter_matched) { - mp_err(log, "No adapter matching '%.*s'!\n", BSTR_P(param)); - } - - return adapter_matched ? 0 : M_OPT_INVALID; -} - static struct ra_tex *get_backbuffer(struct ra_ctx *ctx) { struct priv *p = ctx->priv; diff --git a/video/out/gpu/d3d11_helpers.c b/video/out/gpu/d3d11_helpers.c index 08d1013cbd..033b593f8b 100644 --- a/video/out/gpu/d3d11_helpers.c +++ b/video/out/gpu/d3d11_helpers.c @@ -371,9 +371,9 @@ static int get_feature_levels(int max_fl, int min_fl, return len; } -static IDXGIAdapter1 *get_dxgi_adapter(struct mp_log *log, - struct bstr requested_adapter_name, - struct bstr *listing) +IDXGIAdapter1 *mp_get_dxgi_adapter(struct mp_log *log, + bstr requested_adapter_name, + bstr *listing) { HRESULT hr = S_OK; IDXGIFactory1 *factory; @@ -437,6 +437,37 @@ static IDXGIAdapter1 *get_dxgi_adapter(struct mp_log *log, return picked_adapter; } +int mp_dxgi_validate_adapter(struct mp_log *log, + const struct m_option *opt, + struct bstr name, const char **value) +{ + struct bstr param = bstr0(*value); + bool help = bstr_equals0(param, "help"); + bool adapter_matched = false; + struct bstr listing = { 0 }; + + if (bstr_equals0(param, "")) { + return 0; + } + + adapter_matched = mp_dxgi_list_or_verify_adapters(log, + help ? bstr0(NULL) : param, + help ? &listing : NULL); + + if (help) { + mp_info(log, "Available DXGI adapters:\n%.*s", + BSTR_P(listing)); + talloc_free(listing.start); + return M_OPT_EXIT; + } + + if (!adapter_matched) { + mp_err(log, "No adapter matching '%.*s'!\n", BSTR_P(param)); + } + + return adapter_matched ? 0 : M_OPT_INVALID; +} + static HRESULT create_device(struct mp_log *log, IDXGIAdapter1 *adapter, bool warp, bool debug, int max_fl, int min_fl, ID3D11Device **dev) @@ -465,7 +496,7 @@ bool mp_dxgi_list_or_verify_adapters(struct mp_log *log, return false; } - if ((picked_adapter = get_dxgi_adapter(log, adapter_name, listing))) { + if ((picked_adapter = mp_get_dxgi_adapter(log, adapter_name, listing))) { SAFE_RELEASE(picked_adapter); return true; } @@ -497,7 +528,7 @@ bool mp_d3d11_create_present_device(struct mp_log *log, goto done; } - adapter = get_dxgi_adapter(log, bstr0(adapter_name), NULL); + adapter = mp_get_dxgi_adapter(log, bstr0(adapter_name), NULL); if (adapter_name && !adapter) { mp_warn(log, "Adapter matching '%s' was not found in the system! " diff --git a/video/out/gpu/d3d11_helpers.h b/video/out/gpu/d3d11_helpers.h index 0d44ae6536..51a2a207c6 100644 --- a/video/out/gpu/d3d11_helpers.h +++ b/video/out/gpu/d3d11_helpers.h @@ -65,6 +65,14 @@ struct d3d11_device_opts { char *adapter_name; }; +IDXGIAdapter1 *mp_get_dxgi_adapter(struct mp_log *log, + bstr requested_adapter_name, + bstr *listing); + +int mp_dxgi_validate_adapter(struct mp_log *log, + const struct m_option *opt, + struct bstr name, const char **value); + bool mp_dxgi_list_or_verify_adapters(struct mp_log *log, bstr adapter_name, bstr *listing); |