From e25051ec8f8fdb7e982eae0e7354ff2e84588a5a Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Wed, 21 Aug 2024 12:37:31 +0200 Subject: [PATCH] [d3d12] treat failure to populate references to resources as `DeviceError::Unexpected` These are guaranteed to be populated if the creation methods didn't error. If they are not, the driver/runtime is at fault. --- wgpu-hal/src/dx12/device.rs | 6 +++--- wgpu-hal/src/dx12/suballocation.rs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index 95a7f0627..2715b5c94 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -85,7 +85,7 @@ impl super::Device { } .into_device_result("Zero buffer creation")?; - let zero_buffer = zero_buffer.ok_or(crate::DeviceError::ResourceCreationFailed)?; + let zero_buffer = zero_buffer.ok_or(crate::DeviceError::Unexpected)?; // Note: without `D3D12_HEAP_FLAG_CREATE_NOT_ZEROED` // this resource is zeroed by default. @@ -114,7 +114,7 @@ impl super::Device { ) } .into_device_result("Command signature creation")?; - signature.ok_or(crate::DeviceError::ResourceCreationFailed) + signature.ok_or(crate::DeviceError::Unexpected) } let shared = super::DeviceShared { @@ -1637,7 +1637,7 @@ impl crate::Device for super::Device { } .into_device_result("Query heap creation")?; - let raw = raw.ok_or(crate::DeviceError::ResourceCreationFailed)?; + let raw = raw.ok_or(crate::DeviceError::Unexpected)?; if let Some(label) = desc.label { unsafe { raw.SetName(&windows::core::HSTRING::from(label)) } diff --git a/wgpu-hal/src/dx12/suballocation.rs b/wgpu-hal/src/dx12/suballocation.rs index 77fe5d480..bdb3e8512 100644 --- a/wgpu-hal/src/dx12/suballocation.rs +++ b/wgpu-hal/src/dx12/suballocation.rs @@ -94,7 +94,7 @@ pub(crate) fn create_buffer_resource( } .into_device_result("Placed buffer creation")?; - let resource = resource.ok_or(crate::DeviceError::ResourceCreationFailed)?; + let resource = resource.ok_or(crate::DeviceError::Unexpected)?; device .counters @@ -141,7 +141,7 @@ pub(crate) fn create_texture_resource( } .into_device_result("Placed texture creation")?; - let resource = resource.ok_or(crate::DeviceError::ResourceCreationFailed)?; + let resource = resource.ok_or(crate::DeviceError::Unexpected)?; device .counters @@ -265,7 +265,7 @@ pub(crate) fn create_committed_buffer_resource( } .into_device_result("Committed buffer creation")?; - resource.ok_or(crate::DeviceError::ResourceCreationFailed) + resource.ok_or(crate::DeviceError::Unexpected) } pub(crate) fn create_committed_texture_resource( @@ -302,5 +302,5 @@ pub(crate) fn create_committed_texture_resource( } .into_device_result("Committed texture creation")?; - resource.ok_or(crate::DeviceError::ResourceCreationFailed) + resource.ok_or(crate::DeviceError::Unexpected) }