Skip to content

Commit

Permalink
chore: satisfy unused_qualifications lint after Rust 1.80
Browse files Browse the repository at this point in the history
`std::mem::{size,align}_of{,_val}` was added to `std::prelude` in Rust
1.80; see
[`rust`#123168](rust-lang/rust#123168).
  • Loading branch information
ErichDonGubler committed Aug 12, 2024
1 parent e17f151 commit 5b300f7
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions wgpu-core/src/command/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ use crate::{
};
use arrayvec::ArrayVec;

use std::{borrow::Cow, mem, num::NonZeroU32, ops::Range, sync::Arc};
use std::{borrow::Cow, num::NonZeroU32, ops::Range, sync::Arc};
use thiserror::Error;

use hal::CommandEncoder as _;
Expand Down Expand Up @@ -876,7 +876,7 @@ fn multi_draw_indirect<A: HalApi>(
.buffer_memory_init_actions
.extend(buffer.initialization_status.read().create_action(
&buffer,
offset..(offset + mem::size_of::<wgt::DrawIndirectArgs>() as u64),
offset..(offset + size_of::<wgt::DrawIndirectArgs>() as u64),
MemoryInitKind::NeedsInitializedMemory,
));

Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use thiserror::Error;
use wgt::{BufferAddress, DynamicOffset};

use std::sync::Arc;
use std::{fmt, mem, str};
use std::{fmt, str};

use super::{bind::BinderError, memory_init::CommandBufferTextureMemoryActions, DynComputePass};

Expand Down Expand Up @@ -877,7 +877,7 @@ fn dispatch_indirect<A: HalApi>(
.merge_single(&buffer, hal::BufferUses::INDIRECT)?;
buffer.check_usage(wgt::BufferUsages::INDIRECT)?;

let end_offset = offset + mem::size_of::<wgt::DispatchIndirectArgs>() as u64;
let end_offset = offset + size_of::<wgt::DispatchIndirectArgs>() as u64;
if end_offset > buffer.size {
return Err(ComputePassErrorInner::IndirectBufferOverrun {
offset,
Expand Down
10 changes: 5 additions & 5 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use serde::Deserialize;
use serde::Serialize;

use std::sync::Arc;
use std::{borrow::Cow, fmt, iter, mem, num::NonZeroU32, ops::Range, str};
use std::{borrow::Cow, fmt, iter, num::NonZeroU32, ops::Range, str};

use super::render_command::ArcRenderCommand;
use super::{
Expand Down Expand Up @@ -2465,8 +2465,8 @@ fn multi_draw_indirect<A: HalApi>(
state.is_ready(indexed)?;

let stride = match indexed {
false => mem::size_of::<wgt::DrawIndirectArgs>(),
true => mem::size_of::<wgt::DrawIndexedIndirectArgs>(),
false => size_of::<wgt::DrawIndirectArgs>(),
true => size_of::<wgt::DrawIndexedIndirectArgs>(),
};

if count.is_some() {
Expand Down Expand Up @@ -2543,8 +2543,8 @@ fn multi_draw_indirect_count<A: HalApi>(
state.is_ready(indexed)?;

let stride = match indexed {
false => mem::size_of::<wgt::DrawIndirectArgs>(),
true => mem::size_of::<wgt::DrawIndexedIndirectArgs>(),
false => size_of::<wgt::DrawIndirectArgs>(),
true => size_of::<wgt::DrawIndexedIndirectArgs>(),
} as u64;

state
Expand Down
6 changes: 3 additions & 3 deletions wgpu-core/src/pipeline_cache.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use thiserror::Error;
use wgt::AdapterInfo;

pub const HEADER_LENGTH: usize = std::mem::size_of::<PipelineCacheHeader>();
pub const HEADER_LENGTH: usize = size_of::<PipelineCacheHeader>();

#[derive(Debug, PartialEq, Eq, Clone, Error)]
#[non_exhaustive]
Expand Down Expand Up @@ -112,7 +112,7 @@ pub fn add_cache_header(

const MAGIC: [u8; 8] = *b"WGPUPLCH";
const HEADER_VERSION: u32 = 1;
const ABI: u32 = std::mem::size_of::<*const ()>() as u32;
const ABI: u32 = size_of::<*const ()>() as u32;

/// The value used to fill [`PipelineCacheHeader::hash_space`]
///
Expand Down Expand Up @@ -181,7 +181,7 @@ impl PipelineCacheHeader {

assert_eq!(
reader.total_read,
std::mem::size_of::<PipelineCacheHeader>()
size_of::<PipelineCacheHeader>()
);

Some((
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl<T: StorageItem> Registry<T> {
pub(crate) fn generate_report(&self) -> RegistryReport {
let storage = self.storage.read();
let mut report = RegistryReport {
element_size: std::mem::size_of::<T>(),
element_size: size_of::<T>(),
..Default::default()
};
report.num_allocated = self.identity.values.lock().count();
Expand Down
6 changes: 3 additions & 3 deletions wgpu-hal/src/gles/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl super::CommandBuffer {

fn add_push_constant_data(&mut self, data: &[u32]) -> Range<u32> {
let data_raw =
unsafe { std::slice::from_raw_parts(data.as_ptr().cast(), mem::size_of_val(data)) };
unsafe { std::slice::from_raw_parts(data.as_ptr().cast(), size_of_val(data)) };
let start = self.data_bytes.len();
assert!(start < u32::MAX as usize);
self.data_bytes.extend_from_slice(data_raw);
Expand Down Expand Up @@ -1080,7 +1080,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
self.prepare_draw(0);
for draw in 0..draw_count as wgt::BufferAddress {
let indirect_offset =
offset + draw * mem::size_of::<wgt::DrawIndirectArgs>() as wgt::BufferAddress;
offset + draw * size_of::<wgt::DrawIndirectArgs>() as wgt::BufferAddress;
#[allow(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation
self.cmd_buffer.commands.push(C::DrawIndirect {
topology: self.state.topology,
Expand All @@ -1103,7 +1103,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
};
for draw in 0..draw_count as wgt::BufferAddress {
let indirect_offset = offset
+ draw * mem::size_of::<wgt::DrawIndexedIndirectArgs>() as wgt::BufferAddress;
+ draw * size_of::<wgt::DrawIndexedIndirectArgs>() as wgt::BufferAddress;
#[allow(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation
self.cmd_buffer.commands.push(C::DrawIndexedIndirect {
topology: self.state.topology,
Expand Down
6 changes: 3 additions & 3 deletions wgpu-hal/src/gles/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{conv::is_layered_target, Command as C, PrivateCapabilities};
use arrayvec::ArrayVec;
use glow::HasContext;
use std::{
mem, slice,
slice,
sync::{atomic::Ordering, Arc},
};

Expand Down Expand Up @@ -956,7 +956,7 @@ impl super::Queue {
let query_data = unsafe {
slice::from_raw_parts(
temp_query_results.as_ptr().cast::<u8>(),
temp_query_results.len() * mem::size_of::<u64>(),
temp_query_results.len() * size_of::<u64>(),
)
};
match dst.raw {
Expand Down Expand Up @@ -1520,7 +1520,7 @@ impl super::Queue {
//
// This function is absolutely sketchy and we really should be using bytemuck.
unsafe fn get_data<T, const COUNT: usize>(data: &[u8], offset: u32) -> &[T; COUNT] {
let data_required = mem::size_of::<T>() * COUNT;
let data_required = size_of::<T>() * COUNT;

let raw = &data[(offset as usize)..][..data_required];

Expand Down
6 changes: 3 additions & 3 deletions wgpu-hal/src/metal/command.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{conv, AsNative, TimestampQuerySupport};
use crate::CommandEncoder as _;
use std::{borrow::Cow, mem, ops::Range};
use std::{borrow::Cow, ops::Range};

// has to match `Temp::binding_sizes`
const WORD_SIZE: usize = 4;
Expand Down Expand Up @@ -1080,7 +1080,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
let encoder = self.state.render.as_ref().unwrap();
for _ in 0..draw_count {
encoder.draw_primitives_indirect(self.state.raw_primitive_type, &buffer.raw, offset);
offset += mem::size_of::<wgt::DrawIndirectArgs>() as wgt::BufferAddress;
offset += size_of::<wgt::DrawIndirectArgs>() as wgt::BufferAddress;
}
}

Expand All @@ -1101,7 +1101,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
&buffer.raw,
offset,
);
offset += mem::size_of::<wgt::DrawIndexedIndirectArgs>() as wgt::BufferAddress;
offset += size_of::<wgt::DrawIndexedIndirectArgs>() as wgt::BufferAddress;
}
}

Expand Down
8 changes: 4 additions & 4 deletions wgpu-hal/src/vulkan/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
buffer.raw,
offset,
draw_count,
mem::size_of::<wgt::DrawIndirectArgs>() as u32,
size_of::<wgt::DrawIndirectArgs>() as u32,
)
};
}
Expand All @@ -1008,7 +1008,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
buffer.raw,
offset,
draw_count,
mem::size_of::<wgt::DrawIndexedIndirectArgs>() as u32,
size_of::<wgt::DrawIndexedIndirectArgs>() as u32,
)
};
}
Expand All @@ -1020,7 +1020,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
count_offset: wgt::BufferAddress,
max_count: u32,
) {
let stride = mem::size_of::<wgt::DrawIndirectArgs>() as u32;
let stride = size_of::<wgt::DrawIndirectArgs>() as u32;
match self.device.extension_fns.draw_indirect_count {
Some(ref t) => {
unsafe {
Expand All @@ -1046,7 +1046,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
count_offset: wgt::BufferAddress,
max_count: u32,
) {
let stride = mem::size_of::<wgt::DrawIndexedIndirectArgs>() as u32;
let stride = size_of::<wgt::DrawIndexedIndirectArgs>() as u32;
match self.device.extension_fns.draw_indirect_count {
Some(ref t) => {
unsafe {
Expand Down

0 comments on commit 5b300f7

Please sign in to comment.