Skip to content

Commit

Permalink
refactor(dx12): remove unsafe ops in `Adapter::texture_format_capab…
Browse files Browse the repository at this point in the history
…ilities` (#3194)
  • Loading branch information
ErichDonGubler authored Nov 30, 2022
1 parent 9bb2d28 commit 46b1216
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions wgpu-hal/src/dx12/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use crate::{
auxil::{self, dxgi::result::HResult as _},
dx12::SurfaceTarget,
};
use std::{mem, sync::Arc, thread};
use std::{mem, ptr, sync::Arc, thread};
use winapi::{
shared::{dxgi, dxgi1_2, windef, winerror},
shared::{dxgi, dxgi1_2, minwindef::DWORD, windef, winerror},
um::{d3d12, d3d12sdklayers, winuser},
};

Expand Down Expand Up @@ -382,16 +382,17 @@ impl crate::Adapter<super::Api> for super::Adapter {
// the features that use SRV/UAVs using the no-depth format.
let mut data_no_depth = d3d12::D3D12_FEATURE_DATA_FORMAT_SUPPORT {
Format: no_depth_format,
Support1: unsafe { mem::zeroed() },
Support2: unsafe { mem::zeroed() },
Support1: d3d12::D3D12_FORMAT_SUPPORT1_NONE,
Support2: d3d12::D3D12_FORMAT_SUPPORT2_NONE,
};
if raw_format != no_depth_format {
// Only-recheck if we're using a different format
assert_eq!(winerror::S_OK, unsafe {
self.device.CheckFeatureSupport(
d3d12::D3D12_FEATURE_FORMAT_SUPPORT,
&mut data_no_depth as *mut _ as *mut _,
mem::size_of::<d3d12::D3D12_FEATURE_DATA_FORMAT_SUPPORT>() as _,
ptr::addr_of_mut!(data_no_depth).cast(),
DWORD::try_from(mem::size_of::<d3d12::D3D12_FEATURE_DATA_FORMAT_SUPPORT>())
.unwrap(),
)
});
} else {
Expand Down

0 comments on commit 46b1216

Please sign in to comment.