Skip to content

Commit 6151330

Browse files
[wgpu-hal]: MVP no_std support (#7599)
* MVP `no_std` support in `wgpu-hal` * Update CHANGELOG.md * Fix visibility * Fix unused imports * Response to feedback Co-Authored-By: Connor Fitzgerald <connorwadefitzgerald@gmail.com> * Update other `validation_canary` usages Co-Authored-By: Connor Fitzgerald <connorwadefitzgerald@gmail.com> --------- Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
1 parent d190106 commit 6151330

File tree

14 files changed

+73
-54
lines changed

14 files changed

+73
-54
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,12 @@ jobs:
302302
# check with no features
303303
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-types --no-default-features
304304
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p naga --no-default-features
305+
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-hal --no-default-features
305306
306307
# Check with all compatible features
307308
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
308309
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p naga --no-default-features --features dot-out,compact
310+
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-hal --no-default-features --features fragile-send-sync-non-atomic-wasm
309311
310312
# Building for native platforms with standard tests.
311313
- name: Check native

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ Naga now infers the correct binding layout when a resource appears only in an as
106106

107107
- The type of the `size` parameter to `copy_buffer_to_buffer` has changed from `BufferAddress` to `impl Into<Option<BufferAddress>>`. This achieves the spec-defined behavior of the value being optional, while still accepting existing calls without changes. By @andyleiserson in [#7659](https://github.com/gfx-rs/wgpu/pull/7659).
108108

109+
#### HAL
110+
111+
- Added initial `no_std` support to `wgpu-hal`. By @bushrat011899 in [#7599](https://github.com/gfx-rs/wgpu/pull/7599)
112+
109113
### Bug Fixes
110114

111115
#### Naga

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ wgpu-core = { version = "25.0.0", path = "./wgpu-core" }
7878
wgpu-hal = { version = "25.0.0", path = "./wgpu-hal" }
7979
wgpu-macros = { version = "25.0.0", path = "./wgpu-macros" }
8080
wgpu-test = { version = "25.0.0", path = "./tests" }
81-
wgpu-types = { version = "25.0.0", path = "./wgpu-types" }
81+
wgpu-types = { version = "25.0.0", path = "./wgpu-types", default-features = false }
8282

8383
# These _cannot_ have a version specified. If it does, crates.io will look
8484
# for a version of the package on crates when we publish naga. Path dependencies

deno_webgpu/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ wgpu-core = { workspace = true, features = [
2525
"wgsl",
2626
"gles",
2727
] }
28-
wgpu-types = { workspace = true, features = ["serde"] }
28+
wgpu-types = { workspace = true, features = ["serde", "std"] }
2929

3030
deno_core.workspace = true
3131
deno_error.workspace = true

examples/features/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ png.workspace = true
4545
pollster.workspace = true
4646
web-time.workspace = true
4747
wgpu-types = { workspace = true, features = [
48+
"std",
4849
"trace", # TODO(#5974): this should be a dep on wgpu/trace and not wgpu-types at all
4950
] }
5051
winit.workspace = true

player/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ name = "play"
1919
test = false
2020

2121
[dependencies]
22-
wgpu-types = { workspace = true, features = ["serde"] }
22+
wgpu-types = { workspace = true, features = ["serde", "std"] }
2323

2424
env_logger.workspace = true
2525
log.workspace = true

tests/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ webgl = ["wgpu/webgl"]
3232

3333
[dependencies]
3434
wgpu = { workspace = true, features = ["noop"] }
35+
wgpu-hal = { workspace = true, features = ["validation_canary"] }
3536
wgpu-macros.workspace = true
3637

3738
anyhow.workspace = true

wgpu-hal/Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ metal = [
8181
"dep:log",
8282
"dep:metal",
8383
"dep:objc",
84+
"dep:parking_lot",
8485
"dep:profiling",
8586
]
8687
vulkan = [
@@ -96,6 +97,7 @@ vulkan = [
9697
"dep:libloading",
9798
"dep:log",
9899
"dep:ordered-float",
100+
"dep:parking_lot",
99101
"dep:profiling",
100102
"dep:smallvec",
101103
"dep:windows",
@@ -115,6 +117,7 @@ gles = [
115117
"dep:log",
116118
"dep:ndk-sys",
117119
"dep:objc",
120+
"dep:parking_lot",
118121
"dep:profiling",
119122
"dep:wasm-bindgen",
120123
"dep:web-sys",
@@ -134,6 +137,7 @@ dx12 = [
134137
"dep:libloading",
135138
"dep:log",
136139
"dep:ordered-float",
140+
"dep:parking_lot",
137141
"dep:profiling",
138142
"dep:range-alloc",
139143
"dep:windows-core",
@@ -175,6 +179,8 @@ device_lost_panic = []
175179
#
176180
# Only affects the d3d12 and vulkan backends.
177181
internal_error_panic = []
182+
# Tracks validation errors in a `VALIDATION_CANARY` static.
183+
validation_canary = ["dep:parking_lot"]
178184

179185
###################
180186
### Workarounds ###
@@ -197,12 +203,12 @@ required-features = ["gles"]
197203

198204
[dependencies]
199205
naga.workspace = true
200-
wgpu-types.workspace = true
206+
wgpu-types = { workspace = true, default-features = false }
201207

202208
# Dependencies in the lib and empty backend
203209
bitflags.workspace = true
204210
raw-window-handle.workspace = true
205-
parking_lot.workspace = true
211+
parking_lot = { workspace = true, optional = true }
206212
thiserror.workspace = true
207213

208214
# Target agnostic dependencies used only in backends.

wgpu-hal/src/auxil/dxgi/exception.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use alloc::{
2-
borrow::Cow,
3-
string::{String, ToString as _},
4-
};
1+
use alloc::{borrow::Cow, string::String};
52

63
use parking_lot::Mutex;
74
use windows::Win32::{Foundation, System::Diagnostics::Debug};
@@ -86,7 +83,10 @@ unsafe extern "system" fn output_debug_string_handler(
8683
log::log!(level, "{}", message);
8784
});
8885

86+
#[cfg(feature = "validation_canary")]
8987
if cfg!(debug_assertions) && level == log::Level::Error {
88+
use alloc::string::ToString as _;
89+
9090
// Set canary and continue
9191
crate::VALIDATION_CANARY.add(message.to_string());
9292
}

0 commit comments

Comments
 (0)