Skip to content

Commit

Permalink
Fix issue 585 (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
khyperia authored Apr 13, 2021
1 parent 9679e61 commit 6c8dece
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
13 changes: 12 additions & 1 deletion crates/rustc_codegen_spirv/src/codegen_cx/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,18 @@ impl<'tcx> CodegenCx<'tcx> {
// Some types automatically specify a storage class. Compute that here.
let inferred_storage_class_from_ty = match self.lookup_type(spirv_ty) {
SpirvType::Image { .. } | SpirvType::Sampler | SpirvType::SampledImage { .. } => {
Some(StorageClass::UniformConstant)
if is_ref {
Some(StorageClass::UniformConstant)
} else {
self.tcx.sess.span_err(
hir_param.ty_span,
&format!(
"entry parameter type must be by-reference: `&{}`",
layout.ty,
),
);
None
}
}
_ => None,
};
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/spirv-attr/bad-infer-storage-class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ use spirv_std::Image2d;

#[spirv(vertex)]
pub fn main(#[spirv(uniform)] error: &Image2d, #[spirv(uniform_constant)] warning: &Image2d) {}

// https://github.com/EmbarkStudios/rust-gpu/issues/585
#[spirv(vertex)]
pub fn issue_585(invalid: Image2d) {}
8 changes: 7 additions & 1 deletion tests/ui/spirv-attr/bad-infer-storage-class.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,11 @@ warning: redundant storage class specifier, storage class is inferred from type
7 | pub fn main(#[spirv(uniform)] error: &Image2d, #[spirv(uniform_constant)] warning: &Image2d) {}
| ^^^^^^^^^^^^^^^^

error: aborting due to previous error; 1 warning emitted
error: entry parameter type must be by-reference: `&spirv_std::Image2d`
--> $DIR/bad-infer-storage-class.rs:11:27
|
11 | pub fn issue_585(invalid: Image2d) {}
| ^^^^^^^

error: aborting due to 2 previous errors; 1 warning emitted

0 comments on commit 6c8dece

Please sign in to comment.