1 #ifndef _VKTTESTCASE_HPP 2 #define _VKTTESTCASE_HPP 3 /*------------------------------------------------------------------------- 4 * Vulkan Conformance Tests 5 * ------------------------ 6 * 7 * Copyright (c) 2015 Google Inc. 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 *//*! 22 * \file 23 * \brief Vulkan test case base classes 24 *//*--------------------------------------------------------------------*/ 25 26 #include "tcuDefs.hpp" 27 #include "tcuTestCase.hpp" 28 #include "vkDefs.hpp" 29 #include "deUniquePtr.hpp" 30 31 namespace glu 32 { 33 struct ProgramSources; 34 } 35 36 namespace vk 37 { 38 class PlatformInterface; 39 class ProgramBinary; 40 template<typename Program> class ProgramCollection; 41 class Allocator; 42 struct SourceCollections; 43 } 44 45 namespace vkt 46 { 47 48 class DefaultDevice; 49 50 class Context 51 { 52 public: 53 Context (tcu::TestContext& testCtx, 54 const vk::PlatformInterface& platformInterface, 55 vk::ProgramCollection<vk::ProgramBinary>& progCollection); 56 ~Context (void); 57 58 tcu::TestContext& getTestContext (void) const { return m_testCtx; } 59 const vk::PlatformInterface& getPlatformInterface (void) const { return m_platformInterface; } 60 vk::ProgramCollection<vk::ProgramBinary>& getBinaryCollection (void) const { return m_progCollection; } 61 62 // Default instance & device, selected with --deqp-vk-device-id=N 63 vk::VkInstance getInstance (void) const; 64 const vk::InstanceInterface& getInstanceInterface (void) const; 65 vk::VkPhysicalDevice getPhysicalDevice (void) const; 66 const vk::VkPhysicalDeviceFeatures& getDeviceFeatures (void) const; 67 const vk::VkPhysicalDeviceProperties& getDeviceProperties (void) const; 68 const std::vector<std::string>& getDeviceExtensions (void) const; 69 vk::VkDevice getDevice (void) const; 70 const vk::DeviceInterface& getDeviceInterface (void) const; 71 deUint32 getUniversalQueueFamilyIndex (void) const; 72 vk::VkQueue getUniversalQueue (void) const; 73 74 vk::Allocator& getDefaultAllocator (void) const; 75 76 protected: 77 tcu::TestContext& m_testCtx; 78 const vk::PlatformInterface& m_platformInterface; 79 vk::ProgramCollection<vk::ProgramBinary>& m_progCollection; 80 81 const de::UniquePtr<DefaultDevice> m_device; 82 const de::UniquePtr<vk::Allocator> m_allocator; 83 84 private: 85 Context (const Context&); // Not allowed 86 Context& operator= (const Context&); // Not allowed 87 }; 88 89 90 class TestInstance; 91 92 class TestCase : public tcu::TestCase 93 { 94 public: 95 TestCase (tcu::TestContext& testCtx, const std::string& name, const std::string& description); 96 TestCase (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description); 97 virtual ~TestCase (void) {} 98 99 virtual void initPrograms (vk::SourceCollections& programCollection) const; 100 virtual TestInstance* createInstance (Context& context) const = 0; 101 102 IterateResult iterate (void) { DE_ASSERT(false); return STOP; } // Deprecated in this module 103 }; 104 105 class TestInstance 106 { 107 public: 108 TestInstance (Context& context) : m_context(context) {} 109 virtual ~TestInstance (void) {} 110 111 virtual tcu::TestStatus iterate (void) = 0; 112 113 protected: 114 Context& m_context; 115 116 private: 117 TestInstance (const TestInstance&); 118 TestInstance& operator= (const TestInstance&); 119 }; 120 121 inline TestCase::TestCase (tcu::TestContext& testCtx, const std::string& name, const std::string& description) 122 : tcu::TestCase(testCtx, name.c_str(), description.c_str()) 123 { 124 } 125 126 inline TestCase::TestCase (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description) 127 : tcu::TestCase(testCtx, type, name.c_str(), description.c_str()) 128 { 129 } 130 131 } // vkt 132 133 #endif // _VKTTESTCASE_HPP 134