1 #ifndef _VKTDYNAMICSTATETESTCASEUTIL_HPP
2 #define _VKTDYNAMICSTATETESTCASEUTIL_HPP
3 /*------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2015 The Khronos Group Inc.
8 * Copyright (c) 2015 Intel Corporation
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and/or associated documentation files (the
12 * "Materials"), to deal in the Materials without restriction, including
13 * without limitation the rights to use, copy, modify, merge, publish,
14 * distribute, sublicense, and/or sell copies of the Materials, and to
15 * permit persons to whom the Materials are furnished to do so, subject to
16 * the following conditions:
18 * The above copyright notice(s) and this permission notice shall be included
19 * in all copies or substantial portions of the Materials.
21 * The Materials are Confidential Information as defined by the
22 * Khronos Membership Agreement until designated non-confidential by Khronos,
23 * at which point this condition clause shall be removed.
25 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
28 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
29 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
30 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
31 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
35 * \brief Dynamic State Tests Test Case Utilities
36 *//*--------------------------------------------------------------------*/
38 #include "tcuDefs.hpp"
39 #include "tcuResource.hpp"
41 #include "vktTestCase.hpp"
43 #include "gluShaderUtil.hpp"
44 #include "vkPrograms.hpp"
50 namespace DynamicState
53 struct PositionColorVertex
55 PositionColorVertex(const tcu::Vec4& position_, const tcu::Vec4& color_)
63 class ShaderSourceProvider
66 static std::string getSource(tcu::Archive& archive, const char* path)
68 tcu::Resource *resource = archive.getResource(path);
70 std::vector<deUint8> readBuffer(resource->getSize() + 1);
71 resource->read(&readBuffer[0], resource->getSize());
72 readBuffer[readBuffer.size() - 1] = 0;
74 return reinterpret_cast<const char*>(&readBuffer[0]);
78 typedef std::map<glu::ShaderType, const char*> ShaderMap;
80 template<typename Instance>
81 class InstanceFactory : public TestCase
84 InstanceFactory (tcu::TestContext& testCtx, const std::string& name, const std::string& desc,
85 const std::map<glu::ShaderType, const char*> shaderPaths)
86 : TestCase (testCtx, name, desc)
87 , m_shaderPaths (shaderPaths)
91 TestInstance* createInstance (Context& context) const
93 return new Instance(context, m_shaderPaths);
96 virtual void initPrograms (vk::SourceCollections& programCollection) const
98 for (ShaderMap::const_iterator i = m_shaderPaths.begin(); i != m_shaderPaths.end(); ++i)
100 programCollection.glslSources.add(i->second) <<
101 glu::ShaderSource(i->first, ShaderSourceProvider::getSource(m_testCtx.getArchive(), i->second));
106 const ShaderMap m_shaderPaths;
112 #endif // _VKTDYNAMICSTATETESTCASEUTIL_HPP