Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 D3dDevice::~D3dDevice() = default; | 24 D3dDevice::~D3dDevice() = default; |
| 25 | 25 |
| 26 bool D3dDevice::Initialize(const ComPtr<IDXGIAdapter>& adapter) { | 26 bool D3dDevice::Initialize(const ComPtr<IDXGIAdapter>& adapter) { |
| 27 dxgi_adapter_ = adapter; | 27 dxgi_adapter_ = adapter; |
| 28 if (!dxgi_adapter_) { | 28 if (!dxgi_adapter_) { |
| 29 LOG(LS_WARNING) << "An empty IDXGIAdapter instance has been received."; | 29 LOG(LS_WARNING) << "An empty IDXGIAdapter instance has been received."; |
| 30 return false; | 30 return false; |
| 31 } | 31 } |
| 32 | 32 |
| 33 D3D_FEATURE_LEVEL feature_level; | 33 D3D_FEATURE_LEVEL feature_level; |
| 34 // Default feature levels contain D3D 9.1 through D3D 11.0. | |
| 34 _com_error error = D3D11CreateDevice( | 35 _com_error error = D3D11CreateDevice( |
| 35 adapter.Get(), D3D_DRIVER_TYPE_UNKNOWN, nullptr, | 36 adapter.Get(), D3D_DRIVER_TYPE_UNKNOWN, nullptr, |
| 36 D3D11_CREATE_DEVICE_BGRA_SUPPORT | D3D11_CREATE_DEVICE_SINGLETHREADED, | 37 D3D11_CREATE_DEVICE_BGRA_SUPPORT | D3D11_CREATE_DEVICE_SINGLETHREADED, |
| 37 nullptr, 0, D3D11_SDK_VERSION, d3d_device_.GetAddressOf(), &feature_level, | 38 nullptr, 0, D3D11_SDK_VERSION, d3d_device_.GetAddressOf(), &feature_level, |
| 38 context_.GetAddressOf()); | 39 context_.GetAddressOf()); |
| 39 if (error.Error() != S_OK || !d3d_device_ || !context_) { | 40 if (error.Error() != S_OK || !d3d_device_ || !context_) { |
| 40 LOG(LS_WARNING) << "D3D11CreateDeivce returns error " | 41 LOG(LS_WARNING) << "D3D11CreateDeivce returns error " |
| 41 << error.ErrorMessage() << " with code " << error.Error(); | 42 << error.ErrorMessage() << " with code " << error.Error(); |
| 42 return false; | 43 return false; |
| 43 } | 44 } |
| 44 | 45 |
| 45 if (feature_level < D3D_FEATURE_LEVEL_11_0) { | 46 if (feature_level < D3D_FEATURE_LEVEL_11_0) { |
|
Sergey Ulanov
2016/11/07 19:37:16
Do we need this check at all? Maybe just log featu
Hzj_jie
2016/11/08 01:25:39
Indeed I cannot quite tell whether the following d
| |
| 46 LOG(LS_WARNING) << "D3D11CreateDevice returns an instance without DirectX " | 47 LOG(LS_WARNING) << "D3D11CreateDevice returns an instance without DirectX " |
| 47 "11 support, level " | 48 "11 support, level " << feature_level |
| 48 << feature_level; | 49 << ". Following initialization may fail."; |
| 49 return false; | 50 // D3D_FEATURE_LEVEL_11_0 is not officially documented on MSDN to be a |
| 51 // requirement of Dxgi duplicator APIs. | |
| 50 } | 52 } |
| 51 | 53 |
| 52 error = d3d_device_.As(&dxgi_device_); | 54 error = d3d_device_.As(&dxgi_device_); |
| 53 if (error.Error() != S_OK || !dxgi_device_) { | 55 if (error.Error() != S_OK || !dxgi_device_) { |
| 54 LOG(LS_WARNING) << "ID3D11Device is not an implementation of IDXGIDevice, " | 56 LOG(LS_WARNING) << "ID3D11Device is not an implementation of IDXGIDevice, " |
| 55 "this usually means the system does not support DirectX " | 57 "this usually means the system does not support DirectX " |
| 56 "11"; | 58 "11. Error " |
| 59 << error.ErrorMessage() << " with code " << error.Error(); | |
| 57 return false; | 60 return false; |
| 58 } | 61 } |
| 59 | 62 |
| 60 return true; | 63 return true; |
| 61 } | 64 } |
| 62 | 65 |
| 63 // static | 66 // static |
| 64 std::vector<D3dDevice> D3dDevice::EnumDevices() { | 67 std::vector<D3dDevice> D3dDevice::EnumDevices() { |
| 65 ComPtr<IDXGIFactory1> factory; | 68 ComPtr<IDXGIFactory1> factory; |
| 66 _com_error error = CreateDXGIFactory1(__uuidof(IDXGIFactory1), | 69 _com_error error = CreateDXGIFactory1(__uuidof(IDXGIFactory1), |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 85 LOG(LS_WARNING) << "IDXGIFactory1::EnumAdapters returns an unexpected " | 88 LOG(LS_WARNING) << "IDXGIFactory1::EnumAdapters returns an unexpected " |
| 86 "error " | 89 "error " |
| 87 << error.ErrorMessage() << " with code " << error.Error(); | 90 << error.ErrorMessage() << " with code " << error.Error(); |
| 88 return std::vector<D3dDevice>(); | 91 return std::vector<D3dDevice>(); |
| 89 } | 92 } |
| 90 } | 93 } |
| 91 return result; | 94 return result; |
| 92 } | 95 } |
| 93 | 96 |
| 94 } // namespace webrtc | 97 } // namespace webrtc |
| OLD | NEW |