1 #ifndef _VKTDRAWTESTCASEUTIL_HPP 2 #define _VKTDRAWTESTCASEUTIL_HPP 3 /*------------------------------------------------------------------------ 4 * Vulkan Conformance Tests 5 * ------------------------ 6 * 7 * Copyright (c) 2015 The Khronos Group Inc. 8 * Copyright (c) 2015 Intel Corporation 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 Draw Test Case Utils 25 *//*--------------------------------------------------------------------*/ 26 27 28 #include "tcuDefs.hpp" 29 30 #include "vktTestCase.hpp" 31 #include "vktTestCaseUtil.hpp" 32 33 #include "gluShaderUtil.hpp" 34 #include "vkPrograms.hpp" 35 36 #include "deUniquePtr.hpp" 37 38 #include <map> 39 40 namespace vkt 41 { 42 namespace Draw 43 { 44 45 typedef std::map<glu::ShaderType, const char*> ShaderMap; 46 47 struct TestSpecBase 48 { 49 ShaderMap shaders; 50 vk::VkPrimitiveTopology topology; 51 bool useDynamicRendering; 52 }; 53 54 template<typename Instance, typename Support = NoSupport0> 55 class InstanceFactory : public TestCase 56 { 57 public: InstanceFactory(tcu::TestContext & testCtx,const std::string & name,const std::string & desc,typename Instance::TestSpec testSpec)58 InstanceFactory (tcu::TestContext& testCtx, const std::string& name, const std::string& desc, typename Instance::TestSpec testSpec) 59 : TestCase (testCtx, name, desc) 60 , m_testSpec (testSpec) 61 , m_support () 62 { 63 } 64 InstanceFactory(tcu::TestContext & testCtx,const std::string & name,const std::string & desc,typename Instance::TestSpec testSpec,const Support & support)65 InstanceFactory (tcu::TestContext& testCtx, const std::string& name, const std::string& desc, typename Instance::TestSpec testSpec, const Support& support) 66 : TestCase (testCtx, name, desc) 67 , m_testSpec (testSpec) 68 , m_support (support) 69 { 70 } 71 createInstance(Context & context) const72 TestInstance* createInstance (Context& context) const 73 { 74 return new Instance(context, m_testSpec); 75 } 76 initPrograms(vk::SourceCollections & programCollection) const77 virtual void initPrograms (vk::SourceCollections& programCollection) const 78 { 79 for (ShaderMap::const_iterator i = m_testSpec.shaders.begin(); i != m_testSpec.shaders.end(); ++i) 80 { 81 programCollection.glslSources.add(i->second) << 82 glu::ShaderSource(i->first, ShaderSourceProvider::getSource(m_testCtx.getArchive(), i->second)); 83 } 84 } 85 checkSupport(Context & context) const86 virtual void checkSupport (Context& context) const 87 { 88 m_support.checkSupport(context); 89 } 90 91 private: 92 const typename Instance::TestSpec m_testSpec; 93 const Support m_support; 94 }; 95 96 } // Draw 97 } // vkt 98 99 #endif // _VKTDRAWTESTCASEUTIL_HPP 100