• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _VKTDYNAMICSTATETESTCASEUTIL_HPP
2 #define _VKTDYNAMICSTATETESTCASEUTIL_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 Dynamic State Tests Test Case Utilities
25  *//*--------------------------------------------------------------------*/
26 
27 #include "tcuDefs.hpp"
28 
29 #include "vktTestCase.hpp"
30 #include "vktTestCaseUtil.hpp"
31 
32 #include "gluShaderUtil.hpp"
33 #include "vkPrograms.hpp"
34 
35 #include "deUniquePtr.hpp"
36 
37 #include <map>
38 
39 namespace vkt
40 {
41 namespace DynamicState
42 {
43 
44 struct PositionColorVertex
45 {
PositionColorVertexvkt::DynamicState::PositionColorVertex46 	PositionColorVertex(const tcu::Vec4& position_, const tcu::Vec4& color_)
47 		: position(position_)
48 		, color(color_)
49 	{}
50 	tcu::Vec4 position;
51 	tcu::Vec4 color;
52 };
53 
54 typedef std::map<glu::ShaderType, const char*> ShaderMap;
55 
56 template<typename Instance, typename Support = NoSupport0>
57 class InstanceFactory : public TestCase
58 {
59 public:
InstanceFactory(tcu::TestContext & testCtx,const std::string & name,const std::string & desc,const std::map<glu::ShaderType,const char * > shaderPaths)60 	InstanceFactory (tcu::TestContext& testCtx, const std::string& name, const std::string& desc,
61 		const std::map<glu::ShaderType, const char*> shaderPaths)
62 		: TestCase		(testCtx, name, desc)
63 		, m_shaderPaths (shaderPaths)
64 		, m_support		()
65 	{
66 	}
67 
InstanceFactory(tcu::TestContext & testCtx,const std::string & name,const std::string & desc,const std::map<glu::ShaderType,const char * > shaderPaths,const Support & support)68 	InstanceFactory (tcu::TestContext& testCtx, const std::string& name, const std::string& desc,
69 		const std::map<glu::ShaderType, const char*> shaderPaths, const Support& support)
70 		: TestCase		(testCtx, name, desc)
71 		, m_shaderPaths (shaderPaths)
72 		, m_support		(support)
73 	{
74 	}
75 
createInstance(Context & context) const76 	TestInstance*	createInstance	(Context& context) const
77 	{
78 		return new Instance(context, m_shaderPaths);
79 	}
80 
initPrograms(vk::SourceCollections & programCollection) const81 	virtual void	initPrograms	(vk::SourceCollections& programCollection) const
82 	{
83 		for (ShaderMap::const_iterator i = m_shaderPaths.begin(); i != m_shaderPaths.end(); ++i)
84 		{
85 			programCollection.glslSources.add(i->second) <<
86 				glu::ShaderSource(i->first, ShaderSourceProvider::getSource(m_testCtx.getArchive(), i->second));
87 		}
88 	}
89 
checkSupport(Context & context) const90 	virtual void	checkSupport	(Context& context) const
91 	{
92 		m_support.checkSupport(context);
93 	}
94 
95 private:
96 	const ShaderMap	m_shaderPaths;
97 	const Support	m_support;
98 };
99 
100 } // DynamicState
101 } // vkt
102 
103 #endif // _VKTDYNAMICSTATETESTCASEUTIL_HPP
104