aboutsummaryrefslogtreecommitdiff
path: root/source/val/validate_instruction.cpp
diff options
context:
space:
mode:
authoralan-baker <alanbaker@google.com>2019-09-13 14:59:02 -0400
committerDavid Neto <dneto@google.com>2019-09-13 14:59:02 -0400
commit5a48c0da15628d69b176f152fcddb1d67661f61e (patch)
tree6c6da36c76b5cdeeb5f806710ff1aaae34b905f7 /source/val/validate_instruction.cpp
parentad7f2c5c4c7f51360e9e079109a9217aa5ba5cc0 (diff)
downloadSPIRV-Tools-5a48c0da15628d69b176f152fcddb1d67661f61e.tar.gz
SPIRV-Tools support for SPIR-V 1.5 (#2865)
* Ensure same enum values have consistent extension lists * val: fix checking of capabilities The operand for an OpCapability should only be checked for the extension or core version. The InstructionPass registers a capability, and all its implied sub-capabilities before actually checking the operand to an OpCapability. * Add basic support for SPIR-V 1.5 - Adds SPV_ENV_UNIVERSAL_1_5 - Command line tools default to spv1.5 environment - SPIR-V 1.5 incorporates several extensions. Now the disassembler prefers outputing the non-EXT or non-KHR names. This requires updates to many tests, to make strings match again. - Command line tests: Expect SPIR-V 1.5 by default * Test validation of SPIR-V 1.5 incorporated extensions Starting with 1.5, incorporated features no longer require the associated OpExtension instruction.
Diffstat (limited to 'source/val/validate_instruction.cpp')
-rw-r--r--source/val/validate_instruction.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/source/val/validate_instruction.cpp b/source/val/validate_instruction.cpp
index b74b5355..fecc3519 100644
--- a/source/val/validate_instruction.cpp
+++ b/source/val/validate_instruction.cpp
@@ -205,17 +205,24 @@ spv_result_t CheckRequiredCapabilities(ValidationState_t& state,
operand_desc->capabilities, operand_desc->numCapabilities);
}
- if (!state.HasAnyOfCapabilities(enabling_capabilities)) {
- return state.diag(SPV_ERROR_INVALID_CAPABILITY, inst)
- << "Operand " << which_operand << " of "
- << spvOpcodeString(inst->opcode())
- << " requires one of these capabilities: "
- << ToString(enabling_capabilities, state.grammar());
+ // When encountering an OpCapability instruction, the instruction pass
+ // registers a capability with the module *before* checking capabilities.
+ // So in the case of an OpCapability instruction, don't bother checking
+ // enablement by another capability.
+ if (inst->opcode() != SpvOpCapability) {
+ const bool enabled_by_cap =
+ state.HasAnyOfCapabilities(enabling_capabilities);
+ if (!enabling_capabilities.IsEmpty() && !enabled_by_cap) {
+ return state.diag(SPV_ERROR_INVALID_CAPABILITY, inst)
+ << "Operand " << which_operand << " of "
+ << spvOpcodeString(inst->opcode())
+ << " requires one of these capabilities: "
+ << ToString(enabling_capabilities, state.grammar());
+ }
}
return OperandVersionExtensionCheck(state, inst, which_operand,
*operand_desc, word);
}
-
return SPV_SUCCESS;
}