Skip to content

Commit

Permalink
fixup! refactor: resolve clippy::bool_to_int_with_if
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Nov 7, 2022
1 parent c14908b commit 342b36e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions wgpu-hal/src/dx12/conv.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use std::iter;
use winapi::um::{d3d12, d3dcommon};
use winapi::{
shared::minwindef::BOOL,
um::{d3d12, d3dcommon},
};

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

pub fn map_depth_stencil(ds: &wgt::DepthStencilState) -> d3d12::D3D12_DEPTH_STENCIL_DESC {
d3d12::D3D12_DEPTH_STENCIL_DESC {
DepthEnable: ds.is_depth_enabled().into(),
DepthEnable: BOOL::from(ds.is_depth_enabled()),
DepthWriteMask: if ds.depth_write_enabled {
d3d12::D3D12_DEPTH_WRITE_MASK_ALL
} else {
d3d12::D3D12_DEPTH_WRITE_MASK_ZERO
},
DepthFunc: map_comparison(ds.depth_compare),
StencilEnable: ds.stencil.is_enabled().into(),
StencilEnable: BOOL::from(ds.stencil.is_enabled()),
StencilReadMask: ds.stencil.read_mask as u8,
StencilWriteMask: ds.stencil.write_mask as u8,
FrontFace: map_stencil_face(&ds.stencil.front),
Expand Down
8 changes: 4 additions & 4 deletions wgpu-hal/src/dx12/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::{conv, descriptor, view};
use parking_lot::Mutex;
use std::{ffi, mem, num::NonZeroU32, ptr, slice, sync::Arc};
use winapi::{
shared::{dxgiformat, dxgitype, winerror},
shared::{dxgiformat, dxgitype, minwindef::BOOL, winerror},
um::{d3d12, d3dcompiler, synchapi, winbase},
Interface,
};
Expand Down Expand Up @@ -1358,8 +1358,8 @@ impl crate::Device<super::Api> for super::Device {
DepthBias: bias.constant,
DepthBiasClamp: bias.clamp,
SlopeScaledDepthBias: bias.slope_scale,
DepthClipEnable: (!desc.primitive.unclipped_depth).into(),
MultisampleEnable: (desc.multisample.count > 1).into(),
DepthClipEnable: BOOL::from(!desc.primitive.unclipped_depth),
MultisampleEnable: BOOL::from(desc.multisample.count > 1),
ForcedSampleCount: 0,
AntialiasedLineEnable: 0,
ConservativeRaster: if desc.primitive.conservative {
Expand Down Expand Up @@ -1388,7 +1388,7 @@ impl crate::Device<super::Api> for super::Device {
RasterizedStream: 0,
},
BlendState: d3d12::D3D12_BLEND_DESC {
AlphaToCoverageEnable: desc.multisample.alpha_to_coverage_enabled.into(),
AlphaToCoverageEnable: BOOL::from(desc.multisample.alpha_to_coverage_enabled),
IndependentBlendEnable: 1,
RenderTarget: conv::map_render_targets(desc.color_targets),
},
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ impl crate::Instance<super::Api> for Instance {
EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE as egl::Attrib,
EGL_PLATFORM_X11_KHR as egl::Attrib,
EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED as egl::Attrib,
desc.flags.contains(crate::InstanceFlags::VALIDATION).into(),
usize::from(desc.flags.contains(crate::InstanceFlags::VALIDATION)),
egl::ATTRIB_NONE,
];
let display = egl
Expand Down

0 comments on commit 342b36e

Please sign in to comment.