• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "vktDrawGroupParams.hpp"
33 
34 #include "gluShaderUtil.hpp"
35 #include "vkPrograms.hpp"
36 
37 #include "deUniquePtr.hpp"
38 
39 #include <map>
40 
41 namespace vkt
42 {
43 namespace Draw
44 {
45 
46 typedef std::map<glu::ShaderType, const char*> ShaderMap;
47 
48 struct TestSpecBase
49 {
50 	ShaderMap					shaders;
51 	vk::VkPrimitiveTopology		topology;
52 	const SharedGroupParams		groupParams;
53 };
54 
55 template<typename Instance, typename Support = NoSupport0>
56 class InstanceFactory : public TestCase
57 {
58 public:
InstanceFactory(tcu::TestContext & testCtx,const std::string & name,const std::string & desc,typename Instance::TestSpec testSpec)59 	InstanceFactory (tcu::TestContext& testCtx, const std::string& name, const std::string& desc, typename Instance::TestSpec testSpec)
60 		: TestCase		(testCtx, name, desc)
61 		, m_testSpec	(testSpec)
62 		, m_support		()
63 	{
64 	}
65 
InstanceFactory(tcu::TestContext & testCtx,const std::string & name,const std::string & desc,typename Instance::TestSpec testSpec,const Support & support)66 	InstanceFactory (tcu::TestContext& testCtx, const std::string& name, const std::string& desc, typename Instance::TestSpec testSpec, const Support& support)
67 		: TestCase		(testCtx, name, desc)
68 		, m_testSpec	(testSpec)
69 		, m_support		(support)
70 	{
71 	}
72 
createInstance(Context & context) const73 	TestInstance*	createInstance	(Context& context) const
74 	{
75 		return new Instance(context, m_testSpec);
76 	}
77 
initPrograms(vk::SourceCollections & programCollection) const78 	virtual void	initPrograms	(vk::SourceCollections& programCollection) const
79 	{
80 		for (ShaderMap::const_iterator i = m_testSpec.shaders.begin(); i != m_testSpec.shaders.end(); ++i)
81 		{
82 			programCollection.glslSources.add(i->second) <<
83 				glu::ShaderSource(i->first, ShaderSourceProvider::getSource(m_testCtx.getArchive(), i->second));
84 		}
85 	}
86 
checkSupport(Context & context) const87 	virtual void	checkSupport	(Context& context) const
88 	{
89 		m_support.checkSupport(context);
90 	}
91 
92 private:
93 	const typename Instance::TestSpec	m_testSpec;
94 	const Support						m_support;
95 };
96 
97 } // Draw
98 } // vkt
99 
100 #endif // _VKTDRAWTESTCASEUTIL_HPP
101