From b3b54b6941459e8a5208700c3c10e771f8cebc88 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Thu, 20 Feb 2025 13:20:49 -0800 Subject: [PATCH] wgpu: Adjust imports to allow `no_std`. Remaining uses of `std`: * `trace_path` / `trace_dir` * `std::error::Error` (waiting for Rust 1.81) * `std::ffi::c_void` * Various uses in `util` --- wgpu/src/api/adapter.rs | 2 +- wgpu/src/api/blas.rs | 5 ++- wgpu/src/api/buffer.rs | 6 ++-- wgpu/src/api/command_encoder.rs | 2 +- wgpu/src/api/device.rs | 5 +-- wgpu/src/api/instance.rs | 10 +++--- wgpu/src/api/mod.rs | 4 +-- wgpu/src/api/pipeline_cache.rs | 4 ++- wgpu/src/api/queue.rs | 3 +- wgpu/src/api/render_bundle_encoder.rs | 2 +- wgpu/src/api/render_pass.rs | 2 +- wgpu/src/api/render_pipeline.rs | 2 +- wgpu/src/api/shader_module.rs | 8 ++++- wgpu/src/api/surface.rs | 12 ++++--- wgpu/src/api/surface_texture.rs | 4 ++- wgpu/src/api/tlas.rs | 5 +-- wgpu/src/backend/webgpu.rs | 18 +++++++--- .../webgpu/defined_non_null_js_value.rs | 2 +- wgpu/src/backend/wgpu_core.rs | 33 +++++++++++-------- wgpu/src/cmp.rs | 28 ++++++++-------- wgpu/src/dispatch.rs | 9 ++--- wgpu/src/lib.rs | 11 ++++--- wgpu/src/util/belt.rs | 3 +- wgpu/src/util/device.rs | 2 ++ wgpu/src/util/encoder.rs | 2 +- wgpu/src/util/mod.rs | 6 ++-- 26 files changed, 115 insertions(+), 75 deletions(-) diff --git a/wgpu/src/api/adapter.rs b/wgpu/src/api/adapter.rs index 0b38c5310..fd3f5fa6a 100644 --- a/wgpu/src/api/adapter.rs +++ b/wgpu/src/api/adapter.rs @@ -1,4 +1,4 @@ -use std::future::Future; +use core::future::Future; use crate::*; diff --git a/wgpu/src/api/blas.rs b/wgpu/src/api/blas.rs index ed7a14e33..67798487d 100644 --- a/wgpu/src/api/blas.rs +++ b/wgpu/src/api/blas.rs @@ -1,6 +1,9 @@ +use alloc::{boxed::Box, vec::Vec}; + +use wgt::WasmNotSendSync; + use crate::dispatch; use crate::{Buffer, Label}; -use wgt::WasmNotSendSync; /// Descriptor for the size defining attributes of a triangle geometry, for a bottom level acceleration structure. pub type BlasTriangleGeometrySizeDescriptor = wgt::BlasTriangleGeometrySizeDescriptor; diff --git a/wgpu/src/api/buffer.rs b/wgpu/src/api/buffer.rs index cfcb8a02a..49a3b58e9 100644 --- a/wgpu/src/api/buffer.rs +++ b/wgpu/src/api/buffer.rs @@ -1,7 +1,7 @@ -use std::{ +use alloc::{boxed::Box, sync::Arc, vec::Vec}; +use core::{ error, fmt, ops::{Bound, Deref, DerefMut, Range, RangeBounds}, - sync::Arc, }; use parking_lot::Mutex; @@ -701,7 +701,7 @@ pub struct BufferView<'a> { inner: dispatch::DispatchBufferMappedRange, } -impl std::ops::Deref for BufferView<'_> { +impl core::ops::Deref for BufferView<'_> { type Target = [u8]; #[inline] diff --git a/wgpu/src/api/command_encoder.rs b/wgpu/src/api/command_encoder.rs index affafc123..1f5b67b33 100644 --- a/wgpu/src/api/command_encoder.rs +++ b/wgpu/src/api/command_encoder.rs @@ -1,4 +1,4 @@ -use std::ops::Range; +use core::ops::Range; use crate::{ api::{ diff --git a/wgpu/src/api/device.rs b/wgpu/src/api/device.rs index 762302275..45b0a43f2 100644 --- a/wgpu/src/api/device.rs +++ b/wgpu/src/api/device.rs @@ -1,4 +1,5 @@ -use std::{error, fmt, future::Future, sync::Arc}; +use alloc::{boxed::Box, string::String, sync::Arc}; +use core::{error, fmt, future::Future}; use parking_lot::Mutex; @@ -162,7 +163,7 @@ impl Device { let encoder = self.inner.create_render_bundle_encoder(desc); RenderBundleEncoder { inner: encoder, - _p: std::marker::PhantomData, + _p: core::marker::PhantomData, } } diff --git a/wgpu/src/api/instance.rs b/wgpu/src/api/instance.rs index a8daf37fd..4afc67fdc 100644 --- a/wgpu/src/api/instance.rs +++ b/wgpu/src/api/instance.rs @@ -1,9 +1,11 @@ +#[cfg(native)] +use alloc::vec::Vec; +use core::future::Future; + use parking_lot::Mutex; use crate::{dispatch::InstanceInterface, *}; -use std::future::Future; - bitflags::bitflags! { /// WGSL language extensions. /// @@ -309,7 +311,7 @@ impl Instance { handle_source = None; let value: &wasm_bindgen::JsValue = &canvas; - let obj = std::ptr::NonNull::from(value).cast(); + let obj = core::ptr::NonNull::from(value).cast(); let raw_window_handle = raw_window_handle::WebCanvasWindowHandle::new(obj).into(); let raw_display_handle = raw_window_handle::WebDisplayHandle::new().into(); @@ -328,7 +330,7 @@ impl Instance { handle_source = None; let value: &wasm_bindgen::JsValue = &canvas; - let obj = std::ptr::NonNull::from(value).cast(); + let obj = core::ptr::NonNull::from(value).cast(); let raw_window_handle = raw_window_handle::WebOffscreenCanvasWindowHandle::new(obj).into(); let raw_display_handle = raw_window_handle::WebDisplayHandle::new().into(); diff --git a/wgpu/src/api/mod.rs b/wgpu/src/api/mod.rs index 593d8a259..90b35b49b 100644 --- a/wgpu/src/api/mod.rs +++ b/wgpu/src/api/mod.rs @@ -85,11 +85,11 @@ pub type Label<'a> = Option<&'a str>; /// with the type to be used until the Drop impl is ran. This prevents /// lifetimes from being shortened. #[derive(Debug)] -pub(crate) struct PhantomDrop(std::marker::PhantomData); +pub(crate) struct PhantomDrop(core::marker::PhantomData); impl Default for PhantomDrop { fn default() -> Self { - Self(std::marker::PhantomData) + Self(core::marker::PhantomData) } } diff --git a/wgpu/src/api/pipeline_cache.rs b/wgpu/src/api/pipeline_cache.rs index e3b7a4b04..f1cd414f5 100644 --- a/wgpu/src/api/pipeline_cache.rs +++ b/wgpu/src/api/pipeline_cache.rs @@ -1,3 +1,5 @@ +use alloc::vec::Vec; + use crate::*; /// Handle to a pipeline cache, which is used to accelerate @@ -67,7 +69,7 @@ use crate::*; /// [renaming]: std::fs::rename #[derive(Debug, Clone)] pub struct PipelineCache { - pub(crate) inner: dispatch::DispatchPipelineCache, + pub(crate) inner: crate::dispatch::DispatchPipelineCache, } #[cfg(send_sync)] diff --git a/wgpu/src/api/queue.rs b/wgpu/src/api/queue.rs index 8442f2aae..b0e7e5817 100644 --- a/wgpu/src/api/queue.rs +++ b/wgpu/src/api/queue.rs @@ -1,4 +1,5 @@ -use std::ops::{Deref, DerefMut}; +use alloc::boxed::Box; +use core::ops::{Deref, DerefMut}; use crate::*; diff --git a/wgpu/src/api/render_bundle_encoder.rs b/wgpu/src/api/render_bundle_encoder.rs index af0a22510..50e842464 100644 --- a/wgpu/src/api/render_bundle_encoder.rs +++ b/wgpu/src/api/render_bundle_encoder.rs @@ -1,4 +1,4 @@ -use std::{marker::PhantomData, num::NonZeroU32, ops::Range}; +use core::{marker::PhantomData, num::NonZeroU32, ops::Range}; use crate::dispatch::RenderBundleEncoderInterface; use crate::*; diff --git a/wgpu/src/api/render_pass.rs b/wgpu/src/api/render_pass.rs index 680202563..a541b3150 100644 --- a/wgpu/src/api/render_pass.rs +++ b/wgpu/src/api/render_pass.rs @@ -1,4 +1,4 @@ -use std::ops::Range; +use core::ops::Range; use crate::*; pub use wgt::{LoadOp, Operations, StoreOp}; diff --git a/wgpu/src/api/render_pipeline.rs b/wgpu/src/api/render_pipeline.rs index 11600c56a..fdd80cda7 100644 --- a/wgpu/src/api/render_pipeline.rs +++ b/wgpu/src/api/render_pipeline.rs @@ -1,4 +1,4 @@ -use std::num::NonZeroU32; +use core::num::NonZeroU32; use crate::*; diff --git a/wgpu/src/api/shader_module.rs b/wgpu/src/api/shader_module.rs index 14eadfd69..241d19b09 100644 --- a/wgpu/src/api/shader_module.rs +++ b/wgpu/src/api/shader_module.rs @@ -1,4 +1,10 @@ -use std::{borrow::Cow, future::Future, marker::PhantomData}; +use alloc::{ + borrow::Cow, + string::{String, ToString as _}, + vec, + vec::Vec, +}; +use core::{future::Future, marker::PhantomData}; use crate::*; diff --git a/wgpu/src/api/surface.rs b/wgpu/src/api/surface.rs index bd2532d61..dddfd13ec 100644 --- a/wgpu/src/api/surface.rs +++ b/wgpu/src/api/surface.rs @@ -1,4 +1,6 @@ -use std::{error, fmt}; +use alloc::{boxed::Box, string::String, vec, vec::Vec}; +use core::fmt; +use std::error; // TODO(https://github.com/gfx-rs/wgpu/issues/6826): use core::error after MSRV bump use parking_lot::Mutex; use raw_window_handle::{HasDisplayHandle, HasWindowHandle}; @@ -294,7 +296,7 @@ pub enum SurfaceTargetUnsafe { /// /// - layer must be a valid object to create a surface upon. #[cfg(metal)] - CoreAnimationLayer(*mut std::ffi::c_void), + CoreAnimationLayer(*mut core::ffi::c_void), /// Surface from `IDCompositionVisual`. /// @@ -302,7 +304,7 @@ pub enum SurfaceTargetUnsafe { /// /// - visual must be a valid `IDCompositionVisual` to create a surface upon. Its refcount will be incremented internally and kept live as long as the resulting [`Surface`] is live. #[cfg(dx12)] - CompositionVisual(*mut std::ffi::c_void), + CompositionVisual(*mut core::ffi::c_void), /// Surface from DX12 `DirectComposition` handle. /// @@ -313,7 +315,7 @@ pub enum SurfaceTargetUnsafe { /// - surface_handle must be a valid `DirectComposition` handle to create a surface upon. Its lifetime **will not** be internally managed: this handle **should not** be freed before /// the resulting [`Surface`] is destroyed. #[cfg(dx12)] - SurfaceHandle(*mut std::ffi::c_void), + SurfaceHandle(*mut core::ffi::c_void), /// Surface from DX12 `SwapChainPanel`. /// @@ -321,7 +323,7 @@ pub enum SurfaceTargetUnsafe { /// /// - visual must be a valid SwapChainPanel to create a surface upon. Its refcount will be incremented internally and kept live as long as the resulting [`Surface`] is live. #[cfg(dx12)] - SwapChainPanel(*mut std::ffi::c_void), + SwapChainPanel(*mut core::ffi::c_void), } impl SurfaceTargetUnsafe { diff --git a/wgpu/src/api/surface_texture.rs b/wgpu/src/api/surface_texture.rs index 2ca5155c6..16aa4cc3c 100644 --- a/wgpu/src/api/surface_texture.rs +++ b/wgpu/src/api/surface_texture.rs @@ -1,4 +1,6 @@ -use std::{error, fmt, thread}; +use core::fmt; +use std::error; // TODO(https://github.com/gfx-rs/wgpu/issues/6826): use core::error after MSRV bump +use std::thread; use crate::*; diff --git a/wgpu/src/api/tlas.rs b/wgpu/src/api/tlas.rs index c7a80ef63..bf1c8531e 100644 --- a/wgpu/src/api/tlas.rs +++ b/wgpu/src/api/tlas.rs @@ -1,7 +1,8 @@ +use alloc::{sync::Arc, vec, vec::Vec}; +use core::ops::{Index, IndexMut, Range}; + use crate::{api::blas::TlasInstance, dispatch}; use crate::{BindingResource, Buffer, Label}; -use std::ops::{Index, IndexMut, Range}; -use std::sync::Arc; use wgt::WasmNotSendSync; /// Descriptor to create top level acceleration structures. diff --git a/wgpu/src/backend/webgpu.rs b/wgpu/src/backend/webgpu.rs index 1e87e76e1..508a72fbc 100644 --- a/wgpu/src/backend/webgpu.rs +++ b/wgpu/src/backend/webgpu.rs @@ -5,16 +5,24 @@ mod ext_bindings; #[allow(clippy::allow_attributes)] mod webgpu_sys; -use js_sys::Promise; -use std::{ +use alloc::{ + boxed::Box, + format, + rc::Rc, + string::{String, ToString as _}, + vec, + vec::Vec, +}; +use core::{ cell::RefCell, fmt, future::Future, ops::Range, pin::Pin, - rc::Rc, task::{self, Poll}, }; + +use js_sys::Promise; use wasm_bindgen::{prelude::*, JsCast}; use crate::{dispatch, SurfaceTargetUnsafe}; @@ -54,7 +62,7 @@ impl fmt::Debug for ContextWebGpu { impl crate::Error { fn from_js(js_error: js_sys::Object) -> Self { - let source = Box::::from(""); + let source = Box::::from(""); if let Some(js_error) = js_error.dyn_ref::() { crate::Error::Validation { source, @@ -967,7 +975,7 @@ fn future_compilation_info( .collect() } Err(_v) => base_messages - .chain(std::iter::once(crate::CompilationMessage { + .chain(core::iter::once(crate::CompilationMessage { message: "Getting compilation info failed".to_string(), message_type: crate::CompilationMessageType::Error, location: None, diff --git a/wgpu/src/backend/webgpu/defined_non_null_js_value.rs b/wgpu/src/backend/webgpu/defined_non_null_js_value.rs index 376102881..c2b61bfd5 100644 --- a/wgpu/src/backend/webgpu/defined_non_null_js_value.rs +++ b/wgpu/src/backend/webgpu/defined_non_null_js_value.rs @@ -1,4 +1,4 @@ -use std::ops::{Deref, DerefMut}; +use core::ops::{Deref, DerefMut}; use wasm_bindgen::JsValue; diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index 98463cbcd..561d39322 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -1,3 +1,20 @@ +use alloc::{ + borrow::Cow::Borrowed, + boxed::Box, + format, + string::{String, ToString as _}, + sync::Arc, + vec, + vec::Vec, +}; +use core::{error::Error, fmt, future::ready, ops::Range, pin::Pin, ptr::NonNull, slice}; + +use arrayvec::ArrayVec; +use parking_lot::Mutex; +use smallvec::SmallVec; +use wgc::{command::bundle_ffi::*, error::ContextErrorSource, pipeline::CreateShaderModuleError}; +use wgt::WasmNotSendSync; + use crate::{ api, dispatch::{self, BufferMappedRangeInterface, InterfaceTypes}, @@ -6,16 +23,6 @@ use crate::{ ShaderSource, SurfaceTargetUnsafe, TextureDescriptor, }; -use arrayvec::ArrayVec; -use parking_lot::Mutex; -use smallvec::SmallVec; -use std::{ - borrow::Cow::Borrowed, error::Error, fmt, future::ready, ops::Range, pin::Pin, ptr::NonNull, - slice, sync::Arc, -}; -use wgc::{command::bundle_ffi::*, error::ContextErrorSource, pipeline::CreateShaderModuleError}; -use wgt::WasmNotSendSync; - #[derive(Clone)] pub struct ContextWgpuCore(Arc); @@ -338,7 +345,7 @@ impl ContextWgpuCore { fn print_tree(output: &mut String, level: &mut usize, e: &(dyn Error + 'static)) { let mut print = |e: &(dyn Error + 'static)| { - use std::fmt::Write; + use core::fmt::Write; writeln!(output, "{}{}", " ".repeat(*level * 2), e).unwrap(); if let Some(e) = e.source() { @@ -642,7 +649,7 @@ impl ErrorSinkRaw { } impl fmt::Debug for ErrorSinkRaw { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "ErrorSink") } } @@ -2304,7 +2311,7 @@ impl dispatch::CommandEncoderInterface for CoreCommandEncoder { &wgc::command::RenderPassDescriptor { label: desc.label.map(Borrowed), timestamp_writes: timestamp_writes.as_ref(), - color_attachments: std::borrow::Cow::Borrowed(&colors), + color_attachments: Borrowed(&colors), depth_stencil_attachment: depth_stencil.as_ref(), occlusion_query_set: desc.occlusion_query_set.map(|qs| qs.inner.as_core().id), }, diff --git a/wgpu/src/cmp.rs b/wgpu/src/cmp.rs index 2ba35fac9..64fc73f11 100644 --- a/wgpu/src/cmp.rs +++ b/wgpu/src/cmp.rs @@ -4,7 +4,7 @@ //! //! For types (like WebGPU) that don't have such a property, we generate an identifier and use that. -use std::{ +use core::{ num::NonZeroU64, sync::atomic::{AtomicU64, Ordering}, }; @@ -41,19 +41,19 @@ macro_rules! impl_eq_ord_hash_proxy { impl Eq for $type {} impl PartialOrd for $type { - fn partial_cmp(&self, other: &Self) -> Option { + fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } impl Ord for $type { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { + fn cmp(&self, other: &Self) -> core::cmp::Ordering { self $($access)*.cmp(&other $($access)*) } } - impl std::hash::Hash for $type { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for $type { + fn hash(&self, state: &mut H) { self $($access)*.hash(state) } } @@ -70,8 +70,8 @@ macro_rules! impl_eq_ord_hash_arc_address { ($type:ty => $($access:tt)*) => { impl PartialEq for $type { fn eq(&self, other: &Self) -> bool { - let address_left = std::sync::Arc::as_ptr(&self $($access)*); - let address_right = std::sync::Arc::as_ptr(&other $($access)*); + let address_left = alloc::sync::Arc::as_ptr(&self $($access)*); + let address_right = alloc::sync::Arc::as_ptr(&other $($access)*); address_left == address_right } @@ -80,23 +80,23 @@ macro_rules! impl_eq_ord_hash_arc_address { impl Eq for $type {} impl PartialOrd for $type { - fn partial_cmp(&self, other: &Self) -> Option { + fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } impl Ord for $type { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - let address_left = std::sync::Arc::as_ptr(&self $($access)*); - let address_right = std::sync::Arc::as_ptr(&other $($access)*); + fn cmp(&self, other: &Self) -> core::cmp::Ordering { + let address_left = alloc::sync::Arc::as_ptr(&self $($access)*); + let address_right = alloc::sync::Arc::as_ptr(&other $($access)*); address_left.cmp(&address_right) } } - impl std::hash::Hash for $type { - fn hash(&self, state: &mut H) { - let address = std::sync::Arc::as_ptr(&self $($access)*); + impl core::hash::Hash for $type { + fn hash(&self, state: &mut H) { + let address = alloc::sync::Arc::as_ptr(&self $($access)*); address.hash(state) } } diff --git a/wgpu/src/dispatch.rs b/wgpu/src/dispatch.rs index 9a790dee3..06c11d6e0 100644 --- a/wgpu/src/dispatch.rs +++ b/wgpu/src/dispatch.rs @@ -13,7 +13,8 @@ use crate::{WasmNotSend, WasmNotSendSync}; -use std::{any::Any, fmt::Debug, future::Future, hash::Hash, ops::Range, pin::Pin, sync::Arc}; +use alloc::{boxed::Box, string::String, sync::Arc, vec::Vec}; +use core::{any::Any, fmt::Debug, future::Future, hash::Hash, ops::Range, pin::Pin}; use crate::backend; @@ -632,7 +633,7 @@ macro_rules! dispatch_types_inner { } } - impl std::ops::Deref for $name { + impl core::ops::Deref for $name { type Target = dyn $trait; #[inline] @@ -763,7 +764,7 @@ macro_rules! dispatch_types_inner { } } - impl std::ops::Deref for $name { + impl core::ops::Deref for $name { type Target = dyn $trait; #[inline] @@ -779,7 +780,7 @@ macro_rules! dispatch_types_inner { } } - impl std::ops::DerefMut for $name { + impl core::ops::DerefMut for $name { #[inline] fn deref_mut(&mut self) -> &mut Self::Target { match self { diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 7b799a2a3..3739cd314 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -14,10 +14,14 @@ //! - **`naga`** ---- Enabled when any non-wgsl shader input is enabled. //! +#![no_std] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![doc(html_logo_url = "https://raw.githubusercontent.com/gfx-rs/wgpu/trunk/logo.png")] #![warn( + clippy::alloc_instead_of_core, clippy::allow_attributes, + clippy::std_instead_of_alloc, + clippy::std_instead_of_core, missing_docs, rust_2018_idioms, unsafe_op_in_unsafe_fn @@ -25,6 +29,8 @@ #![allow(clippy::arc_with_non_send_sync)] #![cfg_attr(not(any(wgpu_core, webgpu)), allow(unused))] +extern crate alloc; +extern crate std; #[cfg(wgpu_core)] pub extern crate wgpu_core as wgc; #[cfg(wgpu_core)] @@ -111,8 +117,3 @@ pub use raw_window_handle as rwh; /// #[cfg(any(webgl, webgpu))] pub use web_sys; - -/// `web-sys` has a `no_std` mode, and instead refers to the `alloc` crate in its generated code. -/// Since we vendor the WebGPU bindings we need to explicitly add the `alloc` crate ourselves. -#[cfg(webgpu)] -extern crate alloc; diff --git a/wgpu/src/util/belt.rs b/wgpu/src/util/belt.rs index 0e9049207..222a49f4c 100644 --- a/wgpu/src/util/belt.rs +++ b/wgpu/src/util/belt.rs @@ -2,7 +2,8 @@ use crate::{ util::align_to, Buffer, BufferAddress, BufferDescriptor, BufferSize, BufferSlice, BufferUsages, BufferViewMut, CommandEncoder, Device, MapMode, }; -use std::fmt; +use alloc::vec::Vec; +use core::fmt; use std::sync::mpsc; /// Efficiently performs many buffer writes by sharing and reusing temporary buffers. diff --git a/wgpu/src/util/device.rs b/wgpu/src/util/device.rs index 54dc77b17..97973c422 100644 --- a/wgpu/src/util/device.rs +++ b/wgpu/src/util/device.rs @@ -1,3 +1,5 @@ +use alloc::borrow::ToOwned as _; + use wgt::TextureDataOrder; /// Describes a [Buffer](crate::Buffer) when allocating. diff --git a/wgpu/src/util/encoder.rs b/wgpu/src/util/encoder.rs index c6d42e3eb..3ce71c32f 100644 --- a/wgpu/src/util/encoder.rs +++ b/wgpu/src/util/encoder.rs @@ -1,4 +1,4 @@ -use std::ops::Range; +use core::ops::Range; use wgt::{BufferAddress, DynamicOffset, IndexFormat}; diff --git a/wgpu/src/util/mod.rs b/wgpu/src/util/mod.rs index 7d04000af..100862e6d 100644 --- a/wgpu/src/util/mod.rs +++ b/wgpu/src/util/mod.rs @@ -9,8 +9,8 @@ mod encoder; mod init; mod texture_blitter; -use std::sync::Arc; -use std::{borrow::Cow, ptr::copy_nonoverlapping}; +use alloc::{borrow::Cow, format, string::String, sync::Arc, vec}; +use core::ptr::copy_nonoverlapping; pub use belt::StagingBelt; pub use device::{BufferInitDescriptor, DeviceExt}; @@ -134,7 +134,7 @@ impl DownloadBuffer { } } -impl std::ops::Deref for DownloadBuffer { +impl core::ops::Deref for DownloadBuffer { type Target = [u8]; fn deref(&self) -> &[u8] { self.mapped_range.slice()