diff --git a/.cargo/config b/.cargo/config index bb78f3eeeb..2b1a6f47ca 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,7 +1,2 @@ -[build] -# Currently there's an issue where the Example CPU runner fails without -# `-C prefer-dynamic`. -rustflags = "-C prefer-dynamic" - [alias] compiletest = "run --release -p compiletests --" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 44706649d1..f1e59c38ff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,7 +23,8 @@ jobs: runs-on: ${{ matrix.os }} env: spirv_tools_version: "20200928" - RUSTUP_UNPACK_RAM: "104857600" + RUSTUP_UNPACK_RAM: "26214400" + RUSTUP_IO_THREADS: "1" steps: - uses: actions/checkout@v2 # Ubuntu does have `brew install spirv-tools`, but it installs from @@ -51,14 +52,38 @@ jobs: - if: ${{ runner.os == 'Windows' }} # Runs separately to add spir-v tools to Powershell's Path. run: echo "$HOME/spirv-tools/install/bin" >> $env:GITHUB_PATH + # cargo version is a random command that forces the installation of rust-toolchain + - name: install rust-toolchain + run: cargo version # Fetch dependencies in a separate step to clearly show how long each part # of the testing takes - name: cargo fetch --locked run: cargo fetch --locked --target ${{ matrix.target }} - - name: Run tests + + # Core crates + # Compiled in --release because cargo compiletest would otherwise compile in release again. + - name: rustc_codegen_spirv build if: ${{ matrix.target != 'aarch64-linux-android' }} - shell: bash - run: .github/workflows/test.sh ${{ runner.os }} + run: cargo test -p rustc_codegen_spirv --release --no-default-features --features "use-installed-tools" --no-run + + - name: rustc_codegen_spirv test + if: ${{ matrix.target != 'aarch64-linux-android' }} + run: cargo test -p rustc_codegen_spirv --release --no-default-features --features "use-installed-tools" + + - name: compiletest + if: ${{ matrix.target != 'aarch64-linux-android' }} + run: cargo run -p compiletests --release --no-default-features --features "use-installed-tools" -- --target-env vulkan1.1,spv1.3 + + # Examples + - name: cargo check examples + if: ${{ matrix.target != 'aarch64-linux-android' }} + run: cargo check -p example-runner-ash -p example-runner-wgpu -p example-runner-cpu -p compute-shader -p mouse-shader -p simplest-shader -p sky-shader --no-default-features --features "use-installed-tools" + + - name: build example shaders + if: ${{ matrix.target != 'aarch64-linux-android' }} + env: + OUT_DIR: "target/tmp" + run: cargo run -p example-runner-wgpu-builder --release --no-default-features --features "use-installed-tools" - name: Build WGPU Example for Android if: ${{ matrix.target == 'aarch64-linux-android' }} @@ -95,6 +120,9 @@ jobs: echo "${HOME}/spirv-tools/install/bin" >> $GITHUB_PATH - name: Install rustup components run: rustup component add rustfmt clippy + # cargo version is a random command that forces the installation of rust-toolchain + - name: install rust-toolchain + run: cargo version - name: cargo fetch --locked run: cargo fetch --locked - name: Rustfmt diff --git a/.github/workflows/test.sh b/.github/workflows/test.sh deleted file mode 100755 index c6a318ed10..0000000000 --- a/.github/workflows/test.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env bash -set -e - -if [[ -z "${CI}" ]]; then - FEAT="use-compiled-tools" -else - FEAT="use-installed-tools" -fi - -os=$1 - -function cargo_test() { - echo ::group::"$1 build" - cargo test \ - --manifest-path "$1/Cargo.toml" \ - --no-default-features \ - --features "$FEAT" \ - --no-run - echo ::endgroup:: - - echo ::group::"$1 test" - cargo test \ - --manifest-path "$1/Cargo.toml" \ - --no-default-features \ - --features "$FEAT" - echo ::endgroup:: -} - -function cargo_test_no_features() { - echo ::group::"$1 build" - cargo test --manifest-path "$1/Cargo.toml" --no-run - echo ::endgroup:: - - echo ::group::"$1 test" - cargo test --manifest-path "$1/Cargo.toml" - echo ::endgroup:: -} - -# Core crates -cargo_test crates/rustc_codegen_spirv - -# Examples -# See: https://github.com/EmbarkStudios/rust-gpu/issues/84 -if [[ "$os" != "macOS" ]]; then - cargo_test examples/runners/ash -fi - -cargo_test examples/runners/wgpu - -cargo_test_no_features examples/runners/cpu -cargo_test_no_features examples/shaders/sky-shader -cargo_test_no_features examples/shaders/simplest-shader - -cargo compiletest --target-env vulkan1.1,spv1.3 diff --git a/Cargo.lock b/Cargo.lock index 46cb7c256e..97d768e518 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -93,8 +93,7 @@ dependencies = [ [[package]] name = "ash-molten" version = "0.9.0+1.1.2-f28ab1c" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c4d72ca0f3c4037e64e0ee622907177b6594a6bce03efbeb91fcca6e9bd900a" +source = "git+https://github.com/EmbarkStudios/ash-molten.git?rev=fea270b0c9186b8a45e62215314204f4c16a57b6#fea270b0c9186b8a45e62215314204f4c16a57b6" dependencies = [ "anyhow", "ash 0.32.1", diff --git a/examples/runners/ash/Cargo.toml b/examples/runners/ash/Cargo.toml index d171e667b4..167ff5819f 100644 --- a/examples/runners/ash/Cargo.toml +++ b/examples/runners/ash/Cargo.toml @@ -24,4 +24,4 @@ shared = { path = "../../shaders/shared" } spirv-builder = { path = "../../../crates/spirv-builder", default-features = false } [target.'cfg(target_os = "macos")'.dependencies] -ash-molten = { version = "0.9", features = ["pre-built"] } +ash-molten = { git = "https://github.com/EmbarkStudios/ash-molten.git", rev = "fea270b0c9186b8a45e62215314204f4c16a57b6", features = ["pre-built"] } diff --git a/examples/runners/wgpu/build.rs b/examples/runners/wgpu/build.rs index e0d7c97cae..ac51966c24 100644 --- a/examples/runners/wgpu/build.rs +++ b/examples/runners/wgpu/build.rs @@ -5,17 +5,14 @@ use std::path::PathBuf; fn main() -> Result<(), Box> { let target_os = std::env::var("CARGO_CFG_TARGET_OS")?; let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH")?; - // Always build on CI to make sure the shaders can still build - let is_on_ci = std::env::var("CI"); println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-env-changed=CARGO_CFG_TARGET_OS"); println!("cargo:rerun-if-env-changed=CARGO_CFG_TARGET_ARCH"); - println!("cargo:rerun-if-env-changed=CI"); // While OUT_DIR is set for both build.rs and compiling the crate, PROFILE is only set in // build.rs. So, export it to crate compilation as well. let profile = env::var("PROFILE").unwrap(); println!("cargo:rustc-env=PROFILE={}", profile); - if target_os != "android" && target_arch != "wasm32" && is_on_ci.is_err() { + if target_os != "android" && target_arch != "wasm32" { return Ok(()); } let mut dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); diff --git a/examples/runners/wgpu/builder/src/main.rs b/examples/runners/wgpu/builder/src/main.rs index 77211469e7..a215b48dbf 100644 --- a/examples/runners/wgpu/builder/src/main.rs +++ b/examples/runners/wgpu/builder/src/main.rs @@ -5,11 +5,13 @@ use std::fs; use std::path::Path; fn build_shader( - path_to_create: &str, + path_to_crate: &str, codegen_names: bool, caps: &[Capability], ) -> Result<(), Box> { - let mut builder = SpirvBuilder::new(path_to_create, "spirv-unknown-vulkan1.0"); + let builder_dir = &Path::new(env!("CARGO_MANIFEST_DIR")); + let path_to_crate = builder_dir.join(path_to_crate); + let mut builder = SpirvBuilder::new(path_to_crate, "spirv-unknown-vulkan1.0"); for &cap in caps { builder = builder.capability(cap); } @@ -17,17 +19,18 @@ fn build_shader( if codegen_names { let out_dir = env::var_os("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join("entry_points.rs"); + fs::create_dir_all(&out_dir).unwrap(); fs::write(&dest_path, result.codegen_entry_point_strings()).unwrap(); } Ok(()) } fn main() -> Result<(), Box> { - build_shader("../../shaders/sky-shader", true, &[])?; - build_shader("../../shaders/simplest-shader", false, &[])?; - build_shader("../../shaders/compute-shader", false, &[])?; + build_shader("../../../shaders/sky-shader", true, &[])?; + build_shader("../../../shaders/simplest-shader", false, &[])?; + build_shader("../../../shaders/compute-shader", false, &[])?; build_shader( - "../../shaders/mouse-shader", + "../../../shaders/mouse-shader", false, &[Capability::Int8, Capability::Int16, Capability::Int64], )?;