Skip to content

Commit 0bacbdf

Browse files
committed
(Naga) Remove override workaround and properly track expression kind in the SPIR-V frontend
1 parent 958fc57 commit 0bacbdf

File tree

5 files changed

+331
-173
lines changed

5 files changed

+331
-173
lines changed

naga/src/front/spv/error.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
use alloc::borrow::Cow;
12
use alloc::{
23
format,
34
string::{String, ToString},
45
};
5-
66
use codespan_reporting::diagnostic::Diagnostic;
77
use codespan_reporting::files::SimpleFile;
88
use codespan_reporting::term;
@@ -14,6 +14,8 @@ use crate::{
1414
front::atomic_upgrade,
1515
};
1616

17+
use crate::proc::ConstantEvaluatorError;
18+
1719
#[derive(Clone, Debug, thiserror::Error)]
1820
pub enum Error {
1921
#[error("invalid header")]
@@ -30,6 +32,8 @@ pub enum Error {
3032
UnsupportedSpecConstantOp(spirv::Op),
3133
#[error("invalid opcode in specialization constant operation {0:?}")]
3234
InvalidSpecConstantOp(spirv::Op),
35+
#[error("{0}")]
36+
SemanticError(Cow<'static, str>),
3337
#[error("unsupported capability {0:?}")]
3438
UnsupportedCapability(spirv::Capability),
3539
#[error("unsupported extension {0}")]
@@ -155,11 +159,16 @@ pub enum Error {
155159
NonBindingArrayOfImageOrSamplers,
156160
#[error("naga only supports specialization constant IDs up to 65535 but was given {0}")]
157161
SpecIdTooHigh(u32),
158-
159162
#[error("atomic upgrade error: {0}")]
160163
AtomicUpgradeError(atomic_upgrade::Error),
161164
}
162165

166+
impl From<ConstantEvaluatorError> for Error {
167+
fn from(err: ConstantEvaluatorError) -> Self {
168+
Error::SemanticError(err.to_string().into())
169+
}
170+
}
171+
163172
impl Error {
164173
pub fn emit_to_writer(&self, writer: &mut impl ErrorWrite, source: &str) {
165174
self.emit_to_writer_with_path(writer, source, "glsl");

0 commit comments

Comments
 (0)