assert(operand.offset < inst->num_words);
const uint32_t capability = inst->words[operand.offset];
+ const auto capability_str = [&_, capability]() {
+ spv_operand_desc desc = nullptr;
+ if (_.grammar().lookupOperand(SPV_OPERAND_TYPE_CAPABILITY, capability,
+ &desc) != SPV_SUCCESS ||
+ !desc) {
+ return std::string("Unknown");
+ }
+ return std::string(desc->name);
+ };
const auto env = _.context()->target_env;
const bool opencl_embedded = env == SPV_ENV_OPENCL_EMBEDDED_1_2 ||
!IsSupportOptionalVulkan_1_0(capability) &&
!IsEnabledByExtension(_, capability)) {
return _.diag(SPV_ERROR_INVALID_CAPABILITY)
- << "Capability value " << capability
+ << "Capability " << capability_str()
<< " is not allowed by Vulkan 1.0 specification"
<< " (or requires extension)";
}
!IsEnabledByExtension(_, capability) &&
!IsEnabledByCapabilityOpenCL_1_2(_, capability)) {
return _.diag(SPV_ERROR_INVALID_CAPABILITY)
- << "Capability value " << capability
+ << "Capability " << capability_str()
<< " is not allowed by OpenCL 1.2 " << opencl_profile
<< " Profile specification"
<< " (or requires extension or capability)";
!IsEnabledByExtension(_, capability) &&
!IsEnabledByCapabilityOpenCL_2_0(_, capability)) {
return _.diag(SPV_ERROR_INVALID_CAPABILITY)
- << "Capability value " << capability
+ << "Capability " << capability_str()
<< " is not allowed by OpenCL 2.0/2.1 " << opencl_profile
<< " Profile specification"
<< " (or requires extension or capability)";
!IsEnabledByExtension(_, capability) &&
!IsEnabledByCapabilityOpenCL_2_0(_, capability)) {
return _.diag(SPV_ERROR_INVALID_CAPABILITY)
- << "Capability value " << capability
+ << "Capability " << capability_str()
<< " is not allowed by OpenCL 2.2 " << opencl_profile
<< " Profile specification"
<< " (or requires extension or capability)";
EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
ValidateInstructions(SPV_ENV_VULKAN_1_0));
EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Capability value 5 is not allowed by Vulkan 1.0"));
+ HasSubstr("Capability Linkage is not allowed by Vulkan 1.0"));
}
TEST_F(ValidateCapability, Vulkan10EnabledByExtension) {
CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0);
EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
ValidateInstructions(SPV_ENV_VULKAN_1_0));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Capability value 4427 is not allowed by Vulkan 1.0"));
+ EXPECT_THAT(
+ getDiagnosticString(),
+ HasSubstr("Capability DrawParameters is not allowed by Vulkan 1.0"));
}
TEST_F(ValidateCapability, NonOpenCL12FullCapability) {
ValidateInstructions(SPV_ENV_OPENCL_1_2));
EXPECT_THAT(
getDiagnosticString(),
- HasSubstr(
- "Capability value 17 is not allowed by OpenCL 1.2 Full Profile"));
+ HasSubstr("Capability Pipes is not allowed by OpenCL 1.2 Full Profile"));
}
TEST_F(ValidateCapability, OpenCL12FullEnabledByCapability) {
EXPECT_THAT(
getDiagnosticString(),
HasSubstr(
- "Capability value 43 is not allowed by OpenCL 1.2 Full Profile"));
+ "Capability Sampled1D is not allowed by OpenCL 1.2 Full Profile"));
}
TEST_F(ValidateCapability, NonOpenCL12EmbeddedCapability) {
EXPECT_THAT(
getDiagnosticString(),
HasSubstr(
- "Capability value 11 is not allowed by OpenCL 1.2 Embedded Profile"));
+ "Capability Int64 is not allowed by OpenCL 1.2 Embedded Profile"));
}
TEST_F(ValidateCapability, OpenCL12EmbeddedEnabledByCapability) {
CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_1_2);
EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_1_2));
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "Capability value 43 is not allowed by OpenCL 1.2 Embedded Profile"));
+ EXPECT_THAT(getDiagnosticString(),
+ HasSubstr("Capability Sampled1D is not allowed by OpenCL 1.2 "
+ "Embedded Profile"));
}
TEST_F(ValidateCapability, OpenCL20FullCapability) {
EXPECT_THAT(
getDiagnosticString(),
HasSubstr(
- "Capability value 0 is not allowed by OpenCL 2.0/2.1 Full Profile"));
+ "Capability Matrix is not allowed by OpenCL 2.0/2.1 Full Profile"));
}
TEST_F(ValidateCapability, OpenCL20FullEnabledByCapability) {
CompileSuccessfully(spirv, SPV_ENV_OPENCL_2_0);
EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
ValidateInstructions(SPV_ENV_OPENCL_2_0));
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "Capability value 43 is not allowed by OpenCL 2.0/2.1 Full Profile"));
+ EXPECT_THAT(getDiagnosticString(),
+ HasSubstr("Capability Sampled1D is not allowed by OpenCL 2.0/2.1 "
+ "Full Profile"));
}
TEST_F(ValidateCapability, NonOpenCL20EmbeddedCapability) {
EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_2_0));
EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Capability value 11 is not allowed by OpenCL 2.0/2.1 "
+ HasSubstr("Capability Int64 is not allowed by OpenCL 2.0/2.1 "
"Embedded Profile"));
}
EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_2_0));
EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Capability value 43 is not allowed by OpenCL 2.0/2.1 "
+ HasSubstr("Capability Sampled1D is not allowed by OpenCL 2.0/2.1 "
"Embedded Profile"));
}
ValidateInstructions(SPV_ENV_OPENCL_2_2));
EXPECT_THAT(
getDiagnosticString(),
- HasSubstr(
- "Capability value 0 is not allowed by OpenCL 2.2 Full Profile"));
+ HasSubstr("Capability Matrix is not allowed by OpenCL 2.2 Full Profile"));
}
TEST_F(ValidateCapability, OpenCL22FullEnabledByCapability) {
EXPECT_THAT(
getDiagnosticString(),
HasSubstr(
- "Capability value 43 is not allowed by OpenCL 2.2 Full Profile"));
+ "Capability Sampled1D is not allowed by OpenCL 2.2 Full Profile"));
}
TEST_F(ValidateCapability, NonOpenCL22EmbeddedCapability) {
EXPECT_THAT(
getDiagnosticString(),
HasSubstr(
- "Capability value 11 is not allowed by OpenCL 2.2 Embedded Profile"));
+ "Capability Int64 is not allowed by OpenCL 2.2 Embedded Profile"));
}
TEST_F(ValidateCapability, OpenCL22EmbeddedEnabledByCapability) {
CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_2_2);
EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_2_2));
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "Capability value 43 is not allowed by OpenCL 2.2 Embedded Profile"));
+ EXPECT_THAT(getDiagnosticString(),
+ HasSubstr("Capability Sampled1D is not allowed by OpenCL 2.2 "
+ "Embedded Profile"));
}
} // namespace