use crate::ctypes::ShaderStage;
use crate::shader::Target;
use crate::GlslProfile;
use thiserror::Error;
#[derive(Debug)]
pub struct GlslangErrorLog {
pub log: String,
pub debug_log: String,
}
impl GlslangErrorLog {
pub fn new(log: String, debug_log: String) -> Self {
Self {
log, debug_log
}
}
}
impl std::fmt::Display for GlslangErrorLog {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Log:\n{}\nDebugLog:\n{}", self.log, self.debug_log)
}
}
#[derive(Debug, Error)]
pub enum GlslangError {
#[error("preprocess error: {0}")]
PreprocessError(GlslangErrorLog),
#[error("parse error: {0}")]
ParseError(GlslangErrorLog),
#[error("map io error: {0}")]
MapIoError(GlslangErrorLog),
#[error("program link error: {0}")]
LinkError(GlslangErrorLog),
#[error("shader stage not found: {0:?}")]
ShaderStageNotFound(ShaderStage),
#[error("tried to compile shader with no language target")]
NoLanguageTarget,
#[error("the target is invalid")]
InvalidTarget(Target),
#[error("the profile is invalid")]
InvalidProfile(Target, i32, GlslProfile),
#[error("the profile is invalid")]
VersionUnsupported(i32, GlslProfile),
}