diff options
author | sfricke-samsung <46493288+sfricke-samsung@users.noreply.github.com> | 2020-12-17 10:51:17 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-17 13:51:17 -0500 |
commit | 17ffa89097b26efeb323e6963220326b5ffb2baf (patch) | |
tree | 9671e0afd52455415fc7f93fcd0a4d99a8ad6acd | |
parent | 8f4b35c332e1b8dab2b5b8c56363bb106d335998 (diff) | |
download | spirv-tools-17ffa89097b26efeb323e6963220326b5ffb2baf.tar.gz |
spirv-val: Add first StandAlone VUID 04633 (#4077)
-rw-r--r-- | source/val/validate_mode_setting.cpp | 6 | ||||
-rw-r--r-- | source/val/validation_state.cpp | 2 | ||||
-rw-r--r-- | test/val/val_builtins_test.cpp | 38 | ||||
-rw-r--r-- | test/val/val_fixtures.h | 39 | ||||
-rw-r--r-- | test/val/val_id_test.cpp | 57 |
5 files changed, 93 insertions, 49 deletions
diff --git a/source/val/validate_mode_setting.cpp b/source/val/validate_mode_setting.cpp index a7f8d339..1db1d4c4 100644 --- a/source/val/validate_mode_setting.cpp +++ b/source/val/validate_mode_setting.cpp @@ -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."; } diff --git a/source/val/validation_state.cpp b/source/val/validation_state.cpp index d59f3883..539fbb97 100644 --- a/source/val/validation_state.cpp +++ b/source/val/validation_state.cpp @@ -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 }; diff --git a/test/val/val_builtins_test.cpp b/test/val/val_builtins_test.cpp index eac38344..7d12aaca 100644 --- a/test/val/val_builtins_test.cpp +++ b/test/val/val_builtins_test.cpp @@ -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()); diff --git a/test/val/val_fixtures.h b/test/val/val_fixtures.h index 5635c781..acbe0e57 100644 --- a/test/val/val_fixtures.h +++ b/test/val/val_fixtures.h @@ -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_ diff --git a/test/val/val_id_test.cpp b/test/val/val_id_test.cpp index 069e8f20..ad8ebfc6 100644 --- a/test/val/val_id_test.cpp +++ b/test/val/val_id_test.cpp @@ -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"( |