diff options
author | Spencer Fricke <115671160+spencer-lunarg@users.noreply.github.com> | 2022-10-17 23:54:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-17 23:54:39 +0300 |
commit | ecd5b9c167ad03dcd4b3211d209581f40e03c608 (patch) | |
tree | dc2163f70acab618a444ac664416ff05c644e490 /test | |
parent | b53d3a6be38b032dedbc72639dfc6249b5e92697 (diff) |
spirv-val: Add remaining Component decoration validation (#4966)
Diffstat (limited to 'test')
-rw-r--r-- | test/val/val_decoration_test.cpp | 107 | ||||
-rw-r--r-- | test/val/val_interfaces_test.cpp | 2 |
2 files changed, 106 insertions, 3 deletions
diff --git a/test/val/val_decoration_test.cpp b/test/val/val_decoration_test.cpp index 28ee970a1..076267088 100644 --- a/test/val/val_decoration_test.cpp +++ b/test/val/val_decoration_test.cpp @@ -6885,6 +6885,8 @@ OpFunctionEnd CompileSuccessfully(spirv, env); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Component-04924")); + EXPECT_THAT(getDiagnosticString(), HasSubstr("Component decoration specified for type")); EXPECT_THAT(getDiagnosticString(), HasSubstr("is not a scalar or vector")); } @@ -6893,6 +6895,7 @@ std::string ShaderWithComponentDecoration(const std::string& type, const std::string& decoration) { return R"( OpCapability Shader +OpCapability Int64 OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %main "main" %entryPointOutput OpExecutionMode %main OriginUpperLeft @@ -6905,6 +6908,9 @@ OpDecorate %entryPointOutput )" + %v3float = OpTypeVector %float 3 %v4float = OpTypeVector %float 4 %uint = OpTypeInt 32 0 +%uint64 = OpTypeInt 64 0 +%v2uint64 = OpTypeVector %uint64 2 +%v3uint64 = OpTypeVector %uint64 3 %uint_2 = OpConstant %uint 2 %arr_v3float_uint_2 = OpTypeArray %v3float %uint_2 %float_0 = OpConstant %float 0 @@ -6960,8 +6966,10 @@ TEST_F(ValidateDecorations, ComponentDecorationIntBad4Vulkan) { CompileSuccessfully(spirv, env); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); EXPECT_THAT(getDiagnosticString(), - HasSubstr("Sequence of components starting with 4 " - "and ending with 4 gets larger than 3")); + AnyVUID("VUID-StandaloneSpirv-Component-04920")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Component decoration value must not be greater than 3")); } TEST_F(ValidateDecorations, ComponentDecorationVector3GoodVulkan) { @@ -6989,6 +6997,8 @@ TEST_F(ValidateDecorations, ComponentDecorationVector4Bad1Vulkan) { CompileSuccessfully(spirv, env); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Component-04921")); + EXPECT_THAT(getDiagnosticString(), HasSubstr("Sequence of components starting with 1 " "and ending with 4 gets larger than 3")); } @@ -7000,6 +7010,8 @@ TEST_F(ValidateDecorations, ComponentDecorationVector4Bad3Vulkan) { CompileSuccessfully(spirv, env); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Component-04921")); + EXPECT_THAT(getDiagnosticString(), HasSubstr("Sequence of components starting with 3 " "and ending with 6 gets larger than 3")); } @@ -7022,10 +7034,99 @@ TEST_F(ValidateDecorations, ComponentDecorationArrayBadVulkan) { CompileSuccessfully(spirv, env); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Component-04921")); + EXPECT_THAT(getDiagnosticString(), HasSubstr("Sequence of components starting with 2 " "and ending with 4 gets larger than 3")); } +TEST_F(ValidateDecorations, ComponentDecoration64ScalarGoodVulkan) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = ShaderWithComponentDecoration("uint64", "Component 0"); + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState(env)); +} + +TEST_F(ValidateDecorations, ComponentDecoration64Scalar1BadVulkan) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = ShaderWithComponentDecoration("uint64", "Component 1"); + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Component-04923")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Component decoration value must not be 1 or 3 for " + "64-bit data types")); +} + +TEST_F(ValidateDecorations, ComponentDecoration64Scalar2GoodVulkan) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = ShaderWithComponentDecoration("uint64", "Component 2"); + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState(env)); +} + +TEST_F(ValidateDecorations, ComponentDecoration64Scalar3BadVulkan) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = ShaderWithComponentDecoration("uint64", "Component 3"); + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Component-04923")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Component decoration value must not be 1 or 3 for " + "64-bit data types")); +} + +TEST_F(ValidateDecorations, ComponentDecoration64Vec0GoodVulkan) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = ShaderWithComponentDecoration("v2uint64", "Component 0"); + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState(env)); +} + +TEST_F(ValidateDecorations, ComponentDecoration64Vec1BadVulkan) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = ShaderWithComponentDecoration("v2uint64", "Component 1"); + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Component-04923")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Component decoration value must not be 1 or 3 for " + "64-bit data types")); +} + +TEST_F(ValidateDecorations, ComponentDecoration64Vec2BadVulkan) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = ShaderWithComponentDecoration("v2uint64", "Component 2"); + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Component-04922")); + HasSubstr( + "Sequence of components starting with 2 " + "and ending with 6 gets larger than 3"); +} + +TEST_F(ValidateDecorations, ComponentDecoration64VecWideBadVulkan) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = ShaderWithComponentDecoration("v3uint64", "Component 0"); + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Component decoration only allowed on 64-bit scalar " + "and 2-component vector")); +} + TEST_F(ValidateDecorations, ComponentDecorationBlockGood) { std::string spirv = R"( OpCapability Shader @@ -7097,6 +7198,8 @@ OpFunctionEnd CompileSuccessfully(spirv, env); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Component-04921")); + EXPECT_THAT(getDiagnosticString(), HasSubstr("Sequence of components starting with 2 " "and ending with 4 gets larger than 3")); } diff --git a/test/val/val_interfaces_test.cpp b/test/val/val_interfaces_test.cpp index 22a0e7c34..175652872 100644 --- a/test/val/val_interfaces_test.cpp +++ b/test/val/val_interfaces_test.cpp @@ -1456,7 +1456,7 @@ OpDecorate %struct Block OpMemberDecorate %struct 0 Location 0 OpMemberDecorate %struct 0 Component 0 OpMemberDecorate %struct 1 Location 0 -OpMemberDecorate %struct 1 Component 1 +OpMemberDecorate %struct 1 Component 2 %void = OpTypeVoid %void_fn = OpTypeFunction %void %float = OpTypeFloat 32 |