mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-23 16:01:04 +01:00
test: Check for device loss (#9477)
This commit is contained in:
1 parent
54bf53eb11
commit
aba219f910
8 files changed
+42
-9
No files matched your search
@@ -201,6 +201,23 @@ impl FailureCase {
|
||||
self
|
||||
}
|
||||
|
||||
/// Matches this failure case against an unexpected driver error.
|
||||
///
|
||||
/// Depending on build configuration, the error may surface as either a
|
||||
/// panic raised by the `internal_error_panic` feature (with the supplied
|
||||
/// message as a substring), or as a device-loss. Either behavior is
|
||||
/// accepted. In the device loss case, the original message has been
|
||||
/// discarded, and there is some risk this accepts a different error than
|
||||
/// intended (but it must be a device loss due to an unexpected driver
|
||||
/// error, which should be rare).
|
||||
pub fn unexpected_error(mut self, msg: &'static str) -> Self {
|
||||
self.reasons.push(FailureReason::panic().with_message(msg));
|
||||
self.reasons.push(FailureReason::panic().with_message(
|
||||
"Device lost: Unexpected error variant (driver implementation is at fault)",
|
||||
));
|
||||
self
|
||||
}
|
||||
|
||||
/// Test is flaky with the given configuration. Do not assert failure.
|
||||
///
|
||||
/// Use this _very_ sparyingly, and match as tightly as you can, including giving a specific failure message.
|
||||
|
||||
+19
-3
@@ -2,6 +2,18 @@ use wgpu::{Adapter, Backends, Device, Features, Instance, Limits, Queue};
|
||||
|
||||
use crate::{report::AdapterReport, TestParameters};
|
||||
|
||||
/// Default device-lost callback installed by [`initialize_device`]. Panics on
|
||||
/// any non-[`wgpu::DeviceLostReason::Destroyed`] device loss, which will
|
||||
/// cause the test to be treated as a failure.
|
||||
///
|
||||
/// Tests intentionally provoking device loss should install their own callback
|
||||
/// with [`wgpu::Device::set_device_lost_callback`].
|
||||
fn default_device_lost_callback(reason: wgpu::DeviceLostReason, message: String) {
|
||||
if reason != wgpu::DeviceLostReason::Destroyed {
|
||||
panic!("Device lost: {message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialize the logger for the test runner.
|
||||
pub fn init_logger() {
|
||||
// We don't actually care if it fails
|
||||
@@ -182,10 +194,14 @@ pub async fn initialize_device(
|
||||
})
|
||||
.await;
|
||||
|
||||
match bundle {
|
||||
Ok(b) => b,
|
||||
let (device, queue) = match bundle {
|
||||
Ok((device, queue)) => (device, queue),
|
||||
Err(e) => panic!("Failed to initialize device: {e}"),
|
||||
}
|
||||
};
|
||||
|
||||
device.set_device_lost_callback(default_device_lost_callback);
|
||||
|
||||
(device, queue)
|
||||
}
|
||||
|
||||
/// Create a canvas for testing.
|
||||
|
||||
@@ -16,7 +16,7 @@ static CLIP_DISTANCES: GpuTestConfiguration = GpuTestConfiguration::new()
|
||||
wgpu_test::FailureCase::molten_vk()
|
||||
.validation_error("Shader library compile failed")
|
||||
.validation_error("could not be compiled into pipeline")
|
||||
.panic("Unexpected Vulkan error: ERROR_INITIALIZATION_FAILED"),
|
||||
.unexpected_error("Unexpected Vulkan error: ERROR_INITIALIZATION_FAILED"),
|
||||
),
|
||||
)
|
||||
.run_async(clip_distances);
|
||||
|
||||
@@ -74,7 +74,7 @@ static DRAW_INDEX: GpuTestConfiguration = GpuTestConfiguration::new()
|
||||
wgpu_test::FailureCase::molten_vk()
|
||||
.validation_error("could not be compiled into pipeline")
|
||||
.validation_error("vkDestroyDevice")
|
||||
.panic("Unexpected Vulkan error: ERROR_INITIALIZATION_FAILED"),
|
||||
.unexpected_error("Unexpected Vulkan error: ERROR_INITIALIZATION_FAILED"),
|
||||
),
|
||||
)
|
||||
.run_async(test);
|
||||
|
||||
@@ -23,7 +23,7 @@ static RESTRICT_WORKGROUP_PRIVATE_FUNCTION_LET: GpuTestConfiguration = GpuTestCo
|
||||
FailureCase::molten_vk()
|
||||
.validation_error("Shader library compile failed")
|
||||
.validation_error("could not be compiled into pipeline")
|
||||
.panic("Unexpected Vulkan error: ERROR_INITIALIZATION_FAILED"),
|
||||
.unexpected_error("Unexpected Vulkan error: ERROR_INITIALIZATION_FAILED"),
|
||||
),
|
||||
)
|
||||
.run_async(|ctx| async move {
|
||||
|
||||
@@ -40,7 +40,7 @@ static PER_VERTEX: GpuTestConfiguration = GpuTestConfiguration::new()
|
||||
.expect_fail(
|
||||
wgpu_test::FailureCase::molten_vk()
|
||||
.validation_error("could not be compiled into pipeline")
|
||||
.panic("Unexpected Vulkan error: ERROR_INITIALIZATION_FAILED"),
|
||||
.unexpected_error("Unexpected Vulkan error: ERROR_INITIALIZATION_FAILED"),
|
||||
),
|
||||
)
|
||||
.run_async(per_vertex);
|
||||
|
||||
@@ -60,7 +60,7 @@ static ARRAY_SIZE_OVERRIDES: GpuTestConfiguration = GpuTestConfiguration::new()
|
||||
wgpu_test::FailureCase::molten_vk()
|
||||
.validation_error("Shader library compile failed")
|
||||
.validation_error("could not be compiled into pipeline")
|
||||
.panic("Unexpected Vulkan error: ERROR_INITIALIZATION_FAILED"),
|
||||
.unexpected_error("Unexpected Vulkan error: ERROR_INITIALIZATION_FAILED"),
|
||||
),
|
||||
)
|
||||
.run_async(move |ctx| async move {
|
||||
|
||||
@@ -25,7 +25,7 @@ static ZERO_INIT_WORKGROUP_MEMORY: GpuTestConfiguration = GpuTestConfiguration::
|
||||
wgpu_test::FailureCase::molten_vk()
|
||||
.validation_error("Shader library compile failed")
|
||||
.validation_error("could not be compiled into pipeline")
|
||||
.panic("Unexpected Vulkan error: ERROR_INITIALIZATION_FAILED"),
|
||||
.unexpected_error("Unexpected Vulkan error: ERROR_INITIALIZATION_FAILED"),
|
||||
),
|
||||
)
|
||||
.run_async(|ctx| async move {
|
||||
|
||||
Reference in new issue
Block a user