Skip to content

Commit 83c90d6

Browse files
committed
Fix operand extension validation to use ANY-of semantics
Same fix as the capability extension validation: grammar extension lists for operands are alternatives (ANY suffices, not ALL). The operand validation was checking each extension individually and failing on the first one not satisfied. Combine all extension sources and check if at least one is satisfied, matching C++ HasAnyOfExtensions() behavior. This fixes validation of decorations like PerPrimitiveNV which list both SPV_NV_mesh_shader and SPV_EXT_mesh_shader as alternatives.
1 parent 0693158 commit 83c90d6

File tree

1 file changed

+14
-12
lines changed
  • rust/spirv-tools-core/src/validation

1 file changed

+14
-12
lines changed

rust/spirv-tools-core/src/validation/mod.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -997,21 +997,23 @@ fn validate_instruction_requirements(
997997
});
998998
}
999999
}
1000-
for required_ext in operand.required_extensions() {
1001-
if !extension_satisfied(required_ext, extensions, target_version) {
1002-
return Err(ValidationError::MissingOperandExtension {
1003-
opcode: inst.class.opcode,
1004-
operand_index: index,
1005-
required_extension: ExtensionName::from(required_ext),
1006-
});
1007-
}
1008-
}
1009-
for required_ext in grammar_required_extensions_for_operand(operand) {
1010-
if !extension_satisfied(required_ext, extensions, target_version) {
1000+
// Collect ALL extensions from all sources and check DISJUNCTIVELY
1001+
// (like C++ spirv-val's HasAnyOfExtensions).
1002+
// The grammar lists alternatives and you need AT LEAST ONE
1003+
// from the combined set.
1004+
let mut all_required_exts: Vec<&str> = Vec::new();
1005+
all_required_exts.extend(operand.required_extensions());
1006+
all_required_exts.extend(grammar_required_extensions_for_operand(operand));
1007+
1008+
if !all_required_exts.is_empty() {
1009+
let has_any = all_required_exts
1010+
.iter()
1011+
.any(|&ext| extension_satisfied(ext, extensions, target_version));
1012+
if !has_any {
10111013
return Err(ValidationError::MissingOperandExtension {
10121014
opcode: inst.class.opcode,
10131015
operand_index: index,
1014-
required_extension: ExtensionName::from(required_ext),
1016+
required_extension: ExtensionName::from(all_required_exts[0]),
10151017
});
10161018
}
10171019
}

0 commit comments

Comments
 (0)