Skip to content

Commit

Permalink
chore: [spv-in] atomics snapshot tests (gfx-rs#6692)
Browse files Browse the repository at this point in the history
* chore: [spv-in] clean up atomic upgrade tests

* add output test files

* update changelog

* remove extraneous snapshot out files
  • Loading branch information
schell authored Dec 10, 2024
1 parent 90859b4 commit 8b93a71
Show file tree
Hide file tree
Showing 11 changed files with 330 additions and 686 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456), [#6148]

#### Naga

- Clean up tests for atomic operations support in SPIR-V frontend. By @schell in [#6692](https://github.com/gfx-rs/wgpu/pull/6692)
- Fix an issue where `naga` CLI would incorrectly skip the first positional argument when `--stdin-file-path` was specified. By @ErichDonGubler in [#6480](https://github.com/gfx-rs/wgpu/pull/6480).
- Fix textureNumLevels in the GLSL backend. By @magcius in [#6483](https://github.com/gfx-rs/wgpu/pull/6483).
- Support 64-bit hex literals and unary operations in constants [#6616](https://github.com/gfx-rs/wgpu/pull/6616).
Expand Down
86 changes: 0 additions & 86 deletions naga/src/front/spv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6057,89 +6057,3 @@ mod test {
let _ = super::parse_u8_slice(&bin, &Default::default()).unwrap();
}
}

#[cfg(all(test, feature = "wgsl-in", wgsl_out))]
mod test_atomic {
fn atomic_test(bytes: &[u8]) {
let _ = env_logger::builder().is_test(true).try_init();
let m = crate::front::spv::parse_u8_slice(bytes, &Default::default()).unwrap();

let mut wgsl = String::new();

for (vflags, name) in [
(crate::valid::ValidationFlags::empty(), "empty"),
(crate::valid::ValidationFlags::all(), "all"),
] {
log::info!("validating with flags - {name}");
let mut validator = crate::valid::Validator::new(vflags, Default::default());
match validator.validate(&m) {
Err(e) => {
log::error!("SPIR-V validation {}", e.emit_to_string(""));
log::info!("types: {:#?}", m.types);
panic!("validation error");
}
Ok(i) => {
wgsl = crate::back::wgsl::write_string(
&m,
&i,
crate::back::wgsl::WriterFlags::empty(),
)
.unwrap();
log::info!("wgsl-out:\n{wgsl}");
}
};
}

let m = match crate::front::wgsl::parse_str(&wgsl) {
Ok(m) => m,
Err(e) => {
log::error!("round trip WGSL validation {}", e.emit_to_string(&wgsl));
panic!("invalid module");
}
};
let mut validator =
crate::valid::Validator::new(crate::valid::ValidationFlags::all(), Default::default());
if let Err(e) = validator.validate(&m) {
log::error!("{}", e.emit_to_string(&wgsl));
panic!("invalid generated wgsl");
}
}

#[test]
fn atomic_i_inc() {
atomic_test(include_bytes!(
"../../../tests/in/spv/atomic_i_increment.spv"
));
}

#[test]
fn atomic_load_and_store() {
atomic_test(include_bytes!(
"../../../tests/in/spv/atomic_load_and_store.spv"
));
}

#[test]
fn atomic_exchange() {
atomic_test(include_bytes!("../../../tests/in/spv/atomic_exchange.spv"));
}

#[test]
fn atomic_compare_exchange() {
atomic_test(include_bytes!(
"../../../tests/in/spv/atomic_compare_exchange.spv"
));
}

#[test]
fn atomic_i_decrement() {
atomic_test(include_bytes!(
"../../../tests/in/spv/atomic_i_decrement.spv"
));
}

#[test]
fn atomic_i_add_and_sub() {
atomic_test(include_bytes!("../../../tests/in/spv/atomic_i_add_sub.spv"));
}
}
287 changes: 0 additions & 287 deletions naga/tests/out/ir/atomic_i_increment.compact.ron

This file was deleted.

Loading

0 comments on commit 8b93a71

Please sign in to comment.