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 getRunnerType(void) const100 tcu::TestRunnerType getRunnerType (void) const override { return tcu::RUNNERTYPE_AMBER; } 101 102 private: 103 bool parse (const std::string& readFilename); 104 105 amber::Recipe* m_recipe; 106 vk::SpirVAsmBuildOptions m_asm_options; 107 108 std::string m_readFilename; 109 110 // Instance and device extensions required by the test. 111 // We don't differentiate between the two: We consider the requirement 112 // satisfied if the string is registered as either an instance or device 113 // extension. Use a set for consistent ordering. 114 std::set<std::string> m_required_extensions; 115 116 // Features required by the test. 117 // A feature bit is represented by a string of form "<structure>.<feature>", where 118 // the structure name matches the Vulkan spec, but without the leading "VkPhysicalDevice". 119 // An example entry is: "VariablePointerFeatures.variablePointers". 120 // Use a set for consistent ordering. 121 std::set<std::string> m_required_features; 122 123 std::vector<vk::VkImageCreateInfo> m_imageRequirements; 124 std::vector<BufferRequirement> m_bufferRequirements; 125 }; 126 127 AmberTestCase* createAmberTestCase (tcu::TestContext& testCtx, 128 const char* name, 129 const char* description, 130 const char* category, 131 const std::string& filename, 132 const std::vector<std::string> requirements = std::vector<std::string>(), 133 const std::vector<vk::VkImageCreateInfo> imageRequirements = std::vector<vk::VkImageCreateInfo>(), 134 const std::vector<BufferRequirement> bufferRequirements = std::vector<BufferRequirement>()); 135 136 void createAmberTestsFromIndexFile (tcu::TestContext& testCtx, 137 tcu::TestCaseGroup* group, 138 const std::string filename, 139 const char* category); 140 141 } // cts_amber 142 } // vkt 143 144 #endif // _VKTAMBERTESTCASE_HPP 145