diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2024-03-06 06:41:53 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2024-03-17 14:28:00 +0100 |
commit | 2b0c7b1aa4a9fcc2cc44458bc00963675074748a (patch) | |
tree | 0841b0e5057a2a977afb8aaff55a7c61d8ef6fc8 | |
parent | 3afcaeb71a01fbacbbd0208b14e5263165bf169b (diff) | |
download | mpv-2b0c7b1aa4a9fcc2cc44458bc00963675074748a.tar.bz2 mpv-2b0c7b1aa4a9fcc2cc44458bc00963675074748a.tar.xz |
d3d11: add mp_get_dxgi_output_desc
-rw-r--r-- | video/out/gpu/d3d11_helpers.c | 44 | ||||
-rw-r--r-- | video/out/gpu/d3d11_helpers.h | 3 |
2 files changed, 25 insertions, 22 deletions
diff --git a/video/out/gpu/d3d11_helpers.c b/video/out/gpu/d3d11_helpers.c index 7adc2752d2..d45c038553 100644 --- a/video/out/gpu/d3d11_helpers.c +++ b/video/out/gpu/d3d11_helpers.c @@ -287,28 +287,8 @@ static bool query_output_format_and_colorspace(struct mp_log *log, if (!out_fmt || !out_cspace) return false; - HRESULT hr = IDXGISwapChain_GetContainingOutput(swapchain, &output); - if (FAILED(hr)) { - mp_err(log, "Failed to get swap chain's containing output: %s!\n", - mp_HRESULT_to_str(hr)); - goto done; - } - - hr = IDXGIOutput_QueryInterface(output, &IID_IDXGIOutput6, - (void**)&output6); - if (FAILED(hr)) { - // point where systems older than Windows 10 would fail, - // thus utilizing error log level only with windows 10+ - mp_msg(log, IsWindows10OrGreater() ? MSGL_ERR : MSGL_V, - "Failed to create a DXGI 1.6 output interface: %s\n", - mp_HRESULT_to_str(hr)); - goto done; - } - - hr = IDXGIOutput6_GetDesc1(output6, &desc); - if (FAILED(hr)) { - mp_err(log, "Failed to query swap chain's output information: %s\n", - mp_HRESULT_to_str(hr)); + if (!mp_get_dxgi_output_desc(swapchain, &desc)) { + mp_err(log, "Failed to query swap chain's output information\n"); goto done; } @@ -995,3 +975,23 @@ done: SAFE_RELEASE(dxgi_dev); return success; } + +bool mp_get_dxgi_output_desc(IDXGISwapChain *swapchain, DXGI_OUTPUT_DESC1 *desc) +{ + bool ret = false; + IDXGIOutput *output = NULL; + IDXGIOutput6 *output6 = NULL; + + if (FAILED(IDXGISwapChain_GetContainingOutput(swapchain, &output))) + goto done; + + if (FAILED(IDXGIOutput_QueryInterface(output, &IID_IDXGIOutput6, (void**)&output6))) + goto done; + + ret = SUCCEEDED(IDXGIOutput6_GetDesc1(output6, desc)); + +done: + SAFE_RELEASE(output); + SAFE_RELEASE(output6); + return ret; +} diff --git a/video/out/gpu/d3d11_helpers.h b/video/out/gpu/d3d11_helpers.h index 5ba013e747..6cc6818064 100644 --- a/video/out/gpu/d3d11_helpers.h +++ b/video/out/gpu/d3d11_helpers.h @@ -22,6 +22,7 @@ #include <windows.h> #include <d3d11.h> #include <dxgi1_2.h> +#include <dxgi1_6.h> #include "video/mp_image.h" @@ -69,6 +70,8 @@ IDXGIAdapter1 *mp_get_dxgi_adapter(struct mp_log *log, bstr requested_adapter_name, bstr *listing); +bool mp_get_dxgi_output_desc(IDXGISwapChain *swapchain, DXGI_OUTPUT_DESC1 *desc); + OPT_STRING_VALIDATE_FUNC(mp_dxgi_validate_adapter); bool mp_dxgi_list_or_verify_adapters(struct mp_log *log, |