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 * 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
14 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 * \brief Dynamic State Tests Test Case Utilities
25 *//*--------------------------------------------------------------------*/
27 #include "tcuDefs.hpp"
29 #include "vktTestCase.hpp"
30 #include "vktTestCaseUtil.hpp"
32 #include "gluShaderUtil.hpp"
33 #include "vkPrograms.hpp"
34 #include "vkPipelineConstructionUtil.hpp"
36 #include "deUniquePtr.hpp"
42 namespace DynamicState
45 struct PositionColorVertex
47 PositionColorVertex(const tcu::Vec4& position_, const tcu::Vec4& color_)
55 typedef std::map<glu::ShaderType, const char*> ShaderMap;
57 template<typename Instance, typename Support = NoSupport0>
58 class InstanceFactory : public TestCase
61 InstanceFactory (tcu::TestContext& testCtx, const std::string& name, const std::string& desc,
62 const vk::PipelineConstructionType pipelineConstructionType,
63 const ShaderMap& shaderPaths)
64 : TestCase (testCtx, name, desc)
65 , m_pipelineConstructionType (pipelineConstructionType)
66 , m_shaderPaths (shaderPaths)
71 InstanceFactory (tcu::TestContext& testCtx, const std::string& name, const std::string& desc,
72 const vk::PipelineConstructionType pipelineConstructionType,
73 const ShaderMap& shaderPaths, const Support& support)
74 : TestCase (testCtx, name, desc)
75 , m_pipelineConstructionType (pipelineConstructionType)
76 , m_shaderPaths (shaderPaths)
81 TestInstance* createInstance (Context& context) const
83 return new Instance(context, m_pipelineConstructionType, m_shaderPaths);
86 virtual void initPrograms (vk::SourceCollections& programCollection) const
88 const vk::ShaderBuildOptions defaultOptions (programCollection.usedVulkanVersion, vk::SPIRV_VERSION_1_0, 0u);
89 const vk::ShaderBuildOptions spv14Options (programCollection.usedVulkanVersion, vk::SPIRV_VERSION_1_4, 0u, true);
91 for (ShaderMap::const_iterator i = m_shaderPaths.begin(); i != m_shaderPaths.end(); ++i)
95 programCollection.glslSources.add(i->second)
96 << glu::ShaderSource(i->first, ShaderSourceProvider::getSource(m_testCtx.getArchive(), i->second))
97 << ((i->first == glu::SHADERTYPE_TASK || i->first == glu::SHADERTYPE_MESH) ? spv14Options : defaultOptions);
102 virtual void checkSupport (Context& context) const
104 checkPipelineLibraryRequirements(context.getInstanceInterface(), context.getPhysicalDevice(), m_pipelineConstructionType);
106 m_support.checkSupport(context);
110 const vk::PipelineConstructionType m_pipelineConstructionType;
111 const ShaderMap m_shaderPaths;
112 const Support m_support;
118 #endif // _VKTDYNAMICSTATETESTCASEUTIL_HPP