Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ By @cwfitzgerald in [#8579](https://github.com/gfx-rs/wgpu/pull/8579).
#### Naga

- Prevent UB with invalid ray query calls on spirv. By @Vecvec in [#8390](https://github.com/gfx-rs/wgpu/pull/8390).
- The SPIR-V frontend implements OpSpecConstantOp. By @hasenbanck in [8308](https://github.com/gfx-rs/wgpu/pull/8308).

### Bug Fixes

Expand Down
17 changes: 15 additions & 2 deletions naga/src/front/spv/error.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use alloc::borrow::Cow;
use alloc::{
format,
string::{String, ToString},
};

use codespan_reporting::diagnostic::Diagnostic;
use codespan_reporting::files::SimpleFile;
use codespan_reporting::term;
Expand All @@ -14,6 +14,8 @@ use crate::{
front::atomic_upgrade,
};

use crate::proc::ConstantEvaluatorError;

#[derive(Clone, Debug, thiserror::Error)]
pub enum Error {
#[error("invalid header")]
Expand All @@ -26,6 +28,12 @@ pub enum Error {
UnknownCapability(spirv::Word),
#[error("unsupported instruction {1:?} at {0:?}")]
UnsupportedInstruction(ModuleState, spirv::Op),
#[error("unsupported opcode in specialization constant operation {0:?}")]
UnsupportedSpecConstantOp(spirv::Op),
#[error("invalid opcode in specialization constant operation {0:?}")]
InvalidSpecConstantOp(spirv::Op),
#[error("{0}")]
SemanticError(Cow<'static, str>),
#[error("unsupported capability {0:?}")]
UnsupportedCapability(spirv::Capability),
#[error("unsupported extension {0}")]
Expand Down Expand Up @@ -151,11 +159,16 @@ pub enum Error {
NonBindingArrayOfImageOrSamplers,
#[error("naga only supports specialization constant IDs up to 65535 but was given {0}")]
SpecIdTooHigh(u32),

#[error("atomic upgrade error: {0}")]
AtomicUpgradeError(atomic_upgrade::Error),
}

impl From<ConstantEvaluatorError> for Error {
fn from(err: ConstantEvaluatorError) -> Self {
Error::SemanticError(err.to_string().into())
}
}

impl Error {
pub fn emit_to_writer(&self, writer: &mut impl ErrorWrite, source: &str) {
self.emit_to_writer_with_path(writer, source, "glsl");
Expand Down
Loading
Loading