Skip to content

Commit 408b5a1

Browse files
committed
Review: check for cap rather than adding cap, fix error messages.
1 parent 233241f commit 408b5a1

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

crates/rustc_codegen_spirv/src/codegen_cx/entry.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -680,25 +680,28 @@ impl<'tcx> CodegenCx<'tcx> {
680680
),
681681
_ => false,
682682
};
683-
if let Some(attachment_index) = attrs.input_attachment_index.map(|attr| attr.value) {
684-
if is_subpass_input {
685-
self.emit_global().capability(Capability::InputAttachment);
683+
if let Some(attachment_index) = attrs.input_attachment_index {
684+
if is_subpass_input && self.builder.has_capability(Capability::InputAttachment) {
686685
self.emit_global().decorate(
687686
var,
688687
Decoration::InputAttachmentIndex,
689-
std::iter::once(Operand::LiteralInt32(attachment_index)),
688+
std::iter::once(Operand::LiteralInt32(attachment_index.value)),
690689
)
690+
} else if is_subpass_input {
691+
self.tcx
692+
.sess
693+
.span_err(hir_param.ty_span, "Missing capability InputAttachment")
691694
} else {
692695
self.tcx.sess.span_err(
693-
attrs.input_attachment_index.unwrap().span,
694-
"#[spirv(attachment_index)] is only valid on Image types with dim = SubpassData"
696+
attachment_index.span,
697+
"#[spirv(input_attachment_index)] is only valid on Image types with dim = SubpassData"
695698
);
696699
}
697700
decoration_supersedes_location = true;
698701
} else if is_subpass_input {
699702
self.tcx.sess.span_err(
700703
hir_param.ty_span,
701-
"Image types with dim = SubpassData require #[spirv(attachment_index)] decoration",
704+
"Image types with dim = SubpassData require #[spirv(input_attachment_index)] decoration",
702705
)
703706
}
704707

tests/ui/image/read_subpass.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// build-pass
2+
// compile-flags: -C target-feature=+InputAttachment
23

34
use spirv_std::{arch, Image};
45

0 commit comments

Comments
 (0)