Skip to content

Commit

Permalink
Review: check for cap rather than adding cap, fix error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectronicRU committed Jun 2, 2021
1 parent 233241f commit 408b5a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
17 changes: 10 additions & 7 deletions crates/rustc_codegen_spirv/src/codegen_cx/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,25 +680,28 @@ impl<'tcx> CodegenCx<'tcx> {
),
_ => false,
};
if let Some(attachment_index) = attrs.input_attachment_index.map(|attr| attr.value) {
if is_subpass_input {
self.emit_global().capability(Capability::InputAttachment);
if let Some(attachment_index) = attrs.input_attachment_index {
if is_subpass_input && self.builder.has_capability(Capability::InputAttachment) {
self.emit_global().decorate(
var,
Decoration::InputAttachmentIndex,
std::iter::once(Operand::LiteralInt32(attachment_index)),
std::iter::once(Operand::LiteralInt32(attachment_index.value)),
)
} else if is_subpass_input {
self.tcx
.sess
.span_err(hir_param.ty_span, "Missing capability InputAttachment")
} else {
self.tcx.sess.span_err(
attrs.input_attachment_index.unwrap().span,
"#[spirv(attachment_index)] is only valid on Image types with dim = SubpassData"
attachment_index.span,
"#[spirv(input_attachment_index)] is only valid on Image types with dim = SubpassData"
);
}
decoration_supersedes_location = true;
} else if is_subpass_input {
self.tcx.sess.span_err(
hir_param.ty_span,
"Image types with dim = SubpassData require #[spirv(attachment_index)] decoration",
"Image types with dim = SubpassData require #[spirv(input_attachment_index)] decoration",
)
}

Expand Down
1 change: 1 addition & 0 deletions tests/ui/image/read_subpass.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// build-pass
// compile-flags: -C target-feature=+InputAttachment

use spirv_std::{arch, Image};

Expand Down

0 comments on commit 408b5a1

Please sign in to comment.