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
6 changes: 4 additions & 2 deletions naga/src/front/spv/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ pub enum Error {
InvalidGlobalVar(crate::Expression),
#[error("invalid image/sampler expression {0:?}")]
InvalidImageExpression(crate::Expression),
#[error("image write without format is not currently supported. See https://github.com/gfx-rs/wgpu/issues/6797")]
InvalidImageWriteType,
#[error("cannot create a OpTypeImage as both a depth and storage image")]
InvalidImageDepthStorage,
#[error("image read/write without format is not currently supported. See https://github.com/gfx-rs/wgpu/issues/6797")]
InvalidStorageImageWithoutFormat,
#[error("invalid image base type {0:?}")]
InvalidImageBaseType(Handle<crate::Type>),
#[error("invalid image {0:?}")]
Expand Down
24 changes: 20 additions & 4 deletions naga/src/front/spv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2597,15 +2597,31 @@ impl<I: Iterator<Item = u32>> Frontend<I> {

let inner = crate::TypeInner::Image {
class: if is_depth == 1 {
if is_sampled == 2 {
return Err(Error::InvalidImageDepthStorage);
}

crate::ImageClass::Depth { multi: is_msaa }
} else if format != 0 {
}
// If we have an unknown format and storage texture, this is
// StorageRead/WriteWithoutFormat. We don't currently support
// this.
else if is_sampled == 2 && format == 0 {
return Err(Error::InvalidStorageImageWithoutFormat);
}
// If we have explicit class information (is_sampled = 2 = Storage), use it.
//
// If we have unknown class information (is_sampled = 0 = Unknown), infer the
// class from the presence of an explicit format.
else if format != 0 && (is_sampled == 0 || is_sampled == 2) {
crate::ImageClass::Storage {
format: map_image_format(format)?,
access: crate::StorageAccess::default(),
}
} else if is_sampled == 2 {
return Err(Error::InvalidImageWriteType);
} else {
}
// We will hit this case either when sampled is 1, or if we have unknown
// sampling information or when sampled is 0 and we have no explicit format.
else {
crate::ImageClass::Sampled {
kind,
multi: is_msaa,
Expand Down
16 changes: 11 additions & 5 deletions naga/src/valid/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ pub enum ExpressionError {
InvalidDerivative,
#[error("Image array index parameter is misplaced")]
InvalidImageArrayIndex,
#[error("Inappropriate sample or level-of-detail index for texel access")]
InvalidImageOtherIndex,
#[error("Cannot textureLoad from a specific multisample sample on a non-multisampled image.")]
InvalidImageSampleSelector,
#[error("Cannot textureLoad from a multisampled image without specifying a sample.")]
MissingImageSampleSelector,
#[error("Image array index type of {0:?} is not an integer scalar")]
InvalidImageArrayIndexType(Handle<crate::Expression>),
#[error("Image sample or level-of-detail index's type of {0:?} is not an integer scalar")]
Expand Down Expand Up @@ -715,8 +717,11 @@ impl super::Validator {
return Err(ExpressionError::InvalidImageOtherIndexType(sample));
}
}
_ => {
return Err(ExpressionError::InvalidImageOtherIndex);
(Some(_), false) => {
return Err(ExpressionError::InvalidImageSampleSelector);
}
(None, true) => {
return Err(ExpressionError::MissingImageSampleSelector);
}
}

Expand All @@ -729,7 +734,8 @@ impl super::Validator {
}) => {}
_ => return Err(ExpressionError::InvalidImageArrayIndexType(level)),
},
_ => {
e => {
std::dbg!(e, class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover dbg

Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug print statement (std::dbg!) should be removed before merging. This appears to be leftover debugging code that will pollute stderr output in production.

Suggested change
std::dbg!(e, class);

Copilot uses AI. Check for mistakes.
return Err(ExpressionError::InvalidImageOtherIndex);
}
}
Expand Down
Loading