Skip to content
Draft
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
6 changes: 6 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ slow-timeout = { period = "45s", terminate-after = 2 }
fail-fast = false
retries = 0

[profile.wasm]
default-filter = "test([wasm])"
slow-timeout = { period = "45s", terminate-after = 2 }
fail-fast = false
retries = 0

[profile.default-miri]
# Miri is very very slow, so give it a much longer timeout.
slow-timeout = { period = "120s", terminate-after = 4 }
Expand Down
25 changes: 20 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -564,16 +564,31 @@ jobs:
rustup override set ${{ env.REPO_MSRV }}
cargo -V

- name: Install `wasm-pack`
- name: Get `wasm-bindgen` version
run: |
WASM_BINDGEN_VERSION=$(cargo metadata --format-version 1 --all-features | jq '.packages[] | select(.name == "wasm-bindgen") | .version' | tr -d '"')

echo $WASM_BINDGEN_VERSION

echo "WASM_BINDGEN_VERSION=$WASM_BINDGEN_VERSION" >> "$GITHUB_ENV"

- name: Install `wasm-bindgen`
run: cargo +stable install wasm-bindgen-cli --version=$WASM_BINDGEN_VERSION

- name: Install `cargo-nextest`
uses: taiki-e/install-action@v2
with:
tool: wasm-pack
tool: cargo-nextest

- name: Execute tests
- name: Install playwright and npm dependencies
run: |
cd wgpu
cd tests/wasm/runner
npm install
npx playwright install chromium --with-deps

wasm-pack test --headless --chrome --no-default-features --features wgsl,webgl,web --workspace
- name: Execute tests
run: |
cargo xtask test-wasm --headless

gpu-test:
# runtime is normally 5-15 minutes
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ wgpu/red.png

# Cached GPU config
.gpuconfig
.wasmgpuconfig

# Temporary clone location for wasm-bindgen mirroring
wgpu/src/backend/webgpu/webgpu_sys/wasm_bindgen_clone_tmp

# LLM-related
.claude/settings.local.json

# Wasm test generated files
/tests/wasm/dist
/tests/wasm/runner/node_modules
135 changes: 135 additions & 0 deletions Cargo.lock

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

7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ libfuzzer-sys = ">0.4.0,<=0.4.7"
libloading = "0.8"
libm = { version = "0.2.6", default-features = false }
libtest-mimic = "0.8"
log = "0.4.21"
log = "0.4.25"
macro_rules_attribute = "0.2"
nanoserde = "0.2"
nanorand = { version = "0.8", default-features = false, features = ["wyrand"] }
Expand Down Expand Up @@ -195,6 +195,7 @@ toml = "1.0.0"
trybuild = "1"
tracy-client = "0.18"
thiserror = { version = "2.0.12", default-features = false }
ureq = "3.2.0"
unicode-ident = "1.0.5"
walkdir = "2.3"
winit = { version = "0.29", features = ["android-native-activity"] }
Expand Down Expand Up @@ -322,7 +323,3 @@ generator = { git = "https://github.com/Xudong-Huang/generator-rs", rev = "70b89
[profile.release]
lto = "thin"
debug = true

# Speed up image comparison even in debug builds
[profile.dev.package."nv-flip-sys"]
opt-level = 3
Comment on lines -325 to -328
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this about?

4 changes: 2 additions & 2 deletions examples/features/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ test = false

[features]
default = []
webgl = ["wgpu/webgl"]
webgpu = ["wgpu/webgpu"]
webgl = ["wgpu/webgl", "wgpu-test/webgl"]
webgpu = ["wgpu/webgpu", "wgpu-test/webgl"]

[dependencies]
bytemuck.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ trybuild.workspace = true
cargo_metadata.workspace = true
env_logger.workspace = true
parking_lot = { workspace = true, features = ["deadlock_detection"] }
ureq.workspace = true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: as we don't need tls, it is possible that we turn it off to prevent taking in deps on the TLS stack?


[target.'cfg(not(any(target_arch = "wasm32", miri)))'.dependencies]
nv-flip.workspace = true
Expand All @@ -95,7 +96,9 @@ nv-flip.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_log.workspace = true
wasm-bindgen.workspace = true
wasm-bindgen-futures.workspace = true
web-sys = { workspace = true }
parking_lot = { workspace = true, features = ["deadlock_detection"] }

# Webassembly Dev Dependencies
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
Expand Down
14 changes: 12 additions & 2 deletions tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ mod params;
mod poll;
mod report;
mod run;
pub mod wasm;
pub mod wasm_manager;

#[cfg(target_arch = "wasm32")]
pub use init::initialize_html_canvas;
Expand Down Expand Up @@ -120,7 +122,11 @@ pub fn did_oom<T>(device: &wgpu::Device, callback: impl FnOnce() -> T) -> (bool,
macro_rules! gpu_test_main {
($tests: expr) => {
#[cfg(target_arch = "wasm32")]
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen::prelude::wasm_bindgen]
pub fn run_test(test_name: String) {
$crate::wasm::main($tests, test_name);
}

#[cfg(target_arch = "wasm32")]
fn main() {
// Ensure that value is used so that warnings don't happen.
Expand All @@ -129,7 +135,11 @@ macro_rules! gpu_test_main {

#[cfg(not(target_arch = "wasm32"))]
fn main() -> $crate::native::MainResult {
$crate::native::main($tests)
if std::env::var("TEST_WASM") == Ok("true".to_string()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if std::env::var("TEST_WASM") == Ok("true".to_string()) {
if std::env::var("TEST_WASM").as_deref() == Ok("true") {

super nit

$crate::wasm_manager::run_wasm_browser_tests($tests)
} else {
$crate::native::main($tests)
}
}
};
}
6 changes: 3 additions & 3 deletions tests/src/report.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::collections::HashMap;

use serde::Deserialize;
use serde::{Deserialize, Serialize};
use wgpu::{
AdapterInfo, DownlevelCapabilities, Features, Limits, TextureFormat, TextureFormatFeatures,
};

/// Report specifying the capabilities of the GPUs on the system.
///
/// Must be synchronized with the definition on wgpu-info/src/report.rs.
#[derive(Deserialize)]
#[derive(Serialize, Deserialize)]
pub(crate) struct GpuReport {
#[cfg_attr(target_arch = "wasm32", allow(unused))]
pub devices: Vec<AdapterReport>,
Expand Down Expand Up @@ -39,7 +39,7 @@ impl GpuReport {
/// A single report of the capabilities of an Adapter.
///
/// Must be synchronized with the definition on wgpu-info/src/report.rs.
#[derive(Deserialize, Clone)]
#[derive(Serialize, Deserialize, Clone)]
pub struct AdapterReport {
pub info: AdapterInfo,
pub features: Features,
Expand Down
Loading
Loading