mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-23 18:06:34 +11:00
[vello_shaders] Use thiserror::Error for the library Error type
This commit is contained in:
parent
14ab8d90ae
commit
b52ef32c90
2 changed files with 22 additions and 25 deletions
|
@ -5,13 +5,15 @@ edition = "2021"
|
|||
|
||||
[features]
|
||||
default = ["compile", "wgsl", "msl"]
|
||||
compile = ["naga"]
|
||||
compile = ["naga", "thiserror"]
|
||||
wgsl = []
|
||||
msl = []
|
||||
|
||||
[dependencies]
|
||||
naga = { git = "https://github.com/gfx-rs/naga", features = ["wgsl-in", "msl-out", "validate"], optional = true }
|
||||
thiserror = { version = "1.0.40", optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
naga = { git = "https://github.com/gfx-rs/naga", features = ["wgsl-in", "msl-out", "validate"] }
|
||||
thiserror = "1.0.40"
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
use naga::{
|
||||
front::wgsl,
|
||||
valid::{Capabilities, ModuleInfo, ValidationError, ValidationFlags},
|
||||
AddressSpace, ImageClass, Module, StorageAccess, WithSpan,
|
||||
};
|
||||
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
path::Path,
|
||||
use {
|
||||
naga::{
|
||||
front::wgsl,
|
||||
valid::{Capabilities, ModuleInfo, ValidationError, ValidationFlags},
|
||||
AddressSpace, ImageClass, Module, StorageAccess, WithSpan,
|
||||
},
|
||||
std::{
|
||||
collections::{HashMap, HashSet},
|
||||
path::Path,
|
||||
},
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub mod permutations;
|
||||
|
@ -16,25 +18,18 @@ pub mod msl;
|
|||
|
||||
use crate::types::{BindType, BindingInfo};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
Parse(wgsl::ParseError),
|
||||
Validate(WithSpan<ValidationError>),
|
||||
#[error("failed to parse shader: {0}")]
|
||||
Parse(#[from] wgsl::ParseError),
|
||||
|
||||
#[error("failed to validate shader: {0}")]
|
||||
Validate(#[from] WithSpan<ValidationError>),
|
||||
|
||||
#[error("missing entry point function")]
|
||||
EntryPointNotFound,
|
||||
}
|
||||
|
||||
impl From<wgsl::ParseError> for Error {
|
||||
fn from(e: wgsl::ParseError) -> Self {
|
||||
Self::Parse(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<WithSpan<ValidationError>> for Error {
|
||||
fn from(e: WithSpan<ValidationError>) -> Self {
|
||||
Self::Validate(e)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ShaderInfo {
|
||||
pub source: String,
|
||||
|
|
Loading…
Add table
Reference in a new issue