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

apologies meant to raise on my personal fork: no-std support in naga #6951

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 35 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ env:
RUST_LOG: debug
RUST_BACKTRACE: full
PKG_CONFIG_ALLOW_CROSS: 1 # allow android to work
# XXX TODO CONFIGURE THIS PER JOB - NOT ALL JOBS SHOULD FAIL WITH CARGO WARNINGS
RUSTFLAGS: -D warnings
RUSTDOCFLAGS: -D warnings
WASM_BINDGEN_TEST_TIMEOUT: 300 # 5 minutes
Expand Down Expand Up @@ -161,15 +162,19 @@ jobs:
target: wasm32-unknown-emscripten
tier: 2
kind: wgpu-only


# XXX TODO REMOVE TRAILING SPACE IN SEPARATE PR

# TODO: Uncomment once web-sys updates past 0.3.76
# See https://github.com/rustwasm/wasm-bindgen/pull/4378 for details
# - name: WebAssembly Core 1.0
# os: ubuntu-22.04
# target: wasm32v1-none
# tier: 2
# kind: no_std


# XXX TODO REMOVE TRAILING SPACE IN SEPARATE PR

# Bare-metal x86-64
# TODO: Remove once web-sys updates past 0.3.76
# Included while wasm32v1-none is failing to ensure `no_std` does not regress
Expand All @@ -179,6 +184,13 @@ jobs:
tier: 2
kind: no_std

# XXX TODO MOVE INTO SEPARATE CI JOB:
- name: no-std feature test - Linux x86_64
os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
tier: 1
kind: no-std-feature-test

name: Clippy ${{ matrix.name }}
runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -276,17 +288,22 @@ jobs:
# Check with all features.
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-hal --all-features
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu --all-features


# XXX TODO REMOVE TRAILING SPACE IN SEPARATE PR

# Building for no_std platforms where every feature is enabled except "std".
- name: check no_std
if: matrix.kind == 'no_std'
shell: bash
run: |
set -e

# check with no features
# check with no features - wgpu-types
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-types --no-default-features
# check with no features - naga
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p naga --no-default-features

# XXX TODO SIMILAR SUB-STEP for naga with all features possible with no-std (once this is supported)
# Check with all features except "std".
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-types --no-default-features --features strict_asserts,fragile-send-sync-non-atomic-wasm,serde,counters

Expand All @@ -306,6 +323,20 @@ jobs:
# build docs
cargo doc --target ${{ matrix.target }} ${{ matrix.extra-flags }} --all-features --no-deps

# XXX TODO MOVE INTO SEPARATE CI JOB - MAY SHOW UP AS A "Clippy" job in GitHub CI
- name: no-std feature test
if: matrix.kind == 'no-std-feature-test'
shell: bash
run: |
set -e

# no-std feature test with no features - naga
cargo test --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p naga --no-default-features

# XXX TODO FIX & TEST MULTIPLE naga features for no-std
# no-std test with multiple features - naga
# cargo test [...]

- name: check private item docs
if: matrix.kind == 'native'
shell: bash
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ Bottom level categories:

## Unreleased

### Major changes

#### no-std support in naga

XXX TODO

### Changes

#### General
Expand Down
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ version = "24.0.0"
[workspace.dependencies]
anyhow = "1.0.95"
argh = "0.1.13"
arrayvec = "0.7"
arrayvec = { version = "0.7", default-features = false }
bincode = "1"
bit-set = { version = "0.8", default-features = false }
bit-vec = "0.8"
bitflags = "2.7"
bytemuck = { version = "1.21", features = ["derive", "min_const_generics"] }
Expand All @@ -100,7 +101,7 @@ hashbrown = { version = "0.15.2", default-features = false, features = [
] }
heck = "0.5.0"
image = { version = "0.24", default-features = false, features = ["png"] }
indexmap = "2"
indexmap = { version = "2", default-features = false }
itertools = { version = "0.13.0" }
ktx2 = "0.3"
libc = "0.2"
Expand Down Expand Up @@ -129,15 +130,16 @@ rayon = "1"
renderdoc-sys = "1.1.0"
ron = "0.8"
# rustc-hash 2.0 is a completely different hasher with different performance characteristics
# XXX TODO NEED UPDATE FROM OTHER PR WITH UPDATED COMMENT: https://github.com/gfx-rs/wgpu/pull/6938
rustc-hash = { version = "1", default-features = false }
serde_json = "1.0.134"
rustc-hash = "1"
serde = { version = "1", default-features = false }
smallvec = "1"
static_assertions = "1.1.0"
strum = { version = "0.26.0", features = ["derive"] }
strum = { version = "0.26", default-features = false, features = ["derive"] }
trybuild = "1"
tracy-client = "0.17"
thiserror = "2"
thiserror = { version = "2", default-features = false }
wgpu = { version = "24.0.0", path = "./wgpu", default-features = false, features = [
"serde",
"wgsl",
Expand All @@ -164,7 +166,6 @@ gpu-alloc = "0.6"
gpu-descriptor = "0.3"

# DX dependencies
bit-set = "0.8"
gpu-allocator = { version = "0.27", default-features = false }
range-alloc = "0.1"
mach-dxcompiler-rs = { version = "0.1.4", default-features = false }
Expand Down
28 changes: 22 additions & 6 deletions naga/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ path = "tests/root.rs"
all-features = true

[features]
default = []
default = ["std"]

# XXX TBD ADD DESCRIPTION HERE (???)
std = ["dep:codespan-reporting", "dep:termcolor"]

# XXX TODO ALL FEATURES BELOW REQUIRE std feature to build - NEED TO SPECIFY THIS
# XXX TODO DETERMINE which features may or may not be able to work with no-std

dot-out = []
glsl-in = ["dep:pp-rs"]
glsl-out = []
Expand All @@ -41,8 +48,13 @@ msl-out = []
## If you want to enable MSL output it regardless of the target platform, use `naga/msl-out`.
msl-out-if-target-apple = []

serialize = ["dep:serde", "bitflags/serde", "indexmap/serde"]
deserialize = ["dep:serde", "bitflags/serde", "indexmap/serde"]
serialize = ["dep:serde", "bitflags/serde", "hashbrown/serde", "indexmap/serde"]
deserialize = [
"dep:serde",
"bitflags/serde",
"hashbrown/serde",
"indexmap/serde",
]
arbitrary = ["dep:arbitrary", "bitflags/arbitrary", "indexmap/arbitrary"]
spv-in = ["dep:petgraph", "dep:spirv"]
spv-out = ["dep:spirv"]
Expand All @@ -67,14 +79,18 @@ arbitrary = { version = "1.4", features = ["derive"], optional = true }
arrayvec.workspace = true
bitflags.workspace = true
bit-set.workspace = true
termcolor = { version = "1.4.1" }
# remove termcolor dep when updating to the next version of codespan-reporting
# remove termcolor from here when updating to the next version of codespan-reporting
# termcolor minimum version was wrong and was fixed in
# https://github.com/brendanzab/codespan/commit/e99c867339a877731437e7ee6a903a3d03b5439e
codespan-reporting = { version = "0.11.0" }
termcolor = { version = "1.4.1", optional = true }
codespan-reporting = { version = "0.11.0", optional = true }
hashbrown.workspace = true
rustc-hash.workspace = true
indexmap.workspace = true
log = "0.4"
num-traits = { version = "0.2.19", default-features = false, features = [
"libm",
] }
strum.workspace = true
spirv = { version = "0.3", optional = true }
thiserror.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions naga/src/arena/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
//! [`Arena`]: super::Arena
//! [`UniqueArena`]: super::UniqueArena

#[cfg(not(feature = "std"))]
use crate::aliases::*;

use std::{cmp::Ordering, fmt, hash, marker::PhantomData};

/// An unique index in the arena array that a handle points to.
Expand Down
3 changes: 3 additions & 0 deletions naga/src/arena/handle_set.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! The [`HandleSet`] type and associated definitions.

#[cfg(not(feature = "std"))]
use crate::aliases::*;

use crate::arena::{Arena, Handle, UniqueArena};

/// A set of `Handle<T>` values.
Expand Down
3 changes: 3 additions & 0 deletions naga/src/arena/handlevec.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! The [`HandleVec`] type and associated definitions.

#[cfg(not(feature = "std"))]
use crate::aliases::*;

use super::handle::Handle;

use std::marker::PhantomData;
Expand Down
3 changes: 3 additions & 0 deletions naga/src/arena/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ pub(crate) use handlevec::HandleVec;
pub use range::{BadRangeError, Range};
pub use unique_arena::UniqueArena;

#[cfg(not(feature = "std"))]
use crate::aliases::*;

use crate::Span;

use handle::Index;
Expand Down
3 changes: 3 additions & 0 deletions naga/src/arena/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
//!
//! [`Arena`]: super::Arena

#[cfg(not(feature = "std"))]
use crate::aliases::*;

use super::{
handle::{Handle, Index},
Arena,
Expand Down
3 changes: 3 additions & 0 deletions naga/src/arena/unique_arena.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! The [`UniqueArena`] type and supporting definitions.

#[cfg(not(feature = "std"))]
use crate::aliases::*;

use crate::{FastIndexSet, Span};

use super::handle::{BadHandle, Handle, Index};
Expand Down
3 changes: 3 additions & 0 deletions naga/src/back/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Backend functions that export shader [`Module`](super::Module)s into binary and
*/
#![allow(dead_code)] // can be dead if none of the enabled backends need it

#[cfg(not(feature = "std"))]
use crate::aliases::*;

use crate::proc::ExpressionKindTracker;

#[cfg(dot_out)]
Expand Down
4 changes: 4 additions & 0 deletions naga/src/block.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#[cfg(not(feature = "std"))]
use crate::aliases::*;

use crate::{Span, Statement};

use std::ops::{Deref, DerefMut, RangeBounds};

/// A code block is a vector of statements, with maybe a vector of spans.
Expand Down
3 changes: 3 additions & 0 deletions naga/src/common/wgsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

use std::fmt::{self, Display, Formatter};

#[cfg(not(feature = "std"))]
use crate::aliases::*;

use crate::diagnostic_filter::{
FilterableTriggeringRule, Severity, StandardFilterableTriggeringRule,
};
Expand Down
3 changes: 3 additions & 0 deletions naga/src/diagnostic_filter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! [`DiagnosticFilter`]s and supporting functionality.

#[cfg(not(feature = "std"))]
use crate::aliases::*;

#[cfg(feature = "wgsl-in")]
use crate::Span;
use crate::{Arena, Handle};
Expand Down
5 changes: 5 additions & 0 deletions naga/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[cfg(not(feature = "std"))]
use crate::aliases::*;

use std::{error::Error, fmt};

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -32,6 +35,8 @@ impl fmt::Display for ShaderError<crate::front::spv::Error> {
write!(f, "\nShader '{label}' parsing {string}")
}
}
// XXX TBD FIX for no-std ???
#[cfg(feature = "std")]
impl fmt::Display for ShaderError<crate::WithSpan<crate::valid::ValidationError>> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use codespan_reporting::{files::SimpleFile, term};
Expand Down
3 changes: 3 additions & 0 deletions naga/src/front/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ pub mod spv;
#[cfg(feature = "wgsl-in")]
pub mod wgsl;

#[cfg(not(feature = "std"))]
use crate::aliases::*;

use crate::{
arena::{Arena, Handle, HandleVec, UniqueArena},
proc::{ResolveContext, ResolveError, TypeResolution},
Expand Down
3 changes: 3 additions & 0 deletions naga/src/front/type_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Type generators.
*/

#[cfg(not(feature = "std"))]
use crate::aliases::*;

use crate::{arena::Handle, span::Span};

impl crate::Module {
Expand Down
Loading
Loading