OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 return false; | 40 return false; |
41 } | 41 } |
42 | 42 |
43 if (feature_level < D3D_FEATURE_LEVEL_11_0) { | 43 if (feature_level < D3D_FEATURE_LEVEL_11_0) { |
44 LOG(LS_WARNING) << "D3D11CreateDevice returns an instance without DirectX " | 44 LOG(LS_WARNING) << "D3D11CreateDevice returns an instance without DirectX " |
45 "11 support, level " | 45 "11 support, level " |
46 << feature_level; | 46 << feature_level; |
47 return false; | 47 return false; |
48 } | 48 } |
49 | 49 |
50 error = _com_error(d3d_device_.As(&dxgi_device_)); | 50 error = d3d_device_.As(&dxgi_device_); |
51 if (error.Error() != S_OK || !dxgi_device_) { | 51 if (error.Error() != S_OK || !dxgi_device_) { |
52 LOG(LS_WARNING) << "ID3D11Device is not an implementation of IDXGIDevice, " | 52 LOG(LS_WARNING) << "ID3D11Device is not an implementation of IDXGIDevice, " |
53 "this usually means the system does not support DirectX " | 53 "this usually means the system does not support DirectX " |
54 "11"; | 54 "11"; |
55 return false; | 55 return false; |
56 } | 56 } |
57 | 57 |
58 return true; | 58 return true; |
59 } | 59 } |
60 | 60 |
61 // static | 61 // static |
62 std::vector<D3dDevice> D3dDevice::EnumDevices() { | 62 std::vector<D3dDevice> D3dDevice::EnumDevices() { |
63 ComPtr<IDXGIFactory1> factory; | 63 ComPtr<IDXGIFactory1> factory; |
64 _com_error error = _com_error( | 64 _com_error error = CreateDXGIFactory1(__uuidof(IDXGIFactory1), |
65 CreateDXGIFactory1(__uuidof(IDXGIFactory1), | 65 reinterpret_cast<void**>(factory.GetAddressOf())); |
66 reinterpret_cast<void**>(factory.GetAddressOf()))); | |
67 if (error.Error() != S_OK || !factory) { | 66 if (error.Error() != S_OK || !factory) { |
68 return std::vector<D3dDevice>(); | 67 return std::vector<D3dDevice>(); |
69 } | 68 } |
70 | 69 |
71 std::vector<D3dDevice> result; | 70 std::vector<D3dDevice> result; |
72 for (int i = 0;; i++) { | 71 for (int i = 0;; i++) { |
73 ComPtr<IDXGIAdapter> adapter; | 72 ComPtr<IDXGIAdapter> adapter; |
74 error = _com_error(factory->EnumAdapters(i, adapter.GetAddressOf())); | 73 error = factory->EnumAdapters(i, adapter.GetAddressOf()); |
75 if (error.Error() == S_OK) { | 74 if (error.Error() == S_OK) { |
76 D3dDevice device; | 75 D3dDevice device; |
77 if (!device.Initialize(adapter)) { | 76 if (!device.Initialize(adapter)) { |
78 return std::vector<D3dDevice>(); | 77 return std::vector<D3dDevice>(); |
79 } | 78 } |
80 result.push_back(std::move(device)); | 79 result.push_back(std::move(device)); |
81 } else if (error.Error() == DXGI_ERROR_NOT_FOUND) { | 80 } else if (error.Error() == DXGI_ERROR_NOT_FOUND) { |
82 break; | 81 break; |
83 } else { | 82 } else { |
84 LOG(LS_WARNING) << "IDXGIFactory1::EnumAdapters returns an unexpected " | 83 LOG(LS_WARNING) << "IDXGIFactory1::EnumAdapters returns an unexpected " |
85 "error " | 84 "error " |
86 << error.ErrorMessage() << " with code " << error.Error(); | 85 << error.ErrorMessage() << " with code " << error.Error(); |
87 return std::vector<D3dDevice>(); | 86 return std::vector<D3dDevice>(); |
88 } | 87 } |
89 } | 88 } |
90 return result; | 89 return result; |
91 } | 90 } |
92 | 91 |
93 } // namespace webrtc | 92 } // namespace webrtc |
OLD | NEW |