From 71955be8fd18c859e5e1e6cd94a228472e17c838 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Wed, 6 Jul 2022 19:20:26 +0200 Subject: [PATCH 1/8] add CI --- .github/workflows/ci.yml | 97 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..923f831 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,97 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +env: + CARGO_INCREMENTAL: false + CARGO_TERM_COLOR: always + RUST_BACKTRACE: full + NIGHTLY: nightly-2022-06-24 + +jobs: + msrv_and_minimal_versions: + name: Check MSRV and minimal-versions + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install tools + uses: taiki-e/install-action@v1 + with: + tool: sd,cargo-hack + + # workaround for https://github.com/rust-lang/rustup/issues/2925 + - name: Set environment variables + run: | + echo "MSRV=$(cargo metadata --format-version=1 --no-deps --offline | sd '.*"rust_version":"([.0-9]+?)".*' '$1')" >> $GITHUB_ENV + + - name: Install MSRV toolchain + run: rustup toolchain install $MSRV --no-self-update --profile=minimal + + - name: Install nightly toolchain + run: rustup toolchain install $NIGHTLY --no-self-update --profile=minimal + + # -Z avoid-dev-deps doesn't work + - run: cargo +$NIGHTLY hack generate-lockfile --remove-dev-deps -Z minimal-versions --offline + + - run: cargo +$MSRV check --workspace --all-features + + format: + name: Check format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: cargo fmt --check --all + + clippy: + name: Check clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: cargo clippy --all-targets --workspace --all-features -- -D warnings + + doc_tests: + name: Run doc tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: cargo test --doc --workspace --features mint,glam + + docs: + name: Build docs + runs-on: ubuntu-latest + env: + RUSTDOCFLAGS: --cfg docs + steps: + - uses: actions/checkout@v3 + + - name: Install nightly toolchain + run: rustup toolchain install $NIGHTLY --no-self-update --profile=minimal + + - run: cargo +$NIGHTLY doc --workspace --all-features + + tests: + name: Run tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install tools + uses: taiki-e/install-action@v1 + with: + tool: cargo-llvm-cov,cargo-nextest + + - name: Install nightly toolchain + run: rustup toolchain install $NIGHTLY --no-self-update --profile=minimal -c llvm-tools-preview + + - name: Install llvmpipe and lavapipe + run: | + sudo apt-get update -y -qq + sudo add-apt-repository ppa:oibaf/graphics-drivers -y + sudo apt-get update + sudo apt install -y libxcb-xfixes0-dev mesa-vulkan-drivers + + - run: cargo +$NIGHTLY llvm-cov nextest --workspace --features mint,glam --fail-under-lines 80 From cac9fe7cfe7872e9c0ec70f7b1b3e9013384e07e Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Thu, 7 Jul 2022 16:37:51 +0200 Subject: [PATCH 2/8] update wgpu to v0.13 --- Cargo.toml | 2 +- tests/shaders/array_length.wgsl | 18 +++++++------- tests/shaders/general.wgsl | 44 ++++++++++++++++----------------- tests/wgpu.rs | 11 ++++----- 4 files changed, 37 insertions(+), 38 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ad1b5df..582de22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ static-rc = { version = "0.5", features = ["alloc"], default-features = false, o criterion = { version = "0.3", features = ["cargo_bench_support", "html_reports"], default-features = false } rand = { version = "0.8", features = ["std_rng"], default-features = false } mimalloc = { version = "0.1", default-features = false } -wgpu = { version = "0.12", default-features = false } +wgpu = { version = "0.13", default-features = false } futures = { version = "0.3", features = ["executor"], default-features = false } pprof = { version = "0.8", features = ["criterion", "flamegraph"], default-features = false } trybuild = { version = "1", default-features = false } diff --git a/tests/shaders/array_length.wgsl b/tests/shaders/array_length.wgsl index f57bd83..0bec1dd 100644 --- a/tests/shaders/array_length.wgsl +++ b/tests/shaders/array_length.wgsl @@ -1,18 +1,18 @@ struct A { - array_length: u32; - array_length_call_ret_val: u32; - a: vec3; - [[align(16)]] - arr: array; -}; + array_length: u32, + array_length_call_ret_val: u32, + a: vec3, + @align(16) + arr: array, +} -[[group(0), binding(0)]] +@group(0) @binding(0) var in: A; -[[group(0), binding(1)]] +@group(0) @binding(1) var out: A; -[[stage(compute), workgroup_size(1, 1, 1)]] +@compute @workgroup_size(1, 1, 1) fn main() { out.array_length = in.array_length; out.a = in.a; diff --git a/tests/shaders/general.wgsl b/tests/shaders/general.wgsl index 7fc788f..bf822fd 100644 --- a/tests/shaders/general.wgsl +++ b/tests/shaders/general.wgsl @@ -1,33 +1,33 @@ struct A { - u: u32; - v: u32; - w: vec2; - [[size(16), align(8)]] - x: u32; - xx: u32; -}; + u: u32, + v: u32, + w: vec2, + @size(16) @align(8) + x: u32, + xx: u32, +} struct B { - a: vec2; - b: vec3; - c: u32; - d: u32; - [[align(16)]] - e: A; - f: vec3; - g: array; - h: i32; - [[align(32)]] - i: array; -}; + a: vec2, + b: vec3, + c: u32, + d: u32, + @align(16) + e: A, + f: vec3, + g: array, + h: i32, + @align(32) + i: array, +} -[[group(0), binding(0)]] +@group(0) @binding(0) var in: B; -[[group(0), binding(1)]] +@group(0) @binding(1) var out: B; -[[stage(compute), workgroup_size(1, 1, 1)]] +@compute @workgroup_size(1, 1, 1) fn main() { out.a = in.a; out.b = in.b; diff --git a/tests/wgpu.rs b/tests/wgpu.rs index 6648a59..c917a30 100644 --- a/tests/wgpu.rs +++ b/tests/wgpu.rs @@ -105,7 +105,7 @@ fn test_wgpu() { assert_eq!(in_byte_buffer.len(), b.size().get() as _); let shader = include_wgsl!("./shaders/general.wgsl"); - let out_byte_buffer = in_out::(&shader, &in_byte_buffer, false); + let out_byte_buffer = in_out::(shader, &in_byte_buffer, false); assert_eq!(in_byte_buffer, out_byte_buffer); @@ -140,7 +140,7 @@ fn array_length() { assert_eq!(in_byte_buffer.len(), in_value.size().get() as _); let shader = include_wgsl!("./shaders/array_length.wgsl"); - let out_byte_buffer = in_out::(&shader, &in_byte_buffer, false); + let out_byte_buffer = in_out::(shader, &in_byte_buffer, false); assert_eq!(in_byte_buffer, out_byte_buffer); @@ -151,7 +151,7 @@ fn array_length() { } fn in_out( - shader: &wgpu::ShaderModuleDescriptor, + shader: wgpu::ShaderModuleDescriptor, data: &[u8], is_uniform: bool, ) -> Vec { @@ -246,16 +246,15 @@ fn in_out( let mut cpass = encoder.begin_compute_pass(&wgpu::ComputePassDescriptor::default()); cpass.set_pipeline(&compute_pipeline); cpass.set_bind_group(0, &bind_group, &[]); - cpass.dispatch(1, 1, 1); + cpass.dispatch_workgroups(1, 1, 1); } queue.submit(core::iter::once(encoder.finish())); let output_slice = output_gpu_buffer.slice(..); - let output_future = output_slice.map_async(wgpu::MapMode::Read); + output_slice.map_async(wgpu::MapMode::Read, |_| {}); device.poll(wgpu::Maintain::Wait); - block_on(output_future).unwrap(); let output = output_slice.get_mapped_range().to_vec(); output_gpu_buffer.unmap(); From 50adb8b525ade5130b048d00395c3f8ead43b02a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Mon, 31 Oct 2022 02:12:08 +0100 Subject: [PATCH 3/8] update glam to 0.22 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 582de22..a05e6fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ const_panic = { version = "0.2", default-features = false } mint = { version = "0.5.9", default-features = false, optional = true } cgmath = { version = "0.18", default-features = false, optional = true } -glam = { version = "0.21", features = [ "std" ], default-features = false, optional = true } +glam = { version = "0.22", features = [ "std" ], default-features = false, optional = true } nalgebra = { version = "0.31", default-features = false, optional = true } ultraviolet = { version = "0.9", features = [ "int" ], default-features = false, optional = true } vek = { version = "0.15", default-features = false, optional = true } From f2c8f5e8fdf9812d2755ba993e3b833440435839 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Sun, 6 Nov 2022 11:42:12 +0100 Subject: [PATCH 4/8] update wgpu to v0.14 --- Cargo.toml | 2 +- tests/wgpu.rs | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a05e6fa..3b806e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ static-rc = { version = "0.5", features = ["alloc"], default-features = false, o criterion = { version = "0.3", features = ["cargo_bench_support", "html_reports"], default-features = false } rand = { version = "0.8", features = ["std_rng"], default-features = false } mimalloc = { version = "0.1", default-features = false } -wgpu = { version = "0.13", default-features = false } +wgpu = { version = "0.14", default-features = false } futures = { version = "0.3", features = ["executor"], default-features = false } pprof = { version = "0.8", features = ["criterion", "flamegraph"], default-features = false } trybuild = { version = "1", default-features = false } diff --git a/tests/wgpu.rs b/tests/wgpu.rs index c917a30..37e1e9f 100644 --- a/tests/wgpu.rs +++ b/tests/wgpu.rs @@ -176,7 +176,14 @@ fn in_out( let output_gpu_buffer = device.create_buffer(&wgpu::BufferDescriptor { label: Some("Output Buffer"), size: data.len() as _, - usage: wgpu::BufferUsages::STORAGE | wgpu::BufferUsages::MAP_READ, + usage: wgpu::BufferUsages::STORAGE | wgpu::BufferUsages::COPY_SRC, + mapped_at_creation: false, + }); + + let mapping_buffer = device.create_buffer(&wgpu::BufferDescriptor { + label: Some("Mapping Buffer"), + size: data.len() as _, + usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ, mapped_at_creation: false, }); @@ -249,14 +256,16 @@ fn in_out( cpass.dispatch_workgroups(1, 1, 1); } + encoder.copy_buffer_to_buffer(&output_gpu_buffer, 0, &mapping_buffer, 0, data.len() as _); + queue.submit(core::iter::once(encoder.finish())); - let output_slice = output_gpu_buffer.slice(..); + let output_slice = mapping_buffer.slice(..); output_slice.map_async(wgpu::MapMode::Read, |_| {}); device.poll(wgpu::Maintain::Wait); let output = output_slice.get_mapped_range().to_vec(); - output_gpu_buffer.unmap(); + mapping_buffer.unmap(); output } From 1072958868159b5b6abf555b2c7d937ebc8bd1e1 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Sun, 6 Nov 2022 13:08:25 +0100 Subject: [PATCH 5/8] update criterion to v0.4 and pprof to v0.11 --- Cargo.toml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3b806e1..f4ac4d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,9 +28,6 @@ harness = false [workspace] members = ["derive", "derive/impl"] -[patch.crates-io] -criterion = { git = "https://github.com/bheisler/criterion.rs", rev = "6929f48e4828360de038f4e9732066d85b9a57c6" } - [dependencies] encase_derive = { version = "=0.3.0", path = "derive" } @@ -55,10 +52,10 @@ imbl = { version = "2", default-features = false, optional = true } static-rc = { version = "0.5", features = ["alloc"], default-features = false, optional = true } [dev-dependencies] -criterion = { version = "0.3", features = ["cargo_bench_support", "html_reports"], default-features = false } +criterion = { version = "0.4", features = ["cargo_bench_support", "html_reports"], default-features = false } rand = { version = "0.8", features = ["std_rng"], default-features = false } mimalloc = { version = "0.1", default-features = false } wgpu = { version = "0.14", default-features = false } futures = { version = "0.3", features = ["executor"], default-features = false } -pprof = { version = "0.8", features = ["criterion", "flamegraph"], default-features = false } +pprof = { version = "0.11", features = ["criterion", "flamegraph"], default-features = false } trybuild = { version = "1", default-features = false } From 210695d7652119a0e6a7f3ebae53d4703d377d02 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Sun, 6 Nov 2022 13:38:09 +0100 Subject: [PATCH 6/8] update rpds to v0.12 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f4ac4d2..347c46a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,7 @@ smallvec = { version = "1.8.0", features = ["const_generics"], default-features arrayvec = { version = "0.7", default-features = false, optional = true } tinyvec = { version = "1.4", features = ["rustc_1_55", "alloc"], default-features = false, optional = true } ndarray = { version = "0.15", default-features = false, optional = true } -rpds = { version = "0.11", default-features = false, optional = true } +rpds = { version = "0.12", default-features = false, optional = true } archery = { version = "0.4", default-features = false, optional = true } im = { version = "15", default-features = false, optional = true } im-rc = { version = "15", default-features = false, optional = true } From 75dc8f0edebe8f7b802178829d60bd02fac2bcab Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Sun, 6 Nov 2022 13:38:21 +0100 Subject: [PATCH 7/8] update static-rc to v0.6 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 347c46a..59c1356 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,7 @@ archery = { version = "0.4", default-features = false, optional = true } im = { version = "15", default-features = false, optional = true } im-rc = { version = "15", default-features = false, optional = true } imbl = { version = "2", default-features = false, optional = true } -static-rc = { version = "0.5", features = ["alloc"], default-features = false, optional = true } +static-rc = { version = "0.6", features = ["alloc"], default-features = false, optional = true } [dev-dependencies] criterion = { version = "0.4", features = ["cargo_bench_support", "html_reports"], default-features = false } From 38e07b1d3df24299efa49c8110dc73773f66f045 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Sun, 6 Nov 2022 21:51:35 +0100 Subject: [PATCH 8/8] release v0.4.0 --- CHANGELOG.md | 6 ++++++ Cargo.toml | 4 ++-- derive/Cargo.toml | 4 ++-- derive/impl/Cargo.toml | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a00ab92..3e0bdf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v0.4.0 (2022-11-06) + +- Updated `glam` to v0.22 +- Updated `rpds` to v0.12 +- Updated `static-rc` to v0.6 + ## v0.3.0 (2022-07-03) - Renamed `Size::SIZE` to `ShaderSize::SHADER_SIZE` diff --git a/Cargo.toml b/Cargo.toml index 59c1356..baceb21 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "encase" -version = "0.3.0" +version = "0.4.0" edition = "2021" rust-version = "1.58" @@ -29,7 +29,7 @@ harness = false members = ["derive", "derive/impl"] [dependencies] -encase_derive = { version = "=0.3.0", path = "derive" } +encase_derive = { version = "=0.4.0", path = "derive" } thiserror = { version = "1", default-features = false } const_panic = { version = "0.2", default-features = false } diff --git a/derive/Cargo.toml b/derive/Cargo.toml index 5cf8534..b74863e 100644 --- a/derive/Cargo.toml +++ b/derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "encase_derive" -version = "0.3.0" +version = "0.4.0" edition = "2021" license = "MIT-0" @@ -14,4 +14,4 @@ categories = ["rendering"] proc-macro = true [dependencies] -encase_derive_impl = { version = "=0.3.0", path = "./impl" } \ No newline at end of file +encase_derive_impl = { version = "=0.4.0", path = "./impl" } \ No newline at end of file diff --git a/derive/impl/Cargo.toml b/derive/impl/Cargo.toml index 6c72a0b..1bc5cf9 100644 --- a/derive/impl/Cargo.toml +++ b/derive/impl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "encase_derive_impl" -version = "0.3.0" +version = "0.4.0" edition = "2021" license = "MIT-0"