Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-std support in wgpu-core #6926

Draft
wants to merge 20 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
df036fa
trace directory path updates
brody4hire Jan 16, 2025
7b79bbe
start using hashbrown (in wgpu-core)
brody4hire Jan 16, 2025
213f61a
update CHANGELOG.md
brody4hire Jan 16, 2025
dd51a90
Merge branch 'start-using-hashbrown' into no-std-support-in-wgpu-core
brody4hire Jan 16, 2025
d402fe5
FIXUP taplo fmt
brody4hire Jan 16, 2025
8fc9c59
Merge branch 'start-using-hashbrown' into no-std-support-in-wgpu-core
brody4hire Jan 16, 2025
bbc1af2
no-std support in wgpu-core (with help from new "std" feature)
brody4hire Jan 16, 2025
ab211cd
Merge branch 'trunk' of https://github.com/gfx-rs/wgpu into no-std-su…
brody4hire Jan 16, 2025
d293ee8
FIXUP for unit testing etc.
brody4hire Jan 16, 2025
eac4774
fixup fmt
brody4hire Jan 16, 2025
da8453f
comment out no-std OnceCell alias for now - XXX THIS SHOULD TRIGGER C…
brody4hire Jan 16, 2025
f4d275d
XXX IGNORE WARNINGS FOR NOW - XXX TODO CLEANUP WARNING(S) & REMOVE AL…
brody4hire Jan 16, 2025
c68e0a2
XXX QUICK error import FIXUP for MSRV & FIXUP COMMENT - XXX XXX MISSI…
brody4hire Jan 16, 2025
3b73f30
update CI to check wgpu-core with no features - XXX XXX CI SHOULD FAI…
brody4hire Jan 17, 2025
b82f877
Merge branch 'trunk' of https://github.com/gfx-rs/wgpu into no-std-su…
brody4hire Jan 17, 2025
af41fdb
FIXUP typo (etc) in ci.yml - XXX XXX CI SHOULD STILL FAIL & SIGNAL MI…
brody4hire Jan 17, 2025
ea17991
XXX TBD SKIP FAILING CI SUB-STEP FOR NOW WITH XXX TODO COMMENT - XXX …
brody4hire Jan 17, 2025
d0f0a66
XXX ADD EXTRA CI SUB-STEP for now - XXX XXX SHOULD (HOPEFULLY) DETECT…
brody4hire Jan 17, 2025
a1edb9c
FIXUP: remove extra import - XXX XXX CI SHOULD STILL FAIL DUE TO MISS…
brody4hire Jan 17, 2025
a20d79b
FIXUP: uncomment imports needed for no-std; update XXX comments - XXX…
brody4hire Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ Bottom level categories:

## Unreleased

### Major changes

#### no-std support in `wgpu-core`

XXX TODO

By XXX in XXX

### Changes

#### Refactored internal trace path parameter
Expand Down
13 changes: 10 additions & 3 deletions wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(wgpu_validate_locks)'] }
[lib]

[features]
default = ["std"]

## XXX TODO DOCUMENT THIS
std = []

# XXX TODO I think I got it right which features actually require std - I think we should find a way to check this in CI

## Internally count resources and events for debugging purposes. If the counters
## feature is disabled, the counting infrastructure is removed from the build and
## the exposed counters always return 0.
Expand Down Expand Up @@ -63,13 +70,13 @@ indirect-validation = ["naga/wgsl-in"]
serde = ["dep:serde", "wgt/serde", "arrayvec/serde"]

## Enable API tracing.
trace = ["dep:ron", "serde", "naga/serialize"]
trace = ["std", "dep:ron", "serde", "naga/serialize"]

## Enable lock order observation.
observe_locks = ["dep:ron", "serde/serde_derive"]
observe_locks = ["std", "dep:ron", "serde/serde_derive"]

## Enable API replaying
replay = ["serde", "naga/deserialize"]
replay = ["std", "serde", "naga/deserialize"]

## Enable creating instances using raw-window-handle
raw-window-handle = ["dep:raw-window-handle"]
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/binding_model.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
alias::*,
device::{
bgl, Device, DeviceError, MissingDownlevelFlags, MissingFeatures, SHADER_STAGE_COUNT,
},
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/command/allocator.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::alias::*;
use crate::lock::{rank, Mutex};

/// A pool of free [`wgpu_hal::CommandEncoder`]s, owned by a `Device`.
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/command/bind.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::sync::Arc;

use crate::{
alias::*,
binding_model::{BindGroup, LateMinBufferBindingSizeMismatch, PipelineLayout},
device::SHADER_STAGE_COUNT,
pipeline::LateSizedBufferGroup,
Expand All @@ -16,6 +17,7 @@ mod compat {
use wgt::{BindingType, ShaderStages};

use crate::{
alias::*,
binding_model::BindGroupLayout,
error::MultiError,
resource::{Labeled, ParentDevice, ResourceErrorIdent},
Expand Down
3 changes: 2 additions & 1 deletion wgpu-core/src/command/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ index format changes.
#![allow(clippy::reversed_empty_ranges)]

use crate::{
alias::*,
binding_model::{BindError, BindGroup, PipelineLayout},
command::{
BasePass, BindGroupStateChange, ColorAttachmentError, DrawError, MapPassErr,
Expand Down Expand Up @@ -1573,7 +1574,7 @@ where

pub mod bundle_ffi {
use super::{RenderBundleEncoder, RenderCommand};
use crate::{id, RawString};
use crate::{alias::*, id, RawString};
use std::{convert::TryInto, slice};
use wgt::{BufferAddress, BufferSize, DynamicOffset, IndexFormat};

Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/command/clear.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::alias::*;

use std::{ops::Range, sync::Arc};

#[cfg(feature = "trace")]
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
alias::*,
binding_model::{
BindError, BindGroup, LateMinBufferBindingSizeMismatch, PushConstantUploadError,
},
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/command/compute_command.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::sync::Arc;

use crate::{
alias::*,
binding_model::BindGroup,
id,
pipeline::ComputePipeline,
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/command/draw.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
alias::*,
binding_model::{LateMinBufferBindingSizeMismatch, PushConstantUploadError},
resource::{
DestroyedResourceError, MissingBufferUsageError, MissingTextureUsageError,
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/command/memory_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{ops::Range, sync::Arc, vec::Drain};
use hashbrown::hash_map::Entry;

use crate::{
alias::*,
device::Device,
init_tracker::*,
resource::{DestroyedResourceError, ParentDevice, Texture, Trackable},
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ mod render_command;
mod timestamp_writes;
mod transfer;

use crate::alias::*;

use std::mem::{self, ManuallyDrop};
use std::sync::Arc;

Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/command/query.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[cfg(feature = "trace")]
use crate::device::trace::Command as TraceCommand;
use crate::{
alias::*,
command::{CommandBuffer, CommandEncoderError},
device::{DeviceError, MissingFeatures},
global::Global,
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/command/ray_tracing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
alias::*,
device::queue::TempResource,
global::Global,
hub::Hub,
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::alias::*;
use crate::binding_model::BindGroup;
use crate::command::{
validate_and_begin_occlusion_query, validate_and_begin_pipeline_statistics_query,
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/command/render_command.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
alias::*,
binding_model::BindGroup,
id,
pipeline::RenderPipeline,
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/command/timestamp_writes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::sync::Arc;

use crate::alias::*;
use crate::id;

/// Describes the writing of timestamp values in a render or compute pass.
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/command/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[cfg(feature = "trace")]
use crate::device::trace::Command as TraceCommand;
use crate::{
alias::*,
api_log,
command::{clear_texture, CommandEncoderError},
conv,
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/device/bgl.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::hash::{Hash, Hasher};

use crate::{
alias::*,
binding_model::{self},
FastIndexMap,
};
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/device/global.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[cfg(feature = "trace")]
use crate::device::trace;
use crate::{
alias::*,
api_log,
binding_model::{
self, BindGroupEntry, BindingResource, BufferBinding, ResolvedBindGroupDescriptor,
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/device/life.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
alias::*,
device::{
queue::{EncoderInFlight, SubmittedWorkDoneClosure, TempResource},
DeviceError,
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
alias::*,
binding_model,
hub::Hub,
id::{BindGroupLayoutId, PipelineLayoutId},
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/device/queue.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[cfg(feature = "trace")]
use crate::device::trace::Action;
use crate::{
alias::*,
api_log,
command::{
extract_texture_selector, validate_linear_texture_data, validate_texture_copy_range,
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/device/ray_tracing.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::alias::*;

use std::mem::ManuallyDrop;
use std::sync::Arc;

Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/device/resource.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[cfg(feature = "trace")]
use crate::device::trace;
use crate::{
alias::*,
binding_model::{self, BindGroup, BindGroupLayout, BindGroupLayoutEntryError},
command, conv,
device::{
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/device/trace.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::alias::*;
use crate::id;
use std::ops::Range;
#[cfg(feature = "trace")]
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::alias::*;

use core::fmt;
use std::{error::Error, sync::Arc};

Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/global.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::alias::*;

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

use crate::{
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/hash_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//!
//! Named hash_utils to prevent clashing with the std::hash module.

use crate::alias::*;

/// HashMap using a fast, non-cryptographic hash algorithm.
pub type FastHashMap<K, V> =
hashbrown::HashMap<K, V, std::hash::BuildHasherDefault<rustc_hash::FxHasher>>;
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ flagged as errors as well.
*/

use crate::{
alias::*,
binding_model::{BindGroup, BindGroupLayout, PipelineLayout},
command::{CommandBuffer, RenderBundle},
device::{queue::Queue, Device},
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/id.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// XXX TBD FMT ???
use crate::alias::*;
use crate::{Epoch, Index};
use std::{
cmp::Ordering,
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/identity.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
alias::*,
id::{Id, Marker},
lock::{rank, Mutex},
Epoch, Index,
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/indirect_validation.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::alias::*;

use std::mem::size_of;
use std::num::NonZeroU64;

Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/init_tracker/buffer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::{InitTracker, MemoryInitKind};
use crate::alias::*;
use crate::resource::Buffer;
use std::{ops::Range, sync::Arc};

Expand Down
3 changes: 3 additions & 0 deletions wgpu-core/src/init_tracker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ system there are two kind of writes:

*/

use crate::alias::*;

use smallvec::SmallVec;
use std::{fmt, iter, ops::Range};

Expand Down Expand Up @@ -280,6 +282,7 @@ impl InitTracker<u32> {

#[cfg(test)]
mod test {
use crate::alias::*;
use std::ops::Range;

type Tracker = super::InitTracker<u32>;
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/init_tracker/texture.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use super::{InitTracker, MemoryInitKind};
// XXX TBD FMT ???
use crate::alias::*;
use crate::{resource::Texture, track::TextureSelector};
use arrayvec::ArrayVec;
use std::{ops::Range, sync::Arc};
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/instance.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::alias::*;

use std::borrow::Cow;
use std::sync::Arc;

Expand Down
Loading
Loading