mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Allow overriding instance flags in tests (#7374)
This commit is contained in:
parent
187e1a6967
commit
db4cb26858
@ -493,11 +493,11 @@ static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTest
|
||||
base_test_parameters: wgpu_test::TestParameters {
|
||||
required_features: <Example as crate::framework::Example>::required_features(),
|
||||
required_limits: <Example as crate::framework::Example>::required_limits(),
|
||||
force_fxc: false,
|
||||
skips: vec![],
|
||||
failures: Vec::new(),
|
||||
required_downlevel_caps:
|
||||
<Example as crate::framework::Example>::required_downlevel_capabilities(),
|
||||
..Default::default()
|
||||
},
|
||||
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
|
||||
_phantom: std::marker::PhantomData::<Example>,
|
||||
|
||||
@ -380,11 +380,11 @@ static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTest
|
||||
base_test_parameters: wgpu_test::TestParameters {
|
||||
required_features: <Example as crate::framework::Example>::required_features(),
|
||||
required_limits: <Example as crate::framework::Example>::required_limits(),
|
||||
force_fxc: false,
|
||||
skips: vec![],
|
||||
failures: Vec::new(),
|
||||
required_downlevel_caps:
|
||||
<Example as crate::framework::Example>::required_downlevel_capabilities(),
|
||||
..Default::default()
|
||||
},
|
||||
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
|
||||
_phantom: std::marker::PhantomData::<Example>,
|
||||
|
||||
@ -486,6 +486,7 @@ static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTest
|
||||
failures: Vec::new(),
|
||||
required_downlevel_caps:
|
||||
<Example as crate::framework::Example>::required_downlevel_capabilities(),
|
||||
..Default::default()
|
||||
},
|
||||
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
|
||||
_phantom: std::marker::PhantomData::<Example>,
|
||||
|
||||
@ -560,11 +560,11 @@ static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTest
|
||||
base_test_parameters: wgpu_test::TestParameters {
|
||||
required_features: <Example as crate::framework::Example>::required_features(),
|
||||
required_limits: <Example as crate::framework::Example>::required_limits(),
|
||||
force_fxc: false,
|
||||
skips: vec![],
|
||||
failures: Vec::new(),
|
||||
required_downlevel_caps:
|
||||
<Example as crate::framework::Example>::required_downlevel_capabilities(),
|
||||
..Default::default()
|
||||
},
|
||||
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
|
||||
_phantom: std::marker::PhantomData::<Example>,
|
||||
|
||||
@ -380,7 +380,7 @@ static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTest
|
||||
failures: Vec::new(),
|
||||
required_downlevel_caps:
|
||||
<Example as crate::framework::Example>::required_downlevel_capabilities(),
|
||||
force_fxc: false,
|
||||
..Default::default()
|
||||
},
|
||||
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
|
||||
_phantom: std::marker::PhantomData::<Example>,
|
||||
|
||||
@ -439,6 +439,7 @@ static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTest
|
||||
failures: Vec::new(),
|
||||
required_downlevel_caps:
|
||||
<Example as crate::framework::Example>::required_downlevel_capabilities(),
|
||||
..Default::default()
|
||||
},
|
||||
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
|
||||
_phantom: std::marker::PhantomData::<Example>,
|
||||
|
||||
@ -6,7 +6,10 @@
|
||||
#[wasm_bindgen_test::wasm_bindgen_test]
|
||||
fn canvas_get_context_returned_null() {
|
||||
// Not using the normal testing infrastructure because that goes straight to creating the canvas for us.
|
||||
let instance = wgpu_test::initialize_instance(wgpu::Backends::all(), false);
|
||||
let instance = wgpu_test::initialize_instance(
|
||||
wgpu::Backends::all(),
|
||||
&wgpu_test::TestParameters::default(),
|
||||
);
|
||||
// Create canvas
|
||||
let canvas = wgpu_test::initialize_html_canvas();
|
||||
|
||||
|
||||
@ -102,7 +102,8 @@ static REQUEST_DEVICE_ERROR_MESSAGE_NATIVE: GpuTestConfiguration = GpuTestConfig
|
||||
async fn request_device_error_message() {
|
||||
// Not using initialize_test() because that doesn't let us catch the error
|
||||
// nor .await anything
|
||||
let (_instance, adapter, _surface_guard) = wgpu_test::initialize_adapter(None, false).await;
|
||||
let (_instance, adapter, _surface_guard) =
|
||||
wgpu_test::initialize_adapter(None, &TestParameters::default()).await;
|
||||
|
||||
let device_error = adapter
|
||||
.request_device(&wgpu::DeviceDescriptor {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use wgpu::{Adapter, Backends, Device, Features, Instance, Limits, Queue};
|
||||
|
||||
use crate::report::AdapterReport;
|
||||
use crate::{report::AdapterReport, TestParameters};
|
||||
|
||||
/// Initialize the logger for the test runner.
|
||||
pub fn init_logger() {
|
||||
@ -12,7 +12,7 @@ pub fn init_logger() {
|
||||
}
|
||||
|
||||
/// Initialize a wgpu instance with the options from the environment.
|
||||
pub fn initialize_instance(backends: wgpu::Backends, force_fxc: bool) -> Instance {
|
||||
pub fn initialize_instance(backends: wgpu::Backends, params: &TestParameters) -> Instance {
|
||||
// We ignore `WGPU_BACKEND` for now, merely using test filtering to only run a single backend's tests.
|
||||
//
|
||||
// We can potentially work support back into the test runner in the future, but as the adapters are matched up
|
||||
@ -30,14 +30,19 @@ pub fn initialize_instance(backends: wgpu::Backends, force_fxc: bool) -> Instanc
|
||||
};
|
||||
// Some tests need to be able to force demote to FXC, to specifically test workarounds for FXC
|
||||
// behavior.
|
||||
let dx12_shader_compiler = if force_fxc {
|
||||
let dx12_shader_compiler = if params.force_fxc {
|
||||
wgpu::Dx12Compiler::Fxc
|
||||
} else {
|
||||
wgpu::Dx12Compiler::from_env().unwrap_or(wgpu::Dx12Compiler::StaticDxc)
|
||||
};
|
||||
// The defaults for debugging, overridden by the environment, overridden by the test parameters.
|
||||
let flags = wgpu::InstanceFlags::debugging()
|
||||
.with_env()
|
||||
.union(params.required_instance_flags);
|
||||
|
||||
Instance::new(&wgpu::InstanceDescriptor {
|
||||
backends,
|
||||
flags: wgpu::InstanceFlags::debugging().with_env(),
|
||||
flags,
|
||||
backend_options: wgpu::BackendOptions {
|
||||
dx12: wgpu::Dx12BackendOptions {
|
||||
shader_compiler: dx12_shader_compiler,
|
||||
@ -65,13 +70,13 @@ pub fn initialize_instance(backends: wgpu::Backends, force_fxc: bool) -> Instanc
|
||||
/// Initialize a wgpu adapter, using the given adapter report to match the adapter.
|
||||
pub async fn initialize_adapter(
|
||||
adapter_report: Option<&AdapterReport>,
|
||||
force_fxc: bool,
|
||||
params: &TestParameters,
|
||||
) -> (Instance, Adapter, Option<SurfaceGuard>) {
|
||||
let backends = adapter_report
|
||||
.map(|report| Backends::from(report.info.backend))
|
||||
.unwrap_or_default();
|
||||
|
||||
let instance = initialize_instance(backends, force_fxc);
|
||||
let instance = initialize_instance(backends, params);
|
||||
#[allow(unused_variables)]
|
||||
let surface: Option<wgpu::Surface>;
|
||||
let surface_guard: Option<SurfaceGuard>;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use arrayvec::ArrayVec;
|
||||
use wgpu::{DownlevelCapabilities, DownlevelFlags, Features, Limits};
|
||||
use wgpu::{DownlevelCapabilities, DownlevelFlags, Features, InstanceFlags, Limits};
|
||||
|
||||
use crate::{
|
||||
report::AdapterReport, FailureApplicationReasons, FailureBehavior, FailureCase,
|
||||
@ -19,6 +19,8 @@ pub struct TestParameters {
|
||||
pub required_downlevel_caps: DownlevelCapabilities,
|
||||
pub required_limits: Limits,
|
||||
|
||||
pub required_instance_flags: InstanceFlags,
|
||||
|
||||
/// On Dx12, specifically test against the Fxc compiler.
|
||||
///
|
||||
/// For testing workarounds to Fxc bugs.
|
||||
@ -37,6 +39,7 @@ impl Default for TestParameters {
|
||||
required_features: Features::empty(),
|
||||
required_downlevel_caps: LOWEST_DOWNLEVEL_PROPERTIES,
|
||||
required_limits: Limits::downlevel_webgl2_defaults(),
|
||||
required_instance_flags: InstanceFlags::empty(),
|
||||
force_fxc: false,
|
||||
skips: Vec::new(),
|
||||
failures: Vec::new(),
|
||||
@ -69,6 +72,12 @@ impl TestParameters {
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the instance flags that the test requires.
|
||||
pub fn instance_flags(mut self, instance_flags: InstanceFlags) -> Self {
|
||||
self.required_instance_flags |= instance_flags;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn force_fxc(mut self, force_fxc: bool) -> Self {
|
||||
self.force_fxc = force_fxc;
|
||||
self
|
||||
|
||||
@ -43,7 +43,7 @@ pub async fn execute_test(
|
||||
let _test_guard = isolation::OneTestPerProcessGuard::new();
|
||||
|
||||
let (instance, adapter, _surface_guard) =
|
||||
initialize_adapter(adapter_report, config.params.force_fxc).await;
|
||||
initialize_adapter(adapter_report, &config.params).await;
|
||||
|
||||
let adapter_info = adapter.get_info();
|
||||
let adapter_downlevel_capabilities = adapter.get_downlevel_capabilities();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user