VirtualBox

source: vbox/trunk/src/libs/dxvk-native-1.9.2a/tests/dxgi/test_dxgi_factory.cpp@ 104739

最後變更 在這個檔案從104739是 96497,由 vboxsync 提交於 3 年 前

libs/dxvk-native-1.9.2a: export to OSE

  • 屬性 svn:eol-style 設為 native
檔案大小: 3.9 KB
 
1#include <vector>
2
3#include <dxgi.h>
4
5#include <windows.h>
6#include <windowsx.h>
7
8#include "../test_utils.h"
9
10using namespace dxvk;
11
12int WINAPI WinMain(HINSTANCE hInstance,
13 HINSTANCE hPrevInstance,
14 LPSTR lpCmdLine,
15 int nCmdShow) {
16 Com<IDXGIFactory> factory;
17
18 if (CreateDXGIFactory(__uuidof(IDXGIFactory),
19 reinterpret_cast<void**>(&factory)) != S_OK) {
20 std::cerr << "Failed to create DXGI factory" << std::endl;
21 return 1;
22 }
23
24 Com<IDXGIAdapter> adapter;
25
26 for (UINT i = 0; factory->EnumAdapters(i, &adapter) == S_OK; i++) {
27 DXGI_ADAPTER_DESC adapterDesc;
28
29 if (adapter->GetDesc(&adapterDesc) != S_OK) {
30 std::cerr << "Failed to get DXGI adapter info" << std::endl;
31 return 1;
32 }
33
34 DXGI_ADAPTER_DESC desc;
35
36 if (adapter->GetDesc(&desc) != S_OK) {
37 std::cerr << "Failed to get DXGI adapter info" << std::endl;
38 return 1;
39 }
40
41 std::cout << str::format("Adapter ", i, ":") << std::endl;
42 std::cout << str::format(" ", desc.Description) << std::endl;
43 std::cout << str::format(" Vendor: ", desc.VendorId) << std::endl;
44 std::cout << str::format(" Device: ", desc.DeviceId) << std::endl;
45 std::cout << str::format(" Dedicated RAM: ", desc.DedicatedVideoMemory) << std::endl;
46 std::cout << str::format(" Shared RAM: ", desc.SharedSystemMemory) << std::endl;
47
48 Com<IDXGIOutput> output;
49
50 for (UINT j = 0; adapter->EnumOutputs(j, &output) == S_OK; j++) {
51 std::vector<DXGI_MODE_DESC> modes;
52
53 DXGI_OUTPUT_DESC desc;
54
55 if (output->GetDesc(&desc) != S_OK) {
56 std::cerr << "Failed to get DXGI output info" << std::endl;
57 return 1;
58 }
59
60 std::cout << str::format(" Output ", j, ":") << std::endl;
61 std::cout << str::format(" ", desc.DeviceName) << std::endl;
62 std::cout << str::format(" Coordinates: ",
63 desc.DesktopCoordinates.left, ",",
64 desc.DesktopCoordinates.top, ":",
65 desc.DesktopCoordinates.right - desc.DesktopCoordinates.left, "x",
66 desc.DesktopCoordinates.bottom - desc.DesktopCoordinates.top) << std::endl;
67
68 HRESULT status = S_OK;
69 UINT displayModeCount = 0;
70
71 do {
72 if (output->GetDisplayModeList(
73 DXGI_FORMAT_R8G8B8A8_UNORM,
74 DXGI_ENUM_MODES_SCALING,
75 &displayModeCount, nullptr) != S_OK) {
76 std::cerr << "Failed to get DXGI output display mode count" << std::endl;
77 return 1;
78 }
79
80 modes.resize(displayModeCount);
81
82 status = output->GetDisplayModeList(
83 DXGI_FORMAT_R8G8B8A8_UNORM,
84 DXGI_ENUM_MODES_SCALING,
85 &displayModeCount, modes.data());
86 } while (status == DXGI_ERROR_MORE_DATA);
87
88 if (status != S_OK) {
89 std::cerr << "Failed to get DXGI output display mode list" << std::endl;
90 return 1;
91 }
92
93 for (auto mode : modes) {
94 std::cout << str::format(" ",
95 mode.Width, "x", mode.Height, " @ ",
96 mode.RefreshRate.Numerator / mode.RefreshRate.Denominator,
97 mode.Scaling == DXGI_MODE_SCALING_CENTERED ? " (native)" : "") << std::endl;
98
99 //test matching modes
100 DXGI_MODE_DESC matched_mode{ 0 };
101 status = output->FindClosestMatchingMode(&mode, &matched_mode, nullptr);
102
103 if (status != S_OK) {
104 std::cerr << "Failed to get matching mode" << std::endl;
105 return 1;
106 }
107
108 if (matched_mode.Width != mode.Width ||
109 matched_mode.Height != mode.Height ||
110 matched_mode.RefreshRate.Numerator != mode.RefreshRate.Numerator ||
111 matched_mode.RefreshRate.Denominator != mode.RefreshRate.Denominator ||
112 matched_mode.Format != mode.Format)
113 {
114 std::cerr << "Matched mode is incorrect" << std::endl;
115 return 1;
116 }
117 }
118 }
119 }
120
121 return 0;
122}
123
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette