Skip to content

Commit

Permalink
Merge pull request #1311 from linebender/win7_compat
Browse files Browse the repository at this point in the history
Improve Windows 7 DXGI compatibility
  • Loading branch information
raphlinus authored Oct 14, 2020
2 parents 76baabd + fddb814 commit 21673f5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ You can find its changes [documented below](#060---2020-06-01).
- Able to select text in multiple TextBoxes at once. ([#1276] by [@sysint64])
- The scroll bar now shows when the contents of a scrollable area change size. ([#1278] by [@Majora320])
- Fix `widget::Either` using the wrong paint insets ([#1299] by [@andrewhickman])
- Improve Windows 7 DXGI compatibility ([#1311] by [@raphlinus])

### Visual

Expand Down Expand Up @@ -499,6 +500,7 @@ Last release without a changelog :(
[#1295]: https://github.com/linebender/druid/pull/1280
[#1298]: https://github.com/linebender/druid/pull/1298
[#1299]: https://github.com/linebender/druid/pull/1299
[#1311]: https://github.com/linebender/druid/pull/1311

[Unreleased]: https://github.com/linebender/druid/compare/v0.6.0...master
[0.6.0]: https://github.com/linebender/druid/compare/v0.5.0...v0.6.0
Expand Down
36 changes: 22 additions & 14 deletions druid-shell/src/platform/windows/dcomp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use log::error;

use winapi::shared::winerror::SUCCEEDED;
use winapi::um::d3d11::*;
use winapi::um::d3dcommon::D3D_DRIVER_TYPE_HARDWARE;
use winapi::um::d3dcommon::{D3D_DRIVER_TYPE_HARDWARE, D3D_DRIVER_TYPE_WARP};
use winapi::um::winnt::HRESULT;
use winapi::Interface;
use wio::com::ComPtr;
Expand All @@ -45,21 +45,29 @@ pub struct D3D11Device(ComPtr<ID3D11Device>);
impl D3D11Device {
/// Creates a new device with basic defaults.
pub(crate) fn new_simple() -> Result<D3D11Device, HRESULT> {
let mut hr = 0;
unsafe {
let mut d3d11_device: *mut ID3D11Device = null_mut();
let flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; // could probably set single threaded
let hr = D3D11CreateDevice(
null_mut(),
D3D_DRIVER_TYPE_HARDWARE,
null_mut(),
flags,
null(),
0,
D3D11_SDK_VERSION,
&mut d3d11_device,
null_mut(),
null_mut(),
);
// Note: could probably set single threaded in flags for small performance boost.
let flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
// Prefer hardware but use warp if it's the only driver available.
for driver_type in &[D3D_DRIVER_TYPE_HARDWARE, D3D_DRIVER_TYPE_WARP] {
hr = D3D11CreateDevice(
null_mut(),
*driver_type,
null_mut(),
flags,
null(),
0,
D3D11_SDK_VERSION,
&mut d3d11_device,
null_mut(),
null_mut(),
);
if SUCCEEDED(hr) {
break;
}
}
if !SUCCEEDED(hr) {
error!("D3D11CreateDevice: 0x{:x}", hr);
}
Expand Down

0 comments on commit 21673f5

Please sign in to comment.