2023-02-06 17:25:06 +11:00
|
|
|
//! Direct3D 12 shader runtime errors.
|
|
|
|
//!
|
2024-08-28 15:30:02 +10:00
|
|
|
|
|
|
|
use d3d12_descriptor_heap::D3D12DescriptorHeapError;
|
2023-02-06 11:58:51 +11:00
|
|
|
use thiserror::Error;
|
2024-09-29 15:31:21 +10:00
|
|
|
use windows::Win32::Graphics::Direct3D12::D3D12_RESOURCE_DIMENSION;
|
2023-01-22 07:34:13 +11:00
|
|
|
|
2023-02-06 11:58:51 +11:00
|
|
|
/// Cumulative error type for Direct3D12 filter chains.
|
|
|
|
#[derive(Error, Debug)]
|
2024-08-21 14:37:35 +10:00
|
|
|
#[non_exhaustive]
|
2023-02-06 11:58:51 +11:00
|
|
|
pub enum FilterChainError {
|
2024-08-25 15:24:05 +10:00
|
|
|
#[error("invariant assumption about d3d12 did not hold. report this as an issue.")]
|
2023-02-06 11:58:51 +11:00
|
|
|
Direct3DOperationError(&'static str),
|
|
|
|
#[error("direct3d driver error")]
|
|
|
|
Direct3DError(#[from] windows::core::Error),
|
|
|
|
#[error("shader preset parse error")]
|
|
|
|
ShaderPresetError(#[from] ParsePresetError),
|
|
|
|
#[error("shader preprocess error")]
|
|
|
|
ShaderPreprocessError(#[from] PreprocessError),
|
|
|
|
#[error("shader compile error")]
|
|
|
|
ShaderCompileError(#[from] ShaderCompileError),
|
|
|
|
#[error("shader reflect error")]
|
|
|
|
ShaderReflectError(#[from] ShaderReflectError),
|
|
|
|
#[error("lut loading error")]
|
|
|
|
LutLoadError(#[from] ImageError),
|
2024-08-28 15:30:02 +10:00
|
|
|
#[error("heap error")]
|
|
|
|
HeapError(#[from] D3D12DescriptorHeapError),
|
2024-08-25 15:24:05 +10:00
|
|
|
#[error("allocation error")]
|
|
|
|
AllocationError(#[from] gpu_allocator::AllocationError),
|
2024-09-29 15:31:21 +10:00
|
|
|
#[error("invalid resource dimension {0:?}")]
|
|
|
|
InvalidDimensionError(D3D12_RESOURCE_DIMENSION),
|
2024-08-02 14:25:54 +10:00
|
|
|
#[error("unreachable")]
|
|
|
|
Infallible(#[from] std::convert::Infallible),
|
2023-02-06 11:58:51 +11:00
|
|
|
}
|
|
|
|
|
2023-02-06 17:25:06 +11:00
|
|
|
/// Result type for Direct3D 12 filter chains.
|
2023-02-06 11:58:51 +11:00
|
|
|
pub type Result<T> = std::result::Result<T, FilterChainError>;
|
2023-01-25 15:15:43 +11:00
|
|
|
|
|
|
|
macro_rules! assume_d3d12_init {
|
|
|
|
($value:ident, $call:literal) => {
|
2023-02-06 11:58:51 +11:00
|
|
|
let $value = $value.ok_or($crate::error::FilterChainError::Direct3DOperationError(
|
|
|
|
$call,
|
|
|
|
))?;
|
2023-01-25 15:15:43 +11:00
|
|
|
};
|
|
|
|
(mut $value:ident, $call:literal) => {
|
2023-02-06 11:58:51 +11:00
|
|
|
let mut $value = $value.ok_or($crate::error::FilterChainError::Direct3DOperationError(
|
|
|
|
$call,
|
|
|
|
))?;
|
2023-01-25 15:15:43 +11:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Macro for unwrapping result of a D3D function.
|
|
|
|
pub(crate) use assume_d3d12_init;
|
2023-02-06 11:58:51 +11:00
|
|
|
use librashader_preprocess::PreprocessError;
|
|
|
|
use librashader_presets::ParsePresetError;
|
|
|
|
use librashader_reflect::error::{ShaderCompileError, ShaderReflectError};
|
|
|
|
use librashader_runtime::image::ImageError;
|