1 #ifndef _VKTAMBERTESTCASE_HPP 2 #define _VKTAMBERTESTCASE_HPP 3 /*------------------------------------------------------------------------ 4 * Vulkan Conformance Tests 5 * ------------------------ 6 * 7 * Copyright (c) 2019 Google LLC 8 * Copyright (c) 2019 The Khronos Group Inc. 9 * 10 * Licensed under the Apache License, Version 2.0 (the "License"); 11 * you may not use this file except in compliance with the License. 12 * You may obtain a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * Unless required by applicable law or agreed to in writing, software 17 * distributed under the License is distributed on an "AS IS" BASIS, 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 * See the License for the specific language governing permissions and 20 * limitations under the License. 21 * 22 *//*! 23 * \file 24 * \brief Functional tests using amber 25 *//*--------------------------------------------------------------------*/ 26 27 #include <string> 28 #include <set> 29 #include "tcuDefs.hpp" 30 #include "tcuTestCase.hpp" 31 #include "vkSpirVProgram.hpp" 32 #include "vktTestCase.hpp" 33 34 namespace amber { class Recipe; } 35 36 namespace vkt 37 { 38 namespace cts_amber 39 { 40 41 struct BufferRequirement 42 { 43 vk::VkFormat m_format; 44 vk::VkFormatFeatureFlags m_featureFlags; 45 }; 46 47 class AmberTestInstance : public TestInstance 48 { 49 public: AmberTestInstance(Context & context,amber::Recipe * recipe)50 AmberTestInstance (Context& context, 51 amber::Recipe* recipe) 52 : TestInstance(context), m_recipe(recipe) 53 { 54 } 55 56 virtual tcu::TestStatus iterate (void); 57 58 private: 59 amber::Recipe* m_recipe; 60 }; 61 62 class AmberTestCase : public TestCase 63 { 64 public: 65 AmberTestCase (tcu::TestContext& testCtx, 66 const char* name, 67 const char* description, 68 const std::string& readFilename); 69 70 virtual ~AmberTestCase (void); 71 72 TestInstance* createInstance (Context& ctx) const override; 73 74 // Check that the Vulkan implementation supports this test. 75 // We have the principle that client code in dEQP should independently 76 // determine if the test should be supported: 77 // - If any of the extensions registered via |addRequirement| is not 78 // supported then throw a NotSupported exception. 79 // - Otherwise, we do a secondary sanity check depending on code inside 80 // Amber itself: if the Amber test says it is not supported, then 81 // throw an internal error exception. 82 void checkSupport (Context& ctx) const override; 83 84 // If the test case uses SPIR-V Assembly, use these build options. 85 // Otherwise, defaults to target Vulkan 1.0, SPIR-V 1.0. 86 void setSpirVAsmBuildOptions(const vk::SpirVAsmBuildOptions& asm_options); 87 void delayedInit (void) override; 88 void initPrograms (vk::SourceCollections& programCollection) const override; 89 90 // Add a required instance extension, device extension, or feature bit. 91 // A feature bit is represented by a string of form "<structure>.<feature>", where 92 // the structure name matches the Vulkan spec, but without the leading "VkPhysicalDevice". 93 // An example entry is: "VariablePointerFeatures.variablePointers". 94 // An instance or device extension will not have a period in its name. 95 void addRequirement(const std::string& requirement); 96 97 void addImageRequirement(vk::VkImageCreateInfo info); 98 void addBufferRequirement(BufferRequirement req); 99 100 virtual bool validateRequirements() override; 101 getRunnerType(void) const102 tcu::TestRunnerType getRunnerType (void) const override { return tcu::RUNNERTYPE_AMBER; } 103 104 private: 105 bool parse (const std::string& readFilename); 106 107 amber::Recipe* m_recipe; 108 vk::SpirVAsmBuildOptions m_asm_options; 109 110 std::string m_readFilename; 111 112 // Instance and device extensions required by the test. 113 // We don't differentiate between the two: We consider the requirement 114 // satisfied if the string is registered as either an instance or device 115 // extension. Use a set for consistent ordering. 116 std::set<std::string> m_required_extensions; 117 118 // Features required by the test. 119 // A feature bit is represented by a string of form "<structure>.<feature>", where 120 // the structure name matches the Vulkan spec, but without the leading "VkPhysicalDevice". 121 // An example entry is: "VariablePointerFeatures.variablePointers". 122 // Use a set for consistent ordering. 123 std::set<std::string> m_required_features; 124 125 std::vector<vk::VkImageCreateInfo> m_imageRequirements; 126 std::vector<BufferRequirement> m_bufferRequirements; 127 }; 128 129 AmberTestCase* createAmberTestCase (tcu::TestContext& testCtx, 130 const char* name, 131 const char* description, 132 const char* category, 133 const std::string& filename, 134 const std::vector<std::string> requirements = std::vector<std::string>(), 135 const std::vector<vk::VkImageCreateInfo> imageRequirements = std::vector<vk::VkImageCreateInfo>(), 136 const std::vector<BufferRequirement> bufferRequirements = std::vector<BufferRequirement>()); 137 138 void createAmberTestsFromIndexFile (tcu::TestContext& testCtx, 139 tcu::TestCaseGroup* group, 140 const std::string filename, 141 const char* category); 142 143 } // cts_amber 144 } // vkt 145 146 #endif // _VKTAMBERTESTCASE_HPP 147