mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Update naga benchmarks and add a compaction benchmark (#7715)
This commit is contained in:
parent
1da7cd4811
commit
a04085c5e4
@ -108,6 +108,10 @@ impl Inputs {
|
||||
|
||||
self.inner.retain(|input| input.module_info.is_some());
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
self.inner.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_glsl(stage: naga::ShaderStage, inputs: &Inputs) {
|
||||
@ -124,13 +128,15 @@ fn parse_glsl(stage: naga::ShaderStage, inputs: &Inputs) {
|
||||
}
|
||||
|
||||
fn get_wgsl_inputs() -> Inputs {
|
||||
let mut inputs = Inputs::from_dir("../naga/tests/in", "wgsl");
|
||||
let mut inputs = Inputs::from_dir("../naga/tests/in/wgsl", "wgsl");
|
||||
|
||||
// remove "large-source" tests, they skew the results
|
||||
inputs
|
||||
.inner
|
||||
.retain(|input| !input.filename.contains("large-source"));
|
||||
|
||||
assert!(!inputs.is_empty());
|
||||
|
||||
inputs
|
||||
}
|
||||
|
||||
@ -168,6 +174,7 @@ fn frontends(c: &mut Criterion) {
|
||||
});
|
||||
|
||||
let inputs_spirv = Inputs::from_dir("../naga/tests/in/spv", "spvasm");
|
||||
assert!(!inputs_spirv.is_empty());
|
||||
|
||||
// Assemble all the SPIR-V assembly.
|
||||
let mut assembled_spirv = Vec::<Vec<u32>>::new();
|
||||
@ -216,6 +223,8 @@ fn frontends(c: &mut Criterion) {
|
||||
|
||||
let mut inputs_vertex = Inputs::from_dir("../naga/tests/in/glsl", "vert");
|
||||
let mut inputs_fragment = Inputs::from_dir("../naga/tests/in/glsl", "frag");
|
||||
assert!(!inputs_vertex.is_empty());
|
||||
assert!(!inputs_fragment.is_empty());
|
||||
// let mut inputs_compute = Inputs::from_dir("../naga/tests/in/glsl", "comp");
|
||||
group.throughput(Throughput::Bytes(
|
||||
inputs_vertex.bytes() + inputs_fragment.bytes(), // + inputs_compute.bytes()
|
||||
@ -259,6 +268,24 @@ fn validation(c: &mut Criterion) {
|
||||
group.finish();
|
||||
}
|
||||
|
||||
fn compact(c: &mut Criterion) {
|
||||
let mut inputs = get_wgsl_inputs();
|
||||
|
||||
inputs.validate();
|
||||
assert!(!inputs.is_empty());
|
||||
|
||||
let mut group = c.benchmark_group("compact");
|
||||
group.throughput(Throughput::Bytes(inputs.bytes()));
|
||||
group.bench_function("shader: compact", |b| {
|
||||
b.iter(|| {
|
||||
for input in &mut inputs.inner {
|
||||
naga::compact::compact(input.module.as_mut().unwrap());
|
||||
}
|
||||
});
|
||||
});
|
||||
group.finish();
|
||||
}
|
||||
|
||||
fn backends(c: &mut Criterion) {
|
||||
let mut inputs = get_wgsl_inputs();
|
||||
|
||||
@ -267,6 +294,7 @@ fn backends(c: &mut Criterion) {
|
||||
// run this to properly know the size of the inputs, as any that fail validation
|
||||
// will be removed.
|
||||
inputs.validate();
|
||||
assert!(!inputs.is_empty());
|
||||
|
||||
group.throughput(Throughput::Bytes(inputs.bytes()));
|
||||
group.bench_function("shader: wgsl-out", |b| {
|
||||
@ -289,6 +317,10 @@ fn backends(c: &mut Criterion) {
|
||||
let mut data = Vec::new();
|
||||
let options = naga::back::spv::Options::default();
|
||||
for input in &inputs.inner {
|
||||
if input.filename.contains("pointer-function-arg") {
|
||||
// These fail due to https://github.com/gfx-rs/wgpu/issues/7315
|
||||
continue;
|
||||
}
|
||||
let mut writer = naga::back::spv::Writer::new(&options).unwrap();
|
||||
let _ = writer.write(
|
||||
input.module.as_ref().unwrap(),
|
||||
@ -306,6 +338,10 @@ fn backends(c: &mut Criterion) {
|
||||
let mut data = Vec::new();
|
||||
let options = naga::back::spv::Options::default();
|
||||
for input in &inputs.inner {
|
||||
if input.filename.contains("pointer-function-arg") {
|
||||
// These fail due to https://github.com/gfx-rs/wgpu/issues/7315
|
||||
continue;
|
||||
}
|
||||
let mut writer = naga::back::spv::Writer::new(&options).unwrap();
|
||||
let module = input.module.as_ref().unwrap();
|
||||
for ep in module.entry_points.iter() {
|
||||
@ -400,4 +436,4 @@ fn backends(c: &mut Criterion) {
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(shader, frontends, validation, backends);
|
||||
criterion_group!(shader, frontends, validation, compact, backends);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user