forked from haasn/libplacebo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
d3d11.c
59 lines (48 loc) · 1.46 KB
/
d3d11.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "gpu_tests.h"
#include "d3d11/gpu.h"
#include <dxgi1_2.h>
#include <libplacebo/d3d11.h>
int main()
{
pl_log log = pl_test_logger();
IDXGIFactory1 *factory = NULL;
IDXGIAdapter1 *adapter1 = NULL;
HRESULT hr;
HMODULE dxgi = LoadLibraryW(L"dxgi.dll");
if (!dxgi)
return SKIP;
__typeof__(&CreateDXGIFactory1) pCreateDXGIFactory1 =
(void *) GetProcAddress(dxgi, "CreateDXGIFactory1");
if (!pCreateDXGIFactory1)
return SKIP;
hr = pCreateDXGIFactory1(&IID_IDXGIFactory1, (void **) &factory);
if (FAILED(hr)) {
printf("Failed to create DXGI factory\n");
return SKIP;
}
// Test all attached devices
for (int i = 0;; i++) {
hr = IDXGIFactory1_EnumAdapters1(factory, i, &adapter1);
if (hr == DXGI_ERROR_NOT_FOUND)
break;
if (FAILED(hr)) {
printf("Failed to enumerate adapters\n");
return SKIP;
}
DXGI_ADAPTER_DESC1 desc;
hr = IDXGIAdapter1_GetDesc1(adapter1, &desc);
if (FAILED(hr)) {
printf("Failed to enumerate adapters\n");
return SKIP;
}
SAFE_RELEASE(adapter1);
const struct pl_d3d11_t *d3d11 = pl_d3d11_create(log, pl_d3d11_params(
.debug = true,
.adapter_luid = desc.AdapterLuid,
));
REQUIRE(d3d11);
gpu_shader_tests(d3d11->gpu);
pl_d3d11_destroy(&d3d11);
}
SAFE_RELEASE(factory);
}