Move Examples and Tests to Their Own Crates (#3841)

Co-authored-by: Connor Fitzgerald <connor@modyfi.io>
This commit is contained in:
Connor Fitzgerald 2023-06-10 14:35:46 -04:00 committed by GitHub
parent 121cfa2759
commit 10172e1f38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
152 changed files with 1330 additions and 618 deletions

View File

@ -2,11 +2,12 @@
multiple-versions = "deny"
skip-tree = [
{ name = "cts_runner" },
{ name = "dummy" },
{ name = "player" },
{ name = "run-wasm" },
{ name = "wgpu-info" },
]
skip = [
{ name = "wgpu" }
]
wildcards = "deny"
[licenses]

View File

@ -1,7 +1,7 @@
**Checklist**
- [ ] Run `cargo clippy`.
- [ ] Run `RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown` if applicable.
- [ ] Run `cargo clippy --target wasm32-unknown-unknown` if applicable.
- [ ] Add change to CHANGELOG.md. See simple instructions inside file.
**Connections**

View File

@ -138,12 +138,12 @@ jobs:
set -e
# build for WebGPU
cargo clippy --target ${{ matrix.target }} -p wgpu --tests --features glsl,spirv
cargo doc --target ${{ matrix.target }} -p wgpu --no-deps --features glsl,spirv
cargo clippy --target ${{ matrix.target }} --tests --features glsl,spirv
cargo doc --target ${{ matrix.target }} --no-deps --features glsl,spirv
# all features
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-hal --tests --all-features
cargo doc --target ${{ matrix.target }} -p wgpu --no-deps --all-features
cargo clippy --target ${{ matrix.target }} --tests --all-features
cargo doc --target ${{ matrix.target }} --no-deps --all-features
- name: check em
if: matrix.kind == 'em'
@ -155,7 +155,7 @@ jobs:
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-hal --no-default-features
# build cube example
cargo clippy --target ${{ matrix.target }} --example cube
cargo clippy --target ${{ matrix.target }} --bin cube
# build raw-gles example
cargo clippy --target ${{ matrix.target }} --example raw-gles
@ -171,13 +171,13 @@ jobs:
set -e
# check with no features
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-core -p wgpu-info -p player --no-default-features
cargo clippy --target ${{ matrix.target }} --no-default-features
# Check with all features.
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-info -p player -p wgpu-core -p wgpu-hal --tests --all-features
cargo clippy --target ${{ matrix.target }} --tests --all-features
# build docs
cargo doc --target ${{ matrix.target }} -p wgpu -p wgpu-info -p player -p wgpu-core -p wgpu-hal --all-features --no-deps
cargo doc --target ${{ matrix.target }} --all-features --no-deps
wasm-test:
name: Test WebAssembly
@ -194,7 +194,7 @@ jobs:
- name: execute tests
run: |
cd wgpu
wasm-pack test --headless --chrome --features webgl
wasm-pack test --headless --chrome --features webgl --workspace
gpu-test:
strategy:
@ -283,7 +283,7 @@ jobs:
for backend in ${{ matrix.backends }}; do
echo "======= NATIVE TESTS $backend ======";
WGPU_BACKEND=$backend cargo llvm-cov --no-cfg-coverage nextest -p wgpu -p wgpu-types -p wgpu-hal -p wgpu-core -p player --no-fail-fast --no-report
WGPU_BACKEND=$backend cargo llvm-cov --no-cfg-coverage nextest --no-fail-fast --no-report
done
- uses: actions/upload-artifact@v3
@ -331,7 +331,7 @@ jobs:
run: |
set -e
cargo test --doc -p wgpu -p wgpu-core -p wgpu-hal -p wgpu-types
cargo test --doc
fmt:
name: Format

View File

@ -27,11 +27,11 @@ jobs:
run: cargo +stable install wasm-bindgen-cli --version=0.2.84
- name: Build WebGPU examples
run: cargo build --package wgpu --release --target wasm32-unknown-unknown --examples
run: cargo build --release --target wasm32-unknown-unknown
- name: Generate JS bindings for WebGPU examples
run: |
for i in target/wasm32-unknown-unknown/release/examples/*.wasm;
for i in target/wasm32-unknown-unknown/release/*.wasm;
do
wasm-bindgen --no-typescript --out-dir target/generated-gpu --web "$i";
done
@ -49,11 +49,11 @@ jobs:
run: cargo clean
- name: Build WebGL examples
run: cargo build --release --target wasm32-unknown-unknown --examples --features webgl
run: cargo build --release --target wasm32-unknown-unknown --features webgl
- name: Generate JS bindings for WebGL examples
run: |
for i in target/wasm32-unknown-unknown/release/examples/*.wasm;
for i in target/wasm32-unknown-unknown/release/*.wasm;
do
wasm-bindgen --no-typescript --out-dir target/generated-gl --web "$i";
done

798
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -4,14 +4,25 @@ members = [
"cts_runner",
"deno_webgpu",
"player",
"examples/*",
"wgpu",
"wgpu-core",
"wgpu-hal",
"wgpu-info",
"wgpu-types",
"tests",
]
exclude = []
default-members = ["wgpu", "wgpu-hal", "wgpu-info", "wgpu-types"]
default-members = [
"examples/*",
"player",
"wgpu",
"wgpu-core",
"wgpu-hal",
"wgpu-info",
"wgpu-types",
"tests"
]
[workspace.package]
edition = "2021"
@ -48,7 +59,7 @@ arrayvec = "0.7"
async-executor = "1"
bitflags = "2"
bit-vec = "0.6"
bytemuck = "1.13"
bytemuck = { version = "1.13", features = ["derive"] }
cfg_aliases = "0.1"
cfg-if = "1"
codespan-reporting = "0.11"
@ -62,7 +73,7 @@ image = { version = "0.24", default-features = false, features = ["png"] }
libloading = ">=0.7,<0.9"
libc = "0.2"
log = "0.4"
nanorand = { version = "0.7", default-features = false }
nanorand = { version = "0.7", default-features = false, features = ["wyrand"] }
nv-flip = "0.1"
num-traits = { version = "0.2" }
# Opt out of noise's "default-features" to avoid "image" feature as a dependency count optimization.
@ -83,6 +94,8 @@ smallvec = "1"
static_assertions = "1.1.0"
thiserror = "1"
wgpu = { version = "0.16", path = "./wgpu" }
wgpu-example = { version = "0.16", path = "./examples/common" }
wgpu-test = { version = "0.16", path = "./tests"}
winit = "0.27.1"
# Metal dependencies

22
examples/boids/Cargo.toml Normal file
View File

@ -0,0 +1,22 @@
[package]
name = "wgpu-boids-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu boids example"
publish = false
[[bin]]
name = "boids"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
nanorand.workspace = true
wasm-bindgen-test.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 116 KiB

View File

@ -5,9 +5,6 @@ use nanorand::{Rng, WyRand};
use std::{borrow::Cow, mem};
use wgpu::util::DeviceExt;
#[path = "../framework.rs"]
mod framework;
// number of boid particles to simulate
const NUM_PARTICLES: u32 = 1500;
@ -27,7 +24,7 @@ struct Example {
frame_num: usize,
}
impl framework::Example for Example {
impl wgpu_example::framework::Example for Example {
fn required_limits() -> wgpu::Limits {
wgpu::Limits::downlevel_defaults()
}
@ -269,7 +266,7 @@ impl framework::Example for Example {
view: &wgpu::TextureView,
device: &wgpu::Device,
queue: &wgpu::Queue,
_spawner: &framework::Spawner,
_spawner: &wgpu_example::framework::Spawner,
) {
// create render pass descriptor and its color attachments
let color_attachments = [Some(wgpu::RenderPassColorAttachment {
@ -326,7 +323,7 @@ impl framework::Example for Example {
/// run example
fn main() {
framework::run::<Example>("boids");
wgpu_example::framework::run::<Example>("boids");
}
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
@ -334,15 +331,15 @@ wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn boids() {
framework::test::<Example>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Example>(wgpu_example::framework::FrameworkRefTest {
// Generated on 1080ti on Vk/Windows
image_path: "/examples/boids/screenshot.png",
image_path: "examples/boids/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::default(),
base_test_parameters: framework::test_common::TestParameters::default()
base_test_parameters: wgpu_test::TestParameters::default()
.downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS)
.limits(wgpu::Limits::downlevel_defaults()),
comparisons: &[framework::ComparisonType::Mean(0.005)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.005)],
});
}

View File

@ -0,0 +1,24 @@
[package]
name = "wgpu-bunnymark-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu bunnymark example"
publish = false
[[bin]]
name = "bunnymark"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
nanorand.workspace = true
glam.workspace = true
png.workspace = true
wasm-bindgen-test.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@ -3,9 +3,6 @@ use nanorand::{Rng, WyRand};
use std::{borrow::Cow, mem};
use wgpu::util::DeviceExt;
#[path = "../framework.rs"]
mod framework;
const MAX_BUNNIES: usize = 1 << 20;
const BUNNY_SIZE: f32 = 0.15 * 256.0;
const GRAVITY: f32 = -9.8 * 100.0;
@ -39,7 +36,7 @@ struct Example {
rng: WyRand,
}
impl framework::Example for Example {
impl wgpu_example::framework::Example for Example {
fn init(
config: &wgpu::SurfaceConfiguration,
_adapter: &wgpu::Adapter,
@ -294,7 +291,7 @@ impl framework::Example for Example {
view: &wgpu::TextureView,
device: &wgpu::Device,
queue: &wgpu::Queue,
_spawner: &framework::Spawner,
_spawner: &wgpu_example::framework::Spawner,
) {
let delta = 0.01;
for bunny in self.bunnies.iter_mut() {
@ -355,7 +352,7 @@ impl framework::Example for Example {
}
fn main() {
framework::run::<Example>("bunnymark");
wgpu_example::framework::run::<Example>("bunnymark");
}
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
@ -363,16 +360,16 @@ wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn bunnymark() {
framework::test::<Example>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Example>(wgpu_example::framework::FrameworkRefTest {
image_path: "/examples/bunnymark/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::default(),
base_test_parameters: framework::test_common::TestParameters::default(),
base_test_parameters: wgpu_test::TestParameters::default(),
// We're looking for very small differences, so look in the high percentiles.
comparisons: &[
framework::ComparisonType::Mean(0.05),
framework::ComparisonType::Percentile {
wgpu_test::ComparisonType::Mean(0.05),
wgpu_test::ComparisonType::Percentile {
percentile: 0.95,
threshold: 0.05,
},

View File

@ -0,0 +1,28 @@
[package]
name = "wgpu-capture-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu capture example"
publish = false
[[bin]]
name = "capture"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
env_logger.workspace = true
futures-intrusive.workspace = true
pollster.workspace = true
png.workspace = true
wasm-bindgen-test.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true
console_log.workspace = true
wasm-bindgen-futures.workspace = true

View File

Before

Width:  |  Height:  |  Size: 565 B

After

Width:  |  Height:  |  Size: 565 B

View File

@ -229,17 +229,18 @@ mod tests {
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
// This test never creates a canvas, so will always fail on webgl2.
// #[wasm_bindgen_test::wasm_bindgen_test]
fn ensure_generated_data_matches_expected() {
assert_generated_data_matches_expected();
}
fn assert_generated_data_matches_expected() {
let (device, output_buffer, dimensions) =
create_red_image_with_dimensions(100usize, 200usize).await;
let (device, output_buffer, dimensions, submission_index) =
pollster::block_on(create_red_image_with_dimensions(100usize, 200usize));
let buffer_slice = output_buffer.slice(..);
buffer_slice.map_async(wgpu::MapMode::Read, |_| ());
device.poll(wgpu::Maintain::Wait);
device.poll(wgpu::Maintain::WaitForSubmissionIndex(submission_index));
let padded_buffer = buffer_slice.get_mapped_range();
let expected_buffer_size = dimensions.padded_bytes_per_row * dimensions.height;
assert_eq!(padded_buffer.len(), expected_buffer_size);

View File

@ -0,0 +1,42 @@
[package]
name = "wgpu-example"
version.workspace = true
authors.workspace = true
edition.workspace = true
description = "Common example code"
homepage.workspace = true
repository.workspace = true
keywords.workspace = true
license.workspace = true
publish = false
[dependencies]
env_logger.workspace = true
log.workspace = true
pollster.workspace = true
png.workspace = true
winit.workspace = true
wgpu.workspace = true
wgpu-test.workspace = true
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
async-executor.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true
console_log.workspace = true
js-sys.workspace = true
wasm-bindgen.workspace = true
wasm-bindgen-futures.workspace = true
hal = { workspace = true, optional = true }
# We need these features in the framework examples and tests
web-sys = { workspace = true, features = [
"Location",
"Blob",
"RequestInit",
"RequestMode",
"Request",
"Response",
"WebGl2RenderingContext",
"CanvasRenderingContext2d"
] }

View File

@ -10,10 +10,6 @@ use winit::{
event_loop::{ControlFlow, EventLoop},
};
#[cfg(test)]
#[path = "../tests/common/mod.rs"]
pub mod test_common;
#[allow(dead_code)]
pub fn cast_slice<T>(data: &[T]) -> &[u8] {
use std::{mem::size_of, slice::from_raw_parts};
@ -494,21 +490,19 @@ pub fn parse_url_query_string<'a>(query: &'a str, search_key: &str) -> Option<&'
None
}
#[cfg(test)]
pub use test_common::image::ComparisonType;
pub use wgpu_test::image::ComparisonType;
#[cfg(test)]
pub struct FrameworkRefTest {
// Path to the reference image, relative to the root of the repo.
pub image_path: &'static str,
pub width: u32,
pub height: u32,
pub optional_features: wgpu::Features,
pub base_test_parameters: test_common::TestParameters,
pub base_test_parameters: wgpu_test::TestParameters,
/// Comparisons against FLIP statistics that determine if the test passes or fails.
pub comparisons: &'static [ComparisonType],
}
#[cfg(test)]
#[allow(dead_code)]
pub fn test<E: Example>(mut params: FrameworkRefTest) {
use std::mem;
@ -517,7 +511,7 @@ pub fn test<E: Example>(mut params: FrameworkRefTest) {
let features = E::required_features() | params.optional_features;
test_common::initialize_test(
wgpu_test::initialize_test(
mem::take(&mut params.base_test_parameters).features(features),
|ctx| {
let spawner = Spawner::new();
@ -617,8 +611,8 @@ pub fn test<E: Example>(mut params: FrameworkRefTest) {
ctx.device.poll(wgpu::Maintain::Wait);
let bytes = dst_buffer_slice.get_mapped_range().to_vec();
test_common::image::compare_image_output(
env!("CARGO_MANIFEST_DIR").to_string() + params.image_path,
wgpu_test::image::compare_image_output(
env!("CARGO_MANIFEST_DIR").to_string() + "/../../" + params.image_path,
ctx.adapter_info.backend,
params.width,
params.height,

View File

@ -0,0 +1 @@
pub mod framework;

View File

@ -0,0 +1,20 @@
[package]
name = "wgpu-conservative-raster-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu conservative raster example"
publish = false
[[bin]]
name = "conservative-raster"
path = "src/main.rs"
[dependencies]
wasm-bindgen-test.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@ -1,6 +1,3 @@
#[path = "../framework.rs"]
mod framework;
use std::borrow::Cow;
const RENDER_TARGET_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb;
@ -66,7 +63,7 @@ impl Example {
}
}
impl framework::Example for Example {
impl wgpu_example::framework::Example for Example {
fn required_features() -> wgpu::Features {
wgpu::Features::CONSERVATIVE_RASTERIZATION
}
@ -258,7 +255,7 @@ impl framework::Example for Example {
view: &wgpu::TextureView,
device: &wgpu::Device,
queue: &wgpu::Queue,
_spawner: &framework::Spawner,
_spawner: &wgpu_example::framework::Spawner,
) {
let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor {
label: Some("primary"),
@ -312,7 +309,7 @@ impl framework::Example for Example {
}
fn main() {
framework::run::<Example>("conservative-raster");
wgpu_example::framework::run::<Example>("conservative-raster");
}
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
@ -320,12 +317,12 @@ wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn conservative_raster() {
framework::test::<Example>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Example>(wgpu_example::framework::FrameworkRefTest {
image_path: "/examples/conservative-raster/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::default(),
base_test_parameters: framework::test_common::TestParameters::default(),
comparisons: &[framework::ComparisonType::Mean(0.0)],
base_test_parameters: wgpu_test::TestParameters::default(),
comparisons: &[wgpu_test::ComparisonType::Mean(0.0)],
});
}

22
examples/cube/Cargo.toml Normal file
View File

@ -0,0 +1,22 @@
[package]
name = "wgpu-cube-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu cube example"
publish = false
[[bin]]
name = "cube"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
glam.workspace = true
wasm-bindgen-test.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View File

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View File

@ -1,6 +1,3 @@
#[path = "../framework.rs"]
mod framework;
use bytemuck::{Pod, Zeroable};
use std::{borrow::Cow, f32::consts, future::Future, mem, pin::Pin, task};
use wgpu::util::DeviceExt;
@ -127,9 +124,9 @@ impl Example {
}
}
impl framework::Example for Example {
fn optional_features() -> wgt::Features {
wgt::Features::POLYGON_MODE_LINE
impl wgpu_example::framework::Example for Example {
fn optional_features() -> wgpu::Features {
wgpu::Features::POLYGON_MODE_LINE
}
fn init(
@ -285,7 +282,10 @@ impl framework::Example for Example {
multiview: None,
});
let pipeline_wire = if device.features().contains(wgt::Features::POLYGON_MODE_LINE) {
let pipeline_wire = if device
.features()
.contains(wgpu::Features::POLYGON_MODE_LINE)
{
let pipeline_wire = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: None,
layout: Some(&pipeline_layout),
@ -357,7 +357,7 @@ impl framework::Example for Example {
view: &wgpu::TextureView,
device: &wgpu::Device,
queue: &wgpu::Queue,
spawner: &framework::Spawner,
spawner: &wgpu_example::framework::Spawner,
) {
device.push_error_scope(wgpu::ErrorFilter::Validation);
let mut encoder =
@ -404,7 +404,7 @@ impl framework::Example for Example {
}
fn main() {
framework::run::<Example>("cube");
wgpu_example::framework::run::<Example>("cube");
}
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
@ -412,15 +412,15 @@ wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn cube() {
framework::test::<Example>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Example>(wgpu_example::framework::FrameworkRefTest {
// Generated on 1080ti on Vk/Windows
image_path: "/examples/cube/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::default(),
base_test_parameters: framework::test_common::TestParameters::default(),
base_test_parameters: wgpu_test::TestParameters::default(),
comparisons: &[
framework::ComparisonType::Mean(0.04), // Bounded by Intel 630 on Vk/Windows
wgpu_test::ComparisonType::Mean(0.04), // Bounded by Intel 630 on Vk/Windows
],
});
}
@ -428,17 +428,17 @@ fn cube() {
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn cube_lines() {
framework::test::<Example>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Example>(wgpu_example::framework::FrameworkRefTest {
// Generated on 1080ti on Vk/Windows
image_path: "/examples/cube/screenshot-lines.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::POLYGON_MODE_LINE,
base_test_parameters: framework::test_common::TestParameters::default(),
base_test_parameters: wgpu_test::TestParameters::default(),
// We're looking for tiny changes here, so we focus on a spike in the 95th percentile.
comparisons: &[
framework::ComparisonType::Mean(0.05), // Bounded by Intel 630 on Vk/Windows
framework::ComparisonType::Percentile {
wgpu_test::ComparisonType::Mean(0.05), // Bounded by Intel 630 on Vk/Windows
wgpu_test::ComparisonType::Percentile {
percentile: 0.95,
threshold: 0.36,
}, // Bounded by 1080ti on DX12

View File

@ -0,0 +1,30 @@
[package]
name = "wgpu-hello-compute-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu hello compute example"
publish = false
[[bin]]
name = "hello-compute"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
env_logger.workspace = true
futures-intrusive.workspace = true
pollster.workspace = true
wgpu.workspace = true
winit.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true
console_log.workspace = true
log.workspace = true
wasm-bindgen-futures.workspace = true
[dev-dependencies]
wasm-bindgen-test.workspace = true
wgpu-test.workspace = true

View File

@ -1,10 +1,7 @@
#[path = "../../tests/common/mod.rs"]
mod common;
use std::sync::Arc;
use super::*;
use common::{initialize_test, TestParameters};
use wgpu_test::{initialize_test, TestParameters};
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);

View File

@ -0,0 +1,24 @@
[package]
name = "wgpu-hello-triangle-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu hello triangle example"
publish = false
[[bin]]
name = "hello-triangle"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
env_logger.workspace = true
pollster.workspace = true
wgpu.workspace = true
winit.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true
console_log.workspace = true
wasm-bindgen-futures.workspace = true
web-sys.workspace = true

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -0,0 +1,21 @@
[package]
name = "wgpu-hello-windows-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu hello windows example"
publish = false
[[bin]]
name = "hello-windows"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
env_logger.workspace = true
pollster.workspace = true
wgpu.workspace = true
winit.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

27
examples/hello/Cargo.toml Normal file
View File

@ -0,0 +1,27 @@
[package]
name = "wgpu-hello-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu hello example"
publish = false
[[bin]]
name = "hello"
path = "src/main.rs"
[dependencies]
env_logger.workspace = true
glam.workspace = true
log.workspace = true
pollster.workspace = true
wgpu.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true
console_log.workspace = true
wasm-bindgen-futures.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

@ -0,0 +1,22 @@
[package]
name = "wgpu-mipmap-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu mipmap example"
publish = false
[[bin]]
name = "mipmap"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
glam.workspace = true
wasm-bindgen-test.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

Before

Width:  |  Height:  |  Size: 487 KiB

After

Width:  |  Height:  |  Size: 487 KiB

View File

@ -1,6 +1,3 @@
#[path = "../framework.rs"]
mod framework;
use bytemuck::{Pod, Zeroable};
use std::{borrow::Cow, f32::consts, mem};
use wgpu::util::DeviceExt;
@ -198,7 +195,7 @@ impl Example {
}
}
impl framework::Example for Example {
impl wgpu_example::framework::Example for Example {
fn optional_features() -> wgpu::Features {
wgpu::Features::TIMESTAMP_QUERY
| wgpu::Features::PIPELINE_STATISTICS_QUERY
@ -452,7 +449,7 @@ impl framework::Example for Example {
view: &wgpu::TextureView,
device: &wgpu::Device,
queue: &wgpu::Queue,
_spawner: &framework::Spawner,
_spawner: &wgpu_example::framework::Spawner,
) {
let mut encoder =
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
@ -485,7 +482,7 @@ impl framework::Example for Example {
}
fn main() {
framework::run::<Example>("mipmap");
wgpu_example::framework::run::<Example>("mipmap");
}
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
@ -493,13 +490,13 @@ wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn mipmap() {
framework::test::<Example>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Example>(wgpu_example::framework::FrameworkRefTest {
image_path: "/examples/mipmap/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::default(),
base_test_parameters: framework::test_common::TestParameters::default()
base_test_parameters: wgpu_test::TestParameters::default()
.backend_failure(wgpu::Backends::GL),
comparisons: &[framework::ComparisonType::Mean(0.02)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
});
}

View File

@ -0,0 +1,24 @@
[package]
name = "wgpu-msaa-line-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu msaa line example"
publish = false
[[bin]]
name = "msaa-line"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
glam.workspace = true
log.workspace = true
wasm-bindgen-test.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 138 KiB

View File

@ -7,9 +7,6 @@
//! * Set the primitive_topology to PrimitiveTopology::LineList.
//! * Vertices and Indices describe the two points that make up a line.
#[path = "../framework.rs"]
mod framework;
use std::{borrow::Cow, iter};
use bytemuck::{Pod, Zeroable};
@ -118,9 +115,9 @@ impl Example {
}
}
impl framework::Example for Example {
fn optional_features() -> wgt::Features {
wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES
impl wgpu_example::framework::Example for Example {
fn optional_features() -> wgpu::Features {
wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES
}
fn init(
@ -256,7 +253,7 @@ impl framework::Example for Example {
view: &wgpu::TextureView,
device: &wgpu::Device,
queue: &wgpu::Queue,
_spawner: &framework::Spawner,
_spawner: &wgpu_example::framework::Spawner,
) {
if self.rebuild_bundle {
self.bundle = Example::create_bundle(
@ -312,7 +309,7 @@ impl framework::Example for Example {
}
fn main() {
framework::run::<Example>("msaa-line");
wgpu_example::framework::run::<Example>("msaa-line");
}
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
@ -320,19 +317,19 @@ wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn msaa_line() {
framework::test::<Example>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Example>(wgpu_example::framework::FrameworkRefTest {
image_path: "/examples/msaa-line/screenshot.png",
width: 1024,
height: 768,
optional_features: wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
base_test_parameters: framework::test_common::TestParameters::default()
optional_features: wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
base_test_parameters: wgpu_test::TestParameters::default()
// AMD seems to render nothing on DX12 https://github.com/gfx-rs/wgpu/issues/3838
.specific_failure(Some(wgpu::Backends::DX12), Some(0x1002), None, false),
// There's a lot of natural variance so we check the weighted median too to differentiate
// real failures from variance.
comparisons: &[
framework::ComparisonType::Mean(0.065),
framework::ComparisonType::Percentile {
wgpu_test::ComparisonType::Mean(0.065),
wgpu_test::ComparisonType::Percentile {
percentile: 0.5,
threshold: 0.29,
},

View File

@ -0,0 +1,23 @@
[package]
name = "wgpu-shadow-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu shadow example"
publish = false
[[bin]]
name = "shadow"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
glam.workspace = true
wasm-bindgen-test.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB

View File

@ -1,8 +1,5 @@
use std::{borrow::Cow, f32::consts, iter, mem, ops::Range, rc::Rc};
#[path = "../framework.rs"]
mod framework;
use bytemuck::{Pod, Zeroable};
use wgpu::util::{align_to, DeviceExt};
@ -204,7 +201,7 @@ impl Example {
}
}
impl framework::Example for Example {
impl wgpu_example::framework::Example for Example {
fn optional_features() -> wgpu::Features {
wgpu::Features::DEPTH_CLIP_CONTROL
}
@ -711,7 +708,7 @@ impl framework::Example for Example {
view: &wgpu::TextureView,
device: &wgpu::Device,
queue: &wgpu::Queue,
_spawner: &framework::Spawner,
_spawner: &wgpu_example::framework::Spawner,
) {
// update uniforms
for entity in self.entities.iter_mut() {
@ -840,7 +837,7 @@ impl framework::Example for Example {
}
fn main() {
framework::run::<Example>("shadow");
wgpu_example::framework::run::<Example>("shadow");
}
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
@ -848,17 +845,17 @@ wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn shadow() {
framework::test::<Example>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Example>(wgpu_example::framework::FrameworkRefTest {
image_path: "/examples/shadow/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::default(),
base_test_parameters: framework::test_common::TestParameters::default()
base_test_parameters: wgpu_test::TestParameters::default()
.downlevel_flags(wgpu::DownlevelFlags::COMPARISON_SAMPLERS)
// rpi4 on VK doesn't work: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3916
.specific_failure(Some(wgpu::Backends::VULKAN), None, Some("V3D"), false)
// llvmpipe versions in CI are flaky: https://github.com/gfx-rs/wgpu/issues/2594
.specific_failure(Some(wgpu::Backends::VULKAN), None, Some("llvmpipe"), true),
comparisons: &[framework::ComparisonType::Mean(0.02)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
});
}

View File

@ -0,0 +1,25 @@
[package]
name = "wgpu-skybox-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu skybox example"
publish = false
[[bin]]
name = "skybox"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
ddsfile.workspace = true
glam.workspace = true
obj.workspace = true
log.workspace = true
wasm-bindgen-test.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

Before

Width:  |  Height:  |  Size: 546 KiB

After

Width:  |  Height:  |  Size: 546 KiB

View File

Before

Width:  |  Height:  |  Size: 536 KiB

After

Width:  |  Height:  |  Size: 536 KiB

View File

Before

Width:  |  Height:  |  Size: 456 KiB

After

Width:  |  Height:  |  Size: 456 KiB

View File

Before

Width:  |  Height:  |  Size: 588 KiB

After

Width:  |  Height:  |  Size: 588 KiB

View File

@ -1,6 +1,3 @@
#[path = "../framework.rs"]
mod framework;
use bytemuck::{Pod, Zeroable};
use std::{borrow::Cow, f32::consts};
use wgpu::{util::DeviceExt, AstcBlock, AstcChannel};
@ -92,7 +89,7 @@ impl Skybox {
}
}
impl framework::Example for Skybox {
impl wgpu_example::framework::Example for Skybox {
fn optional_features() -> wgpu::Features {
wgpu::Features::TEXTURE_COMPRESSION_ASTC
| wgpu::Features::TEXTURE_COMPRESSION_ETC2
@ -107,7 +104,7 @@ impl framework::Example for Skybox {
) -> Self {
let mut entities = Vec::new();
{
let source = include_bytes!("models/teslacyberv3.0.obj");
let source = include_bytes!("../models/teslacyberv3.0.obj");
let data = obj::ObjData::load_buf(&source[..]).unwrap();
let mut vertices = Vec::new();
for object in data.objects {
@ -309,10 +306,10 @@ impl framework::Example for Skybox {
wgpu::TextureFormat::Astc {
block: AstcBlock::B4x4,
channel: AstcChannel::UnormSrgb,
} => &include_bytes!("images/astc.dds")[..],
wgpu::TextureFormat::Etc2Rgb8UnormSrgb => &include_bytes!("images/etc2.dds")[..],
wgpu::TextureFormat::Bc1RgbaUnormSrgb => &include_bytes!("images/bc1.dds")[..],
wgpu::TextureFormat::Bgra8UnormSrgb => &include_bytes!("images/bgra.dds")[..],
} => &include_bytes!("../images/astc.dds")[..],
wgpu::TextureFormat::Etc2Rgb8UnormSrgb => &include_bytes!("../images/etc2.dds")[..],
wgpu::TextureFormat::Bc1RgbaUnormSrgb => &include_bytes!("../images/bc1.dds")[..],
wgpu::TextureFormat::Bgra8UnormSrgb => &include_bytes!("../images/bgra.dds")[..],
_ => unreachable!(),
};
@ -399,7 +396,7 @@ impl framework::Example for Skybox {
view: &wgpu::TextureView,
device: &wgpu::Device,
queue: &wgpu::Queue,
_spawner: &framework::Spawner,
_spawner: &wgpu_example::framework::Spawner,
) {
let mut encoder =
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
@ -463,7 +460,7 @@ impl framework::Example for Skybox {
}
fn main() {
framework::run::<Skybox>("skybox");
wgpu_example::framework::run::<Skybox>("skybox");
}
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
@ -471,56 +468,56 @@ wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn skybox() {
framework::test::<Skybox>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Skybox>(wgpu_example::framework::FrameworkRefTest {
image_path: "/examples/skybox/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::default(),
base_test_parameters: framework::test_common::TestParameters::default().specific_failure(
base_test_parameters: wgpu_test::TestParameters::default().specific_failure(
Some(wgpu::Backends::GL),
None,
Some("ANGLE"),
false,
),
comparisons: &[framework::ComparisonType::Mean(0.015)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.015)],
});
}
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn skybox_bc1() {
framework::test::<Skybox>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Skybox>(wgpu_example::framework::FrameworkRefTest {
image_path: "/examples/skybox/screenshot-bc1.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::TEXTURE_COMPRESSION_BC,
base_test_parameters: framework::test_common::TestParameters::default(), // https://bugs.chromium.org/p/angleproject/issues/detail?id=7056
comparisons: &[framework::ComparisonType::Mean(0.02)],
base_test_parameters: wgpu_test::TestParameters::default(), // https://bugs.chromium.org/p/angleproject/issues/detail?id=7056
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
});
}
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn skybox_etc2() {
framework::test::<Skybox>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Skybox>(wgpu_example::framework::FrameworkRefTest {
image_path: "/examples/skybox/screenshot-etc2.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::TEXTURE_COMPRESSION_ETC2,
base_test_parameters: framework::test_common::TestParameters::default(), // https://bugs.chromium.org/p/angleproject/issues/detail?id=7056
comparisons: &[framework::ComparisonType::Mean(0.015)],
base_test_parameters: wgpu_test::TestParameters::default(), // https://bugs.chromium.org/p/angleproject/issues/detail?id=7056
comparisons: &[wgpu_test::ComparisonType::Mean(0.015)],
});
}
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn skybox_astc() {
framework::test::<Skybox>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Skybox>(wgpu_example::framework::FrameworkRefTest {
image_path: "/examples/skybox/screenshot-astc.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::TEXTURE_COMPRESSION_ASTC,
base_test_parameters: framework::test_common::TestParameters::default(), // https://bugs.chromium.org/p/angleproject/issues/detail?id=7056
comparisons: &[framework::ComparisonType::Mean(0.016)],
base_test_parameters: wgpu_test::TestParameters::default(), // https://bugs.chromium.org/p/angleproject/issues/detail?id=7056
comparisons: &[wgpu_test::ComparisonType::Mean(0.016)],
});
}

View File

@ -0,0 +1,21 @@
[package]
name = "wgpu-stencil-triangle-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu stencil triangles example"
publish = false
[[bin]]
name = "stencil-triangles"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
wasm-bindgen-test.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -3,9 +3,6 @@ use std::borrow::Cow;
use std::mem;
use wgpu::util::DeviceExt;
#[path = "../framework.rs"]
mod framework;
#[repr(C)]
#[derive(Clone, Copy, Pod, Zeroable)]
struct Vertex {
@ -26,7 +23,7 @@ struct Triangles {
stencil_buffer: wgpu::Texture,
}
impl framework::Example for Triangles {
impl wgpu_example::framework::Example for Triangles {
fn init(
config: &wgpu::SurfaceConfiguration,
_adapter: &wgpu::Adapter,
@ -185,7 +182,7 @@ impl framework::Example for Triangles {
view: &wgpu::TextureView,
device: &wgpu::Device,
queue: &wgpu::Queue,
_spawner: &framework::Spawner,
_spawner: &wgpu_example::framework::Spawner,
) {
let mut encoder =
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
@ -232,7 +229,7 @@ impl framework::Example for Triangles {
}
fn main() {
framework::run::<Triangles>("stencil-triangles");
wgpu_example::framework::run::<Triangles>("stencil-triangles");
}
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
@ -240,12 +237,12 @@ wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn stencil_triangles() {
framework::test::<Triangles>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Triangles>(wgpu_example::framework::FrameworkRefTest {
image_path: "/examples/stencil-triangles/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::default(),
base_test_parameters: framework::test_common::TestParameters::default(),
comparisons: &[framework::ComparisonType::Mean(0.03)],
base_test_parameters: wgpu_test::TestParameters::default(),
comparisons: &[wgpu_test::ComparisonType::Mean(0.03)],
});
}

View File

@ -0,0 +1,21 @@
[package]
name = "wgpu-texture-arrays-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu texture arrays example"
publish = false
[[bin]]
name = "texture-arrays"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
wasm-bindgen-test.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -1,6 +1,3 @@
#[path = "../framework.rs"]
mod framework;
use bytemuck::{Pod, Zeroable};
use std::num::{NonZeroU32, NonZeroU64};
use wgpu::util::DeviceExt;
@ -73,7 +70,7 @@ struct Example {
uniform_workaround: bool,
}
impl framework::Example for Example {
impl wgpu_example::framework::Example for Example {
fn optional_features() -> wgpu::Features {
wgpu::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING
}
@ -369,7 +366,7 @@ impl framework::Example for Example {
view: &wgpu::TextureView,
device: &wgpu::Device,
queue: &wgpu::Queue,
_spawner: &framework::Spawner,
_spawner: &wgpu_example::framework::Spawner,
) {
let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor {
label: Some("primary"),
@ -408,7 +405,7 @@ impl framework::Example for Example {
}
fn main() {
framework::run::<Example>("texture-arrays");
wgpu_example::framework::run::<Example>("texture-arrays");
}
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
@ -416,26 +413,26 @@ wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn texture_arrays_uniform() {
framework::test::<Example>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Example>(wgpu_example::framework::FrameworkRefTest {
image_path: "/examples/texture-arrays/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::empty(),
base_test_parameters: framework::test_common::TestParameters::default(),
comparisons: &[framework::ComparisonType::Mean(0.0)],
base_test_parameters: wgpu_test::TestParameters::default(),
comparisons: &[wgpu_test::ComparisonType::Mean(0.0)],
});
}
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn texture_arrays_non_uniform() {
framework::test::<Example>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Example>(wgpu_example::framework::FrameworkRefTest {
image_path: "/examples/texture-arrays/screenshot.png",
width: 1024,
height: 768,
optional_features:
wgpu::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING,
base_test_parameters: framework::test_common::TestParameters::default(),
comparisons: &[framework::ComparisonType::Mean(0.0)],
base_test_parameters: wgpu_test::TestParameters::default(),
comparisons: &[wgpu_test::ComparisonType::Mean(0.0)],
});
}

24
examples/water/Cargo.toml Normal file
View File

@ -0,0 +1,24 @@
[package]
name = "wgpu-water-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu water example"
publish = false
[[bin]]
name = "water"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
nanorand.workspace = true
glam.workspace = true
noise.workspace = true
wasm-bindgen-test.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

Before

Width:  |  Height:  |  Size: 164 KiB

After

Width:  |  Height:  |  Size: 164 KiB

View File

@ -1,6 +1,3 @@
#[path = "../framework.rs"]
mod framework;
mod point_gen;
use bytemuck::{Pod, Zeroable};
@ -268,7 +265,7 @@ impl Example {
}
}
impl framework::Example for Example {
impl wgpu_example::framework::Example for Example {
fn init(
config: &wgpu::SurfaceConfiguration,
_adapter: &wgpu::Adapter,
@ -699,7 +696,7 @@ impl framework::Example for Example {
view: &wgpu::TextureView,
device: &wgpu::Device,
queue: &wgpu::Queue,
_spawner: &framework::Spawner,
_spawner: &wgpu_example::framework::Spawner,
) {
// Increment frame count regardless of if we draw.
self.current_frame += 1;
@ -817,7 +814,7 @@ impl framework::Example for Example {
}
fn main() {
framework::run::<Example>("water");
wgpu_example::framework::run::<Example>("water");
}
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
@ -825,13 +822,13 @@ wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn water() {
framework::test::<Example>(framework::FrameworkRefTest {
wgpu_example::framework::test::<Example>(wgpu_example::framework::FrameworkRefTest {
image_path: "/examples/water/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::default(),
base_test_parameters: framework::test_common::TestParameters::default()
base_test_parameters: wgpu_test::TestParameters::default()
.downlevel_flags(wgpu::DownlevelFlags::READ_ONLY_DEPTH_STENCIL),
comparisons: &[framework::ComparisonType::Mean(0.01)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.01)],
});
}

View File

@ -25,21 +25,9 @@ winit = { workspace = true, optional = true }
workspace = true
features = ["replay"]
[dependencies.wgc]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc]
workspace = true
features = ["replay", "raw-window-handle", "strict_asserts", "wgsl"]
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgc]
workspace = true
features = ["metal"]
[target.'cfg(windows)'.dependencies.wgc]
workspace = true
features = ["dx11", "dx12"]
[target.'cfg(any(windows, all(unix, not(target_os = "emscripten"), not(target_os = "ios"), not(target_os = "macos"))))'.dependencies.wgc]
workspace = true
features = ["vulkan"]
features = ["replay", "raw-window-handle", "strict_asserts", "wgsl", "metal", "dx11", "dx12", "vulkan", "gles"]
[dev-dependencies]
serde.workspace = true

Some files were not shown because too many files have changed in this diff Show More