@@ -29,15 +29,17 @@ impl Drop for super::Adapter {
29
29
30
30
impl super :: Adapter {
31
31
pub unsafe fn report_live_objects ( & self ) {
32
- if let Ok ( debug_device) = self
33
- . raw
34
- . cast :: < d3d12sdklayers:: ID3D12DebugDevice > ( )
35
- . into_result ( )
36
- {
37
- debug_device. ReportLiveDeviceObjects (
38
- d3d12sdklayers:: D3D12_RLDO_SUMMARY | d3d12sdklayers:: D3D12_RLDO_IGNORE_INTERNAL ,
39
- ) ;
40
- debug_device. destroy ( ) ;
32
+ if let Ok ( debug_device) = unsafe {
33
+ self . raw
34
+ . cast :: < d3d12sdklayers:: ID3D12DebugDevice > ( )
35
+ . into_result ( )
36
+ } {
37
+ unsafe {
38
+ debug_device. ReportLiveDeviceObjects (
39
+ d3d12sdklayers:: D3D12_RLDO_SUMMARY | d3d12sdklayers:: D3D12_RLDO_IGNORE_INTERNAL ,
40
+ )
41
+ } ;
42
+ unsafe { debug_device. destroy ( ) } ;
41
43
}
42
44
}
43
45
@@ -365,35 +367,33 @@ impl crate::Adapter<super::Api> for super::Adapter {
365
367
366
368
let mut data = d3d12:: D3D12_FEATURE_DATA_FORMAT_SUPPORT {
367
369
Format : raw_format,
368
- Support1 : mem:: zeroed ( ) ,
369
- Support2 : mem:: zeroed ( ) ,
370
+ Support1 : unsafe { mem:: zeroed ( ) } ,
371
+ Support2 : unsafe { mem:: zeroed ( ) } ,
370
372
} ;
371
- assert_eq ! (
372
- winerror:: S_OK ,
373
+ assert_eq ! ( winerror:: S_OK , unsafe {
373
374
self . device. CheckFeatureSupport (
374
375
d3d12:: D3D12_FEATURE_FORMAT_SUPPORT ,
375
376
& mut data as * mut _ as * mut _,
376
377
mem:: size_of:: <d3d12:: D3D12_FEATURE_DATA_FORMAT_SUPPORT >( ) as _,
377
378
)
378
- ) ;
379
+ } ) ;
379
380
380
381
// Because we use a different format for SRV and UAV views of depth textures, we need to check
381
382
// the features that use SRV/UAVs using the no-depth format.
382
383
let mut data_no_depth = d3d12:: D3D12_FEATURE_DATA_FORMAT_SUPPORT {
383
384
Format : no_depth_format,
384
- Support1 : mem:: zeroed ( ) ,
385
- Support2 : mem:: zeroed ( ) ,
385
+ Support1 : unsafe { mem:: zeroed ( ) } ,
386
+ Support2 : unsafe { mem:: zeroed ( ) } ,
386
387
} ;
387
388
if raw_format != no_depth_format {
388
389
// Only-recheck if we're using a different format
389
- assert_eq ! (
390
- winerror:: S_OK ,
390
+ assert_eq ! ( winerror:: S_OK , unsafe {
391
391
self . device. CheckFeatureSupport (
392
392
d3d12:: D3D12_FEATURE_FORMAT_SUPPORT ,
393
393
& mut data_no_depth as * mut _ as * mut _,
394
394
mem:: size_of:: <d3d12:: D3D12_FEATURE_DATA_FORMAT_SUPPORT >( ) as _,
395
395
)
396
- ) ;
396
+ } ) ;
397
397
} else {
398
398
// Same format, just copy over.
399
399
data_no_depth = data;
@@ -462,11 +462,13 @@ impl crate::Adapter<super::Api> for super::Adapter {
462
462
let mut set_sample_count = |sc : u32 , tfc : Tfc | {
463
463
ms_levels. SampleCount = sc;
464
464
465
- if self . device . CheckFeatureSupport (
466
- d3d12:: D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS ,
467
- <* mut _ >:: cast ( & mut ms_levels) ,
468
- mem:: size_of :: < d3d12:: D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS > ( ) as _ ,
469
- ) == winerror:: S_OK
465
+ if unsafe {
466
+ self . device . CheckFeatureSupport (
467
+ d3d12:: D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS ,
468
+ <* mut _ >:: cast ( & mut ms_levels) ,
469
+ mem:: size_of :: < d3d12:: D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS > ( ) as _ ,
470
+ )
471
+ } == winerror:: S_OK
470
472
&& ms_levels. NumQualityLevels != 0
471
473
{
472
474
caps. set ( tfc, !no_msaa_load && !no_msaa_target) ;
@@ -487,8 +489,8 @@ impl crate::Adapter<super::Api> for super::Adapter {
487
489
let current_extent = {
488
490
match surface. target {
489
491
SurfaceTarget :: WndHandle ( wnd_handle) => {
490
- let mut rect: windef:: RECT = mem:: zeroed ( ) ;
491
- if winuser:: GetClientRect ( wnd_handle, & mut rect) != 0 {
492
+ let mut rect: windef:: RECT = unsafe { mem:: zeroed ( ) } ;
493
+ if unsafe { winuser:: GetClientRect ( wnd_handle, & mut rect) } != 0 {
492
494
Some ( wgt:: Extent3d {
493
495
width : ( rect. right - rect. left ) as u32 ,
494
496
height : ( rect. bottom - rect. top ) as u32 ,
0 commit comments