mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-24 02:16:32 +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]
|
[features]
|
||||||
default = ["compile", "wgsl", "msl"]
|
default = ["compile", "wgsl", "msl"]
|
||||||
compile = ["naga"]
|
compile = ["naga", "thiserror"]
|
||||||
wgsl = []
|
wgsl = []
|
||||||
msl = []
|
msl = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
naga = { git = "https://github.com/gfx-rs/naga", features = ["wgsl-in", "msl-out", "validate"], optional = true }
|
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]
|
[build-dependencies]
|
||||||
naga = { git = "https://github.com/gfx-rs/naga", features = ["wgsl-in", "msl-out", "validate"] }
|
naga = { git = "https://github.com/gfx-rs/naga", features = ["wgsl-in", "msl-out", "validate"] }
|
||||||
|
thiserror = "1.0.40"
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
use naga::{
|
use {
|
||||||
front::wgsl,
|
naga::{
|
||||||
valid::{Capabilities, ModuleInfo, ValidationError, ValidationFlags},
|
front::wgsl,
|
||||||
AddressSpace, ImageClass, Module, StorageAccess, WithSpan,
|
valid::{Capabilities, ModuleInfo, ValidationError, ValidationFlags},
|
||||||
};
|
AddressSpace, ImageClass, Module, StorageAccess, WithSpan,
|
||||||
|
},
|
||||||
use std::{
|
std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
path::Path,
|
path::Path,
|
||||||
|
},
|
||||||
|
thiserror::Error,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod permutations;
|
pub mod permutations;
|
||||||
|
@ -16,25 +18,18 @@ pub mod msl;
|
||||||
|
|
||||||
use crate::types::{BindType, BindingInfo};
|
use crate::types::{BindType, BindingInfo};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
Parse(wgsl::ParseError),
|
#[error("failed to parse shader: {0}")]
|
||||||
Validate(WithSpan<ValidationError>),
|
Parse(#[from] wgsl::ParseError),
|
||||||
|
|
||||||
|
#[error("failed to validate shader: {0}")]
|
||||||
|
Validate(#[from] WithSpan<ValidationError>),
|
||||||
|
|
||||||
|
#[error("missing entry point function")]
|
||||||
EntryPointNotFound,
|
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)]
|
#[derive(Debug)]
|
||||||
pub struct ShaderInfo {
|
pub struct ShaderInfo {
|
||||||
pub source: String,
|
pub source: String,
|
||||||
|
|
Loading…
Add table
Reference in a new issue