Skip to content

Commit 2c194dc

Browse files
bors[bot]fkaa
andcommitted
2128: [dx11] fix some dxgi calls not being present on windows 7 r=kvark a=fkaa In particular the `CreateDXGIFactory2` was used to create the factory, but it is not present on older dxgi versions. Other function calls shouldn't be affected since the factory creation infers the dxgi version and tip-toes around the newer functions. Fixes #issue PR checklist: - [ ] `make` succeeds (on *nix) - [ ] `make reftests` succeeds - [ ] tested examples with the following backends: Co-authored-by: Felix Kaaman <[email protected]>
2 parents 2e46eca + af393dc commit 2c194dc

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/backend/dx11/src/device.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,16 +1246,18 @@ impl hal::Device<Backend> for Device {
12461246
unsafe { ComPtr::from_raw(swapchain) }
12471247
};
12481248

1249-
let images = (0..config.image_count).map(|i| {
1249+
// TODO: for now we clamp to 1 buffer..
1250+
let images = (0..config.image_count.min(1)).map(|i| {
12501251
let mut resource: *mut d3d11::ID3D11Resource = ptr::null_mut();
12511252

1252-
unsafe {
1253+
let hr = unsafe {
12531254
swapchain.GetBuffer(
12541255
i as _,
12551256
&d3d11::IID_ID3D11Resource,
12561257
&mut resource as *mut *mut _ as *mut *mut _
1257-
);
1258+
)
12581259
};
1260+
assert_eq!(hr, winerror::S_OK);
12591261

12601262
let mut desc: d3d11::D3D11_RENDER_TARGET_VIEW_DESC = unsafe { mem::zeroed() };
12611263
desc.Format = format;

src/backend/dx11/src/dxgi.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,16 @@ fn create_dxgi_factory1(guid: &GUID) -> Result<ComPtr<dxgi::IDXGIFactory>, winer
105105
pub(crate) fn get_dxgi_factory() -> Result<(ComPtr<dxgi::IDXGIFactory>, DxgiVersion), winerror::HRESULT> {
106106
let mut factory: *mut IUnknown = ptr::null_mut();
107107

108-
if let Ok(factory) = create_dxgi_factory2(&dxgi1_5::IDXGIFactory5::uuidof()) {
108+
// TODO: do we even need `create_dxgi_factory2`?
109+
if let Ok(factory) = create_dxgi_factory1(&dxgi1_5::IDXGIFactory5::uuidof()) {
109110
return Ok((factory, DxgiVersion::Dxgi1_5));
110111
}
111112

112-
if let Ok(factory) = create_dxgi_factory2(&dxgi1_4::IDXGIFactory4::uuidof()) {
113+
if let Ok(factory) = create_dxgi_factory1(&dxgi1_4::IDXGIFactory4::uuidof()) {
113114
return Ok((factory, DxgiVersion::Dxgi1_4));
114115
}
115116

116-
if let Ok(factory) = create_dxgi_factory2(&dxgi1_3::IDXGIFactory3::uuidof()) {
117+
if let Ok(factory) = create_dxgi_factory1(&dxgi1_3::IDXGIFactory3::uuidof()) {
117118
return Ok((factory, DxgiVersion::Dxgi1_3));
118119
}
119120

0 commit comments

Comments
 (0)