Skip to content

Commit a59a8ad

Browse files
refactor: resolve clippy::bool_to_int_with_if
1 parent 6ed103e commit a59a8ad

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

wgpu-hal/src/dx12/conv.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use std::iter;
2-
use winapi::um::{d3d12, d3dcommon};
2+
use winapi::{
3+
shared::minwindef::BOOL,
4+
um::{d3d12, d3dcommon},
5+
};
36

47
pub fn map_buffer_usage_to_resource_flags(usage: crate::BufferUses) -> d3d12::D3D12_RESOURCE_FLAGS {
58
let mut flags = 0;
@@ -329,14 +332,14 @@ fn map_stencil_face(face: &wgt::StencilFaceState) -> d3d12::D3D12_DEPTH_STENCILO
329332

330333
pub fn map_depth_stencil(ds: &wgt::DepthStencilState) -> d3d12::D3D12_DEPTH_STENCIL_DESC {
331334
d3d12::D3D12_DEPTH_STENCIL_DESC {
332-
DepthEnable: if ds.is_depth_enabled() { 1 } else { 0 },
335+
DepthEnable: BOOL::from(ds.is_depth_enabled()),
333336
DepthWriteMask: if ds.depth_write_enabled {
334337
d3d12::D3D12_DEPTH_WRITE_MASK_ALL
335338
} else {
336339
d3d12::D3D12_DEPTH_WRITE_MASK_ZERO
337340
},
338341
DepthFunc: map_comparison(ds.depth_compare),
339-
StencilEnable: if ds.stencil.is_enabled() { 1 } else { 0 },
342+
StencilEnable: BOOL::from(ds.stencil.is_enabled()),
340343
StencilReadMask: ds.stencil.read_mask as u8,
341344
StencilWriteMask: ds.stencil.write_mask as u8,
342345
FrontFace: map_stencil_face(&ds.stencil.front),

wgpu-hal/src/dx12/device.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use super::{conv, descriptor, view};
77
use parking_lot::Mutex;
88
use std::{ffi, mem, num::NonZeroU32, ptr, slice, sync::Arc};
99
use winapi::{
10-
shared::{dxgiformat, dxgitype, winerror},
10+
shared::{dxgiformat, dxgitype, minwindef::BOOL, winerror},
1111
um::{d3d12, d3dcompiler, synchapi, winbase},
1212
Interface,
1313
};
@@ -1358,8 +1358,8 @@ impl crate::Device<super::Api> for super::Device {
13581358
DepthBias: bias.constant,
13591359
DepthBiasClamp: bias.clamp,
13601360
SlopeScaledDepthBias: bias.slope_scale,
1361-
DepthClipEnable: if desc.primitive.unclipped_depth { 0 } else { 1 },
1362-
MultisampleEnable: if desc.multisample.count > 1 { 1 } else { 0 },
1361+
DepthClipEnable: BOOL::from(!desc.primitive.unclipped_depth),
1362+
MultisampleEnable: BOOL::from(desc.multisample.count > 1),
13631363
ForcedSampleCount: 0,
13641364
AntialiasedLineEnable: 0,
13651365
ConservativeRaster: if desc.primitive.conservative {
@@ -1388,11 +1388,7 @@ impl crate::Device<super::Api> for super::Device {
13881388
RasterizedStream: 0,
13891389
},
13901390
BlendState: d3d12::D3D12_BLEND_DESC {
1391-
AlphaToCoverageEnable: if desc.multisample.alpha_to_coverage_enabled {
1392-
1
1393-
} else {
1394-
0
1395-
},
1391+
AlphaToCoverageEnable: BOOL::from(desc.multisample.alpha_to_coverage_enabled),
13961392
IndependentBlendEnable: 1,
13971393
RenderTarget: conv::map_render_targets(desc.color_targets),
13981394
},

wgpu-hal/src/gles/egl.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -702,11 +702,7 @@ impl crate::Instance<super::Api> for Instance {
702702
EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE as egl::Attrib,
703703
EGL_PLATFORM_X11_KHR as egl::Attrib,
704704
EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED as egl::Attrib,
705-
if desc.flags.contains(crate::InstanceFlags::VALIDATION) {
706-
1
707-
} else {
708-
0
709-
},
705+
usize::from(desc.flags.contains(crate::InstanceFlags::VALIDATION)),
710706
egl::ATTRIB_NONE,
711707
];
712708
let display = egl

0 commit comments

Comments
 (0)