diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 05d05483a..f44764f94 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -385,14 +385,14 @@ fn map_buffer( pub struct InvalidDevice; #[derive(Clone, Debug)] -pub struct WrongDevice { +pub struct DeviceMismatch { pub(super) res: ResourceErrorIdent, pub(super) res_device: ResourceErrorIdent, pub(super) target: Option, pub(super) target_device: ResourceErrorIdent, } -impl std::fmt::Display for WrongDevice { +impl std::fmt::Display for DeviceMismatch { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, @@ -406,7 +406,7 @@ impl std::fmt::Display for WrongDevice { } } -impl std::error::Error for WrongDevice {} +impl std::error::Error for DeviceMismatch {} #[derive(Clone, Debug, Error)] #[non_exhaustive] @@ -422,7 +422,7 @@ pub enum DeviceError { #[error("QueueId is invalid")] InvalidQueueId, #[error(transparent)] - WrongDevice(#[from] Box), + DeviceMismatch(#[from] Box), } impl From for DeviceError { diff --git a/wgpu-core/src/pipeline_cache.rs b/wgpu-core/src/pipeline_cache.rs index d098cdafc..b88fc21dd 100644 --- a/wgpu-core/src/pipeline_cache.rs +++ b/wgpu-core/src/pipeline_cache.rs @@ -16,7 +16,7 @@ pub enum PipelineCacheValidationError { #[error("The pipeline cacha data was out of date and so cannot be safely used")] Outdated, #[error("The cache data was created for a different device")] - WrongDevice, + DeviceMismatch, #[error("Pipeline cacha data was created for a future version of wgpu")] Unsupported, } @@ -26,7 +26,7 @@ impl PipelineCacheValidationError { /// That is, is there a mistake in user code interacting with the cache pub fn was_avoidable(&self) -> bool { match self { - PipelineCacheValidationError::WrongDevice => true, + PipelineCacheValidationError::DeviceMismatch => true, PipelineCacheValidationError::Truncated | PipelineCacheValidationError::Unsupported | PipelineCacheValidationError::Extended @@ -57,10 +57,10 @@ pub fn validate_pipeline_cache<'d>( return Err(PipelineCacheValidationError::Outdated); } if header.backend != adapter.backend as u8 { - return Err(PipelineCacheValidationError::WrongDevice); + return Err(PipelineCacheValidationError::DeviceMismatch); } if header.adapter_key != adapter_key { - return Err(PipelineCacheValidationError::WrongDevice); + return Err(PipelineCacheValidationError::DeviceMismatch); } if header.validation_key != validation_key { // If the validation key is wrong, that means that this device has changed @@ -420,7 +420,7 @@ mod tests { ]; let cache = cache.into_iter().flatten().collect::>(); let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY); - assert_eq!(validation_result, Err(E::WrongDevice)); + assert_eq!(validation_result, Err(E::DeviceMismatch)); } #[test] fn wrong_adapter() { @@ -436,7 +436,7 @@ mod tests { ]; let cache = cache.into_iter().flatten().collect::>(); let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY); - assert_eq!(validation_result, Err(E::WrongDevice)); + assert_eq!(validation_result, Err(E::DeviceMismatch)); } #[test] fn wrong_validation() { diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index e6389b206..f45095d6d 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -3,8 +3,8 @@ use crate::device::trace; use crate::{ binding_model::BindGroup, device::{ - queue, resource::DeferredDestroy, BufferMapPendingClosure, Device, DeviceError, HostMap, - MissingDownlevelFlags, MissingFeatures, WrongDevice, + queue, resource::DeferredDestroy, BufferMapPendingClosure, Device, DeviceError, + DeviceMismatch, HostMap, MissingDownlevelFlags, MissingFeatures, }, global::Global, hal_api::HalApi, @@ -162,7 +162,7 @@ pub(crate) trait ParentDevice: Resource { Arc::ptr_eq(self.device(), other.device()) .then_some(()) .ok_or_else(|| { - DeviceError::WrongDevice(Box::new(WrongDevice { + DeviceError::DeviceMismatch(Box::new(DeviceMismatch { res: self.error_ident(), res_device: self.device().error_ident(), target: Some(other.error_ident()), @@ -175,7 +175,7 @@ pub(crate) trait ParentDevice: Resource { Arc::ptr_eq(self.device(), device) .then_some(()) .ok_or_else(|| { - DeviceError::WrongDevice(Box::new(WrongDevice { + DeviceError::DeviceMismatch(Box::new(DeviceMismatch { res: self.error_ident(), res_device: self.device().error_ident(), target: None,