From be3e121dcccb214c4f971aa79fa2e7ebe08d5ac4 Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Wed, 25 Oct 2023 15:12:58 -0400 Subject: [PATCH] Fix naga workflows --- .github/workflows/lazy.yml | 59 ++++++++++++++++-------- .github/workflows/validation-linux.yml | 8 ++-- .github/workflows/validation-macos.yml | 2 +- .github/workflows/validation-windows.yml | 6 +-- naga/Cargo.toml | 4 +- naga/benches/criterion.rs | 1 + naga/src/back/msl/sampler.rs | 1 + naga/tests/snapshots.rs | 12 ++--- 8 files changed, 60 insertions(+), 33 deletions(-) diff --git a/.github/workflows/lazy.yml b/.github/workflows/lazy.yml index e7dfe79aaf..542a74055c 100644 --- a/.github/workflows/lazy.yml +++ b/.github/workflows/lazy.yml @@ -1,6 +1,9 @@ # Lazy jobs running on master post merges. name: lazy on: + pull_request: + paths: + - '.github/workflows/lazy.yml' push: branches: [trunk] @@ -16,19 +19,25 @@ jobs: steps: - uses: actions/checkout@v3 - - run: mkdir data + - run: mkdir naga/data - name: Download shaders - run: curl https://user.fm/files/v2-5573e18b9f03f42c6ae53c392083da35/dota2-shaders.zip -o data/all.zip + run: curl https://user.fm/files/v2-5573e18b9f03f42c6ae53c392083da35/dota2-shaders.zip -o naga/data/all.zip - name: Unpack shaders - run: cd data && unzip all.zip + run: | + cd naga/data + unzip all.zip - name: Build Naga - run: cargo build --release --bin naga + run: | + cd naga + cargo build --release --bin naga - name: Convert shaders - run: for file in data/*.spv ; do echo "Translating" ${file} && target/release/naga --validate 27 ${file} ${file}.metal; done + run: | + cd naga + for file in data/*.spv do echo "Translating" ${file} && target/release/naga --validate 27 ${file} ${file}.metal; done parse-vulkan-tutorial-shaders: name: Parse Sascha Willems Vulkan tutorial shaders @@ -37,15 +46,18 @@ jobs: - uses: actions/checkout@v3 - name: Download shaders - run: git clone https://github.com/SaschaWillems/Vulkan.git + run: cd naga && git clone https://github.com/SaschaWillems/Vulkan.git - name: Build Naga - run: cargo build --release --bin naga + run: | + cd naga + cargo build --release --bin naga - name: Convert metal shaders run: | # No needed to stop workflow if we can't validate one file set +e + cd naga touch counter SUCCESS_RESULT_COUNT=0 FILE_COUNT=0 @@ -69,20 +81,25 @@ jobs: - uses: actions/checkout@v3 - name: Download shaders - run: git clone https://github.com/dneto0/spirv-samples.git + run: | + cd naga + git clone https://github.com/dneto0/spirv-samples.git - name: Build Naga - run: cargo build --release --bin naga + run: | + cd naga + cargo build --release --bin naga - name: Install spirv-tools run: | - wget -q https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/linux-clang-release/continuous/1489/20210629-121459/install.tgz - tar zxf install.tgz - ./install/bin/spirv-as --version + cd naga + wget -q https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/linux-clang-release/continuous/1489/20210629-121459/install.tgz + tar zxf install.tgz + ./install/bin/spirv-as --version - name: Compile spv from spvasm run: | - cd spirv-samples + cd naga/spirv-samples mkdir -p spv find "./spvasm" -name '*.spvasm' | while read fname; @@ -94,7 +111,7 @@ jobs: - name: Validate spv and generate wgsl run: | set +e - cd spirv-samples + cd naga/spirv-samples SUCCESS_RESULT_COUNT=0 FILE_COUNT=0 mkdir -p spv @@ -119,7 +136,7 @@ jobs: - name: Validate output wgsl run: | set +e - cd spirv-samples + cd naga/spirv-samples SUCCESS_RESULT_COUNT=0 FILE_COUNT=0 @@ -150,10 +167,16 @@ jobs: tool: cargo-nextest - name: Test minimal (without span) - run: cargo nextest run --features validate -p naga + run: | + cd naga + cargo nextest run --features validate -p naga - name: Test all (without validation) - run: cargo nextest run --features wgsl-in,wgsl-out,glsl-in,glsl-out,spv-in,spv-out,msl-out,hlsl-out,dot-out --workspace + run: | + cd naga + cargo nextest run --features wgsl-in,wgsl-out,glsl-in,glsl-out,spv-in,spv-out,msl-out,hlsl-out,dot-out --workspace - name: Check snapshots (without validation) - run: git diff --exit-code -- tests/out + run: | + cd naga + git diff --exit-code -- tests/out diff --git a/.github/workflows/validation-linux.yml b/.github/workflows/validation-linux.yml index da8d2ad306..019ac6625b 100644 --- a/.github/workflows/validation-linux.yml +++ b/.github/workflows/validation-linux.yml @@ -22,10 +22,10 @@ jobs: workspaces: | naga/xtask -> naga/xtask/target - - run: cargo xtask validate spv + - run: cd naga; cargo xtask validate spv - - run: cargo xtask validate glsl + - run: cd naga; cargo xtask validate glsl - - run: cargo xtask validate dot + - run: cd naga; cargo xtask validate dot - - run: cargo xtask validate wgsl + - run: cd naga; cargo xtask validate wgsl diff --git a/.github/workflows/validation-macos.yml b/.github/workflows/validation-macos.yml index 3ba1e5d335..18bf6892a2 100644 --- a/.github/workflows/validation-macos.yml +++ b/.github/workflows/validation-macos.yml @@ -19,4 +19,4 @@ jobs: workspaces: | naga/xtask -> naga/xtask/target - - run: cargo xtask validate msl + - run: cd naga; cargo xtask validate msl diff --git a/.github/workflows/validation-windows.yml b/.github/workflows/validation-windows.yml index d2a0e21ae7..02f5a24cd0 100644 --- a/.github/workflows/validation-windows.yml +++ b/.github/workflows/validation-windows.yml @@ -22,7 +22,7 @@ jobs: workspaces: | naga/xtask -> naga/xtask/target - - run: cargo xtask validate hlsl dxc + - run: cd naga; cargo xtask validate hlsl dxc validate-windows-fxc: name: Validate Naga HLSL Output on FXC @@ -42,6 +42,6 @@ jobs: - uses: Swatinem/rust-cache@v2 with: workspaces: | - naga/xtask -> target + naga/xtask -> naga/xtask/target - - run: cargo xtask validate hlsl fxc + - run: cd naga; cargo xtask validate hlsl fxc diff --git a/naga/Cargo.toml b/naga/Cargo.toml index 3fc2b307a6..91ed49a5c6 100644 --- a/naga/Cargo.toml +++ b/naga/Cargo.toml @@ -59,9 +59,11 @@ pp-rs = { version = "0.2.1", optional = true } hexf-parse = { version = "0.2.1", optional = true } unicode-xid = { version = "0.2.3", optional = true } +[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] +criterion = { version = "0.5", features = [] } + [dev-dependencies] bincode = "1" -criterion = { version = "0.5", features = [] } diff = "0.1" env_logger = "0.10" hlsl-snapshots = { path = "./hlsl-snapshots" } diff --git a/naga/benches/criterion.rs b/naga/benches/criterion.rs index 9c0dc225fc..697467faa6 100644 --- a/naga/benches/criterion.rs +++ b/naga/benches/criterion.rs @@ -1,3 +1,4 @@ +#![cfg(not(target_arch = "wasm32"))] #![allow(clippy::needless_borrowed_reference)] use criterion::*; diff --git a/naga/src/back/msl/sampler.rs b/naga/src/back/msl/sampler.rs index 3b95fa3781..0bf987076d 100644 --- a/naga/src/back/msl/sampler.rs +++ b/naga/src/back/msl/sampler.rs @@ -156,6 +156,7 @@ pub struct InlineSampler { impl Eq for InlineSampler {} +#[allow(renamed_and_removed_lints)] #[allow(clippy::derive_hash_xor_eq)] impl std::hash::Hash for InlineSampler { fn hash(&self, hasher: &mut H) { diff --git a/naga/tests/snapshots.rs b/naga/tests/snapshots.rs index c3455dd864..014fb6d211 100644 --- a/naga/tests/snapshots.rs +++ b/naga/tests/snapshots.rs @@ -143,8 +143,8 @@ impl Input { .expect("all files in snapshot input directory should have extensions"); let input = Input::new( Some(&subdirectory), - &file_name.file_stem().unwrap().to_str().unwrap(), - &extension.to_str().unwrap(), + file_name.file_stem().unwrap().to_str().unwrap(), + extension.to_str().unwrap(), ); input }), @@ -232,7 +232,7 @@ impl Input { let mut param_path = self.input_path(); param_path.set_extension("param.ron"); match fs::read_to_string(¶m_path) { - Ok(string) => ron::de::from_str(&string).expect(&format!( + Ok(string) => ron::de::from_str(&string).unwrap_or_else(|_| panic!( "Couldn't parse param file: {}", param_path.display() )), @@ -277,7 +277,7 @@ fn check_targets( let info = naga::valid::Validator::new(naga::valid::ValidationFlags::all(), capabilities) .validate(module) - .expect(&format!( + .unwrap_or_else(|_| panic!( "Naga module validation failed on test '{}'", name.display() )); @@ -297,7 +297,7 @@ fn check_targets( naga::valid::Validator::new(naga::valid::ValidationFlags::all(), capabilities) .validate(module) - .expect(&format!( + .unwrap_or_else(|_| panic!( "Post-compaction module validation failed on test '{}'", name.display() )) @@ -576,7 +576,7 @@ fn write_output_hlsl( }); } - config.to_file(&input.output_path("hlsl", "ron")).unwrap(); + config.to_file(input.output_path("hlsl", "ron")).unwrap(); } #[cfg(feature = "wgsl-out")]