Skip to content

Commit

Permalink
Fix naga workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald committed Oct 25, 2023
1 parent d9a425b commit be3e121
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 33 deletions.
59 changes: 41 additions & 18 deletions .github/workflows/lazy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Lazy jobs running on master post merges.
name: lazy
on:
pull_request:
paths:
- '.github/workflows/lazy.yml'
push:
branches: [trunk]

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions .github/workflows/validation-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/validation-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
workspaces: |
naga/xtask -> naga/xtask/target
- run: cargo xtask validate msl
- run: cd naga; cargo xtask validate msl
6 changes: 3 additions & 3 deletions .github/workflows/validation-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 3 additions & 1 deletion naga/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
1 change: 1 addition & 0 deletions naga/benches/criterion.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(not(target_arch = "wasm32"))]
#![allow(clippy::needless_borrowed_reference)]

use criterion::*;
Expand Down
1 change: 1 addition & 0 deletions naga/src/back/msl/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<H: std::hash::Hasher>(&self, hasher: &mut H) {
Expand Down
12 changes: 6 additions & 6 deletions naga/tests/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}),
Expand Down Expand Up @@ -232,7 +232,7 @@ impl Input {
let mut param_path = self.input_path();
param_path.set_extension("param.ron");
match fs::read_to_string(&param_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()
)),
Expand Down Expand Up @@ -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()
));
Expand All @@ -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()
))
Expand Down Expand Up @@ -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")]
Expand Down

0 comments on commit be3e121

Please sign in to comment.