1 #ifndef _VKTPIPELINESPECCONSTANTUTIL_HPP
2 #define _VKTPIPELINESPECCONSTANTUTIL_HPP
3 /*------------------------------------------------------------------------
4  * Vulkan Conformance Tests
5  * ------------------------
6  *
7  * Copyright (c) 2016 The Khronos Group Inc.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief Pipeline specialization constants test utilities
24  *//*--------------------------------------------------------------------*/
25 
26 #include "vkDefs.hpp"
27 #include "vkRef.hpp"
28 #include "vkPrograms.hpp"
29 #include "vkMemUtil.hpp"
30 #include "vkRefUtil.hpp"
31 #include "vkQueryUtil.hpp"
32 #include "vktTestCase.hpp"
33 
34 namespace vkt
35 {
36 namespace pipeline
37 {
38 
39 class GraphicsPipelineBuilder
40 {
41 public:
GraphicsPipelineBuilder(void)42 														GraphicsPipelineBuilder			(void) : m_renderSize		(16, 16)
43 																							   , m_shaderStageFlags	(0u) {}
44 
setRenderSize(const tcu::IVec2 & size)45 	GraphicsPipelineBuilder&							setRenderSize					(const tcu::IVec2& size) { m_renderSize = size; return *this; }
46 	GraphicsPipelineBuilder&							setShader						(const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkShaderStageFlagBits stage, const vk::ProgramBinary& binary, const vk::VkSpecializationInfo* specInfo);
47 	vk::Move<vk::VkPipeline>							build							(const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkPipelineLayout pipelineLayout, const vk::VkRenderPass renderPass);
48 
49 private:
50 	tcu::IVec2											m_renderSize;
51 	vk::Move<vk::VkShaderModule>						m_vertexShaderModule;
52 	vk::Move<vk::VkShaderModule>						m_fragmentShaderModule;
53 	vk::Move<vk::VkShaderModule>						m_geometryShaderModule;
54 	vk::Move<vk::VkShaderModule>						m_tessControlShaderModule;
55 	vk::Move<vk::VkShaderModule>						m_tessEvaluationShaderModule;
56 	std::vector<vk::VkPipelineShaderStageCreateInfo>	m_shaderStages;
57 	vk::VkShaderStageFlags								m_shaderStageFlags;
58 
59 														GraphicsPipelineBuilder			(const GraphicsPipelineBuilder&); // "deleted"
60 	GraphicsPipelineBuilder&							operator=						(const GraphicsPipelineBuilder&);
61 };
62 
63 enum FeatureFlagBits
64 {
65 	FEATURE_TESSELLATION_SHADER					= 1u << 0,
66 	FEATURE_GEOMETRY_SHADER						= 1u << 1,
67 	FEATURE_SHADER_FLOAT_64						= 1u << 2,
68 	FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS	= 1u << 3,
69 	FEATURE_FRAGMENT_STORES_AND_ATOMICS			= 1u << 4,
70 	FEATURE_SHADER_INT_64						= 1u << 5,
71 	FEATURE_SHADER_INT_16						= 1u << 6,
72 	FEATURE_SHADER_FLOAT_16						= 1u << 7,
73 	FEATURE_SHADER_INT_8						= 1u << 8,
74 };
75 typedef deUint32 FeatureFlags;
76 
77 vk::VkImageCreateInfo			makeImageCreateInfo		(const tcu::IVec2& size, const vk::VkFormat format, const vk::VkImageUsageFlags usage);
78 void							requireFeatures			(vkt::Context& context, const FeatureFlags flags);
79 
80 // Ugly, brute-force replacement for the initializer list
81 
82 template<typename T>
makeVector(const T & o1)83 std::vector<T> makeVector (const T& o1)
84 {
85 	std::vector<T> vec;
86 	vec.reserve(1);
87 	vec.push_back(o1);
88 	return vec;
89 }
90 
91 template<typename T>
makeVector(const T & o1,const T & o2)92 std::vector<T> makeVector (const T& o1, const T& o2)
93 {
94 	std::vector<T> vec;
95 	vec.reserve(2);
96 	vec.push_back(o1);
97 	vec.push_back(o2);
98 	return vec;
99 }
100 
101 template<typename T>
makeVector(const T & o1,const T & o2,const T & o3)102 std::vector<T> makeVector (const T& o1, const T& o2, const T& o3)
103 {
104 	std::vector<T> vec;
105 	vec.reserve(3);
106 	vec.push_back(o1);
107 	vec.push_back(o2);
108 	vec.push_back(o3);
109 	return vec;
110 }
111 
112 template<typename T>
makeVector(const T & o1,const T & o2,const T & o3,const T & o4)113 std::vector<T> makeVector (const T& o1, const T& o2, const T& o3, const T& o4)
114 {
115 	std::vector<T> vec;
116 	vec.reserve(4);
117 	vec.push_back(o1);
118 	vec.push_back(o2);
119 	vec.push_back(o3);
120 	vec.push_back(o4);
121 	return vec;
122 }
123 
124 } // pipeline
125 } // vkt
126 
127 #endif // _VKTPIPELINESPECCONSTANTUTIL_HPP
128