• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
33 namespace vkt
34 {
35 namespace pipeline
36 {
37 
38 class GraphicsPipelineBuilder
39 {
40 public:
GraphicsPipelineBuilder(void)41 														GraphicsPipelineBuilder			(void) : m_renderSize		(16, 16)
42 																							   , m_shaderStageFlags	(0u) {}
43 
setRenderSize(const tcu::IVec2 & size)44 	GraphicsPipelineBuilder&							setRenderSize					(const tcu::IVec2& size) { m_renderSize = size; return *this; }
45 	GraphicsPipelineBuilder&							setShader						(const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkShaderStageFlagBits stage, const vk::ProgramBinary& binary, const vk::VkSpecializationInfo* specInfo);
46 	vk::Move<vk::VkPipeline>							build							(const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkPipelineLayout pipelineLayout, const vk::VkRenderPass renderPass);
47 
48 private:
49 	tcu::IVec2											m_renderSize;
50 	vk::Move<vk::VkShaderModule>						m_vertexShaderModule;
51 	vk::Move<vk::VkShaderModule>						m_fragmentShaderModule;
52 	vk::Move<vk::VkShaderModule>						m_geometryShaderModule;
53 	vk::Move<vk::VkShaderModule>						m_tessControlShaderModule;
54 	vk::Move<vk::VkShaderModule>						m_tessEvaluationShaderModule;
55 	std::vector<vk::VkPipelineShaderStageCreateInfo>	m_shaderStages;
56 	vk::VkShaderStageFlags								m_shaderStageFlags;
57 
58 														GraphicsPipelineBuilder			(const GraphicsPipelineBuilder&); // "deleted"
59 	GraphicsPipelineBuilder&							operator=						(const GraphicsPipelineBuilder&);
60 };
61 
62 enum FeatureFlagBits
63 {
64 	FEATURE_TESSELLATION_SHADER					= 1u << 0,
65 	FEATURE_GEOMETRY_SHADER						= 1u << 1,
66 	FEATURE_SHADER_FLOAT_64						= 1u << 2,
67 	FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS	= 1u << 3,
68 	FEATURE_FRAGMENT_STORES_AND_ATOMICS			= 1u << 4,
69 };
70 typedef deUint32 FeatureFlags;
71 
72 vk::VkImageCreateInfo			makeImageCreateInfo		(const tcu::IVec2& size, const vk::VkFormat format, const vk::VkImageUsageFlags usage);
73 vk::Move<vk::VkRenderPass>		makeRenderPass			(const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkFormat colorFormat);
74 void							beginRenderPass			(const vk::DeviceInterface& vk, const vk::VkCommandBuffer commandBuffer, const vk::VkRenderPass renderPass, const vk::VkFramebuffer framebuffer, const vk::VkRect2D& renderArea, const tcu::Vec4& clearColor);
75 void							requireFeatures			(const vk::InstanceInterface& vki, const vk::VkPhysicalDevice physDevice, const FeatureFlags flags);
76 
77 // Ugly, brute-force replacement for the initializer list
78 
79 template<typename T>
makeVector(const T & o1)80 std::vector<T> makeVector (const T& o1)
81 {
82 	std::vector<T> vec;
83 	vec.reserve(1);
84 	vec.push_back(o1);
85 	return vec;
86 }
87 
88 template<typename T>
makeVector(const T & o1,const T & o2)89 std::vector<T> makeVector (const T& o1, const T& o2)
90 {
91 	std::vector<T> vec;
92 	vec.reserve(2);
93 	vec.push_back(o1);
94 	vec.push_back(o2);
95 	return vec;
96 }
97 
98 template<typename T>
makeVector(const T & o1,const T & o2,const T & o3)99 std::vector<T> makeVector (const T& o1, const T& o2, const T& o3)
100 {
101 	std::vector<T> vec;
102 	vec.reserve(3);
103 	vec.push_back(o1);
104 	vec.push_back(o2);
105 	vec.push_back(o3);
106 	return vec;
107 }
108 
109 template<typename T>
makeVector(const T & o1,const T & o2,const T & o3,const T & o4)110 std::vector<T> makeVector (const T& o1, const T& o2, const T& o3, const T& o4)
111 {
112 	std::vector<T> vec;
113 	vec.reserve(4);
114 	vec.push_back(o1);
115 	vec.push_back(o2);
116 	vec.push_back(o3);
117 	vec.push_back(o4);
118 	return vec;
119 }
120 
121 } // pipeline
122 } // vkt
123 
124 #endif // _VKTPIPELINESPECCONSTANTUTIL_HPP
125