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