diff --git a/wgpu-core/src/command/bundle.rs b/wgpu-core/src/command/bundle.rs index 56f7d551b03..1cd9a0bcf7f 100644 --- a/wgpu-core/src/command/bundle.rs +++ b/wgpu-core/src/command/bundle.rs @@ -100,7 +100,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 super::{ @@ -873,7 +873,7 @@ fn multi_draw_indirect( .buffer_memory_init_actions .extend(buffer.initialization_status.read().create_action( &buffer, - offset..(offset + mem::size_of::() as u64), + offset..(offset + size_of::() as u64), MemoryInitKind::NeedsInitializedMemory, )); diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 5f23fb72211..bf8c66cf6df 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -29,7 +29,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}; @@ -854,7 +854,7 @@ fn dispatch_indirect( .merge_single(&buffer, hal::BufferUses::INDIRECT)?; buffer.check_usage(wgt::BufferUsages::INDIRECT)?; - let end_offset = offset + mem::size_of::() as u64; + let end_offset = offset + size_of::() as u64; if end_offset > buffer.size { return Err(ComputePassErrorInner::IndirectBufferOverrun { offset, diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 1f11ba09374..0017b2b4fc2 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -45,7 +45,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::{ @@ -2442,8 +2442,8 @@ fn multi_draw_indirect( state.is_ready(indexed)?; let stride = match indexed { - false => mem::size_of::(), - true => mem::size_of::(), + false => size_of::(), + true => size_of::(), }; if count.is_some() { @@ -2520,8 +2520,8 @@ fn multi_draw_indirect_count( state.is_ready(indexed)?; let stride = match indexed { - false => mem::size_of::(), - true => mem::size_of::(), + false => size_of::(), + true => size_of::(), } as u64; state diff --git a/wgpu-core/src/pipeline_cache.rs b/wgpu-core/src/pipeline_cache.rs index b88fc21dda5..057223fb573 100644 --- a/wgpu-core/src/pipeline_cache.rs +++ b/wgpu-core/src/pipeline_cache.rs @@ -1,7 +1,7 @@ use thiserror::Error; use wgt::AdapterInfo; -pub const HEADER_LENGTH: usize = std::mem::size_of::(); +pub const HEADER_LENGTH: usize = size_of::(); #[derive(Debug, PartialEq, Eq, Clone, Error)] #[non_exhaustive] @@ -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`] /// @@ -179,10 +179,7 @@ impl PipelineCacheHeader { let data_size = reader.read_u64()?; let data_hash = reader.read_u64()?; - assert_eq!( - reader.total_read, - std::mem::size_of::() - ); + assert_eq!(reader.total_read, size_of::()); Some(( PipelineCacheHeader { diff --git a/wgpu-core/src/registry.rs b/wgpu-core/src/registry.rs index fa7e0def6c4..3cb451951c3 100644 --- a/wgpu-core/src/registry.rs +++ b/wgpu-core/src/registry.rs @@ -125,7 +125,7 @@ impl Registry { pub(crate) fn generate_report(&self) -> RegistryReport { let storage = self.storage.read(); let mut report = RegistryReport { - element_size: std::mem::size_of::(), + element_size: size_of::(), ..Default::default() }; report.num_allocated = self.identity.values.lock().count(); diff --git a/wgpu-hal/src/gles/command.rs b/wgpu-hal/src/gles/command.rs index c002e76c1bb..7d8ce413754 100644 --- a/wgpu-hal/src/gles/command.rs +++ b/wgpu-hal/src/gles/command.rs @@ -82,7 +82,7 @@ impl super::CommandBuffer { fn add_push_constant_data(&mut self, data: &[u32]) -> Range { 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); @@ -1083,7 +1083,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::() as wgt::BufferAddress; + offset + draw * size_of::() 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, @@ -1105,8 +1105,8 @@ impl crate::CommandEncoder for super::CommandEncoder { wgt::IndexFormat::Uint32 => glow::UNSIGNED_INT, }; for draw in 0..draw_count as wgt::BufferAddress { - let indirect_offset = offset - + draw * mem::size_of::() as wgt::BufferAddress; + let indirect_offset = + offset + draw * size_of::() 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, diff --git a/wgpu-hal/src/gles/queue.rs b/wgpu-hal/src/gles/queue.rs index 3752b0869da..08499748369 100644 --- a/wgpu-hal/src/gles/queue.rs +++ b/wgpu-hal/src/gles/queue.rs @@ -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}, }; @@ -1012,7 +1012,7 @@ impl super::Queue { let query_data = unsafe { slice::from_raw_parts( temp_query_results.as_ptr().cast::(), - temp_query_results.len() * mem::size_of::(), + temp_query_results.len() * size_of::(), ) }; match dst.raw { @@ -1576,7 +1576,7 @@ impl super::Queue { // // This function is absolutely sketchy and we really should be using bytemuck. unsafe fn get_data(data: &[u8], offset: u32) -> &[T; COUNT] { - let data_required = mem::size_of::() * COUNT; + let data_required = size_of::() * COUNT; let raw = &data[(offset as usize)..][..data_required]; diff --git a/wgpu-hal/src/metal/command.rs b/wgpu-hal/src/metal/command.rs index 7eea069a814..98c395b8708 100644 --- a/wgpu-hal/src/metal/command.rs +++ b/wgpu-hal/src/metal/command.rs @@ -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; @@ -1083,7 +1083,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::() as wgt::BufferAddress; + offset += size_of::() as wgt::BufferAddress; } } @@ -1104,7 +1104,7 @@ impl crate::CommandEncoder for super::CommandEncoder { &buffer.raw, offset, ); - offset += mem::size_of::() as wgt::BufferAddress; + offset += size_of::() as wgt::BufferAddress; } } diff --git a/wgpu-hal/src/vulkan/command.rs b/wgpu-hal/src/vulkan/command.rs index dd89f7dae2d..0eb9a7abc77 100644 --- a/wgpu-hal/src/vulkan/command.rs +++ b/wgpu-hal/src/vulkan/command.rs @@ -1012,7 +1012,7 @@ impl crate::CommandEncoder for super::CommandEncoder { buffer.raw, offset, draw_count, - mem::size_of::() as u32, + size_of::() as u32, ) }; } @@ -1028,7 +1028,7 @@ impl crate::CommandEncoder for super::CommandEncoder { buffer.raw, offset, draw_count, - mem::size_of::() as u32, + size_of::() as u32, ) }; } @@ -1040,7 +1040,7 @@ impl crate::CommandEncoder for super::CommandEncoder { count_offset: wgt::BufferAddress, max_count: u32, ) { - let stride = mem::size_of::() as u32; + let stride = size_of::() as u32; match self.device.extension_fns.draw_indirect_count { Some(ref t) => { unsafe { @@ -1066,7 +1066,7 @@ impl crate::CommandEncoder for super::CommandEncoder { count_offset: wgt::BufferAddress, max_count: u32, ) { - let stride = mem::size_of::() as u32; + let stride = size_of::() as u32; match self.device.extension_fns.draw_indirect_count { Some(ref t) => { unsafe {