Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Windows 7 DXGI compatibility #1311

Merged
merged 2 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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