diff options
Diffstat (limited to 'test/val/val_decoration_test.cpp')
-rw-r--r-- | test/val/val_decoration_test.cpp | 382 |
1 files changed, 83 insertions, 299 deletions
diff --git a/test/val/val_decoration_test.cpp b/test/val/val_decoration_test.cpp index 04d373a7..28ee970a 100644 --- a/test/val/val_decoration_test.cpp +++ b/test/val/val_decoration_test.cpp @@ -62,10 +62,9 @@ TEST_F(ValidateDecorations, ValidateOpDecorateRegistration) { CompileSuccessfully(spirv); EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()); // Must have 2 decorations. - EXPECT_THAT( - vstate_->id_decorations(id), - Eq(std::set<Decoration>{Decoration(spv::Decoration::Location, {4}), - Decoration(spv::Decoration::Centroid)})); + EXPECT_THAT(vstate_->id_decorations(id), + Eq(std::set<Decoration>{Decoration(SpvDecorationLocation, {4}), + Decoration(SpvDecorationCentroid)})); } TEST_F(ValidateDecorations, ValidateOpMemberDecorateRegistration) { @@ -90,15 +89,15 @@ TEST_F(ValidateDecorations, ValidateOpMemberDecorateRegistration) { const uint32_t arr_id = 1; EXPECT_THAT( vstate_->id_decorations(arr_id), - Eq(std::set<Decoration>{Decoration(spv::Decoration::ArrayStride, {4})})); + Eq(std::set<Decoration>{Decoration(SpvDecorationArrayStride, {4})})); // The struct must have 3 decorations. const uint32_t struct_id = 2; EXPECT_THAT( vstate_->id_decorations(struct_id), - Eq(std::set<Decoration>{Decoration(spv::Decoration::NonReadable, {}, 2), - Decoration(spv::Decoration::Offset, {2}, 2), - Decoration(spv::Decoration::BufferBlock)})); + Eq(std::set<Decoration>{Decoration(SpvDecorationNonReadable, {}, 2), + Decoration(SpvDecorationOffset, {2}, 2), + Decoration(SpvDecorationBufferBlock)})); } TEST_F(ValidateDecorations, ValidateOpMemberDecorateOutOfBound) { @@ -153,9 +152,9 @@ TEST_F(ValidateDecorations, ValidateGroupDecorateRegistration) { // Decoration group has 3 decorations. auto expected_decorations = - std::set<Decoration>{Decoration(spv::Decoration::DescriptorSet, {0}), - Decoration(spv::Decoration::RelaxedPrecision), - Decoration(spv::Decoration::Restrict)}; + std::set<Decoration>{Decoration(SpvDecorationDescriptorSet, {0}), + Decoration(SpvDecorationRelaxedPrecision), + Decoration(SpvDecorationRestrict)}; // Decoration group is applied to id 1, 2, 3, and 4. Note that id 1 (which is // the decoration group id) also has all the decorations. @@ -183,7 +182,7 @@ TEST_F(ValidateDecorations, ValidateGroupMemberDecorateRegistration) { EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()); // Decoration group has 1 decoration. auto expected_decorations = - std::set<Decoration>{Decoration(spv::Decoration::Offset, {3}, 3)}; + std::set<Decoration>{Decoration(SpvDecorationOffset, {3}, 3)}; // Decoration group is applied to id 2, 3, and 4. EXPECT_THAT(vstate_->id_decorations(2), Eq(expected_decorations)); @@ -1219,14 +1218,9 @@ TEST_F(ValidateDecorations, BlockGLSLSharedBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr( - "'GLSLShared' is not valid for the Vulkan execution environment")); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("[VUID-StandaloneSpirv-GLSLShared-04669]")); + HasSubstr("must not use GLSLShared decoration")); } TEST_F(ValidateDecorations, BufferBlockGLSLSharedBad) { @@ -1253,14 +1247,9 @@ TEST_F(ValidateDecorations, BufferBlockGLSLSharedBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr( - "'GLSLShared' is not valid for the Vulkan execution environment")); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("[VUID-StandaloneSpirv-GLSLShared-04669]")); + HasSubstr("must not use GLSLShared decoration")); } TEST_F(ValidateDecorations, BlockNestedStructGLSLSharedBad) { @@ -1293,14 +1282,9 @@ TEST_F(ValidateDecorations, BlockNestedStructGLSLSharedBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr( - "'GLSLShared' is not valid for the Vulkan execution environment")); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("[VUID-StandaloneSpirv-GLSLShared-04669]")); + HasSubstr("must not use GLSLShared decoration")); } TEST_F(ValidateDecorations, BufferBlockNestedStructGLSLSharedBad) { @@ -1333,14 +1317,9 @@ TEST_F(ValidateDecorations, BufferBlockNestedStructGLSLSharedBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr( - "'GLSLShared' is not valid for the Vulkan execution environment")); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("[VUID-StandaloneSpirv-GLSLShared-04669]")); + HasSubstr("must not use GLSLShared decoration")); } TEST_F(ValidateDecorations, BlockGLSLPackedBad) { @@ -1367,14 +1346,9 @@ TEST_F(ValidateDecorations, BlockGLSLPackedBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr( - "'GLSLPacked' is not valid for the Vulkan execution environment")); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("[VUID-StandaloneSpirv-GLSLShared-04669]")); + HasSubstr("must not use GLSLPacked decoration")); } TEST_F(ValidateDecorations, BufferBlockGLSLPackedBad) { @@ -1401,14 +1375,9 @@ TEST_F(ValidateDecorations, BufferBlockGLSLPackedBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr( - "'GLSLPacked' is not valid for the Vulkan execution environment")); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("[VUID-StandaloneSpirv-GLSLShared-04669]")); + HasSubstr("must not use GLSLPacked decoration")); } TEST_F(ValidateDecorations, BlockNestedStructGLSLPackedBad) { @@ -1441,14 +1410,9 @@ TEST_F(ValidateDecorations, BlockNestedStructGLSLPackedBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr( - "'GLSLPacked' is not valid for the Vulkan execution environment")); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("[VUID-StandaloneSpirv-GLSLShared-04669]")); + HasSubstr("must not use GLSLPacked decoration")); } TEST_F(ValidateDecorations, BufferBlockNestedStructGLSLPackedBad) { @@ -1481,14 +1445,9 @@ TEST_F(ValidateDecorations, BufferBlockNestedStructGLSLPackedBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr( - "'GLSLPacked' is not valid for the Vulkan execution environment")); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("[VUID-StandaloneSpirv-GLSLShared-04669]")); + HasSubstr("must not use GLSLPacked decoration")); } TEST_F(ValidateDecorations, BlockMissingArrayStrideBad) { @@ -1889,8 +1848,7 @@ TEST_F(ValidateDecorations, BlockStandardUniformBufferLayout) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_SUCCESS, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()); } TEST_F(ValidateDecorations, BlockLayoutPermitsTightVec3ScalarPackingGood) { @@ -1919,7 +1877,7 @@ TEST_F(ValidateDecorations, BlockLayoutPermitsTightVec3ScalarPackingGood) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)) + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()) << getDiagnosticString(); } @@ -2101,8 +2059,7 @@ TEST_F(ValidateDecorations, BlockLayoutForbidsTightScalarVec3PackingBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr("Structure id 2 decorated as Block for variable in Uniform " @@ -2510,8 +2467,7 @@ TEST_F(ValidateDecorations, BufferBlock16bitStandardStorageBufferLayout) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_SUCCESS, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()); } TEST_F(ValidateDecorations, BlockArrayExtendedAlignmentGood) { @@ -2575,8 +2531,7 @@ TEST_F(ValidateDecorations, BlockArrayBaseAlignmentBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -2773,7 +2728,7 @@ TEST_F(ValidateDecorations, PushConstantArrayBaseAlignmentGood) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)) + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()) << getDiagnosticString(); } @@ -2805,8 +2760,7 @@ TEST_F(ValidateDecorations, PushConstantArrayBadAlignmentBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -2840,7 +2794,7 @@ TEST_F(ValidateDecorations, )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)) + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()) << getDiagnosticString(); } @@ -2869,8 +2823,7 @@ TEST_F(ValidateDecorations, )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -3722,7 +3675,7 @@ TEST_F(ValidateDecorations, StorageBufferStorageClassArrayBaseAlignmentGood) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)) + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()) << getDiagnosticString(); } @@ -3757,8 +3710,7 @@ TEST_F(ValidateDecorations, StorageBufferStorageClassArrayBadAlignmentBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -3825,8 +3777,7 @@ TEST_F(ValidateDecorations, BufferBlockStandardStorageBufferLayout) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_SUCCESS, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()); } TEST_F(ValidateDecorations, @@ -3857,7 +3808,7 @@ TEST_F(ValidateDecorations, )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)) + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()) << getDiagnosticString(); } @@ -3889,8 +3840,7 @@ TEST_F(ValidateDecorations, )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -3958,8 +3908,7 @@ TEST_F(ValidateDecorations, )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr("Structure id 6 decorated as Block for variable in Uniform " @@ -4026,8 +3975,7 @@ TEST_F(ValidateDecorations, )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr("Structure id 8 decorated as Block for variable in Uniform " @@ -4093,8 +4041,7 @@ TEST_F(ValidateDecorations, BlockUniformBufferLayoutIncorrectArrayStrideBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -4130,8 +4077,7 @@ TEST_F(ValidateDecorations, )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr("Structure id 3 decorated as BufferBlock for variable in " @@ -4170,8 +4116,7 @@ TEST_F(ValidateDecorations, )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -4187,7 +4132,6 @@ TEST_F(ValidateDecorations, OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %1 "main" - OpExecutionMode %1 LocalSize 1 1 1 OpMemberDecorate %_struct_6 0 Offset 0 OpMemberDecorate %_struct_2 0 Offset 0 OpMemberDecorate %_struct_2 1 Offset 4 @@ -4206,8 +4150,7 @@ TEST_F(ValidateDecorations, )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -4332,8 +4275,7 @@ TEST_F(ValidateDecorations, BlockLayoutOffsetOverlapBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -4463,7 +4405,7 @@ TEST_F(ValidateDecorations, ArrayArrayRowMajorMatrixTightPackingGood) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)) + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()) << getDiagnosticString(); } @@ -4507,8 +4449,7 @@ TEST_F(ValidateDecorations, ArrayArrayRowMajorMatrixNextMemberOverlapsBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -4523,48 +4464,6 @@ TEST_F(ValidateDecorations, StorageBufferArraySizeCalculationPackGood) { // #version 450 // layout (set=0,binding=0) buffer S { // uvec3 arr[2][2]; // first 3 elements are 16 bytes, last is 12 - // uint i; // Can't have offset 60 = 3x16 + 12 - // } B; - // void main() {} - - std::string spirv = R"( - OpCapability Shader - OpMemoryModel Logical GLSL450 - OpEntryPoint Vertex %1 "main" - OpDecorate %_arr_v3uint_uint_2 ArrayStride 16 - OpDecorate %_arr__arr_v3uint_uint_2_uint_2 ArrayStride 32 - OpMemberDecorate %_struct_4 0 Offset 0 - OpMemberDecorate %_struct_4 1 Offset 64 - OpDecorate %_struct_4 BufferBlock - OpDecorate %5 DescriptorSet 0 - OpDecorate %5 Binding 0 - %void = OpTypeVoid - %7 = OpTypeFunction %void - %uint = OpTypeInt 32 0 - %v3uint = OpTypeVector %uint 3 - %uint_2 = OpConstant %uint 2 -%_arr_v3uint_uint_2 = OpTypeArray %v3uint %uint_2 -%_arr__arr_v3uint_uint_2_uint_2 = OpTypeArray %_arr_v3uint_uint_2 %uint_2 - %_struct_4 = OpTypeStruct %_arr__arr_v3uint_uint_2_uint_2 %uint -%_ptr_Uniform__struct_4 = OpTypePointer Uniform %_struct_4 - %5 = OpVariable %_ptr_Uniform__struct_4 Uniform - %1 = OpFunction %void None %7 - %12 = OpLabel - OpReturn - OpFunctionEnd - )"; - - CompileSuccessfully(spirv); - EXPECT_EQ(SPV_SUCCESS, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); -} - -TEST_F(ValidateDecorations, StorageBufferArraySizeCalculationPackGoodScalar) { - // Original GLSL - - // #version 450 - // layout (set=0,binding=0) buffer S { - // uvec3 arr[2][2]; // first 3 elements are 16 bytes, last is 12 // uint i; // Can have offset 60 = 3x16 + 12 // } B; // void main() {} @@ -4596,10 +4495,8 @@ TEST_F(ValidateDecorations, StorageBufferArraySizeCalculationPackGoodScalar) { OpFunctionEnd )"; - options_->scalar_block_layout = true; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_SUCCESS, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()); } TEST_F(ValidateDecorations, StorageBufferArraySizeCalculationPackBad) { @@ -4612,7 +4509,7 @@ TEST_F(ValidateDecorations, StorageBufferArraySizeCalculationPackBad) { OpDecorate %_arr_v3uint_uint_2 ArrayStride 16 OpDecorate %_arr__arr_v3uint_uint_2_uint_2 ArrayStride 32 OpMemberDecorate %_struct_4 0 Offset 0 - OpMemberDecorate %_struct_4 1 Offset 60 + OpMemberDecorate %_struct_4 1 Offset 56 OpDecorate %_struct_4 BufferBlock OpDecorate %5 DescriptorSet 0 OpDecorate %5 Binding 0 @@ -4633,13 +4530,12 @@ TEST_F(ValidateDecorations, StorageBufferArraySizeCalculationPackBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Structure id 4 decorated as BufferBlock for variable " "in Uniform storage class must follow standard storage " - "buffer layout rules: member 1 at offset 60 overlaps " - "previous member ending at offset 63")); + "buffer layout rules: member 1 at offset 56 overlaps " + "previous member ending at offset 59")); } TEST_F(ValidateDecorations, UniformBufferArraySizeCalculationPackGood) { @@ -4674,8 +4570,7 @@ TEST_F(ValidateDecorations, UniformBufferArraySizeCalculationPackGood) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_SUCCESS, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()); } TEST_F(ValidateDecorations, UniformBufferArraySizeCalculationPackBad) { @@ -4709,8 +4604,7 @@ TEST_F(ValidateDecorations, UniformBufferArraySizeCalculationPackBad) { )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -5248,10 +5142,8 @@ OpGroupDecorate %1 %2 %1 TEST_F(ValidateDecorations, RecurseThroughRuntimeArray) { const std::string spirv = R"( OpCapability Shader -OpExtension "SPV_KHR_storage_buffer_storage_class" +OpCapability Linkage OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %main "main" -OpExecutionMode %main LocalSize 1 1 1 OpDecorate %outer Block OpMemberDecorate %inner 0 Offset 0 OpMemberDecorate %inner 1 Offset 1 @@ -5261,24 +5153,17 @@ OpMemberDecorate %outer 0 Offset 0 %inner = OpTypeStruct %int %int %runtime = OpTypeRuntimeArray %inner %outer = OpTypeStruct %runtime -%outer_ptr = OpTypePointer StorageBuffer %outer -%var = OpVariable %outer_ptr StorageBuffer -%void = OpTypeVoid -%void_fn = OpTypeFunction %void -%main = OpFunction %void None %void_fn -%entry = OpLabel -OpReturn -OpFunctionEnd +%outer_ptr = OpTypePointer Uniform %outer +%var = OpVariable %outer_ptr Uniform )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), - HasSubstr( - "Structure id 3 decorated as Block for variable in StorageBuffer " - "storage class must follow standard storage buffer layout " - "rules: member 1 at offset 1 is not aligned to 4")); + HasSubstr("Structure id 2 decorated as Block for variable in Uniform " + "storage class must follow standard uniform buffer layout " + "rules: member 1 at offset 1 is not aligned to 4")); } TEST_F(ValidateDecorations, EmptyStructAtNonZeroOffsetGood) { @@ -7000,8 +6885,6 @@ 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")); } @@ -7010,7 +6893,6 @@ 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 @@ -7023,9 +6905,6 @@ 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 @@ -7081,10 +6960,8 @@ TEST_F(ValidateDecorations, ComponentDecorationIntBad4Vulkan) { CompileSuccessfully(spirv, env); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); EXPECT_THAT(getDiagnosticString(), - AnyVUID("VUID-StandaloneSpirv-Component-04920")); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr("Component decoration value must not be greater than 3")); + HasSubstr("Sequence of components starting with 4 " + "and ending with 4 gets larger than 3")); } TEST_F(ValidateDecorations, ComponentDecorationVector3GoodVulkan) { @@ -7112,8 +6989,6 @@ 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")); } @@ -7125,8 +7000,6 @@ 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")); } @@ -7149,101 +7022,10 @@ 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(), - AnyVUID("VUID-StandaloneSpirv-Component-07703")); - 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 @@ -7315,8 +7097,6 @@ 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")); } @@ -8192,7 +7972,7 @@ TEST_F(ValidateDecorations, WorkgroupSingleBlockVariableMissingLayout) { CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + ValidateAndRetrieveValidationState(SPV_ENV_UNIVERSAL_1_4)); EXPECT_THAT( getDiagnosticString(), HasSubstr("Block must be explicitly laid out with Offset decorations")); @@ -8227,12 +8007,13 @@ TEST_F(ValidateDecorations, WorkgroupSingleBlockVariableBadLayout) { CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); EXPECT_EQ(SPV_ERROR_INVALID_ID, - ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + ValidateAndRetrieveValidationState(SPV_ENV_UNIVERSAL_1_4)); EXPECT_THAT( getDiagnosticString(), - HasSubstr("Block for variable in Workgroup storage class must follow " - "relaxed storage buffer layout rules: " - "member 0 at offset 1 is not aligned to 4")); + HasSubstr( + "Block for variable in Workgroup storage class must follow " + "standard storage buffer layout rules: " + "member 0 at offset 1 is not aligned to 4")); } TEST_F(ValidateDecorations, BadMatrixStrideUniform) { @@ -8262,7 +8043,7 @@ OpFunctionEnd )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -8299,7 +8080,7 @@ OpFunctionEnd )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -8318,6 +8099,8 @@ OpDecorate %block Block OpMemberDecorate %block 0 Offset 0 OpMemberDecorate %block 0 MatrixStride 3 OpMemberDecorate %block 0 ColMajor +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 %void = OpTypeVoid %float = OpTypeFloat 32 %float4 = OpTypeVector %float 4 @@ -8333,7 +8116,7 @@ OpFunctionEnd )"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -8371,7 +8154,7 @@ OpFunctionEnd options_->scalar_block_layout = true; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -8870,8 +8653,9 @@ TEST_P(ValidateDecorationString, VulkanOutputInvalidInterface) { AnyVUID("VUID-StandaloneSpirv-Flat-06201")); EXPECT_THAT( getDiagnosticString(), - HasSubstr("decorated variable must not be used in fragment execution " - "model as an Output storage class for Entry Point id 2.")); + HasSubstr( + "OpEntryPoint interfaces variable must not be fragment execution " + "model with an output storage class for Entry Point id 2.")); } TEST_P(ValidateDecorationString, VulkanVertexInputInvalidInterface) { @@ -8909,8 +8693,8 @@ TEST_P(ValidateDecorationString, VulkanVertexInputInvalidInterface) { AnyVUID("VUID-StandaloneSpirv-Flat-06202")); EXPECT_THAT( getDiagnosticString(), - HasSubstr("decorated variable must not be used in vertex execution model " - "as an Input storage class for Entry Point id 2.")); + HasSubstr("OpEntryPoint interfaces variable must not be vertex execution " + "model with an input storage class for Entry Point id 2.")); } INSTANTIATE_TEST_SUITE_P(FragmentInputInterface, ValidateDecorationString, |