1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2015 The Khronos Group Inc.
6  * Copyright (c) 2015 Intel Corporation
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  *//*!
21  * \file
22  * \brief CreateInfo utilities
23  *//*--------------------------------------------------------------------*/
24 
25 #include "vktDrawCreateInfoUtil.hpp"
26 
27 #include "vkImageUtil.hpp"
28 
29 namespace vkt
30 {
31 namespace Draw
32 {
33 
ImageSubresourceRange(vk::VkImageAspectFlags _aspectMask,deUint32 _baseMipLevel,deUint32 _levelCount,deUint32 _baseArrayLayer,deUint32 _layerCount)34 ImageSubresourceRange::ImageSubresourceRange (vk::VkImageAspectFlags	_aspectMask,
35 											  deUint32					_baseMipLevel,
36 											  deUint32					_levelCount,
37 											  deUint32					_baseArrayLayer,
38 											  deUint32					_layerCount)
39 {
40 	aspectMask		= _aspectMask;
41 	baseMipLevel	= _baseMipLevel;
42 	levelCount		= _levelCount;
43 	baseArrayLayer	= _baseArrayLayer;
44 	layerCount		= _layerCount;
45 }
46 
ComponentMapping(vk::VkComponentSwizzle _r,vk::VkComponentSwizzle _g,vk::VkComponentSwizzle _b,vk::VkComponentSwizzle _a)47 ComponentMapping::ComponentMapping (vk::VkComponentSwizzle _r,
48 									vk::VkComponentSwizzle _g,
49 									vk::VkComponentSwizzle _b,
50 									vk::VkComponentSwizzle _a)
51 {
52 	r = _r;
53 	g = _g;
54 	b = _b;
55 	a = _a;
56 }
57 
ImageViewCreateInfo(vk::VkImage _image,vk::VkImageViewType _viewType,vk::VkFormat _format,const vk::VkImageSubresourceRange & _subresourceRange,const vk::VkComponentMapping & _components,vk::VkImageViewCreateFlags _flags)58 ImageViewCreateInfo::ImageViewCreateInfo (vk::VkImage							_image,
59 										  vk::VkImageViewType					_viewType,
60 										  vk::VkFormat							_format,
61 										  const vk::VkImageSubresourceRange&	_subresourceRange,
62 										  const vk::VkComponentMapping&			_components,
63 										  vk::VkImageViewCreateFlags			_flags)
64 {
65 	sType = vk::VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
66 	pNext = DE_NULL;
67 	flags				= 0u;
68 	image				= _image;
69 	viewType			= _viewType;
70 	format				= _format;
71 	components.r		= _components.r;
72 	components.g		= _components.g;
73 	components.b		= _components.b;
74 	components.a		= _components.a;
75 	subresourceRange	= _subresourceRange;
76 	flags				= _flags;
77 }
78 
ImageViewCreateInfo(vk::VkImage _image,vk::VkImageViewType _viewType,vk::VkFormat _format,const vk::VkComponentMapping & _components,vk::VkImageViewCreateFlags _flags)79 ImageViewCreateInfo::ImageViewCreateInfo (vk::VkImage					_image,
80 										  vk::VkImageViewType			_viewType,
81 										  vk::VkFormat					_format,
82 										  const vk::VkComponentMapping&	_components,
83 										  vk::VkImageViewCreateFlags	_flags)
84 {
85 	sType = vk::VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
86 	pNext = DE_NULL;
87 	flags			= 0u;
88 	image			= _image;
89 	viewType		= _viewType;
90 	format			= _format;
91 	components.r	= _components.r;
92 	components.g	= _components.g;
93 	components.b	= _components.b;
94 	components.a	= _components.a;
95 
96 	vk::VkImageAspectFlags aspectFlags;
97 	const tcu::TextureFormat tcuFormat = vk::mapVkFormat(_format);
98 
99 	switch (tcuFormat.order)
100 	{
101 		case tcu::TextureFormat::D:
102 			aspectFlags = vk::VK_IMAGE_ASPECT_DEPTH_BIT;
103 			break;
104 		case tcu::TextureFormat::S:
105 			aspectFlags = vk::VK_IMAGE_ASPECT_STENCIL_BIT;
106 			break;
107 		case tcu::TextureFormat::DS:
108 			aspectFlags = vk::VK_IMAGE_ASPECT_STENCIL_BIT | vk::VK_IMAGE_ASPECT_DEPTH_BIT;
109 			break;
110 		default:
111 			aspectFlags = vk::VK_IMAGE_ASPECT_COLOR_BIT;
112 			break;
113 	}
114 
115 	subresourceRange = ImageSubresourceRange(aspectFlags);;
116 	flags = _flags;
117 }
118 
BufferViewCreateInfo(vk::VkBuffer _buffer,vk::VkFormat _format,vk::VkDeviceSize _offset,vk::VkDeviceSize _range)119 BufferViewCreateInfo::BufferViewCreateInfo (vk::VkBuffer	_buffer,
120 											vk::VkFormat		_format,
121 											vk::VkDeviceSize _offset,
122 											vk::VkDeviceSize _range)
123 {
124 	sType = vk::VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO;
125 	pNext = DE_NULL;
126 
127 	flags	= 0;
128 	buffer	= _buffer;
129 	format	= _format;
130 	offset	= _offset;
131 	range	= _range;
132 }
133 
BufferCreateInfo(vk::VkDeviceSize _size,vk::VkBufferUsageFlags _usage,vk::VkSharingMode _sharingMode,deUint32 _queueFamilyIndexCount,const deUint32 * _pQueueFamilyIndices,vk::VkBufferCreateFlags _flags)134 BufferCreateInfo::BufferCreateInfo (vk::VkDeviceSize		_size,
135 									vk::VkBufferUsageFlags	_usage,
136 									vk::VkSharingMode		_sharingMode,
137 									deUint32				_queueFamilyIndexCount,
138 									const deUint32*			_pQueueFamilyIndices,
139 									vk::VkBufferCreateFlags _flags)
140 {
141 	sType = vk::VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
142 	pNext = DE_NULL;
143 	size					= _size;
144 	usage					= _usage;
145 	flags					= _flags;
146 	sharingMode				= _sharingMode;
147 	queueFamilyIndexCount	= _queueFamilyIndexCount;
148 
149 	if (_queueFamilyIndexCount)
150 	{
151 		m_queueFamilyIndices = std::vector<deUint32>(
152 			_pQueueFamilyIndices, _pQueueFamilyIndices + _queueFamilyIndexCount);
153 		pQueueFamilyIndices = &m_queueFamilyIndices[0];
154 	}
155 	else
156 	{
157 		pQueueFamilyIndices = _pQueueFamilyIndices;
158 	}
159 }
160 
BufferCreateInfo(const BufferCreateInfo & other)161 BufferCreateInfo::BufferCreateInfo (const BufferCreateInfo &other)
162 {
163 	sType					= other.sType;
164 	pNext					= other.pNext;
165 	size					= other.size;
166 	usage					= other.usage;
167 	flags					= other.flags;
168 	sharingMode				= other.sharingMode;
169 	queueFamilyIndexCount	= other.queueFamilyIndexCount;
170 
171 	m_queueFamilyIndices	= other.m_queueFamilyIndices;
172 	DE_ASSERT(m_queueFamilyIndices.size() == queueFamilyIndexCount);
173 
174 	if (m_queueFamilyIndices.size())
175 	{
176 		pQueueFamilyIndices = &m_queueFamilyIndices[0];
177 	}
178 	else
179 	{
180 		pQueueFamilyIndices = DE_NULL;
181 	}
182 }
183 
operator =(const BufferCreateInfo & other)184 BufferCreateInfo & BufferCreateInfo::operator= (const BufferCreateInfo &other)
185 {
186 	sType						= other.sType;
187 	pNext						= other.pNext;
188 	size						= other.size;
189 	usage						= other.usage;
190 	flags						= other.flags;
191 	sharingMode					= other.sharingMode;
192 	queueFamilyIndexCount		= other.queueFamilyIndexCount;
193 
194 	m_queueFamilyIndices		= other.m_queueFamilyIndices;
195 
196 	DE_ASSERT(m_queueFamilyIndices.size() == queueFamilyIndexCount);
197 
198 	if (m_queueFamilyIndices.size())
199 	{
200 		pQueueFamilyIndices = &m_queueFamilyIndices[0];
201 	}
202 	else
203 	{
204 		pQueueFamilyIndices = DE_NULL;
205 	}
206 
207 	return *this;
208 }
209 
ImageCreateInfo(vk::VkImageType _imageType,vk::VkFormat _format,vk::VkExtent3D _extent,deUint32 _mipLevels,deUint32 _arrayLayers,vk::VkSampleCountFlagBits _samples,vk::VkImageTiling _tiling,vk::VkImageUsageFlags _usage,vk::VkSharingMode _sharingMode,deUint32 _queueFamilyIndexCount,const deUint32 * _pQueueFamilyIndices,vk::VkImageCreateFlags _flags,vk::VkImageLayout _initialLayout)210 ImageCreateInfo::ImageCreateInfo (vk::VkImageType			_imageType,
211 								  vk::VkFormat				_format,
212 								  vk::VkExtent3D			_extent,
213 								  deUint32					_mipLevels,
214 								  deUint32					_arrayLayers,
215 								  vk::VkSampleCountFlagBits	_samples,
216 								  vk::VkImageTiling			_tiling,
217 								  vk::VkImageUsageFlags		_usage,
218 								  vk::VkSharingMode			_sharingMode,
219 								  deUint32					_queueFamilyIndexCount,
220 								  const deUint32*			_pQueueFamilyIndices,
221 								  vk::VkImageCreateFlags	_flags,
222 								  vk::VkImageLayout			_initialLayout)
223 {
224 	if (_queueFamilyIndexCount)
225 	{
226 		m_queueFamilyIndices = std::vector<deUint32>(_pQueueFamilyIndices, _pQueueFamilyIndices + _queueFamilyIndexCount);
227 	}
228 
229 	sType = vk::VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
230 	pNext = DE_NULL;
231 	flags					= _flags;
232 	imageType				= _imageType;
233 	format					= _format;
234 	extent					= _extent;
235 	mipLevels				= _mipLevels;
236 	arrayLayers				= _arrayLayers;
237 	samples					= _samples;
238 	tiling					= _tiling;
239 	usage					= _usage;
240 	sharingMode				= _sharingMode;
241 	queueFamilyIndexCount	= _queueFamilyIndexCount;
242 
243 	if (m_queueFamilyIndices.size())
244 	{
245 		pQueueFamilyIndices = &m_queueFamilyIndices[0];
246 	}
247 	else
248 	{
249 		pQueueFamilyIndices = DE_NULL;
250 	}
251 	initialLayout	= _initialLayout;
252 }
253 
FramebufferCreateInfo(vk::VkRenderPass _renderPass,const std::vector<vk::VkImageView> & atachments,deUint32 _width,deUint32 _height,deUint32 _layers)254 FramebufferCreateInfo::FramebufferCreateInfo (vk::VkRenderPass						_renderPass,
255 											  const std::vector<vk::VkImageView>&	atachments,
256 											  deUint32								_width,
257 											  deUint32								_height,
258 											  deUint32								_layers)
259 {
260 	sType = vk::VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
261 	pNext = DE_NULL;
262 	flags = 0u;
263 
264 	renderPass		= _renderPass;
265 	attachmentCount	= static_cast<deUint32>(atachments.size());
266 
267 	if (attachmentCount)
268 	{
269 		pAttachments = const_cast<vk::VkImageView *>(&atachments[0]);
270 	}
271 
272 	width	= _width;
273 	height	= _height;
274 	layers	= _layers;
275 }
276 
RenderPassCreateInfo(const std::vector<vk::VkAttachmentDescription> & attachments,const std::vector<vk::VkSubpassDescription> & subpasses,const std::vector<vk::VkSubpassDependency> & dependiences)277 RenderPassCreateInfo::RenderPassCreateInfo (const std::vector<vk::VkAttachmentDescription>&	attachments,
278 											const std::vector<vk::VkSubpassDescription>&	subpasses,
279 											const std::vector<vk::VkSubpassDependency>&		dependiences)
280 
281 	: m_attachments			(attachments.begin(), attachments.end())
282 	, m_subpasses			(subpasses.begin(), subpasses.end())
283 	, m_dependiences		(dependiences.begin(), dependiences.end())
284 	, m_attachmentsStructs	(m_attachments.begin(), m_attachments.end())
285 	, m_subpassesStructs	(m_subpasses.begin(), m_subpasses.end())
286 	, m_dependiencesStructs	(m_dependiences.begin(), m_dependiences.end())
287 {
288 	sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
289 	pNext = DE_NULL;
290 	flags = 0;
291 
292 	attachmentCount = static_cast<deUint32>(m_attachments.size());
293 	pAttachments	= &m_attachmentsStructs[0];
294 	subpassCount	= static_cast<deUint32>(m_subpasses.size());
295 	pSubpasses		= &m_subpassesStructs[0];
296 	dependencyCount = static_cast<deUint32>(m_dependiences.size());
297 	pDependencies	= &m_dependiencesStructs[0];
298 }
299 
RenderPassCreateInfo(deUint32 _attachmentCount,const vk::VkAttachmentDescription * _pAttachments,deUint32 _subpassCount,const vk::VkSubpassDescription * _pSubpasses,deUint32 _dependencyCount,const vk::VkSubpassDependency * _pDependiences)300 RenderPassCreateInfo::RenderPassCreateInfo (deUint32							_attachmentCount,
301 											const vk::VkAttachmentDescription*	_pAttachments,
302 											deUint32							_subpassCount,
303 											const vk::VkSubpassDescription*		_pSubpasses,
304 											deUint32							_dependencyCount,
305 											const vk::VkSubpassDependency*		_pDependiences)
306 {
307 
308 	m_attachments	= std::vector<AttachmentDescription>(_pAttachments, _pAttachments + _attachmentCount);
309 	m_subpasses		= std::vector<SubpassDescription>(_pSubpasses, _pSubpasses + _subpassCount);
310 	m_dependiences	= std::vector<SubpassDependency>(_pDependiences, _pDependiences + _dependencyCount);
311 
312 	m_attachmentsStructs	= std::vector<vk::VkAttachmentDescription>	(m_attachments.begin(),		m_attachments.end());
313 	m_subpassesStructs		= std::vector<vk::VkSubpassDescription>		(m_subpasses.begin(),		m_subpasses.end());
314 	m_dependiencesStructs	= std::vector<vk::VkSubpassDependency>		(m_dependiences.begin(),	m_dependiences.end());
315 
316 	sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
317 	pNext = DE_NULL;
318 	flags = 0;
319 
320 	attachmentCount = static_cast<deUint32>(m_attachments.size());
321 
322 	if (attachmentCount) {
323 		pAttachments = &m_attachmentsStructs[0];
324 	}
325 	else
326 	{
327 		pAttachments = DE_NULL;
328 	}
329 
330 	subpassCount = static_cast<deUint32>(m_subpasses.size());
331 
332 	if (subpassCount) {
333 		pSubpasses = &m_subpassesStructs[0];
334 	}
335 	else
336 	{
337 		pSubpasses = DE_NULL;
338 	}
339 
340 	dependencyCount = static_cast<deUint32>(m_dependiences.size());
341 
342 	if (dependencyCount) {
343 		pDependencies = &m_dependiencesStructs[0];
344 	}
345 	else
346 	{
347 		pDependencies = DE_NULL;
348 	}
349 }
350 
351 void
addAttachment(vk::VkAttachmentDescription attachment)352 RenderPassCreateInfo::addAttachment (vk::VkAttachmentDescription attachment)
353 {
354 
355 	m_attachments.push_back(attachment);
356 	m_attachmentsStructs	= std::vector<vk::VkAttachmentDescription>(m_attachments.begin(), m_attachments.end());
357 	attachmentCount			= static_cast<deUint32>(m_attachments.size());
358 	pAttachments			= &m_attachmentsStructs[0];
359 }
360 
361 void
addSubpass(vk::VkSubpassDescription subpass)362 RenderPassCreateInfo::addSubpass (vk::VkSubpassDescription subpass)
363 {
364 
365 	m_subpasses.push_back(subpass);
366 	m_subpassesStructs	= std::vector<vk::VkSubpassDescription>(m_subpasses.begin(), m_subpasses.end());
367 	subpassCount		= static_cast<deUint32>(m_subpasses.size());
368 	pSubpasses			= &m_subpassesStructs[0];
369 }
370 
371 void
addDependency(vk::VkSubpassDependency dependency)372 RenderPassCreateInfo::addDependency (vk::VkSubpassDependency dependency)
373 {
374 
375 	m_dependiences.push_back(dependency);
376 	m_dependiencesStructs	= std::vector<vk::VkSubpassDependency>(m_dependiences.begin(), m_dependiences.end());
377 
378 	dependencyCount			= static_cast<deUint32>(m_dependiences.size());
379 	pDependencies			= &m_dependiencesStructs[0];
380 }
381 
RenderPassBeginInfo(vk::VkRenderPass _renderPass,vk::VkFramebuffer _framebuffer,vk::VkRect2D _renderArea,const std::vector<vk::VkClearValue> & _clearValues)382 RenderPassBeginInfo::RenderPassBeginInfo (vk::VkRenderPass						_renderPass,
383 										  vk::VkFramebuffer						_framebuffer,
384 										  vk::VkRect2D							_renderArea,
385 										  const std::vector<vk::VkClearValue>&	_clearValues)
386 {
387 
388 	m_clearValues	= _clearValues;
389 
390 	sType			= vk::VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
391 	pNext			= DE_NULL;
392 	renderPass		= _renderPass;
393 	framebuffer		= _framebuffer;
394 	renderArea		= _renderArea;
395 	clearValueCount = static_cast<deUint32>(m_clearValues.size());
396 	pClearValues	= m_clearValues.size() ? &m_clearValues[0] : DE_NULL;
397 }
398 
CmdPoolCreateInfo(deUint32 _queueFamilyIndex,unsigned int _flags)399 CmdPoolCreateInfo::CmdPoolCreateInfo (deUint32 _queueFamilyIndex, unsigned int _flags)
400 {
401 	sType = vk::VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
402 	pNext = DE_NULL;
403 
404 	queueFamilyIndex = _queueFamilyIndex;
405 	flags				= _flags;
406 }
407 
AttachmentDescription(vk::VkFormat _format,vk::VkSampleCountFlagBits _samples,vk::VkAttachmentLoadOp _loadOp,vk::VkAttachmentStoreOp _storeOp,vk::VkAttachmentLoadOp _stencilLoadOp,vk::VkAttachmentStoreOp _stencilStoreOp,vk::VkImageLayout _initialLayout,vk::VkImageLayout _finalLayout)408 AttachmentDescription::AttachmentDescription (vk::VkFormat				_format,
409 											  vk::VkSampleCountFlagBits	_samples,
410 											  vk::VkAttachmentLoadOp	_loadOp,
411 											  vk::VkAttachmentStoreOp	_storeOp,
412 											  vk::VkAttachmentLoadOp	_stencilLoadOp,
413 											  vk::VkAttachmentStoreOp	_stencilStoreOp,
414 											  vk::VkImageLayout			_initialLayout,
415 											  vk::VkImageLayout			_finalLayout)
416 {
417 	flags = 0;
418 	format			= _format;
419 	samples			= _samples;
420 	loadOp			= _loadOp;
421 	storeOp			= _storeOp;
422 	stencilLoadOp	= _stencilLoadOp;
423 	stencilStoreOp	= _stencilStoreOp;
424 	initialLayout	= _initialLayout;
425 	finalLayout		= _finalLayout;
426 }
427 
AttachmentDescription(const vk::VkAttachmentDescription & rhs)428 AttachmentDescription::AttachmentDescription (const vk::VkAttachmentDescription& rhs)
429 {
430 	flags			= rhs.flags;
431 	format			= rhs.format;
432 	samples			= rhs.samples;
433 	loadOp			= rhs.loadOp;
434 	storeOp			= rhs.storeOp;
435 	stencilLoadOp	= rhs.stencilLoadOp;
436 	stencilStoreOp	= rhs.stencilStoreOp;
437 	initialLayout	= rhs.initialLayout;
438 	finalLayout		= rhs.finalLayout;
439 }
440 
AttachmentReference(deUint32 _attachment,vk::VkImageLayout _layout)441 AttachmentReference::AttachmentReference (deUint32 _attachment, vk::VkImageLayout _layout)
442 {
443 	attachment	= _attachment;
444 	layout		= _layout;
445 }
446 
AttachmentReference(void)447 AttachmentReference::AttachmentReference (void)
448 {
449 	attachment = vk::VK_ATTACHMENT_UNUSED;
450 	layout = vk::VK_IMAGE_LAYOUT_UNDEFINED;
451 }
452 
SubpassDescription(vk::VkPipelineBindPoint _pipelineBindPoint,vk::VkSubpassDescriptionFlags _flags,deUint32 _inputAttachmentCount,const vk::VkAttachmentReference * _inputAttachments,deUint32 _colorAttachmentCount,const vk::VkAttachmentReference * _colorAttachments,const vk::VkAttachmentReference * _resolveAttachments,vk::VkAttachmentReference depthStencilAttachment,deUint32 _preserveAttachmentCount,const deUint32 * _preserveAttachments)453 SubpassDescription::SubpassDescription (vk::VkPipelineBindPoint				_pipelineBindPoint,
454 										vk::VkSubpassDescriptionFlags		_flags,
455 										deUint32							_inputAttachmentCount,
456 										const vk::VkAttachmentReference*	_inputAttachments,
457 										deUint32							_colorAttachmentCount,
458 										const vk::VkAttachmentReference*	_colorAttachments,
459 										const vk::VkAttachmentReference*	_resolveAttachments,
460 										vk::VkAttachmentReference			depthStencilAttachment,
461 										deUint32							_preserveAttachmentCount,
462 										const deUint32*						_preserveAttachments)
463 {
464 	m_inputAttachments = std::vector<vk::VkAttachmentReference>(_inputAttachments, _inputAttachments + _inputAttachmentCount);
465 	m_colorAttachments = std::vector<vk::VkAttachmentReference>(_colorAttachments, _colorAttachments + _colorAttachmentCount);
466 
467 	if (_resolveAttachments)
468 		m_resolveAttachments = std::vector<vk::VkAttachmentReference>(_resolveAttachments, _resolveAttachments + _colorAttachmentCount);
469 
470 	m_preserveAttachments = std::vector<deUint32>(_preserveAttachments, _preserveAttachments + _preserveAttachmentCount);
471 
472 	m_depthStencilAttachment = depthStencilAttachment;
473 
474 	flags					= _flags;
475 	pipelineBindPoint		= _pipelineBindPoint;
476 	inputAttachmentCount	= _inputAttachmentCount;
477 	pInputAttachments		= DE_NULL;
478 	colorAttachmentCount	= _colorAttachmentCount;
479 	pColorAttachments		= DE_NULL;
480 	pResolveAttachments		= DE_NULL;
481 	pDepthStencilAttachment	= &m_depthStencilAttachment;
482 	pPreserveAttachments	= DE_NULL;
483 	preserveAttachmentCount	= _preserveAttachmentCount;
484 
485 	if (!m_inputAttachments.empty())
486 		pInputAttachments = &m_inputAttachments[0];
487 
488 	if (!m_colorAttachments.empty())
489 		pColorAttachments = &m_colorAttachments[0];
490 
491 	if (!m_resolveAttachments.empty())
492 		pResolveAttachments = &m_resolveAttachments[0];
493 
494 	if (!m_preserveAttachments.empty())
495 		pPreserveAttachments = &m_preserveAttachments[0];
496 }
497 
SubpassDescription(const vk::VkSubpassDescription & rhs)498 SubpassDescription::SubpassDescription (const vk::VkSubpassDescription& rhs)
499 {
500 	*static_cast<vk::VkSubpassDescription*>(this) = rhs;
501 
502 	m_inputAttachments = std::vector<vk::VkAttachmentReference>(
503 		rhs.pInputAttachments, rhs.pInputAttachments + rhs.inputAttachmentCount);
504 
505 	m_colorAttachments = std::vector<vk::VkAttachmentReference>(
506 		rhs.pColorAttachments, rhs.pColorAttachments + rhs.colorAttachmentCount);
507 
508 	if (rhs.pResolveAttachments)
509 		m_resolveAttachments = std::vector<vk::VkAttachmentReference>(
510 			rhs.pResolveAttachments, rhs.pResolveAttachments + rhs.colorAttachmentCount);
511 
512 	m_preserveAttachments = std::vector<deUint32>(
513 		rhs.pPreserveAttachments, rhs.pPreserveAttachments + rhs.preserveAttachmentCount);
514 
515 	if (rhs.pDepthStencilAttachment)
516 		m_depthStencilAttachment = *rhs.pDepthStencilAttachment;
517 
518 	if (!m_inputAttachments.empty())
519 		pInputAttachments = &m_inputAttachments[0];
520 
521 	if (!m_colorAttachments.empty())
522 		pColorAttachments = &m_colorAttachments[0];
523 
524 	if (!m_resolveAttachments.empty())
525 		pResolveAttachments = &m_resolveAttachments[0];
526 
527 	pDepthStencilAttachment = &m_depthStencilAttachment;
528 
529 	if (!m_preserveAttachments.empty())
530 		pPreserveAttachments = &m_preserveAttachments[0];
531 }
532 
SubpassDescription(const SubpassDescription & rhs)533 SubpassDescription::SubpassDescription (const SubpassDescription& rhs) {
534 	*this = rhs;
535 }
536 
operator =(const SubpassDescription & rhs)537 SubpassDescription& SubpassDescription::operator= (const SubpassDescription& rhs)
538 {
539 	*static_cast<vk::VkSubpassDescription*>(this) = rhs;
540 
541 	m_inputAttachments		= rhs.m_inputAttachments;
542 	m_colorAttachments		= rhs.m_colorAttachments;
543 	m_resolveAttachments	= rhs.m_resolveAttachments;
544 	m_preserveAttachments	= rhs.m_preserveAttachments;
545 	m_depthStencilAttachment = rhs.m_depthStencilAttachment;
546 
547 	if (!m_inputAttachments.empty())
548 		pInputAttachments = &m_inputAttachments[0];
549 
550 	if (!m_colorAttachments.empty())
551 		pColorAttachments = &m_colorAttachments[0];
552 
553 	if (!m_resolveAttachments.empty())
554 		pResolveAttachments = &m_resolveAttachments[0];
555 
556 	pDepthStencilAttachment = &m_depthStencilAttachment;
557 
558 	if (!m_preserveAttachments.empty())
559 		pPreserveAttachments = &m_preserveAttachments[0];
560 
561 	return *this;
562 }
563 
SubpassDependency(deUint32 _srcSubpass,deUint32 _dstSubpass,vk::VkPipelineStageFlags _srcStageMask,vk::VkPipelineStageFlags _dstStageMask,vk::VkAccessFlags _srcAccessMask,vk::VkAccessFlags _dstAccessMask,vk::VkDependencyFlags _dependencyFlags)564 SubpassDependency::SubpassDependency (deUint32					_srcSubpass,
565 									  deUint32					_dstSubpass,
566 									  vk::VkPipelineStageFlags	_srcStageMask,
567 									  vk::VkPipelineStageFlags	_dstStageMask,
568 									  vk::VkAccessFlags			_srcAccessMask,
569 									  vk::VkAccessFlags			_dstAccessMask,
570 									  vk::VkDependencyFlags		_dependencyFlags)
571 {
572 	srcSubpass		= _srcSubpass;
573 	dstSubpass		= _dstSubpass;
574 	srcStageMask	= _srcStageMask;
575 	dstStageMask	= _dstStageMask;
576 	srcAccessMask	= _srcAccessMask;
577 	dstAccessMask	= _dstAccessMask;
578 	dependencyFlags	= _dependencyFlags;
579 }
580 
SubpassDependency(const vk::VkSubpassDependency & rhs)581 SubpassDependency::SubpassDependency (const vk::VkSubpassDependency& rhs)
582 {
583 	srcSubpass		= rhs.srcSubpass;
584 	dstSubpass		= rhs.dstSubpass;
585 	srcStageMask	= rhs.srcStageMask;
586 	dstStageMask	= rhs.dstStageMask;
587 	srcAccessMask	= rhs.srcAccessMask;
588 	dstAccessMask	= rhs.dstAccessMask;
589 	dependencyFlags	= rhs.dependencyFlags;
590 }
591 
CmdBufferBeginInfo(vk::VkCommandBufferUsageFlags _flags)592 CmdBufferBeginInfo::CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags _flags)
593 {
594 	sType				= vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
595 	pNext				= DE_NULL;
596 	flags				= _flags;
597 	pInheritanceInfo	= DE_NULL;
598 }
599 
DescriptorPoolCreateInfo(const std::vector<vk::VkDescriptorPoolSize> & poolSizeCounts,vk::VkDescriptorPoolCreateFlags _flags,deUint32 _maxSets)600 DescriptorPoolCreateInfo::DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>&	poolSizeCounts,
601 													vk::VkDescriptorPoolCreateFlags					_flags,
602 													deUint32										_maxSets)
603 	: m_poolSizeCounts(poolSizeCounts)
604 {
605 	sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
606 	pNext = DE_NULL;
607 	flags			= _flags;
608 	maxSets			= _maxSets;
609 	poolSizeCount	= static_cast<deUint32>(m_poolSizeCounts.size());
610 	pPoolSizes		= &m_poolSizeCounts[0];
611 }
612 
addDescriptors(vk::VkDescriptorType type,deUint32 count)613 DescriptorPoolCreateInfo& DescriptorPoolCreateInfo::addDescriptors (vk::VkDescriptorType type, deUint32 count)
614 {
615 	vk::VkDescriptorPoolSize descriptorTypeCount = { type, count };
616 	m_poolSizeCounts.push_back(descriptorTypeCount);
617 
618 	poolSizeCount	= static_cast<deUint32>(m_poolSizeCounts.size());
619 	pPoolSizes		= &m_poolSizeCounts[0];
620 
621 	return *this;
622 }
623 
DescriptorSetLayoutCreateInfo(deUint32 _bindingCount,const vk::VkDescriptorSetLayoutBinding * _pBindings)624 DescriptorSetLayoutCreateInfo::DescriptorSetLayoutCreateInfo (deUint32 _bindingCount, const vk::VkDescriptorSetLayoutBinding* _pBindings)
625 {
626 	sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
627 	pNext = DE_NULL;
628 	flags = 0;
629 	bindingCount = _bindingCount;
630 	pBindings	 = _pBindings;
631 }
632 
PipelineLayoutCreateInfo(deUint32 _descriptorSetCount,const vk::VkDescriptorSetLayout * _pSetLayouts,deUint32 _pushConstantRangeCount,const vk::VkPushConstantRange * _pPushConstantRanges)633 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (deUint32							_descriptorSetCount,
634 													const vk::VkDescriptorSetLayout*	_pSetLayouts,
635 													deUint32							_pushConstantRangeCount,
636 													const vk::VkPushConstantRange*		_pPushConstantRanges)
637 	: m_pushConstantRanges(_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
638 {
639 	for (unsigned int i = 0; i < _descriptorSetCount; i++)
640 	{
641 		m_setLayouts.push_back(_pSetLayouts[i]);
642 	}
643 
644 	sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
645 	pNext = DE_NULL;
646 	flags					= 0;
647 	setLayoutCount			= static_cast<deUint32>(m_setLayouts.size());
648 	pSetLayouts				= setLayoutCount > 0 ? &m_setLayouts[0] : DE_NULL;
649 	pushConstantRangeCount	= static_cast<deUint32>(m_pushConstantRanges.size());
650 
651 	if (m_pushConstantRanges.size()) {
652 		pPushConstantRanges = &m_pushConstantRanges[0];
653 	}
654 	else
655 	{
656 		pPushConstantRanges = DE_NULL;
657 	}
658 }
659 
PipelineLayoutCreateInfo(const std::vector<vk::VkDescriptorSetLayout> & setLayouts,deUint32 _pushConstantRangeCount,const vk::VkPushConstantRange * _pPushConstantRanges)660 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (const std::vector<vk::VkDescriptorSetLayout>&	setLayouts,
661 													deUint32										_pushConstantRangeCount,
662 													const vk::VkPushConstantRange*					_pPushConstantRanges)
663 	: m_setLayouts			(setLayouts)
664 	, m_pushConstantRanges	(_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
665 {
666 	sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
667 	pNext = DE_NULL;
668 
669 	flags			= 0;
670 	setLayoutCount	= static_cast<deUint32>(m_setLayouts.size());
671 
672 	if (setLayoutCount)
673 	{
674 		pSetLayouts = &m_setLayouts[0];
675 	}
676 	else
677 	{
678 		pSetLayouts = DE_NULL;
679 	}
680 
681 	pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
682 	if (pushConstantRangeCount) {
683 		pPushConstantRanges = &m_pushConstantRanges[0];
684 	}
685 	else
686 	{
687 		pPushConstantRanges = DE_NULL;
688 	}
689 }
690 
PipelineShaderStage(vk::VkShaderModule _module,const char * _pName,vk::VkShaderStageFlagBits _stage)691 PipelineCreateInfo::PipelineShaderStage::PipelineShaderStage (vk::VkShaderModule _module, const char* _pName, vk::VkShaderStageFlagBits _stage)
692 {
693 	sType = vk::VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
694 	pNext = DE_NULL;
695 	flags = 0u;
696 	stage				= _stage;
697 	module				= _module;
698 	pName				= _pName;
699 	pSpecializationInfo = DE_NULL;
700 }
701 
VertexInputState(deUint32 _vertexBindingDescriptionCount,const vk::VkVertexInputBindingDescription * _pVertexBindingDescriptions,deUint32 _vertexAttributeDescriptionCount,const vk::VkVertexInputAttributeDescription * _pVertexAttributeDescriptions)702 PipelineCreateInfo::VertexInputState::VertexInputState (deUint32										_vertexBindingDescriptionCount,
703 														const vk::VkVertexInputBindingDescription*		_pVertexBindingDescriptions,
704 														deUint32										_vertexAttributeDescriptionCount,
705 														const vk::VkVertexInputAttributeDescription*	_pVertexAttributeDescriptions)
706 {
707 	sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
708 	pNext = DE_NULL;
709 	flags							= 0u;
710 	vertexBindingDescriptionCount	= _vertexBindingDescriptionCount;
711 	pVertexBindingDescriptions		= _pVertexBindingDescriptions;
712 	vertexAttributeDescriptionCount	= _vertexAttributeDescriptionCount;
713 	pVertexAttributeDescriptions	= _pVertexAttributeDescriptions;
714 }
715 
InputAssemblerState(vk::VkPrimitiveTopology _topology,vk::VkBool32 _primitiveRestartEnable)716 PipelineCreateInfo::InputAssemblerState::InputAssemblerState (vk::VkPrimitiveTopology	_topology,
717 															  vk::VkBool32				_primitiveRestartEnable)
718 {
719 	sType = vk::VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
720 	pNext = DE_NULL;
721 	flags					= 0u;
722 	topology				= _topology;
723 	primitiveRestartEnable	= _primitiveRestartEnable;
724 }
725 
TessellationState(deUint32 _patchControlPoints)726 PipelineCreateInfo::TessellationState::TessellationState (deUint32 _patchControlPoints)
727 {
728 	sType = vk::VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
729 	pNext = DE_NULL;
730 	flags				= 0;
731 	patchControlPoints	= _patchControlPoints;
732 }
733 
ViewportState(deUint32 _viewportCount,std::vector<vk::VkViewport> _viewports,std::vector<vk::VkRect2D> _scissors)734 PipelineCreateInfo::ViewportState::ViewportState (deUint32						_viewportCount,
735 												  std::vector<vk::VkViewport>	_viewports,
736 												  std::vector<vk::VkRect2D>		_scissors)
737 {
738 	sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
739 	pNext = DE_NULL;
740 	flags			= 0u;
741 	viewportCount	= _viewportCount;
742 	scissorCount	= _viewportCount;
743 
744 	if (!_viewports.size())
745 	{
746 		m_viewports.resize(viewportCount);
747 		deMemset(&m_viewports[0], 0, sizeof(m_viewports[0]) * m_viewports.size());
748 	}
749 	else
750 	{
751 		m_viewports = _viewports;
752 	}
753 
754 	if (!_scissors.size())
755 	{
756 		m_scissors.resize(scissorCount);
757 		deMemset(&m_scissors[0], 0, sizeof(m_scissors[0]) * m_scissors.size());
758 	}
759 	else
760 	{
761 		m_scissors = _scissors;
762 	}
763 
764 	pViewports	= &m_viewports[0];
765 	pScissors	= &m_scissors[0];
766 }
767 
ViewportState(const ViewportState & other)768 PipelineCreateInfo::ViewportState::ViewportState (const ViewportState& other)
769 {
770 	sType			= other.sType;
771 	pNext			= other.pNext;
772 	flags			= other.flags;
773 	viewportCount	= other.viewportCount;
774 	scissorCount	= other.scissorCount;
775 
776 	m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + viewportCount);
777 	m_scissors	= std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
778 
779 	pViewports	= &m_viewports[0];
780 	pScissors	= &m_scissors[0];
781 }
782 
operator =(const ViewportState & other)783 PipelineCreateInfo::ViewportState& PipelineCreateInfo::ViewportState::operator= (const ViewportState& other)
784 {
785 	sType			= other.sType;
786 	pNext			= other.pNext;
787 	flags			= other.flags;
788 	viewportCount	= other.viewportCount;
789 	scissorCount	= other.scissorCount;
790 
791 	m_viewports		= std::vector<vk::VkViewport>(other.pViewports, other.pViewports + scissorCount);
792 	m_scissors		= std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
793 
794 	pViewports		= &m_viewports[0];
795 	pScissors		= &m_scissors[0];
796 	return *this;
797 }
798 
RasterizerState(vk::VkBool32 _depthClampEnable,vk::VkBool32 _rasterizerDiscardEnable,vk::VkPolygonMode _polygonMode,vk::VkCullModeFlags _cullMode,vk::VkFrontFace _frontFace,vk::VkBool32 _depthBiasEnable,float _depthBiasConstantFactor,float _depthBiasClamp,float _depthBiasSlopeFactor,float _lineWidth)799 PipelineCreateInfo::RasterizerState::RasterizerState (vk::VkBool32			_depthClampEnable,
800 													  vk::VkBool32			_rasterizerDiscardEnable,
801 													  vk::VkPolygonMode		_polygonMode,
802 													  vk::VkCullModeFlags	_cullMode,
803 													  vk::VkFrontFace		_frontFace,
804 													  vk::VkBool32			_depthBiasEnable,
805 													  float					_depthBiasConstantFactor,
806 													  float					_depthBiasClamp,
807 													  float					_depthBiasSlopeFactor,
808 													  float					_lineWidth)
809 {
810 	sType = vk::VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
811 	pNext = DE_NULL;
812 	flags					= 0u;
813 	depthClampEnable		= _depthClampEnable;
814 	rasterizerDiscardEnable = _rasterizerDiscardEnable;
815 	polygonMode				= _polygonMode;
816 	cullMode				= _cullMode;
817 	frontFace				= _frontFace;
818 
819 	depthBiasEnable			= _depthBiasEnable;
820 	depthBiasConstantFactor	= _depthBiasConstantFactor;
821 	depthBiasClamp			= _depthBiasClamp;
822 	depthBiasSlopeFactor	= _depthBiasSlopeFactor;
823 	lineWidth				= _lineWidth;
824 }
825 
MultiSampleState(vk::VkSampleCountFlagBits _rasterizationSamples,vk::VkBool32 _sampleShadingEnable,float _minSampleShading,const std::vector<vk::VkSampleMask> & _sampleMask,bool _alphaToCoverageEnable,bool _alphaToOneEnable)826 PipelineCreateInfo::MultiSampleState::MultiSampleState (vk::VkSampleCountFlagBits				_rasterizationSamples,
827 														vk::VkBool32							_sampleShadingEnable,
828 														float									_minSampleShading,
829 														const std::vector<vk::VkSampleMask>&	_sampleMask,
830 														bool									_alphaToCoverageEnable,
831 														bool									_alphaToOneEnable)
832 	: m_sampleMask(_sampleMask)
833 {
834 	sType = vk::VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
835 	pNext = DE_NULL;
836 	flags					= 0u;
837 	rasterizationSamples	= _rasterizationSamples;
838 	sampleShadingEnable		= _sampleShadingEnable;
839 	minSampleShading		= _minSampleShading;
840 	pSampleMask				= &m_sampleMask[0];
841 	alphaToCoverageEnable   = _alphaToCoverageEnable;
842 	alphaToOneEnable		= _alphaToOneEnable;
843 }
844 
MultiSampleState(const MultiSampleState & other)845 PipelineCreateInfo::MultiSampleState::MultiSampleState (const MultiSampleState& other)
846 {
847 	sType					= other.sType;
848 	pNext					= other.pNext;
849 	flags					= other.flags;
850 	rasterizationSamples	= other.rasterizationSamples;
851 	sampleShadingEnable		= other.sampleShadingEnable;
852 	minSampleShading		= other.minSampleShading;
853 
854 	const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
855 
856 	m_sampleMask	= std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
857 	pSampleMask		= &m_sampleMask[0];
858 }
859 
operator =(const MultiSampleState & other)860 PipelineCreateInfo::MultiSampleState& PipelineCreateInfo::MultiSampleState::operator= (const MultiSampleState& other)
861 {
862 	sType = other.sType;
863 	pNext = other.pNext;
864 	flags					= other.flags;
865 	rasterizationSamples	= other.rasterizationSamples;
866 	sampleShadingEnable		= other.sampleShadingEnable;
867 	minSampleShading		= other.minSampleShading;
868 
869 	const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
870 
871 	m_sampleMask	= std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
872 	pSampleMask		= &m_sampleMask[0];
873 
874 	return *this;
875 }
876 
ColorBlendState(const std::vector<vk::VkPipelineColorBlendAttachmentState> & _attachments,vk::VkBool32 _logicOpEnable,vk::VkLogicOp _logicOp)877 PipelineCreateInfo::ColorBlendState::ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>&	_attachments,
878 													  vk::VkBool32													_logicOpEnable,
879 													  vk::VkLogicOp													_logicOp)
880 	: m_attachments(_attachments)
881 {
882 	sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
883 	pNext = DE_NULL;
884 	flags					= 0u;
885 	logicOpEnable			= _logicOpEnable;
886 	logicOp					= _logicOp;
887 	attachmentCount			= static_cast<deUint32>(m_attachments.size());
888 	pAttachments			= &m_attachments[0];
889 }
890 
ColorBlendState(deUint32 _attachmentCount,const vk::VkPipelineColorBlendAttachmentState * _attachments,vk::VkBool32 _logicOpEnable,vk::VkLogicOp _logicOp)891 PipelineCreateInfo::ColorBlendState::ColorBlendState (deUint32											_attachmentCount,
892 													  const vk::VkPipelineColorBlendAttachmentState*	_attachments,
893 													  vk::VkBool32										_logicOpEnable,
894 													  vk::VkLogicOp										_logicOp)
895 	: m_attachments(_attachments, _attachments + _attachmentCount)
896 {
897 	sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
898 	pNext	= DE_NULL;
899 	flags					= 0;
900 	logicOpEnable			= _logicOpEnable;
901 	logicOp					= _logicOp;
902 	attachmentCount			= static_cast<deUint32>(m_attachments.size());
903 	pAttachments			= &m_attachments[0];
904 }
905 
ColorBlendState(const vk::VkPipelineColorBlendStateCreateInfo & createInfo)906 PipelineCreateInfo::ColorBlendState::ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo& createInfo)
907 	: m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
908 {
909 	sType = createInfo.sType;
910 	pNext = createInfo.pNext;
911 	flags					= createInfo.flags;
912 	logicOpEnable			= createInfo.logicOpEnable;
913 	logicOp					= createInfo.logicOp;
914 	attachmentCount			= static_cast<deUint32>(m_attachments.size());
915 	pAttachments			= &m_attachments[0];
916 }
917 
ColorBlendState(const ColorBlendState & createInfo,std::vector<float> _blendConstants)918 PipelineCreateInfo::ColorBlendState::ColorBlendState (const ColorBlendState& createInfo, std::vector<float> _blendConstants)
919 	: m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
920 {
921 	sType = createInfo.sType;
922 	pNext = createInfo.pNext;
923 	flags					= createInfo.flags;
924 	logicOpEnable			= createInfo.logicOpEnable;
925 	logicOp					= createInfo.logicOp;
926 	attachmentCount			= static_cast<deUint32>(m_attachments.size());
927 	pAttachments			= &m_attachments[0];
928 	deMemcpy(blendConstants, &_blendConstants[0], 4 * sizeof(float));
929 }
930 
Attachment(vk::VkBool32 _blendEnable,vk::VkBlendFactor _srcColorBlendFactor,vk::VkBlendFactor _dstColorBlendFactor,vk::VkBlendOp _colorBlendOp,vk::VkBlendFactor _srcAlphaBlendFactor,vk::VkBlendFactor _dstAlphaBlendFactor,vk::VkBlendOp _alphaBlendOp,deUint8 _colorWriteMask)931 PipelineCreateInfo::ColorBlendState::Attachment::Attachment (vk::VkBool32		_blendEnable,
932 															 vk::VkBlendFactor	_srcColorBlendFactor,
933 															 vk::VkBlendFactor	_dstColorBlendFactor,
934 															 vk::VkBlendOp		_colorBlendOp,
935 															 vk::VkBlendFactor	_srcAlphaBlendFactor,
936 															 vk::VkBlendFactor	_dstAlphaBlendFactor,
937 															 vk::VkBlendOp		_alphaBlendOp,
938 															 deUint8			_colorWriteMask)
939 {
940 	blendEnable			= _blendEnable;
941 	srcColorBlendFactor	= _srcColorBlendFactor;
942 	dstColorBlendFactor	= _dstColorBlendFactor;
943 	colorBlendOp		= _colorBlendOp;
944 	srcAlphaBlendFactor	= _srcAlphaBlendFactor;
945 	dstAlphaBlendFactor	= _dstAlphaBlendFactor;
946 	alphaBlendOp		= _alphaBlendOp;
947 	colorWriteMask	= _colorWriteMask;
948 }
949 
StencilOpState(vk::VkStencilOp _failOp,vk::VkStencilOp _passOp,vk::VkStencilOp _depthFailOp,vk::VkCompareOp _compareOp,deUint32 _compareMask,deUint32 _writeMask,deUint32 _reference)950 PipelineCreateInfo::DepthStencilState::StencilOpState::StencilOpState (vk::VkStencilOp	_failOp,
951 																	   vk::VkStencilOp	_passOp,
952 																	   vk::VkStencilOp	_depthFailOp,
953 																	   vk::VkCompareOp	_compareOp,
954 																	   deUint32			_compareMask,
955 																	   deUint32			_writeMask,
956 																	   deUint32			_reference)
957 {
958 	failOp		= _failOp;
959 	passOp		= _passOp;
960 	depthFailOp	= _depthFailOp;
961 	compareOp	= _compareOp;
962 
963 	compareMask	= _compareMask;
964 	writeMask	= _writeMask;
965 	reference	= _reference;
966 }
967 
DepthStencilState(vk::VkBool32 _depthTestEnable,vk::VkBool32 _depthWriteEnable,vk::VkCompareOp _depthCompareOp,vk::VkBool32 _depthBoundsTestEnable,vk::VkBool32 _stencilTestEnable,StencilOpState _front,StencilOpState _back,float _minDepthBounds,float _maxDepthBounds)968 PipelineCreateInfo::DepthStencilState::DepthStencilState (vk::VkBool32		_depthTestEnable,
969 														  vk::VkBool32		_depthWriteEnable,
970 														  vk::VkCompareOp	_depthCompareOp,
971 														  vk::VkBool32		_depthBoundsTestEnable,
972 														  vk::VkBool32		_stencilTestEnable,
973 														  StencilOpState	_front,
974 														  StencilOpState	_back,
975 														  float				_minDepthBounds,
976 														  float				_maxDepthBounds)
977 {
978 	sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
979 	pNext = DE_NULL;
980 	flags					= 0u;
981 	depthTestEnable			= _depthTestEnable;
982 	depthWriteEnable		= _depthWriteEnable;
983 	depthCompareOp			= _depthCompareOp;
984 	depthBoundsTestEnable	= _depthBoundsTestEnable;
985 	stencilTestEnable		= _stencilTestEnable;
986 	front	= _front;
987 	back	= _back;
988 
989 	minDepthBounds = _minDepthBounds;
990 	maxDepthBounds = _maxDepthBounds;
991 }
992 
DynamicState(const std::vector<vk::VkDynamicState> & _dynamicStates)993 PipelineCreateInfo::DynamicState::DynamicState (const std::vector<vk::VkDynamicState>& _dynamicStates)
994 {
995 	sType	= vk::VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
996 	pNext	= DE_NULL;
997 	flags	= 0;
998 
999 	if (!_dynamicStates.size())
1000 	{
1001 		for (size_t i = 0; i < vk::VK_DYNAMIC_STATE_LAST; ++i)
1002 		{
1003 			m_dynamicStates.push_back(static_cast<vk::VkDynamicState>(i));
1004 		}
1005 	}
1006 	else
1007 		m_dynamicStates = _dynamicStates;
1008 
1009 	dynamicStateCount = static_cast<deUint32>(m_dynamicStates.size());
1010 	pDynamicStates = &m_dynamicStates[0];
1011 }
1012 
DynamicState(const DynamicState & other)1013 PipelineCreateInfo::DynamicState::DynamicState (const DynamicState &other)
1014 {
1015 	sType = other.sType;
1016 	pNext = other.pNext;
1017 
1018 	flags				= other.flags;
1019 	dynamicStateCount	= other.dynamicStateCount;
1020 	m_dynamicStates		= std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1021 	pDynamicStates		= &m_dynamicStates[0];
1022 }
1023 
operator =(const DynamicState & other)1024 PipelineCreateInfo::DynamicState& PipelineCreateInfo::DynamicState::operator= (const DynamicState& other)
1025 {
1026 	sType = other.sType;
1027 	pNext = other.pNext;
1028 
1029 	flags				= other.flags;
1030 	dynamicStateCount	= other.dynamicStateCount;
1031 	m_dynamicStates		= std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1032 	pDynamicStates		= &m_dynamicStates[0];
1033 
1034 	return *this;
1035 }
1036 
PipelineCreateInfo(vk::VkPipelineLayout _layout,vk::VkRenderPass _renderPass,int _subpass,vk::VkPipelineCreateFlags _flags)1037 PipelineCreateInfo::PipelineCreateInfo (vk::VkPipelineLayout		_layout,
1038 										vk::VkRenderPass			_renderPass,
1039 										int							_subpass,
1040 										vk::VkPipelineCreateFlags	_flags)
1041 {
1042 	deMemset(static_cast<vk::VkGraphicsPipelineCreateInfo *>(this), 0,
1043 		sizeof(vk::VkGraphicsPipelineCreateInfo));
1044 
1045 	sType = vk::VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
1046 	pNext = DE_NULL;
1047 	flags				= _flags;
1048 	renderPass			= _renderPass;
1049 	subpass				= _subpass;
1050 	layout				= _layout;
1051 	basePipelineHandle	= DE_NULL;
1052 	basePipelineIndex	= 0;
1053 	pDynamicState		= DE_NULL;
1054 }
1055 
addShader(const vk::VkPipelineShaderStageCreateInfo & shader)1056 PipelineCreateInfo& PipelineCreateInfo::addShader (const vk::VkPipelineShaderStageCreateInfo& shader)
1057 {
1058 	m_shaders.push_back(shader);
1059 
1060 	stageCount	= static_cast<deUint32>(m_shaders.size());
1061 	pStages		= &m_shaders[0];
1062 
1063 	return *this;
1064 }
1065 
addState(const vk::VkPipelineVertexInputStateCreateInfo & state)1066 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineVertexInputStateCreateInfo& state)
1067 {
1068 	m_vertexInputState	= state;
1069 	pVertexInputState	= &m_vertexInputState;
1070 
1071 	return *this;
1072 }
1073 
addState(const vk::VkPipelineInputAssemblyStateCreateInfo & state)1074 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state)
1075 {
1076 	m_inputAssemblyState = state;
1077 	pInputAssemblyState = &m_inputAssemblyState;
1078 
1079 	return *this;
1080 }
1081 
addState(const vk::VkPipelineColorBlendStateCreateInfo & state)1082 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineColorBlendStateCreateInfo& state)
1083 {
1084 	m_colorBlendStateAttachments	= std::vector<vk::VkPipelineColorBlendAttachmentState>(state.pAttachments, state.pAttachments + state.attachmentCount);
1085 	m_colorBlendState				= state;
1086 	m_colorBlendState.pAttachments	= &m_colorBlendStateAttachments[0];
1087 	pColorBlendState				= &m_colorBlendState;
1088 
1089 	return *this;
1090 }
1091 
addState(const vk::VkPipelineViewportStateCreateInfo & state)1092 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineViewportStateCreateInfo& state)
1093 {
1094 	m_viewports					= std::vector<vk::VkViewport>(state.pViewports, state.pViewports + state.viewportCount);
1095 	m_scissors					= std::vector<vk::VkRect2D>(state.pScissors, state.pScissors + state.scissorCount);
1096 	m_viewportState				= state;
1097 	m_viewportState.pViewports	= &m_viewports[0];
1098 	m_viewportState.pScissors	= &m_scissors[0];
1099 	pViewportState				= &m_viewportState;
1100 
1101 	return *this;
1102 }
1103 
addState(const vk::VkPipelineDepthStencilStateCreateInfo & state)1104 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDepthStencilStateCreateInfo& state)
1105 {
1106 	m_dynamicDepthStencilState	= state;
1107 	pDepthStencilState			= &m_dynamicDepthStencilState;
1108 	return *this;
1109 }
1110 
addState(const vk::VkPipelineTessellationStateCreateInfo & state)1111 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineTessellationStateCreateInfo& state)
1112 {
1113 	m_tessState			= state;
1114 	pTessellationState	= &m_tessState;
1115 
1116 	return *this;
1117 }
1118 
addState(const vk::VkPipelineRasterizationStateCreateInfo & state)1119 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineRasterizationStateCreateInfo& state)
1120 {
1121 	m_rasterState		= state;
1122 	pRasterizationState	= &m_rasterState;
1123 
1124 	return *this;
1125 }
1126 
addState(const vk::VkPipelineMultisampleStateCreateInfo & state)1127 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineMultisampleStateCreateInfo& state)
1128 {
1129 
1130 	const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + state.rasterizationSamples) / ( sizeof(vk::VkSampleMask) * 8 );
1131 	m_multisampleStateSampleMask	= std::vector<vk::VkSampleMask>(state.pSampleMask, state.pSampleMask + sampleMaskArrayLen);
1132 	m_multisampleState				= state;
1133 	m_multisampleState.pSampleMask	= &m_multisampleStateSampleMask[0];
1134 	pMultisampleState				= &m_multisampleState;
1135 
1136 	return *this;
1137 }
addState(const vk::VkPipelineDynamicStateCreateInfo & state)1138 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDynamicStateCreateInfo& state)
1139 {
1140 	m_dynamicStates					= std::vector<vk::VkDynamicState>(state.pDynamicStates, state.pDynamicStates + state.dynamicStateCount);
1141 	m_dynamicState					= state;
1142 	m_dynamicState.pDynamicStates	= &m_dynamicStates[0];
1143 	pDynamicState					= &m_dynamicState;
1144 
1145 	return *this;
1146 }
1147 
SamplerCreateInfo(vk::VkFilter _magFilter,vk::VkFilter _minFilter,vk::VkSamplerMipmapMode _mipmapMode,vk::VkSamplerAddressMode _addressModeU,vk::VkSamplerAddressMode _addressModeV,vk::VkSamplerAddressMode _addressModeW,float _mipLodBias,vk::VkBool32 _anisotropyEnable,float _maxAnisotropy,vk::VkBool32 _compareEnable,vk::VkCompareOp _compareOp,float _minLod,float _maxLod,vk::VkBorderColor _borderColor,vk::VkBool32 _unnormalizedCoordinates)1148 SamplerCreateInfo::SamplerCreateInfo (vk::VkFilter				_magFilter,
1149 									  vk::VkFilter				_minFilter,
1150 									  vk::VkSamplerMipmapMode	_mipmapMode,
1151 									  vk::VkSamplerAddressMode	_addressModeU,
1152 									  vk::VkSamplerAddressMode	_addressModeV,
1153 									  vk::VkSamplerAddressMode	_addressModeW,
1154 									  float						_mipLodBias,
1155 									  vk::VkBool32				_anisotropyEnable,
1156 									  float						_maxAnisotropy,
1157 									  vk::VkBool32				_compareEnable,
1158 									  vk::VkCompareOp			_compareOp,
1159 									  float						_minLod,
1160 									  float						_maxLod,
1161 									  vk::VkBorderColor			_borderColor,
1162 									  vk::VkBool32				_unnormalizedCoordinates)
1163 {
1164 	sType					= vk::VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
1165 	pNext					= DE_NULL;
1166 	flags					= 0u;
1167 	magFilter				= _magFilter;
1168 	minFilter				= _minFilter;
1169 	mipmapMode				= _mipmapMode;
1170 	addressModeU			= _addressModeU;
1171 	addressModeV			= _addressModeV;
1172 	addressModeW			= _addressModeW;
1173 	mipLodBias				= _mipLodBias;
1174 	anisotropyEnable		= _anisotropyEnable;
1175 	maxAnisotropy			= _maxAnisotropy;
1176 	compareEnable			= _compareEnable;
1177 	compareOp				= _compareOp;
1178 	minLod					= _minLod;
1179 	maxLod					= _maxLod;
1180 	borderColor				= _borderColor;
1181 	unnormalizedCoordinates = _unnormalizedCoordinates;
1182 }
1183 } // Draw
1184 } // vkt
1185