Placate Clippy 0.1.63.

This commit is contained in:
Jim Blandy 2022-08-20 16:25:38 -07:00
parent 18071599a7
commit 4f9e82a77d
18 changed files with 70 additions and 82 deletions

View File

@ -395,6 +395,7 @@ pub struct BindGroupLayout<B: hal::Backend> {
pub(crate) multi_ref_count: MultiRefCount,
pub(crate) entries: BindEntryMap,
pub(crate) desc_count: DescriptorTotalCount,
#[allow(dead_code)]
pub(crate) dynamic_count: usize,
pub(crate) count_validator: BindingTypeMaxCountValidator,
#[cfg(debug_assertions)]
@ -595,7 +596,7 @@ impl<B: hal::Backend> Resource for PipelineLayout<B> {
}
#[repr(C)]
#[derive(Clone, Debug, Hash, PartialEq)]
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "trace", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct BufferBinding {

View File

@ -663,7 +663,7 @@ impl RenderBundle {
&pipeline_layout.raw,
conv::map_shader_stage_flags(stages),
offset,
&data_slice,
data_slice,
)
} else {
super::push_constant_clear(

View File

@ -113,7 +113,7 @@ pub struct ComputePassDescriptor<'a> {
pub label: Label<'a>,
}
#[derive(Clone, Debug, Error, PartialEq)]
#[derive(Clone, Debug, Error, Eq, PartialEq)]
pub enum DispatchError {
#[error("compute pipeline must be set")]
MissingPipeline,
@ -291,7 +291,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
});
}
if let Some(ref label) = base.label {
if let Some(label) = base.label {
unsafe {
raw.begin_debug_marker(label, 0);
}

View File

@ -20,7 +20,7 @@ use thiserror::Error;
pub type BufferError = UseExtendError<BufferUse>;
/// Error validating a draw call.
#[derive(Clone, Debug, Error, PartialEq)]
#[derive(Clone, Debug, Error, Eq, PartialEq)]
pub enum DrawError {
#[error("blend constant needs to be set")]
MissingBlendConstant,

View File

@ -77,7 +77,7 @@ pub enum StoreOp {
/// Describes an individual channel within a render pass, such as color, depth, or stencil.
#[repr(C)]
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
#[cfg_attr(any(feature = "serial-pass", feature = "trace"), derive(Serialize))]
#[cfg_attr(any(feature = "serial-pass", feature = "replay"), derive(Deserialize))]
pub struct PassChannel<V> {
@ -567,7 +567,7 @@ impl<'a, B: GfxBackend> RenderPassInfo<'a, B> {
let view = cmd_buf
.trackers
.views
.use_extend(&*view_guard, at.view, (), ())
.use_extend(view_guard, at.view, (), ())
.map_err(|_| RenderPassErrorInner::InvalidAttachment(at.view))?;
add_view(view, "depth")?;
@ -631,7 +631,7 @@ impl<'a, B: GfxBackend> RenderPassInfo<'a, B> {
let view = cmd_buf
.trackers
.views
.use_extend(&*view_guard, at.view, (), ())
.use_extend(view_guard, at.view, (), ())
.map_err(|_| RenderPassErrorInner::InvalidAttachment(at.view))?;
add_view(view, "color")?;
@ -695,7 +695,7 @@ impl<'a, B: GfxBackend> RenderPassInfo<'a, B> {
let view = cmd_buf
.trackers
.views
.use_extend(&*view_guard, resolve_target, (), ())
.use_extend(view_guard, resolve_target, (), ())
.map_err(|_| RenderPassErrorInner::InvalidAttachment(resolve_target))?;
if extent != Some(view.extent) {
return Err(RenderPassErrorInner::AttachmentsDimensionMismatch {
@ -864,7 +864,7 @@ impl<'a, B: GfxBackend> RenderPassInfo<'a, B> {
device
.raw
.create_framebuffer(
&render_pass,
render_pass,
e.key().attachments.all().cloned(),
conv::map_extent(&extent, wgt::TextureDimension::D3),
)
@ -1067,7 +1067,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let device = &device_guard[cmd_buf.device_id.value];
let mut raw = device.cmd_allocator.extend(cmd_buf);
unsafe {
if let Some(ref label) = base.label {
if let Some(label) = base.label {
device.raw.set_command_buffer_name(&mut raw, label);
}
raw.begin_primary(hal::command::CommandBufferFlags::ONE_TIME_SUBMIT);
@ -1438,10 +1438,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
use std::{convert::TryFrom, i16};
if rect.w <= 0.0
|| rect.h <= 0.0
|| depth_min < 0.0
|| depth_min > 1.0
|| depth_max < 0.0
|| depth_max > 1.0
|| !(0.0..=1.0).contains(&depth_min)
|| !(0.0..=1.0).contains(&depth_max)
{
return Err(RenderCommandError::InvalidViewport).map_pass_err(scope);
}

View File

@ -324,7 +324,7 @@ impl<B: hal::Backend> LifetimeTracker<B> {
.active
.iter()
.position(|a| unsafe { !device.get_fence_status(&a.fence).unwrap_or(false) })
.unwrap_or_else(|| self.active.len());
.unwrap_or(self.active.len());
let last_done = match done_count.checked_sub(1) {
Some(i) => self.active[i].index,
None => return Ok(0),

View File

@ -80,7 +80,7 @@ pub fn all_image_stages() -> hal::pso::PipelineStage {
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "trace", derive(serde::Serialize))]
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]
pub enum HostMap {
@ -454,13 +454,13 @@ impl<B: GfxBackend> Device<B> {
&'this mut self,
hub: &Hub<B, G>,
trackers: &TrackerSet,
mut token: &mut Token<'token, Self>,
token: &mut Token<'token, Self>,
) {
self.temp_suspected.clear();
// As the tracker is cleared/dropped, we need to consider all the resources
// that it references for destruction in the next GC pass.
{
let (bind_group_guard, mut token) = hub.bind_groups.read(&mut token);
let (bind_group_guard, mut token) = hub.bind_groups.read(token);
let (compute_pipe_guard, mut token) = hub.compute_pipelines.read(&mut token);
let (render_pipe_guard, mut token) = hub.render_pipelines.read(&mut token);
let (query_set_guard, mut token) = hub.query_sets.read(&mut token);
@ -511,7 +511,7 @@ impl<B: GfxBackend> Device<B> {
}
}
self.lock_life(&mut token)
self.lock_life(token)
.suspected_resources
.extend(&self.temp_suspected);
@ -1178,7 +1178,7 @@ impl<B: GfxBackend> Device<B> {
) -> Option<id::BindGroupLayoutId> {
guard
.iter(self_id.backend())
.find(|&(_, ref bgl)| bgl.device_id.value.0 == self_id && bgl.entries == *entry_map)
.find(|&(_, bgl)| bgl.device_id.value.0 == self_id && bgl.entries == *entry_map)
.map(|(id, value)| {
value.multi_ref_count.inc();
id
@ -1496,9 +1496,9 @@ impl<B: GfxBackend> Device<B> {
let descriptors: SmallVec<[_; 1]> = match entry.resource {
Br::Buffer(ref bb) => {
let buffer_desc = Self::create_buffer_descriptor(
&bb,
bb,
binding,
&decl,
decl,
&mut used_buffer_ranges,
&mut dynamic_binding_info,
&mut used,
@ -1525,9 +1525,9 @@ impl<B: GfxBackend> Device<B> {
.iter()
.map(|bb| {
Self::create_buffer_descriptor(
&bb,
bb,
binding,
&decl,
decl,
&mut used_buffer_ranges,
&mut dynamic_binding_info,
&mut used,
@ -1782,7 +1782,7 @@ impl<B: GfxBackend> Device<B> {
// Set the descriptor set's label for easier debugging.
if let Some(label) = desc.label.as_ref() {
unsafe {
self.raw.set_descriptor_set_name(desc_set.raw_mut(), &label);
self.raw.set_descriptor_set_name(desc_set.raw_mut(), label);
}
}
@ -2029,7 +2029,7 @@ impl<B: GfxBackend> Device<B> {
let _ = interface.check_stage(
provided_layouts.as_ref().map(|p| p.as_slice()),
&mut derived_group_layouts,
&entry_point_name,
entry_point_name,
flag,
io,
)?;
@ -2038,7 +2038,7 @@ impl<B: GfxBackend> Device<B> {
}
let shader = hal::pso::EntryPoint::<B> {
entry: &entry_point_name, // TODO
entry: entry_point_name, // TODO
module: &shader_module.raw,
specialization: hal::pso::Specialization::EMPTY,
};
@ -2457,7 +2457,7 @@ impl<B: GfxBackend> Device<B> {
.check_stage(
provided_layouts.as_ref().map(|p| p.as_slice()),
&mut derived_group_layouts,
&entry_point_name,
entry_point_name,
flag,
io,
)
@ -2470,7 +2470,7 @@ impl<B: GfxBackend> Device<B> {
}
Some(hal::pso::EntryPoint::<B> {
entry: &entry_point_name,
entry: entry_point_name,
module: &shader_module.raw,
specialization: hal::pso::Specialization::EMPTY,
})
@ -2481,7 +2481,7 @@ impl<B: GfxBackend> Device<B> {
if validated_stages.contains(wgt::ShaderStage::FRAGMENT) {
for (i, state) in color_states.iter().enumerate() {
match io.get(&(i as wgt::ShaderLocation)) {
Some(ref output) => {
Some(output) => {
validation::check_texture_format(state.format, &output.ty).map_err(
|pipeline| {
pipeline::CreateRenderPipelineError::ColorState(
@ -3776,13 +3776,9 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
Ok(layout) => layout,
Err(_) => break binding_model::CreateBindGroupError::InvalidLayout,
};
let bind_group = match device.create_bind_group(
device_id,
bind_group_layout,
desc,
&hub,
&mut token,
) {
let bind_group =
match device.create_bind_group(device_id, bind_group_layout, desc, hub, &mut token)
{
Ok(bind_group) => bind_group,
Err(e) => break e,
};
@ -3963,10 +3959,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
Err(e) => break e,
};
let mut raw = command_buffer.raw.first_mut().unwrap();
let raw = command_buffer.raw.first_mut().unwrap();
unsafe {
if let Some(ref label) = desc.label {
device.raw.set_command_buffer_name(&mut raw, label);
device.raw.set_command_buffer_name(raw, label);
}
raw.begin_primary(hal::command::CommandBufferFlags::ONE_TIME_SUBMIT);
}
@ -3995,7 +3991,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.unregister(command_encoder_id, &mut token);
if let Some(cmdbuf) = cmdbuf {
let device = &mut device_guard[cmdbuf.device_id.value];
device.untrack::<G>(&hub, &cmdbuf.trackers, &mut token);
device.untrack::<G>(hub, &cmdbuf.trackers, &mut token);
device.cmd_allocator.discard(cmdbuf);
}
}
@ -4051,7 +4047,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
});
}
let render_bundle = match bundle_encoder.finish(desc, device, &hub, &mut token) {
let render_bundle = match bundle_encoder.finish(desc, device, hub, &mut token) {
Ok(bundle) => bundle,
Err(e) => break e,
};
@ -4199,7 +4195,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let mut token = Token::root();
let fid = hub.render_pipelines.prepare(id_in);
let implicit_context = implicit_pipeline_ids.map(|ipi| ipi.prepare(&hub));
let implicit_context = implicit_pipeline_ids.map(|ipi| ipi.prepare(hub));
let (adapter_guard, mut token) = hub.adapters.read(&mut token);
let (device_guard, mut token) = hub.devices.read(&mut token);
@ -4223,7 +4219,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
adapter,
desc,
implicit_context,
&hub,
hub,
&mut token,
) {
Ok(pair) => pair,
@ -4333,7 +4329,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let mut token = Token::root();
let fid = hub.compute_pipelines.prepare(id_in);
let implicit_context = implicit_pipeline_ids.map(|ipi| ipi.prepare(&hub));
let implicit_context = implicit_pipeline_ids.map(|ipi| ipi.prepare(hub));
let (device_guard, mut token) = hub.devices.read(&mut token);
let error = loop {
@ -4354,7 +4350,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
device_id,
desc,
implicit_context,
&hub,
hub,
&mut token,
) {
Ok(pair) => pair,
@ -4530,11 +4526,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let num_frames = swap_chain::DESIRED_NUM_FRAMES
.max(*caps.image_count.start())
.min(*caps.image_count.end());
let mut config = swap_chain::swap_chain_descriptor_to_hal(
&desc,
num_frames,
device.private_features,
);
let mut config =
swap_chain::swap_chain_descriptor_to_hal(desc, num_frames, device.private_features);
if let Some(formats) = formats {
if !formats.contains(&config.format) {
break swap_chain::CreateSwapChainError::UnsupportedFormat {
@ -4603,7 +4596,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (device_guard, mut token) = hub.devices.read(&mut token);
let device = device_guard.get(device_id).map_err(|_| InvalidDevice)?;
device.lock_life(&mut token).triage_suspected(
&hub,
hub,
&device.trackers,
#[cfg(feature = "trace")]
None,
@ -4624,7 +4617,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
device_guard
.get(device_id)
.map_err(|_| DeviceError::Invalid)?
.maintain(&hub, force_wait, &mut token)?
.maintain(hub, force_wait, &mut token)?
};
fire_map_callbacks(callbacks);
Ok(())
@ -4641,7 +4634,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let mut token = Token::root();
let (device_guard, mut token) = hub.devices.read(&mut token);
for (_, device) in device_guard.iter(B::VARIANT) {
let cbs = device.maintain(&hub, force_wait, &mut token)?;
let cbs = device.maintain(hub, force_wait, &mut token)?;
callbacks.extend(cbs);
}
Ok(())

View File

@ -797,7 +797,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.after_submit_internal(comb_raw, submit_index);
}
let callbacks = match device.maintain(&hub, false, &mut token) {
let callbacks = match device.maintain(hub, false, &mut token) {
Ok(callbacks) => callbacks,
Err(WaitIdleError::Device(err)) => return Err(QueueSubmitError::Queue(err)),
Err(WaitIdleError::StuckGpu) => return Err(QueueSubmitError::StuckGpu),

View File

@ -29,21 +29,12 @@ use std::cell::Cell;
use std::{fmt::Debug, marker::PhantomData, ops};
/// A simple structure to manage identities of objects.
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct IdentityManager {
free: Vec<Index>,
epochs: Vec<Epoch>,
}
impl Default for IdentityManager {
fn default() -> Self {
Self {
free: Default::default(),
epochs: Default::default(),
}
}
}
impl IdentityManager {
pub fn from_index(min_index: u32) -> Self {
Self {

View File

@ -134,7 +134,7 @@ impl MemoryInitTracker {
let index = self.lower_bound(query_range.start);
self.uninitialized_ranges
.get(index)
.map(|start_range| {
.and_then(|start_range| {
if start_range.start < query_range.end {
let start = start_range.start.max(query_range.start);
match self.uninitialized_ranges.get(index + 1) {
@ -152,7 +152,6 @@ impl MemoryInitTracker {
None
}
})
.flatten()
}
// Drains uninitialized ranges in a query range.

View File

@ -163,6 +163,7 @@ pub enum BufferAccessError {
pub(crate) struct BufferPendingMapping {
pub range: Range<wgt::BufferAddress>,
pub op: BufferMapOperation,
#[allow(dead_code)]
// hold the parent alive while the mapping is active
pub parent_ref_count: RefCount,
}
@ -280,7 +281,7 @@ impl<B: hal::Backend> Borrow<TextureSelector> for Texture<B> {
}
/// Describes a [`TextureView`].
#[derive(Clone, Debug, Default, PartialEq)]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
#[cfg_attr(feature = "trace", derive(serde::Serialize))]
#[cfg_attr(feature = "replay", derive(serde::Deserialize), serde(default))]
pub struct TextureViewDescriptor<'a> {
@ -479,6 +480,7 @@ pub struct QuerySet<B: hal::Backend> {
/// Amount of queries in the query set.
pub(crate) desc: wgt::QuerySetDescriptor,
/// Amount of numbers in each query (i.e. a pipeline statistics query for two attributes will have this number be two)
#[allow(dead_code)]
pub(crate) elements: u32,
}

View File

@ -56,6 +56,7 @@ pub struct SwapChain<B: hal::Backend> {
pub(crate) life_guard: LifeGuard,
pub(crate) device_id: Stored<DeviceId>,
pub(crate) desc: SwapChainDescriptor,
#[allow(dead_code)]
pub(crate) num_frames: hal::window::SwapImageIndex,
pub(crate) semaphore: B::Semaphore,
pub(crate) acquired_view_id: Option<Stored<TextureViewId>>,

View File

@ -20,7 +20,7 @@ pub(crate) use texture::{TextureSelector, TextureState};
/// A single unit of state tracking. It keeps an initial
/// usage as well as the last/current one, similar to `Range`.
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Unit<U> {
first: Option<U>,
last: U,

View File

@ -9,7 +9,7 @@ use std::{cmp::Ordering, fmt::Debug, iter, ops::Range, slice::Iter};
/// Structure that keeps track of a I -> T mapping,
/// optimized for a case where keys of the same values
/// are often grouped together linearly.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct RangedStates<I, T> {
/// List of ranges, each associated with a singe value.
/// Ranges of keys have to be non-intersecting and ordered.

View File

@ -25,6 +25,7 @@ enum ResourceType {
#[derive(Debug)]
struct Resource {
#[allow(dead_code)]
name: Option<String>,
bind: naga::ResourceBinding,
ty: ResourceType,
@ -94,6 +95,7 @@ enum Varying {
BuiltIn(naga::BuiltIn),
}
#[allow(dead_code)]
#[derive(Debug)]
struct SpecializationConstant {
id: u32,
@ -105,6 +107,7 @@ struct EntryPoint {
inputs: Vec<Varying>,
outputs: Vec<Varying>,
resources: Vec<(naga::Handle<Resource>, GlobalUse)>,
#[allow(dead_code)]
spec_constants: Vec<SpecializationConstant>,
sampling_pairs: FastHashSet<(naga::Handle<Resource>, naga::Handle<Resource>)>,
}

View File

@ -716,7 +716,7 @@ pub enum ShaderModel {
/// Supported physical device types.
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "trace", derive(serde::Serialize))]
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]
pub enum DeviceType {
@ -733,7 +733,7 @@ pub enum DeviceType {
}
/// Information about an adapter.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "trace", derive(serde::Serialize))]
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]
pub struct AdapterInfo {
@ -3004,7 +3004,7 @@ pub struct ImageCopyTexture<T> {
/// Subresource range within an image
#[repr(C)]
#[derive(Clone, Debug, Default, PartialEq)]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
#[cfg_attr(feature = "trace", derive(serde::Serialize))]
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]
pub struct ImageSubresourceRange {

View File

@ -968,7 +968,7 @@ impl crate::Context for Context {
let descriptor = wgc::binding_model::PipelineLayoutDescriptor {
label: desc.label.map(Borrowed),
bind_group_layouts: Borrowed(&temp_layouts),
push_constant_ranges: Borrowed(&desc.push_constant_ranges),
push_constant_ranges: Borrowed(desc.push_constant_ranges),
};
let global = &self.0;
@ -1211,7 +1211,7 @@ impl crate::Context for Context {
let global = &self.0;
let (id, error) = wgc::gfx_select!(device.id => global.device_create_query_set(
device.id,
&desc,
desc,
PhantomData
));
if let Some(cause) = error {
@ -1818,7 +1818,7 @@ impl crate::Context for Context {
fn command_encoder_insert_debug_marker(&self, encoder: &Self::CommandEncoderId, label: &str) {
let global = &self.0;
if let Err(cause) = wgc::gfx_select!(encoder.id => global.command_encoder_insert_debug_marker(encoder.id, &label))
if let Err(cause) = wgc::gfx_select!(encoder.id => global.command_encoder_insert_debug_marker(encoder.id, label))
{
self.handle_error_nolabel(
&encoder.error_sink,
@ -1829,7 +1829,7 @@ impl crate::Context for Context {
}
fn command_encoder_push_debug_group(&self, encoder: &Self::CommandEncoderId, label: &str) {
let global = &self.0;
if let Err(cause) = wgc::gfx_select!(encoder.id => global.command_encoder_push_debug_group(encoder.id, &label))
if let Err(cause) = wgc::gfx_select!(encoder.id => global.command_encoder_push_debug_group(encoder.id, label))
{
self.handle_error_nolabel(
&encoder.error_sink,

View File

@ -1082,7 +1082,7 @@ pub type RenderBundleDescriptor<'a> = wgt::RenderBundleDescriptor<Label<'a>>;
pub type TextureDescriptor<'a> = wgt::TextureDescriptor<Label<'a>>;
/// Describes a [`TextureView`].
#[derive(Clone, Debug, Default, PartialEq)]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct TextureViewDescriptor<'a> {
/// Debug label of the texture view. This will show up in graphics debuggers for easy identification.
pub label: Label<'a>,
@ -1722,7 +1722,7 @@ impl Display for BufferAsyncError {
impl error::Error for BufferAsyncError {}
/// Type of buffer mapping.
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum MapMode {
/// Map only for reading
Read,