summaryrefslogtreecommitdiffstats
path: root/video/out/gpu
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2019-09-29 18:21:59 +0300
committerJan Ekström <jeebjp@gmail.com>2019-09-29 19:39:26 +0300
commit1f76e6914596868e53b5ed4f50353ba44177ab4c (patch)
tree6fa257365f34b0aae5607a078c0fbe3cddf05112 /video/out/gpu
parentbca6e14702998220b5744546f17da5e3e75d2f06 (diff)
downloadmpv-1f76e6914596868e53b5ed4f50353ba44177ab4c.tar.bz2
mpv-1f76e6914596868e53b5ed4f50353ba44177ab4c.tar.xz
vo_gpu/d3d11: add adapter name validation and listing with "help"
Not the prettiest way to get it done, but seems to work.
Diffstat (limited to 'video/out/gpu')
-rw-r--r--video/out/gpu/d3d11_helpers.c38
-rw-r--r--video/out/gpu/d3d11_helpers.h4
2 files changed, 37 insertions, 5 deletions
diff --git a/video/out/gpu/d3d11_helpers.c b/video/out/gpu/d3d11_helpers.c
index cfabfbe3ab..14a30faa86 100644
--- a/video/out/gpu/d3d11_helpers.c
+++ b/video/out/gpu/d3d11_helpers.c
@@ -22,6 +22,7 @@
#include "common/common.h"
#include "common/msg.h"
+#include "misc/bstr.h"
#include "osdep/io.h"
#include "osdep/windows_utils.h"
@@ -92,7 +93,9 @@ static int get_feature_levels(int max_fl, int min_fl,
return len;
}
-static IDXGIAdapter1 *get_d3d11_adapter(struct mp_log *log, char *requested_adapter_name)
+static IDXGIAdapter1 *get_d3d11_adapter(struct mp_log *log,
+ char *requested_adapter_name,
+ struct bstr *listing)
{
HRESULT hr = S_OK;
IDXGIFactory1 *factory;
@@ -128,9 +131,12 @@ static IDXGIAdapter1 *get_d3d11_adapter(struct mp_log *log, char *requested_adap
adapter_description = mp_to_utf8(NULL, desc.Description);
- mp_verbose(log, "Adapter %u: vendor: %u, description: %s\n",
- adapter_num, desc.VendorId,
- adapter_description ? adapter_description : "<No Description>");
+ if (listing) {
+ bstr_xappend_asprintf(NULL, listing,
+ "Adapter %u: vendor: %u, description: %s\n",
+ adapter_num, desc.VendorId,
+ adapter_description ? adapter_description : "<No Description>");
+ }
if (requested_adapter_name && adapter_description &&
!strcmp(requested_adapter_name, adapter_description))
@@ -166,6 +172,28 @@ static HRESULT create_device(struct mp_log *log, IDXGIAdapter1 *adapter,
NULL, flags, levels, levels_len, D3D11_SDK_VERSION, dev, NULL, NULL);
}
+bool mp_d3d11_list_or_verify_adapters(struct mp_log *log,
+ bstr *adapter_name,
+ bstr *listing)
+{
+ IDXGIAdapter1 *picked_adapter = NULL;
+
+ if (!load_d3d11_functions(log)) {
+ return false;
+ }
+
+ if ((picked_adapter = get_d3d11_adapter(log,
+ adapter_name ?
+ (char *)adapter_name->start : NULL,
+ listing)))
+ {
+ SAFE_RELEASE(picked_adapter);
+ return true;
+ }
+
+ return false;
+}
+
// Create a Direct3D 11 device for rendering and presentation. This is meant to
// reduce boilerplate in backends that D3D11, while also making sure they share
// the same device creation logic and log the same information.
@@ -189,7 +217,7 @@ bool mp_d3d11_create_present_device(struct mp_log *log,
goto done;
}
- adapter = get_d3d11_adapter(log, adapter_name);
+ adapter = get_d3d11_adapter(log, adapter_name, NULL);
if (adapter_name && !adapter) {
mp_warn(log, "Adapter '%s' was not found in the system! "
diff --git a/video/out/gpu/d3d11_helpers.h b/video/out/gpu/d3d11_helpers.h
index c28afc5405..705c5a59cb 100644
--- a/video/out/gpu/d3d11_helpers.h
+++ b/video/out/gpu/d3d11_helpers.h
@@ -59,6 +59,10 @@ struct d3d11_device_opts {
char *adapter_name;
};
+bool mp_d3d11_list_or_verify_adapters(struct mp_log *log,
+ bstr *adapter_name,
+ bstr *listing);
+
bool mp_d3d11_create_present_device(struct mp_log *log,
struct d3d11_device_opts *opts,
ID3D11Device **dev_out);