• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * Vulkan CTS Framework
3  * --------------------
4  *
5  * Copyright (c) 2018 Google Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Utilities for creating commonly used Vulkan objects
22  *//*--------------------------------------------------------------------*/
23 
24 #include "vkDefs.hpp"
25 #include "vkRefUtil.hpp"
26 #include "vkImageUtil.hpp"
27 #include "vkObjUtil.hpp"
28 #include "vkTypeUtil.hpp"
29 #include "vkQueryUtil.hpp"
30 
31 #include "tcuVector.hpp"
32 
33 #include "deSTLUtil.hpp"
34 
35 namespace vk
36 {
37 
makeComputePipeline(const DeviceInterface & vk,const VkDevice device,const VkPipelineLayout pipelineLayout,const VkPipelineCreateFlags pipelineFlags,const VkShaderModule shaderModule,const VkPipelineShaderStageCreateFlags shaderFlags,const VkSpecializationInfo * specializationInfo)38 Move<VkPipeline> makeComputePipeline (const DeviceInterface&					vk,
39 									  const VkDevice							device,
40 									  const VkPipelineLayout					pipelineLayout,
41 									  const VkPipelineCreateFlags				pipelineFlags,
42 									  const VkShaderModule						shaderModule,
43 									  const VkPipelineShaderStageCreateFlags	shaderFlags,
44 									  const VkSpecializationInfo*				specializationInfo)
45 {
46 	const VkPipelineShaderStageCreateInfo pipelineShaderStageParams =
47 	{
48 		VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,	// VkStructureType						sType;
49 		nullptr,												// const void*							pNext;
50 		shaderFlags,											// VkPipelineShaderStageCreateFlags		flags;
51 		VK_SHADER_STAGE_COMPUTE_BIT,							// VkShaderStageFlagBits				stage;
52 		shaderModule,											// VkShaderModule						module;
53 		"main",													// const char*							pName;
54 		specializationInfo,										// const VkSpecializationInfo*			pSpecializationInfo;
55 	};
56 	const VkComputePipelineCreateInfo pipelineCreateInfo =
57 	{
58 		VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,		// VkStructureType					sType;
59 		nullptr,											// const void*						pNext;
60 		pipelineFlags,										// VkPipelineCreateFlags			flags;
61 		pipelineShaderStageParams,							// VkPipelineShaderStageCreateInfo	stage;
62 		pipelineLayout,										// VkPipelineLayout					layout;
63 		DE_NULL,											// VkPipeline						basePipelineHandle;
64 		0,													// deInt32							basePipelineIndex;
65 	};
66 	return createComputePipeline(vk, device, DE_NULL , &pipelineCreateInfo);
67 }
68 
makeGraphicsPipeline(const DeviceInterface & vk,const VkDevice device,const VkPipelineLayout pipelineLayout,const VkShaderModule vertexShaderModule,const VkShaderModule tessellationControlShaderModule,const VkShaderModule tessellationEvalShaderModule,const VkShaderModule geometryShaderModule,const VkShaderModule fragmentShaderModule,const VkRenderPass renderPass,const std::vector<VkViewport> & viewports,const std::vector<VkRect2D> & scissors,const VkPrimitiveTopology topology,const deUint32 subpass,const deUint32 patchControlPoints,const VkPipelineVertexInputStateCreateInfo * vertexInputStateCreateInfo,const VkPipelineRasterizationStateCreateInfo * rasterizationStateCreateInfo,const VkPipelineMultisampleStateCreateInfo * multisampleStateCreateInfo,const VkPipelineDepthStencilStateCreateInfo * depthStencilStateCreateInfo,const VkPipelineColorBlendStateCreateInfo * colorBlendStateCreateInfo,const VkPipelineDynamicStateCreateInfo * dynamicStateCreateInfo,const void * pNext)69 Move<VkPipeline> makeGraphicsPipeline(const DeviceInterface&						vk,
70 									  const VkDevice								device,
71 									  const VkPipelineLayout						pipelineLayout,
72 									  const VkShaderModule							vertexShaderModule,
73 									  const VkShaderModule							tessellationControlShaderModule,
74 									  const VkShaderModule							tessellationEvalShaderModule,
75 									  const VkShaderModule							geometryShaderModule,
76 									  const VkShaderModule							fragmentShaderModule,
77 									  const VkRenderPass							renderPass,
78 									  const std::vector<VkViewport>&				viewports,
79 									  const std::vector<VkRect2D>&					scissors,
80 									  const VkPrimitiveTopology						topology,
81 									  const deUint32								subpass,
82 									  const deUint32								patchControlPoints,
83 									  const VkPipelineVertexInputStateCreateInfo*	vertexInputStateCreateInfo,
84 									  const VkPipelineRasterizationStateCreateInfo*	rasterizationStateCreateInfo,
85 									  const VkPipelineMultisampleStateCreateInfo*	multisampleStateCreateInfo,
86 									  const VkPipelineDepthStencilStateCreateInfo*	depthStencilStateCreateInfo,
87 									  const VkPipelineColorBlendStateCreateInfo*	colorBlendStateCreateInfo,
88 									  const VkPipelineDynamicStateCreateInfo*		dynamicStateCreateInfo,
89 									  const void*									pNext)
90 {
91 	const VkPipelineInputAssemblyStateCreateInfo	inputAssemblyStateCreateInfo		=
92 	{
93 		VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,	// VkStructureType                            sType
94 		DE_NULL,														// const void*                                pNext
95 		0u,																// VkPipelineInputAssemblyStateCreateFlags    flags
96 		topology,														// VkPrimitiveTopology                        topology
97 		VK_FALSE														// VkBool32                                   primitiveRestartEnable
98 	};
99 
100 	const VkPipelineTessellationStateCreateInfo		tessStateCreateInfo					=
101 	{
102 		VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,	// VkStructureType                           sType
103 		DE_NULL,													// const void*                               pNext
104 		0u,															// VkPipelineTessellationStateCreateFlags    flags
105 		patchControlPoints											// deUint32                                  patchControlPoints
106 	};
107 
108 	const VkPipelineViewportStateCreateInfo			viewportStateCreateInfo				=
109 	{
110 		VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,	// VkStructureType                             sType
111 		DE_NULL,												// const void*                                 pNext
112 		(VkPipelineViewportStateCreateFlags)0,					// VkPipelineViewportStateCreateFlags          flags
113 		viewports.empty() ? 1u : (deUint32)viewports.size(),	// deUint32                                    viewportCount
114 		viewports.empty() ? DE_NULL : &viewports[0],			// const VkViewport*                           pViewports
115 		viewports.empty() ? 1u : (deUint32)scissors.size(),		// deUint32                                    scissorCount
116 		scissors.empty() ? DE_NULL : &scissors[0]				// const VkRect2D*                             pScissors
117 	};
118 
119 	std::vector<VkDynamicState>						dynamicStates;
120 
121 	if (viewports.empty())
122 		dynamicStates.push_back(VK_DYNAMIC_STATE_VIEWPORT);
123 	if (scissors.empty())
124 		dynamicStates.push_back(VK_DYNAMIC_STATE_SCISSOR);
125 
126 	const VkPipelineDynamicStateCreateInfo			dynamicStateCreateInfoDefault		=
127 	{
128 		VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,	// VkStructureType                      sType
129 		DE_NULL,												// const void*                          pNext
130 		0u,														// VkPipelineDynamicStateCreateFlags    flags
131 		(deUint32)dynamicStates.size(),							// deUint32                             dynamicStateCount
132 		dynamicStates.empty() ? DE_NULL : &dynamicStates[0]		// const VkDynamicState*                pDynamicStates
133 	};
134 
135 	const VkPipelineDynamicStateCreateInfo*			dynamicStateCreateInfoDefaultPtr	= dynamicStates.empty() ? DE_NULL : &dynamicStateCreateInfoDefault;
136 
137 	return makeGraphicsPipeline (vk, device, pipelineLayout, vertexShaderModule, tessellationControlShaderModule,
138 								 tessellationEvalShaderModule, geometryShaderModule, fragmentShaderModule,
139 								 renderPass, subpass, vertexInputStateCreateInfo, &inputAssemblyStateCreateInfo,
140 								 &tessStateCreateInfo, &viewportStateCreateInfo, rasterizationStateCreateInfo,
141 								 multisampleStateCreateInfo, depthStencilStateCreateInfo, colorBlendStateCreateInfo,
142 								 dynamicStateCreateInfo ? dynamicStateCreateInfo : dynamicStateCreateInfoDefaultPtr,
143 								 pNext);
144 }
145 
makeGraphicsPipeline(const DeviceInterface & vk,const VkDevice device,const VkPipelineLayout pipelineLayout,const VkShaderModule vertexShaderModule,const VkShaderModule tessellationControlShaderModule,const VkShaderModule tessellationEvalShaderModule,const VkShaderModule geometryShaderModule,const VkShaderModule fragmentShaderModule,const VkRenderPass renderPass,const deUint32 subpass,const VkPipelineVertexInputStateCreateInfo * vertexInputStateCreateInfo,const VkPipelineInputAssemblyStateCreateInfo * inputAssemblyStateCreateInfo,const VkPipelineTessellationStateCreateInfo * tessStateCreateInfo,const VkPipelineViewportStateCreateInfo * viewportStateCreateInfo,const VkPipelineRasterizationStateCreateInfo * rasterizationStateCreateInfo,const VkPipelineMultisampleStateCreateInfo * multisampleStateCreateInfo,const VkPipelineDepthStencilStateCreateInfo * depthStencilStateCreateInfo,const VkPipelineColorBlendStateCreateInfo * colorBlendStateCreateInfo,const VkPipelineDynamicStateCreateInfo * dynamicStateCreateInfo,const void * pNext)146 Move<VkPipeline> makeGraphicsPipeline (const DeviceInterface&							vk,
147 									   const VkDevice									device,
148 									   const VkPipelineLayout							pipelineLayout,
149 									   const VkShaderModule								vertexShaderModule,
150 									   const VkShaderModule								tessellationControlShaderModule,
151 									   const VkShaderModule								tessellationEvalShaderModule,
152 									   const VkShaderModule								geometryShaderModule,
153 									   const VkShaderModule								fragmentShaderModule,
154 									   const VkRenderPass								renderPass,
155 									   const deUint32									subpass,
156 									   const VkPipelineVertexInputStateCreateInfo*		vertexInputStateCreateInfo,
157 									   const VkPipelineInputAssemblyStateCreateInfo*	inputAssemblyStateCreateInfo,
158 									   const VkPipelineTessellationStateCreateInfo*		tessStateCreateInfo,
159 									   const VkPipelineViewportStateCreateInfo*			viewportStateCreateInfo,
160 									   const VkPipelineRasterizationStateCreateInfo*	rasterizationStateCreateInfo,
161 									   const VkPipelineMultisampleStateCreateInfo*		multisampleStateCreateInfo,
162 									   const VkPipelineDepthStencilStateCreateInfo*		depthStencilStateCreateInfo,
163 									   const VkPipelineColorBlendStateCreateInfo*		colorBlendStateCreateInfo,
164 									   const VkPipelineDynamicStateCreateInfo*			dynamicStateCreateInfo,
165 									   const void*										pNext)
166 {
167 	DE_ASSERT(tessStateCreateInfo || (tessellationControlShaderModule == DE_NULL && tessellationEvalShaderModule == DE_NULL));
168 
169 	const VkBool32									disableRasterization				= (fragmentShaderModule == DE_NULL);
170 
171 	VkPipelineShaderStageCreateInfo					stageCreateInfo						=
172 	{
173 		VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,	// VkStructureType                     sType
174 		DE_NULL,												// const void*                         pNext
175 		0u,														// VkPipelineShaderStageCreateFlags    flags
176 		VK_SHADER_STAGE_VERTEX_BIT,								// VkShaderStageFlagBits               stage
177 		DE_NULL,												// VkShaderModule                      module
178 		"main",													// const char*                         pName
179 		DE_NULL													// const VkSpecializationInfo*         pSpecializationInfo
180 	};
181 
182 	std::vector<VkPipelineShaderStageCreateInfo>	pipelineShaderStageParams;
183 
184 	{
185 		stageCreateInfo.stage	= VK_SHADER_STAGE_VERTEX_BIT;
186 		stageCreateInfo.module	= vertexShaderModule;
187 		pipelineShaderStageParams.push_back(stageCreateInfo);
188 	}
189 
190 	if (tessellationControlShaderModule != DE_NULL)
191 	{
192 		stageCreateInfo.stage	= VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT;
193 		stageCreateInfo.module	= tessellationControlShaderModule;
194 		pipelineShaderStageParams.push_back(stageCreateInfo);
195 	}
196 
197 	if (tessellationEvalShaderModule != DE_NULL)
198 	{
199 		stageCreateInfo.stage	= VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT;
200 		stageCreateInfo.module	= tessellationEvalShaderModule;
201 		pipelineShaderStageParams.push_back(stageCreateInfo);
202 	}
203 
204 	if (geometryShaderModule != DE_NULL)
205 	{
206 		stageCreateInfo.stage	= VK_SHADER_STAGE_GEOMETRY_BIT;
207 		stageCreateInfo.module	= geometryShaderModule;
208 		pipelineShaderStageParams.push_back(stageCreateInfo);
209 	}
210 
211 	if (fragmentShaderModule != DE_NULL)
212 	{
213 		stageCreateInfo.stage	= VK_SHADER_STAGE_FRAGMENT_BIT;
214 		stageCreateInfo.module	= fragmentShaderModule;
215 		pipelineShaderStageParams.push_back(stageCreateInfo);
216 	}
217 
218 	const VkVertexInputBindingDescription			vertexInputBindingDescription		=
219 	{
220 		0u,								// deUint32             binding
221 		sizeof(tcu::Vec4),				// deUint32             stride
222 		VK_VERTEX_INPUT_RATE_VERTEX,	// VkVertexInputRate    inputRate
223 	};
224 
225 	const VkVertexInputAttributeDescription			vertexInputAttributeDescription		=
226 	{
227 		0u,								// deUint32    location
228 		0u,								// deUint32    binding
229 		VK_FORMAT_R32G32B32A32_SFLOAT,	// VkFormat    format
230 		0u								// deUint32    offset
231 	};
232 
233 	const VkPipelineVertexInputStateCreateInfo		vertexInputStateCreateInfoDefault	=
234 	{
235 		VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,	// VkStructureType                             sType
236 		DE_NULL,													// const void*                                 pNext
237 		(VkPipelineVertexInputStateCreateFlags)0,					// VkPipelineVertexInputStateCreateFlags       flags
238 		1u,															// deUint32                                    vertexBindingDescriptionCount
239 		&vertexInputBindingDescription,								// const VkVertexInputBindingDescription*      pVertexBindingDescriptions
240 		1u,															// deUint32                                    vertexAttributeDescriptionCount
241 		&vertexInputAttributeDescription							// const VkVertexInputAttributeDescription*    pVertexAttributeDescriptions
242 	};
243 
244 	const VkPipelineInputAssemblyStateCreateInfo	inputAssemblyStateCreateInfoDefault	=
245 	{
246 		VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,	// VkStructureType                            sType
247 		DE_NULL,														// const void*                                pNext
248 		0u,																// VkPipelineInputAssemblyStateCreateFlags    flags
249 		VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,							// VkPrimitiveTopology                        topology
250 		VK_FALSE														// VkBool32                                   primitiveRestartEnable
251 	};
252 
253 	const VkViewport								viewport							= makeViewport(256, 256);
254 	const VkRect2D									scissor								= makeRect2D(256, 256);
255 
256 	const VkPipelineViewportStateCreateInfo			viewportStateCreateInfoDefault		=
257 	{
258 		VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,	// VkStructureType                             sType
259 		DE_NULL,												// const void*                                 pNext
260 		(VkPipelineViewportStateCreateFlags)0,					// VkPipelineViewportStateCreateFlags          flags
261 		1u,														// deUint32                                    viewportCount
262 		&viewport,												// const VkViewport*                           pViewports
263 		1u,														// deUint32                                    scissorCount
264 		&scissor												// const VkRect2D*                             pScissors
265 	};
266 
267 	const VkPipelineRasterizationStateCreateInfo	rasterizationStateCreateInfoDefault	=
268 	{
269 		VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,	// VkStructureType                            sType
270 		DE_NULL,													// const void*                                pNext
271 		0u,															// VkPipelineRasterizationStateCreateFlags    flags
272 		VK_FALSE,													// VkBool32                                   depthClampEnable
273 		disableRasterization,										// VkBool32                                   rasterizerDiscardEnable
274 		VK_POLYGON_MODE_FILL,										// VkPolygonMode                              polygonMode
275 		VK_CULL_MODE_NONE,											// VkCullModeFlags                            cullMode
276 		VK_FRONT_FACE_COUNTER_CLOCKWISE,							// VkFrontFace                                frontFace
277 		VK_FALSE,													// VkBool32                                   depthBiasEnable
278 		0.0f,														// float                                      depthBiasConstantFactor
279 		0.0f,														// float                                      depthBiasClamp
280 		0.0f,														// float                                      depthBiasSlopeFactor
281 		1.0f														// float                                      lineWidth
282 	};
283 
284 	const VkPipelineMultisampleStateCreateInfo		multisampleStateCreateInfoDefault	=
285 	{
286 		VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,	// VkStructureType                          sType
287 		DE_NULL,													// const void*                              pNext
288 		0u,															// VkPipelineMultisampleStateCreateFlags    flags
289 		VK_SAMPLE_COUNT_1_BIT,										// VkSampleCountFlagBits                    rasterizationSamples
290 		VK_FALSE,													// VkBool32                                 sampleShadingEnable
291 		1.0f,														// float                                    minSampleShading
292 		DE_NULL,													// const VkSampleMask*                      pSampleMask
293 		VK_FALSE,													// VkBool32                                 alphaToCoverageEnable
294 		VK_FALSE													// VkBool32                                 alphaToOneEnable
295 	};
296 
297 	const VkStencilOpState							stencilOpState						=
298 	{
299 		VK_STENCIL_OP_KEEP,		// VkStencilOp    failOp
300 		VK_STENCIL_OP_KEEP,		// VkStencilOp    passOp
301 		VK_STENCIL_OP_KEEP,		// VkStencilOp    depthFailOp
302 		VK_COMPARE_OP_NEVER,	// VkCompareOp    compareOp
303 		0,						// deUint32       compareMask
304 		0,						// deUint32       writeMask
305 		0						// deUint32       reference
306 	};
307 
308 	const VkPipelineDepthStencilStateCreateInfo		depthStencilStateCreateInfoDefault	=
309 	{
310 		VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,	// VkStructureType                          sType
311 		DE_NULL,													// const void*                              pNext
312 		0u,															// VkPipelineDepthStencilStateCreateFlags   flags
313 		VK_FALSE,													// VkBool32                                 depthTestEnable
314 		VK_FALSE,													// VkBool32                                 depthWriteEnable
315 		VK_COMPARE_OP_LESS_OR_EQUAL,								// VkCompareOp                              depthCompareOp
316 		VK_FALSE,													// VkBool32                                 depthBoundsTestEnable
317 		VK_FALSE,													// VkBool32                                 stencilTestEnable
318 		stencilOpState,												// VkStencilOpState                         front
319 		stencilOpState,												// VkStencilOpState                         back
320 		0.0f,														// float                                    minDepthBounds
321 		1.0f,														// float                                    maxDepthBounds
322 	};
323 
324 	const VkPipelineColorBlendAttachmentState		colorBlendAttachmentState			=
325 	{
326 		VK_FALSE,					// VkBool32                 blendEnable
327 		VK_BLEND_FACTOR_ZERO,		// VkBlendFactor            srcColorBlendFactor
328 		VK_BLEND_FACTOR_ZERO,		// VkBlendFactor            dstColorBlendFactor
329 		VK_BLEND_OP_ADD,			// VkBlendOp                colorBlendOp
330 		VK_BLEND_FACTOR_ZERO,		// VkBlendFactor            srcAlphaBlendFactor
331 		VK_BLEND_FACTOR_ZERO,		// VkBlendFactor            dstAlphaBlendFactor
332 		VK_BLEND_OP_ADD,			// VkBlendOp                alphaBlendOp
333 		VK_COLOR_COMPONENT_R_BIT	// VkColorComponentFlags    colorWriteMask
334 		| VK_COLOR_COMPONENT_G_BIT
335 		| VK_COLOR_COMPONENT_B_BIT
336 		| VK_COLOR_COMPONENT_A_BIT
337 	};
338 
339 	const VkPipelineColorBlendStateCreateInfo		colorBlendStateCreateInfoDefault	=
340 	{
341 		VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,	// VkStructureType                               sType
342 		DE_NULL,													// const void*                                   pNext
343 		0u,															// VkPipelineColorBlendStateCreateFlags          flags
344 		VK_FALSE,													// VkBool32                                      logicOpEnable
345 		VK_LOGIC_OP_CLEAR,											// VkLogicOp                                     logicOp
346 		1u,															// deUint32                                      attachmentCount
347 		&colorBlendAttachmentState,									// const VkPipelineColorBlendAttachmentState*    pAttachments
348 		{ 0.0f, 0.0f, 0.0f, 0.0f }									// float                                         blendConstants[4]
349 	};
350 
351 	const VkGraphicsPipelineCreateInfo				pipelineCreateInfo					=
352 	{
353 		VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,														// VkStructureType                                  sType
354 		pNext,																									// const void*                                      pNext
355 		0u,																										// VkPipelineCreateFlags                            flags
356 		(deUint32)pipelineShaderStageParams.size(),																// deUint32                                         stageCount
357 		&pipelineShaderStageParams[0],																			// const VkPipelineShaderStageCreateInfo*           pStages
358 		vertexInputStateCreateInfo ? vertexInputStateCreateInfo : &vertexInputStateCreateInfoDefault,			// const VkPipelineVertexInputStateCreateInfo*      pVertexInputState
359 		inputAssemblyStateCreateInfo ? inputAssemblyStateCreateInfo : &inputAssemblyStateCreateInfoDefault,		// const VkPipelineInputAssemblyStateCreateInfo*    pInputAssemblyState
360 		tessStateCreateInfo,																					// const VkPipelineTessellationStateCreateInfo*     pTessellationState
361 		viewportStateCreateInfo ? viewportStateCreateInfo : &viewportStateCreateInfoDefault,					// const VkPipelineViewportStateCreateInfo*         pViewportState
362 		rasterizationStateCreateInfo ? rasterizationStateCreateInfo : &rasterizationStateCreateInfoDefault,		// const VkPipelineRasterizationStateCreateInfo*    pRasterizationState
363 		multisampleStateCreateInfo ? multisampleStateCreateInfo: &multisampleStateCreateInfoDefault,			// const VkPipelineMultisampleStateCreateInfo*      pMultisampleState
364 		depthStencilStateCreateInfo ? depthStencilStateCreateInfo : &depthStencilStateCreateInfoDefault,		// const VkPipelineDepthStencilStateCreateInfo*     pDepthStencilState
365 		colorBlendStateCreateInfo ? colorBlendStateCreateInfo : &colorBlendStateCreateInfoDefault,				// const VkPipelineColorBlendStateCreateInfo*       pColorBlendState
366 		dynamicStateCreateInfo ? dynamicStateCreateInfo : DE_NULL,												// const VkPipelineDynamicStateCreateInfo*          pDynamicState
367 		pipelineLayout,																							// VkPipelineLayout                                 layout
368 		renderPass,																								// VkRenderPass                                     renderPass
369 		subpass,																								// deUint32                                         subpass
370 		DE_NULL,																								// VkPipeline                                       basePipelineHandle
371 		0																										// deInt32                                          basePipelineIndex;
372 	};
373 
374 	return createGraphicsPipeline(vk, device, DE_NULL, &pipelineCreateInfo);
375 }
376 
makeGraphicsPipeline(const DeviceInterface & vk,const VkDevice device,const VkPipelineLayout pipelineLayout,const VkShaderModule taskShaderModule,const VkShaderModule meshShaderModule,const VkShaderModule fragmentShaderModule,const VkRenderPass renderPass,const std::vector<VkViewport> & viewports,const std::vector<VkRect2D> & scissors,const deUint32 subpass,const VkPipelineRasterizationStateCreateInfo * rasterizationStateCreateInfo,const VkPipelineMultisampleStateCreateInfo * multisampleStateCreateInfo,const VkPipelineDepthStencilStateCreateInfo * depthStencilStateCreateInfo,const VkPipelineColorBlendStateCreateInfo * colorBlendStateCreateInfo,const VkPipelineDynamicStateCreateInfo * dynamicStateCreateInfo)377 Move<VkPipeline> makeGraphicsPipeline (const DeviceInterface&							vk,
378 									   const VkDevice									device,
379 									   const VkPipelineLayout							pipelineLayout,
380 									   const VkShaderModule								taskShaderModule,
381 									   const VkShaderModule								meshShaderModule,
382 									   const VkShaderModule								fragmentShaderModule,
383 									   const VkRenderPass								renderPass,
384 									   const std::vector<VkViewport>&					viewports,
385 									   const std::vector<VkRect2D>&						scissors,
386 									   const deUint32									subpass,
387 									   const VkPipelineRasterizationStateCreateInfo*	rasterizationStateCreateInfo,
388 									   const VkPipelineMultisampleStateCreateInfo*		multisampleStateCreateInfo,
389 									   const VkPipelineDepthStencilStateCreateInfo*		depthStencilStateCreateInfo,
390 									   const VkPipelineColorBlendStateCreateInfo*		colorBlendStateCreateInfo,
391 									   const VkPipelineDynamicStateCreateInfo*			dynamicStateCreateInfo)
392 {
393 	const VkBool32									disableRasterization				= (fragmentShaderModule == DE_NULL);
394 
395 	VkPipelineShaderStageCreateInfo					stageCreateInfo						=
396 	{
397 		VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,	// VkStructureType                     sType
398 		nullptr,												// const void*                         pNext
399 		0u,														// VkPipelineShaderStageCreateFlags    flags
400 		VK_SHADER_STAGE_VERTEX_BIT,								// VkShaderStageFlagBits               stage
401 		DE_NULL,												// VkShaderModule                      module
402 		"main",													// const char*                         pName
403 		nullptr													// const VkSpecializationInfo*         pSpecializationInfo
404 	};
405 
406 	std::vector<VkPipelineShaderStageCreateInfo>	pipelineShaderStageParams;
407 
408 	if (taskShaderModule != DE_NULL)
409 	{
410 		stageCreateInfo.stage	= VK_SHADER_STAGE_TASK_BIT_NV;
411 		stageCreateInfo.module	= taskShaderModule;
412 		pipelineShaderStageParams.push_back(stageCreateInfo);
413 	}
414 
415 	{
416 		stageCreateInfo.stage	= VK_SHADER_STAGE_MESH_BIT_NV;
417 		stageCreateInfo.module	= meshShaderModule;
418 		pipelineShaderStageParams.push_back(stageCreateInfo);
419 	}
420 
421 	if (fragmentShaderModule != DE_NULL)
422 	{
423 		stageCreateInfo.stage	= VK_SHADER_STAGE_FRAGMENT_BIT;
424 		stageCreateInfo.module	= fragmentShaderModule;
425 		pipelineShaderStageParams.push_back(stageCreateInfo);
426 	}
427 
428 	VkPipelineViewportStateCreateInfo viewportStateCreateInfo = initVulkanStructure();
429 	viewportStateCreateInfo.viewportCount	= static_cast<uint32_t>(viewports.size());
430 	viewportStateCreateInfo.pViewports		= de::dataOrNull(viewports);
431 	viewportStateCreateInfo.scissorCount	= static_cast<uint32_t>(scissors.size());
432 	viewportStateCreateInfo.pScissors		= de::dataOrNull(scissors);
433 
434 	VkPipelineRasterizationStateCreateInfo rasterizationStateCreateInfoDefault = initVulkanStructure();
435 	rasterizationStateCreateInfoDefault.rasterizerDiscardEnable	= disableRasterization;
436 	rasterizationStateCreateInfoDefault.lineWidth				= 1.0f;
437 
438 	VkPipelineMultisampleStateCreateInfo multisampleStateCreateInfoDefault = initVulkanStructure();
439 	multisampleStateCreateInfoDefault.rasterizationSamples	= VK_SAMPLE_COUNT_1_BIT;
440 	multisampleStateCreateInfoDefault.minSampleShading		= 1.0f;
441 
442 	VkPipelineDepthStencilStateCreateInfo depthStencilStateCreateInfoDefault = initVulkanStructure();
443 	depthStencilStateCreateInfoDefault.maxDepthBounds = 1.0f;
444 
445 	VkPipelineColorBlendAttachmentState colorBlendAttachmentState = {};
446 	colorBlendAttachmentState.colorWriteMask = (VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT);
447 
448 	VkPipelineColorBlendStateCreateInfo colorBlendStateCreateInfoDefault = initVulkanStructure();
449 	colorBlendStateCreateInfoDefault.attachmentCount	= 1u;
450 	colorBlendStateCreateInfoDefault.pAttachments		= &colorBlendAttachmentState;
451 
452 	std::vector<VkDynamicState> dynamicStates;
453 
454 	if (viewports.empty())
455 		dynamicStates.push_back(VK_DYNAMIC_STATE_VIEWPORT);
456 	if (scissors.empty())
457 		dynamicStates.push_back(VK_DYNAMIC_STATE_SCISSOR);
458 
459 	VkPipelineDynamicStateCreateInfo dynamicStateCreateInfoDefault = initVulkanStructure();
460 	dynamicStateCreateInfoDefault.dynamicStateCount	= static_cast<uint32_t>(dynamicStates.size());
461 	dynamicStateCreateInfoDefault.pDynamicStates	= de::dataOrNull(dynamicStates);
462 
463 	const VkPipelineDynamicStateCreateInfo*	dynamicStateCreateInfoDefaultPtr	= dynamicStates.empty() ? nullptr : &dynamicStateCreateInfoDefault;
464 
465 	const VkGraphicsPipelineCreateInfo		pipelineCreateInfo					=
466 	{
467 		VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,														// VkStructureType                                  sType
468 		nullptr,																								// const void*                                      pNext
469 		0u,																										// VkPipelineCreateFlags                            flags
470 		static_cast<uint32_t>(pipelineShaderStageParams.size()),												// deUint32                                         stageCount
471 		de::dataOrNull(pipelineShaderStageParams),																// const VkPipelineShaderStageCreateInfo*           pStages
472 		nullptr,																								// const VkPipelineVertexInputStateCreateInfo*      pVertexInputState
473 		nullptr,																								// const VkPipelineInputAssemblyStateCreateInfo*    pInputAssemblyState
474 		nullptr,																								// const VkPipelineTessellationStateCreateInfo*     pTessellationState
475 		&viewportStateCreateInfo,																				// const VkPipelineViewportStateCreateInfo*         pViewportState
476 		rasterizationStateCreateInfo	? rasterizationStateCreateInfo	: &rasterizationStateCreateInfoDefault,	// const VkPipelineRasterizationStateCreateInfo*    pRasterizationState
477 		multisampleStateCreateInfo		? multisampleStateCreateInfo	: &multisampleStateCreateInfoDefault,	// const VkPipelineMultisampleStateCreateInfo*      pMultisampleState
478 		depthStencilStateCreateInfo		? depthStencilStateCreateInfo	: &depthStencilStateCreateInfoDefault,	// const VkPipelineDepthStencilStateCreateInfo*     pDepthStencilState
479 		colorBlendStateCreateInfo		? colorBlendStateCreateInfo		: &colorBlendStateCreateInfoDefault,	// const VkPipelineColorBlendStateCreateInfo*       pColorBlendState
480 		dynamicStateCreateInfo			? dynamicStateCreateInfo		: dynamicStateCreateInfoDefaultPtr,		// const VkPipelineDynamicStateCreateInfo*          pDynamicState
481 		pipelineLayout,																							// VkPipelineLayout                                 layout
482 		renderPass,																								// VkRenderPass                                     renderPass
483 		subpass,																								// deUint32                                         subpass
484 		DE_NULL,																								// VkPipeline                                       basePipelineHandle
485 		0																										// deInt32                                          basePipelineIndex;
486 	};
487 
488 	return createGraphicsPipeline(vk, device, DE_NULL, &pipelineCreateInfo);
489 }
490 
makeRenderPass(const DeviceInterface & vk,const VkDevice device,const VkFormat colorFormat,const VkFormat depthStencilFormat,const VkAttachmentLoadOp loadOperation,const VkImageLayout finalLayoutColor,const VkImageLayout finalLayoutDepthStencil,const VkImageLayout subpassLayoutColor,const VkImageLayout subpassLayoutDepthStencil,const VkAllocationCallbacks * const allocationCallbacks)491 Move<VkRenderPass> makeRenderPass (const DeviceInterface&				vk,
492 								   const VkDevice						device,
493 								   const VkFormat						colorFormat,
494 								   const VkFormat						depthStencilFormat,
495 								   const VkAttachmentLoadOp				loadOperation,
496 								   const VkImageLayout					finalLayoutColor,
497 								   const VkImageLayout					finalLayoutDepthStencil,
498 								   const VkImageLayout					subpassLayoutColor,
499 								   const VkImageLayout					subpassLayoutDepthStencil,
500 								   const VkAllocationCallbacks* const	allocationCallbacks)
501 {
502 	const bool								hasColor							= colorFormat != VK_FORMAT_UNDEFINED;
503 	const bool								hasDepthStencil						= depthStencilFormat != VK_FORMAT_UNDEFINED;
504 	const VkImageLayout						initialLayoutColor					= loadOperation == VK_ATTACHMENT_LOAD_OP_LOAD ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED;
505 	const VkImageLayout						initialLayoutDepthStencil			= loadOperation == VK_ATTACHMENT_LOAD_OP_LOAD ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED;
506 
507 	const VkAttachmentDescription			colorAttachmentDescription			=
508 	{
509 		(VkAttachmentDescriptionFlags)0,	// VkAttachmentDescriptionFlags    flags
510 		colorFormat,						// VkFormat                        format
511 		VK_SAMPLE_COUNT_1_BIT,				// VkSampleCountFlagBits           samples
512 		loadOperation,						// VkAttachmentLoadOp              loadOp
513 		VK_ATTACHMENT_STORE_OP_STORE,		// VkAttachmentStoreOp             storeOp
514 		VK_ATTACHMENT_LOAD_OP_DONT_CARE,	// VkAttachmentLoadOp              stencilLoadOp
515 		VK_ATTACHMENT_STORE_OP_DONT_CARE,	// VkAttachmentStoreOp             stencilStoreOp
516 		initialLayoutColor,					// VkImageLayout                   initialLayout
517 		finalLayoutColor					// VkImageLayout                   finalLayout
518 	};
519 
520 	const VkAttachmentDescription			depthStencilAttachmentDescription	=
521 	{
522 		(VkAttachmentDescriptionFlags)0,	// VkAttachmentDescriptionFlags    flags
523 		depthStencilFormat,					// VkFormat                        format
524 		VK_SAMPLE_COUNT_1_BIT,				// VkSampleCountFlagBits           samples
525 		loadOperation,						// VkAttachmentLoadOp              loadOp
526 		VK_ATTACHMENT_STORE_OP_STORE,		// VkAttachmentStoreOp             storeOp
527 		loadOperation,						// VkAttachmentLoadOp              stencilLoadOp
528 		VK_ATTACHMENT_STORE_OP_STORE,		// VkAttachmentStoreOp             stencilStoreOp
529 		initialLayoutDepthStencil,			// VkImageLayout                   initialLayout
530 		finalLayoutDepthStencil				// VkImageLayout                   finalLayout
531 	};
532 
533 	std::vector<VkAttachmentDescription>	attachmentDescriptions;
534 
535 	if (hasColor)
536 		attachmentDescriptions.push_back(colorAttachmentDescription);
537 	if (hasDepthStencil)
538 		attachmentDescriptions.push_back(depthStencilAttachmentDescription);
539 
540 	const VkAttachmentReference				colorAttachmentRef					=
541 	{
542 		0u,					// deUint32         attachment
543 		subpassLayoutColor	// VkImageLayout    layout
544 	};
545 
546 	const VkAttachmentReference				depthStencilAttachmentRef			=
547 	{
548 		hasColor ? 1u : 0u,			// deUint32         attachment
549 		subpassLayoutDepthStencil	// VkImageLayout    layout
550 	};
551 
552 	const VkSubpassDescription				subpassDescription					=
553 	{
554 		(VkSubpassDescriptionFlags)0,							// VkSubpassDescriptionFlags       flags
555 		VK_PIPELINE_BIND_POINT_GRAPHICS,						// VkPipelineBindPoint             pipelineBindPoint
556 		0u,														// deUint32                        inputAttachmentCount
557 		DE_NULL,												// const VkAttachmentReference*    pInputAttachments
558 		hasColor ? 1u : 0u,										// deUint32                        colorAttachmentCount
559 		hasColor ? &colorAttachmentRef : DE_NULL,				// const VkAttachmentReference*    pColorAttachments
560 		DE_NULL,												// const VkAttachmentReference*    pResolveAttachments
561 		hasDepthStencil ? &depthStencilAttachmentRef : DE_NULL,	// const VkAttachmentReference*    pDepthStencilAttachment
562 		0u,														// deUint32                        preserveAttachmentCount
563 		DE_NULL													// const deUint32*                 pPreserveAttachments
564 	};
565 
566 	const VkRenderPassCreateInfo			renderPassInfo						=
567 	{
568 		VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,									// VkStructureType                   sType
569 		DE_NULL,																	// const void*                       pNext
570 		(VkRenderPassCreateFlags)0,													// VkRenderPassCreateFlags           flags
571 		(deUint32)attachmentDescriptions.size(),									// deUint32                          attachmentCount
572 		attachmentDescriptions.size() > 0 ? &attachmentDescriptions[0] : DE_NULL,	// const VkAttachmentDescription*    pAttachments
573 		1u,																			// deUint32                          subpassCount
574 		&subpassDescription,														// const VkSubpassDescription*       pSubpasses
575 		0u,																			// deUint32                          dependencyCount
576 		DE_NULL																		// const VkSubpassDependency*        pDependencies
577 	};
578 
579 	return createRenderPass(vk, device, &renderPassInfo, allocationCallbacks);
580 }
581 
makeImageView(const DeviceInterface & vk,const VkDevice vkDevice,const VkImage image,const VkImageViewType imageViewType,const VkFormat format,const VkImageSubresourceRange subresourceRange,const VkImageViewUsageCreateInfo * imageUsageCreateInfo)582 Move<VkImageView> makeImageView (const DeviceInterface&				vk,
583 								 const VkDevice						vkDevice,
584 								 const VkImage						image,
585 								 const VkImageViewType				imageViewType,
586 								 const VkFormat						format,
587 								 const VkImageSubresourceRange		subresourceRange,
588 								 const VkImageViewUsageCreateInfo*	imageUsageCreateInfo)
589 {
590 	const VkImageViewCreateInfo imageViewParams =
591 	{
592 		VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,		// VkStructureType			sType;
593 		imageUsageCreateInfo,							// const void*				pNext;
594 		0u,												// VkImageViewCreateFlags	flags;
595 		image,											// VkImage					image;
596 		imageViewType,									// VkImageViewType			viewType;
597 		format,											// VkFormat					format;
598 		makeComponentMappingRGBA(),						// VkComponentMapping		components;
599 		subresourceRange,								// VkImageSubresourceRange	subresourceRange;
600 	};
601 	return createImageView(vk, vkDevice, &imageViewParams);
602 }
603 
makeBufferView(const DeviceInterface & vk,const VkDevice vkDevice,const VkBuffer buffer,const VkFormat format,const VkDeviceSize offset,const VkDeviceSize size)604 Move<VkBufferView> makeBufferView (const DeviceInterface&	vk,
605 								   const VkDevice			vkDevice,
606 								   const VkBuffer			buffer,
607 								   const VkFormat			format,
608 								   const VkDeviceSize		offset,
609 								   const VkDeviceSize		size)
610 {
611 	const VkBufferViewCreateInfo bufferViewParams =
612 	{
613 		VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO,	// VkStructureType			sType;
614 		DE_NULL,									// const void*				pNext;
615 		0u,											// VkBufferViewCreateFlags	flags;
616 		buffer,										// VkBuffer					buffer;
617 		format,										// VkFormat					format;
618 		offset,										// VkDeviceSize				offset;
619 		size,										// VkDeviceSize				range;
620 	};
621 	return createBufferView(vk, vkDevice, &bufferViewParams);
622 }
623 
makeDescriptorSet(const DeviceInterface & vk,const VkDevice device,const VkDescriptorPool descriptorPool,const VkDescriptorSetLayout setLayout,const void * pNext)624 Move<VkDescriptorSet> makeDescriptorSet (const DeviceInterface&			vk,
625 										 const VkDevice					device,
626 										 const VkDescriptorPool			descriptorPool,
627 										 const VkDescriptorSetLayout	setLayout,
628 										 const void*					pNext)
629 {
630 	const VkDescriptorSetAllocateInfo allocateParams =
631 	{
632 		VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,	// VkStructureType				sType;
633 		pNext,											// const void*					pNext;
634 		descriptorPool,									// VkDescriptorPool				descriptorPool;
635 		1u,												// deUint32						setLayoutCount;
636 		&setLayout,										// const VkDescriptorSetLayout*	pSetLayouts;
637 	};
638 	return allocateDescriptorSet(vk, device, &allocateParams);
639 }
640 
makeBufferCreateInfo(const VkDeviceSize size,const VkBufferUsageFlags usage)641 VkBufferCreateInfo makeBufferCreateInfo (const VkDeviceSize			size,
642 										 const VkBufferUsageFlags	usage)
643 {
644 	const VkBufferCreateInfo bufferCreateInfo =
645 	{
646 		VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,	// VkStructureType		sType;
647 		DE_NULL,								// const void*			pNext;
648 		(VkBufferCreateFlags)0,					// VkBufferCreateFlags	flags;
649 		size,									// VkDeviceSize			size;
650 		usage,									// VkBufferUsageFlags	usage;
651 		VK_SHARING_MODE_EXCLUSIVE,				// VkSharingMode		sharingMode;
652 		0u,										// deUint32				queueFamilyIndexCount;
653 		DE_NULL,								// const deUint32*		pQueueFamilyIndices;
654 	};
655 	return bufferCreateInfo;
656 }
657 
makeBufferCreateInfo(const VkDeviceSize size,const VkBufferUsageFlags usage,const std::vector<deUint32> & queueFamilyIndices)658 VkBufferCreateInfo makeBufferCreateInfo (const VkDeviceSize				size,
659 										 const VkBufferUsageFlags		usage,
660 										 const std::vector<deUint32>&	queueFamilyIndices)
661 {
662 	const deUint32				queueFamilyIndexCount	= static_cast<deUint32>(queueFamilyIndices.size());
663 	const deUint32*				pQueueFamilyIndices		= de::dataOrNull(queueFamilyIndices);
664 	const VkBufferCreateInfo	bufferCreateInfo		=
665 	{
666 		VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,	// VkStructureType		sType;
667 		DE_NULL,								// const void*			pNext;
668 		(VkBufferCreateFlags)0,					// VkBufferCreateFlags	flags;
669 		size,									// VkDeviceSize			size;
670 		usage,									// VkBufferUsageFlags	usage;
671 		VK_SHARING_MODE_EXCLUSIVE,				// VkSharingMode		sharingMode;
672 		queueFamilyIndexCount,					// deUint32				queueFamilyIndexCount;
673 		pQueueFamilyIndices,					// const deUint32*		pQueueFamilyIndices;
674 	};
675 
676 	return bufferCreateInfo;
677 }
678 
679 
makePipelineLayout(const DeviceInterface & vk,const VkDevice device,const VkDescriptorSetLayout descriptorSetLayout)680 Move<VkPipelineLayout> makePipelineLayout (const DeviceInterface&		vk,
681 										   const VkDevice				device,
682 										   const VkDescriptorSetLayout	descriptorSetLayout)
683 {
684 	return makePipelineLayout(vk, device, (descriptorSetLayout == DE_NULL) ? 0u : 1u, &descriptorSetLayout);
685 }
686 
makePipelineLayout(const DeviceInterface & vk,const VkDevice device,const std::vector<vk::Move<VkDescriptorSetLayout>> & descriptorSetLayouts)687 Move<VkPipelineLayout> makePipelineLayout (const DeviceInterface&								vk,
688 										   const VkDevice										device,
689 										   const std::vector<vk::Move<VkDescriptorSetLayout>>	&descriptorSetLayouts)
690 {
691 	// Create a list of descriptor sets without move pointers.
692 	std::vector<vk::VkDescriptorSetLayout> descriptorSetLayoutsUnWrapped;
693 	for (const auto& descriptorSetLayout : descriptorSetLayouts)
694 	{
695 		descriptorSetLayoutsUnWrapped.push_back(descriptorSetLayout.get());
696 	}
697 	return vk::makePipelineLayout(vk, device, static_cast<deUint32>(descriptorSetLayoutsUnWrapped.size()), descriptorSetLayoutsUnWrapped.data());
698 }
699 
makePipelineLayout(const DeviceInterface & vk,const VkDevice device,const deUint32 setLayoutCount,const VkDescriptorSetLayout * descriptorSetLayout)700 Move<VkPipelineLayout> makePipelineLayout (const DeviceInterface&		vk,
701 										   const VkDevice				device,
702 										   const deUint32				setLayoutCount,
703 										   const VkDescriptorSetLayout*	descriptorSetLayout)
704 {
705 	const VkPipelineLayoutCreateInfo pipelineLayoutParams =
706 	{
707 		VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,		// VkStructureType					sType;
708 		DE_NULL,											// const void*						pNext;
709 		0u,													// VkPipelineLayoutCreateFlags		flags;
710 		setLayoutCount,										// deUint32							setLayoutCount;
711 		descriptorSetLayout,								// const VkDescriptorSetLayout*		pSetLayouts;
712 		0u,													// deUint32							pushConstantRangeCount;
713 		DE_NULL,											// const VkPushConstantRange*		pPushConstantRanges;
714 	};
715 
716 	return createPipelineLayout(vk, device, &pipelineLayoutParams);
717 }
718 
makePipelineLayout(const DeviceInterface & vk,const VkDevice device,const deUint32 setLayoutCount,const VkDescriptorSetLayout * descriptorSetLayout,const deUint32 pushConstantRangeCount,const VkPushConstantRange * pPushConstantRanges)719 Move<VkPipelineLayout> makePipelineLayout (const DeviceInterface&		vk,
720 										   const VkDevice				device,
721 										   const deUint32				setLayoutCount,
722 										   const VkDescriptorSetLayout*	descriptorSetLayout,
723 										   const deUint32               pushConstantRangeCount,
724 										   const VkPushConstantRange*   pPushConstantRanges)
725 {
726 	const VkPipelineLayoutCreateInfo pipelineLayoutParams =
727 	{
728 		VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,		// VkStructureType					sType;
729 		DE_NULL,											// const void*						pNext;
730 		0u,													// VkPipelineLayoutCreateFlags		flags;
731 		setLayoutCount,										// deUint32							setLayoutCount;
732 		descriptorSetLayout,								// const VkDescriptorSetLayout*		pSetLayouts;
733 		pushConstantRangeCount,								// deUint32							pushConstantRangeCount;
734 		pPushConstantRanges,								// const VkPushConstantRange*		pPushConstantRanges;
735 	};
736 
737 	return createPipelineLayout(vk, device, &pipelineLayoutParams);
738 }
739 
makeFramebuffer(const DeviceInterface & vk,const VkDevice device,const VkRenderPass renderPass,const VkImageView colorAttachment,const deUint32 width,const deUint32 height,const deUint32 layers)740 Move<VkFramebuffer> makeFramebuffer (const DeviceInterface&	vk,
741 									 const VkDevice			device,
742 									 const VkRenderPass		renderPass,
743 									 const VkImageView		colorAttachment,
744 									 const deUint32			width,
745 									 const deUint32			height,
746 									 const deUint32			layers)
747 {
748 	return makeFramebuffer(vk, device, renderPass, 1u, &colorAttachment, width, height, layers);
749 }
750 
makeFramebuffer(const DeviceInterface & vk,const VkDevice device,const VkRenderPass renderPass,const deUint32 attachmentCount,const VkImageView * attachmentsArray,const deUint32 width,const deUint32 height,const deUint32 layers)751 Move<VkFramebuffer> makeFramebuffer (const DeviceInterface&	vk,
752 									 const VkDevice			device,
753 									 const VkRenderPass		renderPass,
754 									 const deUint32			attachmentCount,
755 									 const VkImageView*		attachmentsArray,
756 									 const deUint32			width,
757 									 const deUint32			height,
758 									 const deUint32			layers)
759 {
760 	const VkFramebufferCreateInfo framebufferInfo =
761 	{
762 		VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,	// VkStructureType			sType;
763 		DE_NULL,									// const void*				pNext;
764 		(VkFramebufferCreateFlags)0,				// VkFramebufferCreateFlags	flags;
765 		renderPass,									// VkRenderPass				renderPass;
766 		attachmentCount,							// uint32_t					attachmentCount;
767 		attachmentsArray,							// const VkImageView*		pAttachments;
768 		width,										// uint32_t					width;
769 		height,										// uint32_t					height;
770 		layers,										// uint32_t					layers;
771 	};
772 
773 	return createFramebuffer(vk, device, &framebufferInfo);
774 }
775 
makeCommandPool(const DeviceInterface & vk,const VkDevice device,const deUint32 queueFamilyIndex)776 Move<VkCommandPool> makeCommandPool (const DeviceInterface& vk,
777 									 const VkDevice			device,
778 									 const deUint32			queueFamilyIndex)
779 {
780 	const VkCommandPoolCreateInfo commandPoolParams =
781 	{
782 		VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,			// VkStructureType			sType;
783 		DE_NULL,											// const void*				pNext;
784 		VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,	// VkCommandPoolCreateFlags	flags;
785 		queueFamilyIndex,									// deUint32					queueFamilyIndex;
786 	};
787 
788 	return createCommandPool(vk, device, &commandPoolParams);
789 }
790 
makeBufferImageCopy(const VkExtent3D extent,const VkImageSubresourceLayers subresourceLayers)791 VkBufferImageCopy makeBufferImageCopy (const VkExtent3D					extent,
792 									   const VkImageSubresourceLayers	subresourceLayers)
793 {
794 	const VkBufferImageCopy copyParams =
795 	{
796 		0ull,					//	VkDeviceSize				bufferOffset;
797 		0u,						//	deUint32					bufferRowLength;
798 		0u,						//	deUint32					bufferImageHeight;
799 		subresourceLayers,		//	VkImageSubresourceLayers	imageSubresource;
800 		makeOffset3D(0, 0, 0),	//	VkOffset3D					imageOffset;
801 		extent,					//	VkExtent3D					imageExtent;
802 	};
803 	return copyParams;
804 }
805 
806 } // vk
807