Change unnamed enum VK_ constants to defines and update API
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / query_pool / vktQueryPoolCreateInfoUtil.cpp
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 "vktQueryPoolCreateInfoUtil.hpp"
26
27 #include "vkImageUtil.hpp"
28
29 namespace vkt
30 {
31 namespace QueryPool
32 {
33
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
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
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
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
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   = 0u;
128         buffer  = _buffer;
129         format  = _format;
130         offset  = _offset;
131         range   = _range;
132 }
133
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
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
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
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
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
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
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         {
324                 pAttachments = &m_attachmentsStructs[0];
325         }
326         else
327         {
328                 pAttachments = DE_NULL;
329         }
330
331         subpassCount = static_cast<deUint32>(m_subpasses.size());
332
333         if (subpassCount)
334         {
335                 pSubpasses = &m_subpassesStructs[0];
336         }
337         else
338         {
339                 pSubpasses = DE_NULL;
340         }
341
342         dependencyCount = static_cast<deUint32>(m_dependiences.size());
343
344         if (dependencyCount)
345         {
346                 pDependencies = &m_dependiencesStructs[0];
347         }
348         else
349         {
350                 pDependencies = DE_NULL;
351         }
352 }
353
354 void
355 RenderPassCreateInfo::addAttachment (vk::VkAttachmentDescription attachment)
356 {
357
358         m_attachments.push_back(attachment);
359         m_attachmentsStructs    = std::vector<vk::VkAttachmentDescription>(m_attachments.begin(), m_attachments.end());
360         attachmentCount                 = static_cast<deUint32>(m_attachments.size());
361         pAttachments                    = &m_attachmentsStructs[0];
362 }
363
364 void
365 RenderPassCreateInfo::addSubpass (vk::VkSubpassDescription subpass)
366 {
367
368         m_subpasses.push_back(subpass);
369         m_subpassesStructs      = std::vector<vk::VkSubpassDescription>(m_subpasses.begin(), m_subpasses.end());
370         subpassCount            = static_cast<deUint32>(m_subpasses.size());
371         pSubpasses                      = &m_subpassesStructs[0];
372 }
373
374 void
375 RenderPassCreateInfo::addDependency (vk::VkSubpassDependency dependency)
376 {
377
378         m_dependiences.push_back(dependency);
379         m_dependiencesStructs   = std::vector<vk::VkSubpassDependency>(m_dependiences.begin(), m_dependiences.end());
380
381         dependencyCount                 = static_cast<deUint32>(m_dependiences.size());
382         pDependencies                   = &m_dependiencesStructs[0];
383 }
384
385 RenderPassBeginInfo::RenderPassBeginInfo (vk::VkRenderPass                                              _renderPass,
386                                                                                   vk::VkFramebuffer                                             _framebuffer,
387                                                                                   vk::VkRect2D                                                  _renderArea,
388                                                                                   const std::vector<vk::VkClearValue>&  _clearValues)
389 {
390
391         m_clearValues   = _clearValues;
392
393         sType                   = vk::VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
394         pNext                   = DE_NULL;
395         renderPass              = _renderPass;
396         framebuffer             = _framebuffer;
397         renderArea              = _renderArea;
398         clearValueCount = static_cast<deUint32>(m_clearValues.size());
399         pClearValues    = m_clearValues.size() ? &m_clearValues[0] : DE_NULL;
400 }
401
402 CmdPoolCreateInfo::CmdPoolCreateInfo (deUint32 _queueFamilyIndex, unsigned int _flags)
403 {
404         sType = vk::VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
405         pNext = DE_NULL;
406
407         queueFamilyIndex = _queueFamilyIndex;
408         flags                           = _flags;
409 }
410
411 AttachmentDescription::AttachmentDescription (vk::VkFormat                              _format,
412                                                                                           vk::VkSampleCountFlagBits     _samples,
413                                                                                           vk::VkAttachmentLoadOp        _loadOp,
414                                                                                           vk::VkAttachmentStoreOp       _storeOp,
415                                                                                           vk::VkAttachmentLoadOp        _stencilLoadOp,
416                                                                                           vk::VkAttachmentStoreOp       _stencilStoreOp,
417                                                                                           vk::VkImageLayout                     _initialLayout,
418                                                                                           vk::VkImageLayout                     _finalLayout)
419 {
420         flags = 0;
421         format                  = _format;
422         samples                 = _samples;
423         loadOp                  = _loadOp;
424         storeOp                 = _storeOp;
425         stencilLoadOp   = _stencilLoadOp;
426         stencilStoreOp  = _stencilStoreOp;
427         initialLayout   = _initialLayout;
428         finalLayout             = _finalLayout;
429 }
430
431 AttachmentDescription::AttachmentDescription (const vk::VkAttachmentDescription& rhs)
432 {
433         flags                   = rhs.flags;
434         format                  = rhs.format;
435         samples                 = rhs.samples;
436         loadOp                  = rhs.loadOp;
437         storeOp                 = rhs.storeOp;
438         stencilLoadOp   = rhs.stencilLoadOp;
439         stencilStoreOp  = rhs.stencilStoreOp;
440         initialLayout   = rhs.initialLayout;
441         finalLayout             = rhs.finalLayout;
442 }
443
444 AttachmentReference::AttachmentReference (deUint32 _attachment, vk::VkImageLayout _layout)
445 {
446         attachment      = _attachment;
447         layout          = _layout;
448 }
449
450 AttachmentReference::AttachmentReference (void)
451 {
452         attachment = VK_ATTACHMENT_UNUSED;
453         layout = vk::VK_IMAGE_LAYOUT_UNDEFINED;
454 }
455
456 SubpassDescription::SubpassDescription (vk::VkPipelineBindPoint                         _pipelineBindPoint,
457                                                                                 vk::VkSubpassDescriptionFlags           _flags,
458                                                                                 deUint32                                                        _inputAttachmentCount,
459                                                                                 const vk::VkAttachmentReference*        _inputAttachments,
460                                                                                 deUint32                                                        _colorAttachmentCount,
461                                                                                 const vk::VkAttachmentReference*        _colorAttachments,
462                                                                                 const vk::VkAttachmentReference*        _resolveAttachments,
463                                                                                 vk::VkAttachmentReference                       depthStencilAttachment,
464                                                                                 deUint32                                                        _preserveAttachmentCount,
465                                                                                 const deUint32*                                         _preserveAttachments)
466 {
467         m_inputAttachments = std::vector<vk::VkAttachmentReference>(_inputAttachments, _inputAttachments + _inputAttachmentCount);
468         m_colorAttachments = std::vector<vk::VkAttachmentReference>(_colorAttachments, _colorAttachments + _colorAttachmentCount);
469
470         if (_resolveAttachments)
471                 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(_resolveAttachments, _resolveAttachments + _colorAttachmentCount);
472
473         m_preserveAttachments = std::vector<deUint32>(_preserveAttachments, _preserveAttachments + _preserveAttachmentCount);
474
475         m_depthStencilAttachment = depthStencilAttachment;
476
477         flags                                   = _flags;
478         pipelineBindPoint               = _pipelineBindPoint;
479         inputAttachmentCount    = _inputAttachmentCount;
480         pInputAttachments               = DE_NULL;
481         colorAttachmentCount    = _colorAttachmentCount;
482         pColorAttachments               = DE_NULL;
483         pResolveAttachments             = DE_NULL;
484         pDepthStencilAttachment = &m_depthStencilAttachment;
485         pPreserveAttachments    = DE_NULL;
486         preserveAttachmentCount = _preserveAttachmentCount;
487
488         if (!m_inputAttachments.empty())
489                 pInputAttachments = &m_inputAttachments[0];
490
491         if (!m_colorAttachments.empty())
492                 pColorAttachments = &m_colorAttachments[0];
493
494         if (!m_resolveAttachments.empty())
495                 pResolveAttachments = &m_resolveAttachments[0];
496
497         if (!m_preserveAttachments.empty())
498                 pPreserveAttachments = &m_preserveAttachments[0];
499 }
500
501 SubpassDescription::SubpassDescription (const vk::VkSubpassDescription& rhs)
502 {
503         *static_cast<vk::VkSubpassDescription*>(this) = rhs;
504
505         m_inputAttachments = std::vector<vk::VkAttachmentReference>(
506                 rhs.pInputAttachments, rhs.pInputAttachments + rhs.inputAttachmentCount);
507
508         m_colorAttachments = std::vector<vk::VkAttachmentReference>(
509                 rhs.pColorAttachments, rhs.pColorAttachments + rhs.colorAttachmentCount);
510
511         if (rhs.pResolveAttachments)
512                 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(
513                         rhs.pResolveAttachments, rhs.pResolveAttachments + rhs.colorAttachmentCount);
514
515         m_preserveAttachments = std::vector<deUint32>(
516                 rhs.pPreserveAttachments, rhs.pPreserveAttachments + rhs.preserveAttachmentCount);
517
518         if (rhs.pDepthStencilAttachment)
519                 m_depthStencilAttachment = *rhs.pDepthStencilAttachment;
520
521         if (!m_inputAttachments.empty())
522                 pInputAttachments = &m_inputAttachments[0];
523
524         if (!m_colorAttachments.empty())
525                 pColorAttachments = &m_colorAttachments[0];
526
527         if (!m_resolveAttachments.empty())
528                 pResolveAttachments = &m_resolveAttachments[0];
529
530         pDepthStencilAttachment = &m_depthStencilAttachment;
531
532         if (!m_preserveAttachments.empty())
533                 pPreserveAttachments = &m_preserveAttachments[0];
534 }
535
536 SubpassDescription::SubpassDescription (const SubpassDescription& rhs) {
537         *this = rhs;
538 }
539
540 SubpassDescription& SubpassDescription::operator= (const SubpassDescription& rhs)
541 {
542         *static_cast<vk::VkSubpassDescription*>(this) = rhs;
543
544         m_inputAttachments              = rhs.m_inputAttachments;
545         m_colorAttachments              = rhs.m_colorAttachments;
546         m_resolveAttachments    = rhs.m_resolveAttachments;
547         m_preserveAttachments   = rhs.m_preserveAttachments;
548         m_depthStencilAttachment = rhs.m_depthStencilAttachment;
549
550         if (!m_inputAttachments.empty())
551                 pInputAttachments = &m_inputAttachments[0];
552
553         if (!m_colorAttachments.empty())
554                 pColorAttachments = &m_colorAttachments[0];
555
556         if (!m_resolveAttachments.empty())
557                 pResolveAttachments = &m_resolveAttachments[0];
558
559         pDepthStencilAttachment = &m_depthStencilAttachment;
560
561         if (!m_preserveAttachments.empty())
562                 pPreserveAttachments = &m_preserveAttachments[0];
563
564         return *this;
565 }
566
567 SubpassDependency::SubpassDependency (deUint32                                  _srcSubpass,
568                                                                           deUint32                                      _dstSubpass,
569                                                                           vk::VkPipelineStageFlags      _srcStageMask,
570                                                                           vk::VkPipelineStageFlags      _dstStageMask,
571                                                                           vk::VkAccessFlags                     _srcAccessMask,
572                                                                           vk::VkAccessFlags                     _dstAccessMask,
573                                                                           vk::VkDependencyFlags         _dependencyFlags)
574 {
575         srcSubpass              = _srcSubpass;
576         dstSubpass              = _dstSubpass;
577         srcStageMask    = _srcStageMask;
578         dstStageMask    = _dstStageMask;
579         srcAccessMask   = _srcAccessMask;
580         dstAccessMask   = _dstAccessMask;
581         dependencyFlags = _dependencyFlags;
582 }
583
584 SubpassDependency::SubpassDependency (const vk::VkSubpassDependency& rhs)
585 {
586         srcSubpass              = rhs.srcSubpass;
587         dstSubpass              = rhs.dstSubpass;
588         srcStageMask    = rhs.srcStageMask;
589         dstStageMask    = rhs.dstStageMask;
590         srcAccessMask   = rhs.srcAccessMask;
591         dstAccessMask   = rhs.dstAccessMask;
592         dependencyFlags = rhs.dependencyFlags;
593 }
594
595 CmdBufferBeginInfo::CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags _flags)
596 {
597         sType                           = vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
598         pNext                           = DE_NULL;
599         flags                           = _flags;
600         pInheritanceInfo        = DE_NULL;
601 }
602
603 DescriptorPoolCreateInfo::DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>&        poolSizeCounts,
604                                                                                                         vk::VkDescriptorPoolCreateFlags                                 _flags,
605                                                                                                         deUint32                                                                                _maxSets)
606         : m_poolSizeCounts(poolSizeCounts)
607 {
608         sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
609         pNext = DE_NULL;
610         flags                   = _flags;
611         maxSets                 = _maxSets;
612         poolSizeCount   = static_cast<deUint32>(m_poolSizeCounts.size());
613         pPoolSizes              = &m_poolSizeCounts[0];
614 }
615
616 DescriptorPoolCreateInfo& DescriptorPoolCreateInfo::addDescriptors (vk::VkDescriptorType type, deUint32 count)
617 {
618         vk::VkDescriptorPoolSize descriptorTypeCount = { type, count };
619         m_poolSizeCounts.push_back(descriptorTypeCount);
620
621         poolSizeCount   = static_cast<deUint32>(m_poolSizeCounts.size());
622         pPoolSizes              = &m_poolSizeCounts[0];
623
624         return *this;
625 }
626
627 DescriptorSetLayoutCreateInfo::DescriptorSetLayoutCreateInfo (deUint32 _bindingCount, const vk::VkDescriptorSetLayoutBinding* _pBindings)
628 {
629         sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
630         pNext = DE_NULL;
631         flags = 0;
632         bindingCount = _bindingCount;
633         pBindings        = _pBindings;
634 }
635
636 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (deUint32                                                    _descriptorSetCount,
637                                                                                                         const vk::VkDescriptorSetLayout*        _pSetLayouts,
638                                                                                                         deUint32                                                        _pushConstantRangeCount,
639                                                                                                         const vk::VkPushConstantRange*          _pPushConstantRanges)
640         : m_pushConstantRanges(_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
641 {
642         for (unsigned int i = 0; i < _descriptorSetCount; i++)
643         {
644                 m_setLayouts.push_back(_pSetLayouts[i]);
645         }
646
647         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
648         pNext = DE_NULL;
649
650         flags                                   = 0u;
651         setLayoutCount                  = static_cast<deUint32>(m_setLayouts.size());
652         pSetLayouts                             = setLayoutCount > 0 ? &m_setLayouts[0] : DE_NULL;
653         pushConstantRangeCount  = static_cast<deUint32>(m_pushConstantRanges.size());
654
655         if (m_pushConstantRanges.size())
656         {
657                 pPushConstantRanges = &m_pushConstantRanges[0];
658         }
659         else
660         {
661                 pPushConstantRanges = DE_NULL;
662         }
663 }
664
665 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (const std::vector<vk::VkDescriptorSetLayout>&       setLayouts,
666                                                                                                         deUint32                                                                                _pushConstantRangeCount,
667                                                                                                         const vk::VkPushConstantRange*                                  _pPushConstantRanges)
668         : m_setLayouts                  (setLayouts)
669         , m_pushConstantRanges  (_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
670 {
671         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
672         pNext = DE_NULL;
673
674         flags                   = 0u;
675         setLayoutCount  = static_cast<deUint32>(m_setLayouts.size());
676
677         if (setLayoutCount)
678         {
679                 pSetLayouts = &m_setLayouts[0];
680         }
681         else
682         {
683                 pSetLayouts = DE_NULL;
684         }
685
686         pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
687         if (pushConstantRangeCount)
688         {
689                 pPushConstantRanges = &m_pushConstantRanges[0];
690         }
691         else
692         {
693                 pPushConstantRanges = DE_NULL;
694         }
695 }
696
697 PipelineCreateInfo::PipelineShaderStage::PipelineShaderStage (vk::VkShaderModule _module, const char* _pName, vk::VkShaderStageFlagBits _stage)
698 {
699         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
700         pNext = DE_NULL;
701         flags = 0u;
702         stage                           = _stage;
703         module                          = _module;
704         pName                           = _pName;
705         pSpecializationInfo = DE_NULL;
706 }
707
708 PipelineCreateInfo::VertexInputState::VertexInputState (deUint32                                                                                _vertexBindingDescriptionCount,
709                                                                                                                 const vk::VkVertexInputBindingDescription*              _pVertexBindingDescriptions,
710                                                                                                                 deUint32                                                                                _vertexAttributeDescriptionCount,
711                                                                                                                 const vk::VkVertexInputAttributeDescription*    _pVertexAttributeDescriptions)
712 {
713         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
714         pNext = DE_NULL;
715         flags                                                   = 0u;
716         vertexBindingDescriptionCount   = _vertexBindingDescriptionCount;
717         pVertexBindingDescriptions              = _pVertexBindingDescriptions;
718         vertexAttributeDescriptionCount = _vertexAttributeDescriptionCount;
719         pVertexAttributeDescriptions    = _pVertexAttributeDescriptions;
720 }
721
722 PipelineCreateInfo::InputAssemblerState::InputAssemblerState (vk::VkPrimitiveTopology   _topology,
723                                                                                                                           vk::VkBool32                          _primitiveRestartEnable)
724 {
725         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
726         pNext = DE_NULL;
727         flags                                   = 0u;
728         topology                                = _topology;
729         primitiveRestartEnable  = _primitiveRestartEnable;
730 }
731
732 PipelineCreateInfo::TessellationState::TessellationState (deUint32 _patchControlPoints)
733 {
734         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
735         pNext = DE_NULL;
736         flags                           = 0u;
737         patchControlPoints      = _patchControlPoints;
738 }
739
740 PipelineCreateInfo::ViewportState::ViewportState (deUint32                                              _viewportCount,
741                                                                                                   std::vector<vk::VkViewport>   _viewports,
742                                                                                                   std::vector<vk::VkRect2D>             _scissors)
743 {
744         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
745         pNext = DE_NULL;
746         flags                   = 0u;
747         viewportCount   = _viewportCount;
748         scissorCount    = _viewportCount;
749
750         if (!_viewports.size())
751         {
752                 m_viewports.resize(viewportCount);
753                 deMemset(&m_viewports[0], 0, sizeof(m_viewports[0]) * m_viewports.size());
754         }
755         else
756         {
757                 m_viewports = _viewports;
758         }
759
760         if (!_scissors.size())
761         {
762                 m_scissors.resize(scissorCount);
763                 deMemset(&m_scissors[0], 0, sizeof(m_scissors[0]) * m_scissors.size());
764         }
765         else
766         {
767                 m_scissors = _scissors;
768         }
769
770         pViewports      = &m_viewports[0];
771         pScissors       = &m_scissors[0];
772 }
773
774 PipelineCreateInfo::ViewportState::ViewportState (const ViewportState& other)
775 {
776         sType                   = other.sType;
777         pNext                   = other.pNext;
778         flags                   = other.flags;
779         viewportCount   = other.viewportCount;
780         scissorCount    = other.scissorCount;
781
782         m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + viewportCount);
783         m_scissors      = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
784
785         pViewports      = &m_viewports[0];
786         pScissors       = &m_scissors[0];
787 }
788
789 PipelineCreateInfo::ViewportState& PipelineCreateInfo::ViewportState::operator= (const ViewportState& other)
790 {
791         sType                   = other.sType;
792         pNext                   = other.pNext;
793         flags                   = other.flags;
794         viewportCount   = other.viewportCount;
795         scissorCount    = other.scissorCount;
796
797         m_viewports             = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + scissorCount);
798         m_scissors              = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
799
800         pViewports              = &m_viewports[0];
801         pScissors               = &m_scissors[0];
802         return *this;
803 }
804
805 PipelineCreateInfo::RasterizerState::RasterizerState (vk::VkBool32                      _depthClampEnable,
806                                                                                                           vk::VkBool32                  _rasterizerDiscardEnable,
807                                                                                                           vk::VkPolygonMode             _polygonMode,
808                                                                                                           vk::VkCullModeFlags   _cullMode,
809                                                                                                           vk::VkFrontFace               _frontFace,
810                                                                                                           vk::VkBool32                  _depthBiasEnable,
811                                                                                                           float                                 _depthBiasConstantFactor,
812                                                                                                           float                                 _depthBiasClamp,
813                                                                                                           float                                 _depthBiasSlopeFactor,
814                                                                                                           float                                 _lineWidth)
815 {
816         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
817         pNext = DE_NULL;
818         flags                                   = 0u;
819         depthClampEnable                = _depthClampEnable;
820         rasterizerDiscardEnable = _rasterizerDiscardEnable;
821         polygonMode                             = _polygonMode;
822         cullMode                                = _cullMode;
823         frontFace                               = _frontFace;
824
825         depthBiasEnable                 = _depthBiasEnable;
826         depthBiasConstantFactor = _depthBiasConstantFactor;
827         depthBiasClamp                  = _depthBiasClamp;
828         depthBiasSlopeFactor    = _depthBiasSlopeFactor;
829         lineWidth                               = _lineWidth;
830 }
831
832 PipelineCreateInfo::MultiSampleState::MultiSampleState (vk::VkSampleCountFlagBits                               _rasterizationSamples,
833                                                                                                                 vk::VkBool32                                                    _sampleShadingEnable,
834                                                                                                                 float                                                                   _minSampleShading,
835                                                                                                                 const std::vector<vk::VkSampleMask>&    _sampleMask,
836                                                                                                                 bool                                                                    _alphaToCoverageEnable,
837                                                                                                                 bool                                                                    _alphaToOneEnable)
838         : m_sampleMask(_sampleMask)
839 {
840         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
841         pNext = DE_NULL;
842         flags                                   = 0u;
843         rasterizationSamples    = _rasterizationSamples;
844         sampleShadingEnable             = _sampleShadingEnable;
845         minSampleShading                = _minSampleShading;
846         pSampleMask                             = &m_sampleMask[0];
847         alphaToCoverageEnable   = _alphaToCoverageEnable;
848         alphaToOneEnable                = _alphaToOneEnable;
849 }
850
851 PipelineCreateInfo::MultiSampleState::MultiSampleState (const MultiSampleState& other)
852 {
853         sType                                   = other.sType;
854         pNext                                   = other.pNext;
855         flags                                   = other.flags;
856         rasterizationSamples    = other.rasterizationSamples;
857         sampleShadingEnable             = other.sampleShadingEnable;
858         minSampleShading                = other.minSampleShading;
859
860         const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
861
862         m_sampleMask    = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
863         pSampleMask             = &m_sampleMask[0];
864 }
865
866 PipelineCreateInfo::MultiSampleState& PipelineCreateInfo::MultiSampleState::operator= (const MultiSampleState& other)
867 {
868         sType = other.sType;
869         pNext = other.pNext;
870         flags                                   = other.flags;
871         rasterizationSamples    = other.rasterizationSamples;
872         sampleShadingEnable             = other.sampleShadingEnable;
873         minSampleShading                = other.minSampleShading;
874
875         const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
876
877         m_sampleMask    = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
878         pSampleMask             = &m_sampleMask[0];
879
880         return *this;
881 }
882
883 PipelineCreateInfo::ColorBlendState::ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>&       _attachments,
884                                                                                                           vk::VkBool32                                                                                                  _logicOpEnable,
885                                                                                                           vk::VkLogicOp                                                                                                 _logicOp)
886         : m_attachments(_attachments)
887 {
888         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
889         pNext = DE_NULL;
890         flags                                   = 0u;
891         logicOpEnable                   = _logicOpEnable;
892         logicOp                                 = _logicOp;
893         attachmentCount                 = static_cast<deUint32>(m_attachments.size());
894         pAttachments                    = &m_attachments[0];
895 }
896
897 PipelineCreateInfo::ColorBlendState::ColorBlendState (deUint32                                                                                  _attachmentCount,
898                                                                                                           const vk::VkPipelineColorBlendAttachmentState*        _attachments,
899                                                                                                           vk::VkBool32                                                                          _logicOpEnable,
900                                                                                                           vk::VkLogicOp                                                                         _logicOp)
901         : m_attachments(_attachments, _attachments + _attachmentCount)
902 {
903         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
904         pNext   = DE_NULL;
905         flags                                   = 0u;
906         logicOpEnable                   = _logicOpEnable;
907         logicOp                                 = _logicOp;
908         attachmentCount                 = static_cast<deUint32>(m_attachments.size());
909         pAttachments                    = &m_attachments[0];
910 }
911
912 PipelineCreateInfo::ColorBlendState::ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo& createInfo)
913         : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
914 {
915         sType = createInfo.sType;
916         pNext = createInfo.pNext;
917         flags                                   = createInfo.flags;
918         logicOpEnable                   = createInfo.logicOpEnable;
919         logicOp                                 = createInfo.logicOp;
920         attachmentCount                 = static_cast<deUint32>(m_attachments.size());
921         pAttachments                    = &m_attachments[0];
922 }
923
924 PipelineCreateInfo::ColorBlendState::ColorBlendState (const ColorBlendState& createInfo, std::vector<float> _blendConstants)
925         : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
926 {
927         sType = createInfo.sType;
928         pNext = createInfo.pNext;
929         flags                                   = createInfo.flags;
930         logicOpEnable                   = createInfo.logicOpEnable;
931         logicOp                                 = createInfo.logicOp;
932         attachmentCount                 = static_cast<deUint32>(m_attachments.size());
933         pAttachments                    = &m_attachments[0];
934         deMemcpy(blendConstants, &_blendConstants[0], 4 * sizeof(float));
935 }
936
937 PipelineCreateInfo::ColorBlendState::Attachment::Attachment (vk::VkBool32               _blendEnable,
938                                                                                                                          vk::VkBlendFactor      _srcColorBlendFactor,
939                                                                                                                          vk::VkBlendFactor      _dstColorBlendFactor,
940                                                                                                                          vk::VkBlendOp          _colorBlendOp,
941                                                                                                                          vk::VkBlendFactor      _srcAlphaBlendFactor,
942                                                                                                                          vk::VkBlendFactor      _dstAlphaBlendFactor,
943                                                                                                                          vk::VkBlendOp          _alphaBlendOp,
944                                                                                                                          deUint8                        _colorWriteMask)
945 {
946         blendEnable                     = _blendEnable;
947         srcColorBlendFactor     = _srcColorBlendFactor;
948         dstColorBlendFactor     = _dstColorBlendFactor;
949         colorBlendOp            = _colorBlendOp;
950         srcAlphaBlendFactor     = _srcAlphaBlendFactor;
951         dstAlphaBlendFactor     = _dstAlphaBlendFactor;
952         alphaBlendOp            = _alphaBlendOp;
953         colorWriteMask  = _colorWriteMask;
954 }
955
956 PipelineCreateInfo::DepthStencilState::StencilOpState::StencilOpState (vk::VkStencilOp  _failOp,
957                                                                                                                                            vk::VkStencilOp      _passOp,
958                                                                                                                                            vk::VkStencilOp      _depthFailOp,
959                                                                                                                                            vk::VkCompareOp      _compareOp,
960                                                                                                                                            deUint32                     _compareMask,
961                                                                                                                                            deUint32                     _writeMask,
962                                                                                                                                            deUint32                     _reference)
963 {
964         failOp          = _failOp;
965         passOp          = _passOp;
966         depthFailOp     = _depthFailOp;
967         compareOp       = _compareOp;
968
969         compareMask     = _compareMask;
970         writeMask       = _writeMask;
971         reference       = _reference;
972 }
973
974 PipelineCreateInfo::DepthStencilState::DepthStencilState (vk::VkBool32          _depthTestEnable,
975                                                                                                                   vk::VkBool32          _depthWriteEnable,
976                                                                                                                   vk::VkCompareOp       _depthCompareOp,
977                                                                                                                   vk::VkBool32          _depthBoundsTestEnable,
978                                                                                                                   vk::VkBool32          _stencilTestEnable,
979                                                                                                                   StencilOpState        _front,
980                                                                                                                   StencilOpState        _back,
981                                                                                                                   float                         _minDepthBounds,
982                                                                                                                   float                         _maxDepthBounds)
983 {
984         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
985         pNext = DE_NULL;
986         flags                                   = 0u;
987         depthTestEnable                 = _depthTestEnable;
988         depthWriteEnable                = _depthWriteEnable;
989         depthCompareOp                  = _depthCompareOp;
990         depthBoundsTestEnable   = _depthBoundsTestEnable;
991         stencilTestEnable               = _stencilTestEnable;
992         front   = _front;
993         back    = _back;
994
995         minDepthBounds = _minDepthBounds;
996         maxDepthBounds = _maxDepthBounds;
997 }
998
999 PipelineCreateInfo::DynamicState::DynamicState (const std::vector<vk::VkDynamicState>& _dynamicStates)
1000 {
1001         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
1002         pNext = DE_NULL;
1003         flags = 0u;
1004
1005         if (!_dynamicStates.size())
1006         {
1007                 for (size_t i = 0; i < vk::VK_DYNAMIC_STATE_LAST; ++i)
1008                 {
1009                         m_dynamicStates.push_back(static_cast<vk::VkDynamicState>(i));
1010                 }
1011         }
1012         else
1013                 m_dynamicStates = _dynamicStates;
1014
1015         dynamicStateCount = static_cast<deUint32>(m_dynamicStates.size());
1016         pDynamicStates = &m_dynamicStates[0];
1017 }
1018
1019 PipelineCreateInfo::DynamicState::DynamicState (const DynamicState &other)
1020 {
1021         sType = other.sType;
1022         pNext = other.pNext;
1023         flags = other.flags;
1024
1025         dynamicStateCount = other.dynamicStateCount;
1026
1027         m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1028         pDynamicStates = &m_dynamicStates[0];
1029 }
1030
1031 PipelineCreateInfo::DynamicState& PipelineCreateInfo::DynamicState::operator= (const DynamicState& other)
1032 {
1033         sType = other.sType;
1034         pNext = other.pNext;
1035         flags = other.flags;
1036
1037         dynamicStateCount = other.dynamicStateCount;
1038
1039         m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1040         pDynamicStates = &m_dynamicStates[0];
1041
1042         return *this;
1043 }
1044
1045 PipelineCreateInfo::PipelineCreateInfo (vk::VkPipelineLayout            _layout,
1046                                                                                 vk::VkRenderPass                        _renderPass,
1047                                                                                 int                                                     _subpass,
1048                                                                                 vk::VkPipelineCreateFlags       _flags)
1049 {
1050         deMemset(static_cast<vk::VkGraphicsPipelineCreateInfo *>(this), 0,
1051                 sizeof(vk::VkGraphicsPipelineCreateInfo));
1052
1053         sType = vk::VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
1054         pNext = DE_NULL;
1055         flags                           = _flags;
1056         renderPass                      = _renderPass;
1057         subpass                         = _subpass;
1058         layout                          = _layout;
1059         basePipelineHandle      = DE_NULL;
1060         basePipelineIndex       = 0;
1061         pDynamicState           = DE_NULL;
1062 }
1063
1064 PipelineCreateInfo& PipelineCreateInfo::addShader (const vk::VkPipelineShaderStageCreateInfo& shader)
1065 {
1066         m_shaders.push_back(shader);
1067
1068         stageCount      = static_cast<deUint32>(m_shaders.size());
1069         pStages         = &m_shaders[0];
1070
1071         return *this;
1072 }
1073
1074 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineVertexInputStateCreateInfo& state)
1075 {
1076         m_vertexInputState      = state;
1077         pVertexInputState       = &m_vertexInputState;
1078
1079         return *this;
1080 }
1081
1082 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state)
1083 {
1084         m_inputAssemblyState = state;
1085         pInputAssemblyState = &m_inputAssemblyState;
1086
1087         return *this;
1088 }
1089
1090 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineColorBlendStateCreateInfo& state)
1091 {
1092         m_colorBlendStateAttachments    = std::vector<vk::VkPipelineColorBlendAttachmentState>(state.pAttachments, state.pAttachments + state.attachmentCount);
1093         m_colorBlendState                               = state;
1094         m_colorBlendState.pAttachments  = &m_colorBlendStateAttachments[0];
1095         pColorBlendState                                = &m_colorBlendState;
1096
1097         return *this;
1098 }
1099
1100 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineViewportStateCreateInfo& state)
1101 {
1102         m_viewports                                     = std::vector<vk::VkViewport>(state.pViewports, state.pViewports + state.viewportCount);
1103         m_scissors                                      = std::vector<vk::VkRect2D>(state.pScissors, state.pScissors + state.scissorCount);
1104         m_viewportState                         = state;
1105         m_viewportState.pViewports      = &m_viewports[0];
1106         m_viewportState.pScissors       = &m_scissors[0];
1107         pViewportState                          = &m_viewportState;
1108
1109         return *this;
1110 }
1111
1112 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDepthStencilStateCreateInfo& state)
1113 {
1114         m_dynamicDepthStencilState      = state;
1115         pDepthStencilState                      = &m_dynamicDepthStencilState;
1116         return *this;
1117 }
1118
1119 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineTessellationStateCreateInfo& state)
1120 {
1121         m_tessState                     = state;
1122         pTessellationState      = &m_tessState;
1123
1124         return *this;
1125 }
1126
1127 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineRasterizationStateCreateInfo& state)
1128 {
1129         m_rasterState           = state;
1130         pRasterizationState     = &m_rasterState;
1131
1132         return *this;
1133 }
1134
1135 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineMultisampleStateCreateInfo& state)
1136 {
1137
1138         const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + state.rasterizationSamples) / ( sizeof(vk::VkSampleMask) * 8 );
1139         m_multisampleStateSampleMask    = std::vector<vk::VkSampleMask>(state.pSampleMask, state.pSampleMask + sampleMaskArrayLen);
1140         m_multisampleState                              = state;
1141         m_multisampleState.pSampleMask  = &m_multisampleStateSampleMask[0];
1142         pMultisampleState                               = &m_multisampleState;
1143
1144         return *this;
1145 }
1146 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDynamicStateCreateInfo& state)
1147 {
1148         m_dynamicStates                                 = std::vector<vk::VkDynamicState>(state.pDynamicStates, state.pDynamicStates + state.dynamicStateCount);
1149         m_dynamicState                                  = state;
1150         m_dynamicState.pDynamicStates   = &m_dynamicStates[0];
1151         pDynamicState                                   = &m_dynamicState;
1152
1153         return *this;
1154 }
1155
1156 SamplerCreateInfo::SamplerCreateInfo (vk::VkFilter                              _magFilter,
1157                                                                           vk::VkFilter                          _minFilter,
1158                                                                           vk::VkSamplerMipmapMode       _mipmapMode,
1159                                                                           vk::VkSamplerAddressMode      _addressModeU,
1160                                                                           vk::VkSamplerAddressMode      _addressModeV,
1161                                                                           vk::VkSamplerAddressMode      _addressModeW,
1162                                                                           float                                         _mipLodBias,
1163                                                                           vk::VkBool32                          _anisotropyEnable,
1164                                                                           float                                         _maxAnisotropy,
1165                                                                           vk::VkBool32                          _compareEnable,
1166                                                                           vk::VkCompareOp                       _compareOp,
1167                                                                           float                                         _minLod,
1168                                                                           float                                         _maxLod,
1169                                                                           vk::VkBorderColor                     _borderColor,
1170                                                                           vk::VkBool32                          _unnormalizedCoordinates)
1171 {
1172         sType                                   = vk::VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
1173         pNext                                   = DE_NULL;
1174         flags                                   = 0u;
1175         magFilter                               = _magFilter;
1176         minFilter                               = _minFilter;
1177         mipmapMode                              = _mipmapMode;
1178         addressModeU                    = _addressModeU;
1179         addressModeV                    = _addressModeV;
1180         addressModeW                    = _addressModeW;
1181         mipLodBias                              = _mipLodBias;
1182         anisotropyEnable                = _anisotropyEnable;
1183         maxAnisotropy                   = _maxAnisotropy;
1184         compareEnable                   = _compareEnable;
1185         compareOp                               = _compareOp;
1186         minLod                                  = _minLod;
1187         maxLod                                  = _maxLod;
1188         borderColor                             = _borderColor;
1189         unnormalizedCoordinates = _unnormalizedCoordinates;
1190 }
1191
1192 } // QueryPool
1193 } // vkt