Skip to content

Commit daced7a

Browse files
authored
Enable ray tracing example tests on metal (#9324)
1 parent 948b1a6 commit daced7a

9 files changed

Lines changed: 29 additions & 8 deletions

File tree

examples/features/src/ray_cube_compute/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ pub static TEST: crate::framework::ExampleTestParams = crate::framework::Example
471471
optional_features: wgpu::Features::default(),
472472
base_test_parameters: wgpu_test::TestParameters::default()
473473
// https://github.com/gfx-rs/wgpu/issues/9100
474-
.expect_fail(wgpu_test::FailureCase::backend(wgpu::Backends::METAL)),
474+
.disable_mtl_shader_validation(),
475475
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
476476
_phantom: std::marker::PhantomData::<Example>,
477477
};

examples/features/src/ray_cube_fragment/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ pub static TEST: crate::framework::ExampleTestParams = crate::framework::Example
357357
optional_features: wgpu::Features::default(),
358358
base_test_parameters: wgpu_test::TestParameters::default()
359359
// https://github.com/gfx-rs/wgpu/issues/9100
360-
.expect_fail(wgpu_test::FailureCase::backend(wgpu::Backends::METAL)),
360+
.disable_mtl_shader_validation(),
361361
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
362362
_phantom: std::marker::PhantomData::<Example>,
363363
};

examples/features/src/ray_scene/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ pub static TEST: crate::framework::ExampleTestParams = crate::framework::Example
537537
optional_features: wgpu::Features::default(),
538538
base_test_parameters: wgpu_test::TestParameters::default()
539539
// https://github.com/gfx-rs/wgpu/issues/9100
540-
.expect_fail(wgpu_test::FailureCase::backend(wgpu::Backends::METAL)),
540+
.disable_mtl_shader_validation(),
541541
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
542542
_phantom: std::marker::PhantomData::<Example>,
543543
};

examples/features/src/ray_shadows/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ pub static TEST: crate::framework::ExampleTestParams = crate::framework::Example
354354
optional_features: wgpu::Features::default(),
355355
base_test_parameters: wgpu_test::TestParameters::default()
356356
// https://github.com/gfx-rs/wgpu/issues/9100
357-
.expect_fail(wgpu_test::FailureCase::backend(wgpu::Backends::METAL)),
357+
.disable_mtl_shader_validation(),
358358
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
359359
_phantom: std::marker::PhantomData::<Example>,
360360
};

examples/features/src/ray_traced_triangle/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ pub static TEST: crate::framework::ExampleTestParams = crate::framework::Example
440440
optional_features: wgpu::Features::default(),
441441
base_test_parameters: wgpu_test::TestParameters::default()
442442
// https://github.com/gfx-rs/wgpu/issues/9100
443-
.expect_fail(wgpu_test::FailureCase::backend(wgpu::Backends::METAL)),
443+
.disable_mtl_shader_validation(),
444444
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
445445
_phantom: std::marker::PhantomData::<Example>,
446446
};

tests/src/native.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,15 @@ impl NativeTest {
6262

6363
let env_value = if metal_validation { "1" } else { "0" };
6464
std::env::set_var("MTL_DEBUG_LAYER", env_value);
65-
if std::env::var("GITHUB_ACTIONS").as_deref() != Ok("true") {
65+
if std::env::var("GITHUB_ACTIONS").as_deref() != Ok("true")
66+
&& !config.params.disable_mtl_shader_validation
67+
{
6668
// Metal Shader Validation is entirely broken in the paravirtualized CI environment.
6769
std::env::set_var("MTL_SHADER_VALIDATION", env_value);
70+
} else if config.params.disable_mtl_shader_validation {
71+
// For ray tracing, where MTL_SHADER_VALIDATION causes acceleration structure ids to be
72+
// completely incorrect.
73+
std::env::set_var("MTL_SHADER_VALIDATION", "0");
6874
}
6975

7076
execute_test(Some(&adapter_report), config, Some(test_info)).await;

tests/src/params.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ pub struct TestParameters {
3131

3232
/// Conditions under which this test should be run, but is expected to fail.
3333
pub failures: Vec<FailureCase>,
34+
35+
/// For certain features (ray tracing), metal shader validation is completely
36+
/// broken
37+
pub disable_mtl_shader_validation: bool,
3438
}
3539

3640
impl Default for TestParameters {
@@ -45,6 +49,7 @@ impl Default for TestParameters {
4549
// parameters ask us to remove it.
4650
skips: vec![FailureCase::backend(wgpu::Backends::NOOP)],
4751
failures: Vec::new(),
52+
disable_mtl_shader_validation: false,
4853
}
4954
}
5055
}
@@ -106,6 +111,15 @@ impl TestParameters {
106111
.retain(|case| *case != FailureCase::backend(wgpu::Backends::NOOP));
107112
self
108113
}
114+
115+
/// Disable metal shader validation.
116+
///
117+
/// Metal shader validation can cause features (ray tracing specifically)
118+
/// to break. This disables it so it can be tested.
119+
pub fn disable_mtl_shader_validation(mut self) -> Self {
120+
self.disable_mtl_shader_validation = true;
121+
self
122+
}
109123
}
110124

111125
/// Information about a test, including if if it should be skipped.

tests/tests/wgpu-gpu/ray_tracing/shader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static PREVENT_INVALID_RAY_QUERY_CALLS: GpuTestConfiguration = GpuTestConfigurat
115115
.features(wgpu::Features::EXPERIMENTAL_RAY_QUERY)
116116
// Otherwise, mistakes in the generated code won't be caught.
117117
.instance_flags(InstanceFlags::GPU_BASED_VALIDATION)
118-
// not yet implemented in directx12
118+
// not yet implemented in metal
119119
.skip(FailureCase::backend(Backends::METAL)),
120120
)
121121
.run_sync(prevent_invalid_ray_query_calls);

wgpu-types/src/limits.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,8 @@ impl Limits {
725725
max_blas_geometry_count: (1 << 24) - 1, // 2^24 - 1: Vulkan's minimum
726726
max_tlas_instance_count: (1 << 24) - 1, // 2^24 - 1: Vulkan's minimum
727727
max_blas_primitive_count: 1 << 28, // 2^28: Metal's minimum
728-
max_acceleration_structures_per_shader_stage: 16, // Vulkan's minimum
728+
// On metal acceleration structures are limited because they share buffer slots
729+
max_acceleration_structures_per_shader_stage: 1,
729730
..self
730731
}
731732
}

0 commit comments

Comments
 (0)