Fix issue 585 (#594)

This commit is contained in:
Ashley Hauck 2021-04-13 11:34:02 +02:00 committed by GitHub
parent 9679e615bd
commit 6c8dece25a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 2 deletions

View File

@ -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,
};

View File

@ -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) {}

View File

@ -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