spirv-val: Add first StandAlone VUID 04633 (#4077)
This commit is contained in:
Родитель
8f4b35c332
Коммит
17ffa89097
|
@ -42,7 +42,8 @@ spv_result_t ValidateEntryPoint(ValidationState_t& _, const Instruction* inst) {
|
|||
const auto entry_point_type = _.FindDef(entry_point_type_id);
|
||||
if (!entry_point_type || 3 != entry_point_type->words().size()) {
|
||||
return _.diag(SPV_ERROR_INVALID_ID, inst)
|
||||
<< "OpEntryPoint Entry Point <id> '" << _.getIdName(entry_point_id)
|
||||
<< _.VkErrorID(4633) << "OpEntryPoint Entry Point <id> '"
|
||||
<< _.getIdName(entry_point_id)
|
||||
<< "'s function parameter count is not zero.";
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +51,8 @@ spv_result_t ValidateEntryPoint(ValidationState_t& _, const Instruction* inst) {
|
|||
auto return_type = _.FindDef(entry_point->type_id());
|
||||
if (!return_type || SpvOpTypeVoid != return_type->opcode()) {
|
||||
return _.diag(SPV_ERROR_INVALID_ID, inst)
|
||||
<< "OpEntryPoint Entry Point <id> '" << _.getIdName(entry_point_id)
|
||||
<< _.VkErrorID(4633) << "OpEntryPoint Entry Point <id> '"
|
||||
<< _.getIdName(entry_point_id)
|
||||
<< "'s function return type is not void.";
|
||||
}
|
||||
|
||||
|
|
|
@ -1665,6 +1665,8 @@ std::string ValidationState_t::VkErrorID(uint32_t id,
|
|||
return VUID_WRAP(VUID-ShadingRateKHR-ShadingRateKHR-04491);
|
||||
case 4492:
|
||||
return VUID_WRAP(VUID-ShadingRateKHR-ShadingRateKHR-04492);
|
||||
case 4633:
|
||||
return VUID_WRAP(VUID-StandaloneSpirv-None-04633);
|
||||
default:
|
||||
return ""; // unknown id
|
||||
};
|
||||
|
|
|
@ -159,44 +159,6 @@ CodeGenerator GetInMainCodeGenerator(spv_target_env env,
|
|||
return generator;
|
||||
}
|
||||
|
||||
// Allows test parameter test to list all possible VUIDs with a delimiter that
|
||||
// is then split here to check if one VUID was in the error message
|
||||
MATCHER_P(AnyVUID, vuid_set, "VUID from the set is in error message") {
|
||||
// use space as delimiter because clang-format will properly line break VUID
|
||||
// strings which is important the entire VUID is in a single line for script
|
||||
// to scan
|
||||
std::string delimiter = " ";
|
||||
std::string token;
|
||||
std::string vuids = std::string(vuid_set);
|
||||
size_t position;
|
||||
|
||||
// Catch case were someone accidentally left spaces by trimming string
|
||||
// clang-format off
|
||||
vuids.erase(std::find_if(vuids.rbegin(), vuids.rend(), [](unsigned char c) {
|
||||
return (c != ' ');
|
||||
}).base(), vuids.end());
|
||||
vuids.erase(vuids.begin(), std::find_if(vuids.begin(), vuids.end(), [](unsigned char c) {
|
||||
return (c != ' ');
|
||||
}));
|
||||
// clang-format on
|
||||
|
||||
do {
|
||||
position = vuids.find(delimiter);
|
||||
if (position != std::string::npos) {
|
||||
token = vuids.substr(0, position);
|
||||
vuids.erase(0, position + delimiter.length());
|
||||
} else {
|
||||
token = vuids.substr(0); // last item
|
||||
}
|
||||
|
||||
// arg contains diagnostic message
|
||||
if (arg.find(token) != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
} while (position != std::string::npos);
|
||||
return false;
|
||||
}
|
||||
|
||||
TEST_P(ValidateVulkanCombineBuiltInExecutionModelDataTypeResult, InMain) {
|
||||
const char* const built_in = std::get<0>(GetParam());
|
||||
const char* const execution_model = std::get<1>(GetParam());
|
||||
|
|
|
@ -183,4 +183,43 @@ spv_position_t ValidateBase<T>::getErrorPosition() {
|
|||
|
||||
} // namespace spvtest
|
||||
|
||||
// For Vulkan testing.
|
||||
// Allows test parameter test to list all possible VUIDs with a delimiter that
|
||||
// is then split here to check if one VUID was in the error message
|
||||
MATCHER_P(AnyVUID, vuid_set, "VUID from the set is in error message") {
|
||||
// use space as delimiter because clang-format will properly line break VUID
|
||||
// strings which is important the entire VUID is in a single line for script
|
||||
// to scan
|
||||
std::string delimiter = " ";
|
||||
std::string token;
|
||||
std::string vuids = std::string(vuid_set);
|
||||
size_t position;
|
||||
|
||||
// Catch case were someone accidentally left spaces by trimming string
|
||||
// clang-format off
|
||||
vuids.erase(std::find_if(vuids.rbegin(), vuids.rend(), [](unsigned char c) {
|
||||
return (c != ' ');
|
||||
}).base(), vuids.end());
|
||||
vuids.erase(vuids.begin(), std::find_if(vuids.begin(), vuids.end(), [](unsigned char c) {
|
||||
return (c != ' ');
|
||||
}));
|
||||
// clang-format on
|
||||
|
||||
do {
|
||||
position = vuids.find(delimiter);
|
||||
if (position != std::string::npos) {
|
||||
token = vuids.substr(0, position);
|
||||
vuids.erase(0, position + delimiter.length());
|
||||
} else {
|
||||
token = vuids.substr(0); // last item
|
||||
}
|
||||
|
||||
// arg contains diagnostic message
|
||||
if (arg.find(token) != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
} while (position != std::string::npos);
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // TEST_VAL_VAL_FIXTURES_H_
|
||||
|
|
|
@ -411,10 +411,10 @@ TEST_F(ValidateIdWithMessage, OpEntryPointFunctionBad) {
|
|||
}
|
||||
TEST_F(ValidateIdWithMessage, OpEntryPointParameterCountBad) {
|
||||
std::string spirv = kGLSL450MemoryModel + R"(
|
||||
OpEntryPoint GLCompute %3 ""
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeFunction %1 %1
|
||||
%3 = OpFunction %1 None %2
|
||||
OpEntryPoint GLCompute %1 ""
|
||||
%2 = OpTypeVoid
|
||||
%3 = OpTypeFunction %2 %2
|
||||
%1 = OpFunction %2 None %3
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd)";
|
||||
|
@ -426,11 +426,11 @@ TEST_F(ValidateIdWithMessage, OpEntryPointParameterCountBad) {
|
|||
}
|
||||
TEST_F(ValidateIdWithMessage, OpEntryPointReturnTypeBad) {
|
||||
std::string spirv = kGLSL450MemoryModel + R"(
|
||||
OpEntryPoint GLCompute %3 ""
|
||||
%1 = OpTypeInt 32 0
|
||||
%ret = OpConstant %1 0
|
||||
%2 = OpTypeFunction %1
|
||||
%3 = OpFunction %1 None %2
|
||||
OpEntryPoint GLCompute %1 ""
|
||||
%2 = OpTypeInt 32 0
|
||||
%ret = OpConstant %2 0
|
||||
%3 = OpTypeFunction %2
|
||||
%1 = OpFunction %2 None %3
|
||||
%4 = OpLabel
|
||||
OpReturnValue %ret
|
||||
OpFunctionEnd)";
|
||||
|
@ -440,6 +440,45 @@ TEST_F(ValidateIdWithMessage, OpEntryPointReturnTypeBad) {
|
|||
HasSubstr("OpEntryPoint Entry Point <id> '1[%1]'s function "
|
||||
"return type is not void."));
|
||||
}
|
||||
TEST_F(ValidateIdWithMessage, OpEntryPointParameterCountBadInVulkan) {
|
||||
std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %1 ""
|
||||
%2 = OpTypeVoid
|
||||
%3 = OpTypeFunction %2 %2
|
||||
%1 = OpFunction %2 None %3
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd)";
|
||||
CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_0);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
AnyVUID("VUID-StandaloneSpirv-None-04633"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("OpEntryPoint Entry Point <id> '1[%1]'s function "
|
||||
"parameter count is not zero"));
|
||||
}
|
||||
TEST_F(ValidateIdWithMessage, OpEntryPointReturnTypeBadInVulkan) {
|
||||
std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %1 ""
|
||||
%2 = OpTypeInt 32 0
|
||||
%ret = OpConstant %2 0
|
||||
%3 = OpTypeFunction %2
|
||||
%1 = OpFunction %2 None %3
|
||||
%4 = OpLabel
|
||||
OpReturnValue %ret
|
||||
OpFunctionEnd)";
|
||||
CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_0);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
AnyVUID("VUID-StandaloneSpirv-None-04633"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("OpEntryPoint Entry Point <id> '1[%1]'s function "
|
||||
"return type is not void."));
|
||||
}
|
||||
|
||||
TEST_F(ValidateIdWithMessage, OpEntryPointInterfaceIsNotVariableTypeBad) {
|
||||
std::string spirv = R"(
|
||||
|
|
Загрузка…
Ссылка в новой задаче