Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / draw / vktDrawCreateInfoUtil.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 "vktDrawCreateInfoUtil.hpp"
26
27 #include "vkImageUtil.hpp"
28
29 namespace vkt
30 {
31 namespace Draw
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   = 0;
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                 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
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
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
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
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
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
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
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
441 AttachmentReference::AttachmentReference (deUint32 _attachment, vk::VkImageLayout _layout)
442 {
443         attachment      = _attachment;
444         layout          = _layout;
445 }
446
447 AttachmentReference::AttachmentReference (void)
448 {
449         attachment = VK_ATTACHMENT_UNUSED;
450         layout = vk::VK_IMAGE_LAYOUT_UNDEFINED;
451 }
452
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
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
533 SubpassDescription::SubpassDescription (const SubpassDescription& rhs) {
534         *this = rhs;
535 }
536
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
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
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
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
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
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
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
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
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
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
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
716 PipelineCreateInfo::VertexInputState& PipelineCreateInfo::VertexInputState::addDivisors (deUint32                                                                                               _vertexBindingDivisorCount,
717                                                                                                                                                                                  const vk::VkVertexInputBindingDivisorDescriptionEXT*   _pVertexBindingDivisors)
718 {
719         m_divisorState.sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT;
720         m_divisorState.vertexBindingDivisorCount = _vertexBindingDivisorCount;
721         m_divisorState.pVertexBindingDivisors = _pVertexBindingDivisors;
722
723         // Link it into the chainadd
724         m_divisorState.pNext = this->pNext;
725         pNext = &m_divisorState;
726
727         return *this;
728 }
729
730 PipelineCreateInfo::InputAssemblerState::InputAssemblerState (vk::VkPrimitiveTopology   _topology,
731                                                                                                                           vk::VkBool32                          _primitiveRestartEnable)
732 {
733         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
734         pNext = DE_NULL;
735         flags                                   = 0u;
736         topology                                = _topology;
737         primitiveRestartEnable  = _primitiveRestartEnable;
738 }
739
740 PipelineCreateInfo::TessellationState::TessellationState (deUint32 _patchControlPoints)
741 {
742         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
743         pNext = DE_NULL;
744         flags                           = 0;
745         patchControlPoints      = _patchControlPoints;
746 }
747
748 PipelineCreateInfo::ViewportState::ViewportState (deUint32                                              _viewportCount,
749                                                                                                   std::vector<vk::VkViewport>   _viewports,
750                                                                                                   std::vector<vk::VkRect2D>             _scissors)
751 {
752         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
753         pNext = DE_NULL;
754         flags                   = 0u;
755         viewportCount   = _viewportCount;
756         scissorCount    = _viewportCount;
757
758         if (!_viewports.size())
759         {
760                 m_viewports.resize(viewportCount);
761                 deMemset(&m_viewports[0], 0, sizeof(m_viewports[0]) * m_viewports.size());
762         }
763         else
764         {
765                 m_viewports = _viewports;
766         }
767
768         if (!_scissors.size())
769         {
770                 m_scissors.resize(scissorCount);
771                 deMemset(&m_scissors[0], 0, sizeof(m_scissors[0]) * m_scissors.size());
772         }
773         else
774         {
775                 m_scissors = _scissors;
776         }
777
778         pViewports      = &m_viewports[0];
779         pScissors       = &m_scissors[0];
780 }
781
782 PipelineCreateInfo::ViewportState::ViewportState (const ViewportState& other)
783 {
784         sType                   = other.sType;
785         pNext                   = other.pNext;
786         flags                   = other.flags;
787         viewportCount   = other.viewportCount;
788         scissorCount    = other.scissorCount;
789
790         m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + viewportCount);
791         m_scissors      = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
792
793         pViewports      = &m_viewports[0];
794         pScissors       = &m_scissors[0];
795 }
796
797 PipelineCreateInfo::ViewportState& PipelineCreateInfo::ViewportState::operator= (const ViewportState& other)
798 {
799         sType                   = other.sType;
800         pNext                   = other.pNext;
801         flags                   = other.flags;
802         viewportCount   = other.viewportCount;
803         scissorCount    = other.scissorCount;
804
805         m_viewports             = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + scissorCount);
806         m_scissors              = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
807
808         pViewports              = &m_viewports[0];
809         pScissors               = &m_scissors[0];
810         return *this;
811 }
812
813 PipelineCreateInfo::RasterizerState::RasterizerState (vk::VkBool32                      _depthClampEnable,
814                                                                                                           vk::VkBool32                  _rasterizerDiscardEnable,
815                                                                                                           vk::VkPolygonMode             _polygonMode,
816                                                                                                           vk::VkCullModeFlags   _cullMode,
817                                                                                                           vk::VkFrontFace               _frontFace,
818                                                                                                           vk::VkBool32                  _depthBiasEnable,
819                                                                                                           float                                 _depthBiasConstantFactor,
820                                                                                                           float                                 _depthBiasClamp,
821                                                                                                           float                                 _depthBiasSlopeFactor,
822                                                                                                           float                                 _lineWidth)
823 {
824         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
825         pNext = DE_NULL;
826         flags                                   = 0u;
827         depthClampEnable                = _depthClampEnable;
828         rasterizerDiscardEnable = _rasterizerDiscardEnable;
829         polygonMode                             = _polygonMode;
830         cullMode                                = _cullMode;
831         frontFace                               = _frontFace;
832
833         depthBiasEnable                 = _depthBiasEnable;
834         depthBiasConstantFactor = _depthBiasConstantFactor;
835         depthBiasClamp                  = _depthBiasClamp;
836         depthBiasSlopeFactor    = _depthBiasSlopeFactor;
837         lineWidth                               = _lineWidth;
838 }
839
840 PipelineCreateInfo::MultiSampleState::MultiSampleState (vk::VkSampleCountFlagBits                               _rasterizationSamples,
841                                                                                                                 vk::VkBool32                                                    _sampleShadingEnable,
842                                                                                                                 float                                                                   _minSampleShading,
843                                                                                                                 const std::vector<vk::VkSampleMask>&    _sampleMask,
844                                                                                                                 bool                                                                    _alphaToCoverageEnable,
845                                                                                                                 bool                                                                    _alphaToOneEnable)
846         : m_sampleMask(_sampleMask)
847 {
848         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
849         pNext = DE_NULL;
850         flags                                   = 0u;
851         rasterizationSamples    = _rasterizationSamples;
852         sampleShadingEnable             = _sampleShadingEnable;
853         minSampleShading                = _minSampleShading;
854         pSampleMask                             = &m_sampleMask[0];
855         alphaToCoverageEnable   = _alphaToCoverageEnable;
856         alphaToOneEnable                = _alphaToOneEnable;
857 }
858
859 PipelineCreateInfo::MultiSampleState::MultiSampleState (const MultiSampleState& other)
860 {
861         sType                                   = other.sType;
862         pNext                                   = other.pNext;
863         flags                                   = other.flags;
864         rasterizationSamples    = other.rasterizationSamples;
865         sampleShadingEnable             = other.sampleShadingEnable;
866         minSampleShading                = other.minSampleShading;
867
868         const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
869
870         m_sampleMask    = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
871         pSampleMask             = &m_sampleMask[0];
872 }
873
874 PipelineCreateInfo::MultiSampleState& PipelineCreateInfo::MultiSampleState::operator= (const MultiSampleState& other)
875 {
876         sType = other.sType;
877         pNext = other.pNext;
878         flags                                   = other.flags;
879         rasterizationSamples    = other.rasterizationSamples;
880         sampleShadingEnable             = other.sampleShadingEnable;
881         minSampleShading                = other.minSampleShading;
882
883         const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
884
885         m_sampleMask    = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
886         pSampleMask             = &m_sampleMask[0];
887
888         return *this;
889 }
890
891 PipelineCreateInfo::ColorBlendState::ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>&       _attachments,
892                                                                                                           vk::VkBool32                                                                                                  _logicOpEnable,
893                                                                                                           vk::VkLogicOp                                                                                                 _logicOp)
894         : m_attachments(_attachments)
895 {
896         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
897         pNext = DE_NULL;
898         flags                                   = 0u;
899         logicOpEnable                   = _logicOpEnable;
900         logicOp                                 = _logicOp;
901         attachmentCount                 = static_cast<deUint32>(m_attachments.size());
902         pAttachments                    = &m_attachments[0];
903         deMemset(blendConstants, 0, sizeof(blendConstants));
904 }
905
906 PipelineCreateInfo::ColorBlendState::ColorBlendState (deUint32                                                                                  _attachmentCount,
907                                                                                                           const vk::VkPipelineColorBlendAttachmentState*        _attachments,
908                                                                                                           vk::VkBool32                                                                          _logicOpEnable,
909                                                                                                           vk::VkLogicOp                                                                         _logicOp)
910         : m_attachments(_attachments, _attachments + _attachmentCount)
911 {
912         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
913         pNext   = DE_NULL;
914         flags                                   = 0;
915         logicOpEnable                   = _logicOpEnable;
916         logicOp                                 = _logicOp;
917         attachmentCount                 = static_cast<deUint32>(m_attachments.size());
918         pAttachments                    = &m_attachments[0];
919         deMemset(blendConstants, 0, sizeof(blendConstants));
920 }
921
922 PipelineCreateInfo::ColorBlendState::ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo& createInfo)
923         : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
924 {
925         sType = createInfo.sType;
926         pNext = createInfo.pNext;
927         flags                                   = createInfo.flags;
928         logicOpEnable                   = createInfo.logicOpEnable;
929         logicOp                                 = createInfo.logicOp;
930         attachmentCount                 = static_cast<deUint32>(m_attachments.size());
931         pAttachments                    = &m_attachments[0];
932         deMemset(blendConstants, 0, sizeof(blendConstants));
933 }
934
935 PipelineCreateInfo::ColorBlendState::ColorBlendState (const ColorBlendState& createInfo, std::vector<float> _blendConstants)
936         : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
937 {
938         sType = createInfo.sType;
939         pNext = createInfo.pNext;
940         flags                                   = createInfo.flags;
941         logicOpEnable                   = createInfo.logicOpEnable;
942         logicOp                                 = createInfo.logicOp;
943         attachmentCount                 = static_cast<deUint32>(m_attachments.size());
944         pAttachments                    = &m_attachments[0];
945         deMemcpy(blendConstants, &_blendConstants[0], 4 * sizeof(float));
946 }
947
948 PipelineCreateInfo::ColorBlendState::Attachment::Attachment (vk::VkBool32                               _blendEnable,
949                                                                                                                          vk::VkBlendFactor                      _srcColorBlendFactor,
950                                                                                                                          vk::VkBlendFactor                      _dstColorBlendFactor,
951                                                                                                                          vk::VkBlendOp                          _colorBlendOp,
952                                                                                                                          vk::VkBlendFactor                      _srcAlphaBlendFactor,
953                                                                                                                          vk::VkBlendFactor                      _dstAlphaBlendFactor,
954                                                                                                                          vk::VkBlendOp                          _alphaBlendOp,
955                                                                                                                          vk::VkColorComponentFlags      _colorWriteMask)
956 {
957         blendEnable                     = _blendEnable;
958         srcColorBlendFactor     = _srcColorBlendFactor;
959         dstColorBlendFactor     = _dstColorBlendFactor;
960         colorBlendOp            = _colorBlendOp;
961         srcAlphaBlendFactor     = _srcAlphaBlendFactor;
962         dstAlphaBlendFactor     = _dstAlphaBlendFactor;
963         alphaBlendOp            = _alphaBlendOp;
964         colorWriteMask          = _colorWriteMask;
965 }
966
967 PipelineCreateInfo::DepthStencilState::StencilOpState::StencilOpState (vk::VkStencilOp  _failOp,
968                                                                                                                                            vk::VkStencilOp      _passOp,
969                                                                                                                                            vk::VkStencilOp      _depthFailOp,
970                                                                                                                                            vk::VkCompareOp      _compareOp,
971                                                                                                                                            deUint32                     _compareMask,
972                                                                                                                                            deUint32                     _writeMask,
973                                                                                                                                            deUint32                     _reference)
974 {
975         failOp          = _failOp;
976         passOp          = _passOp;
977         depthFailOp     = _depthFailOp;
978         compareOp       = _compareOp;
979
980         compareMask     = _compareMask;
981         writeMask       = _writeMask;
982         reference       = _reference;
983 }
984
985 PipelineCreateInfo::DepthStencilState::DepthStencilState (vk::VkBool32          _depthTestEnable,
986                                                                                                                   vk::VkBool32          _depthWriteEnable,
987                                                                                                                   vk::VkCompareOp       _depthCompareOp,
988                                                                                                                   vk::VkBool32          _depthBoundsTestEnable,
989                                                                                                                   vk::VkBool32          _stencilTestEnable,
990                                                                                                                   StencilOpState        _front,
991                                                                                                                   StencilOpState        _back,
992                                                                                                                   float                         _minDepthBounds,
993                                                                                                                   float                         _maxDepthBounds)
994 {
995         sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
996         pNext = DE_NULL;
997         flags                                   = 0u;
998         depthTestEnable                 = _depthTestEnable;
999         depthWriteEnable                = _depthWriteEnable;
1000         depthCompareOp                  = _depthCompareOp;
1001         depthBoundsTestEnable   = _depthBoundsTestEnable;
1002         stencilTestEnable               = _stencilTestEnable;
1003         front   = _front;
1004         back    = _back;
1005
1006         minDepthBounds = _minDepthBounds;
1007         maxDepthBounds = _maxDepthBounds;
1008 }
1009
1010 PipelineCreateInfo::DynamicState::DynamicState (const std::vector<vk::VkDynamicState>& _dynamicStates)
1011 {
1012         sType   = vk::VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
1013         pNext   = DE_NULL;
1014         flags   = 0;
1015
1016         if (!_dynamicStates.size())
1017         {
1018                 const vk::VkDynamicState dynamicState[] =
1019                 {
1020                         vk::VK_DYNAMIC_STATE_VIEWPORT,
1021                         vk::VK_DYNAMIC_STATE_SCISSOR,
1022                         vk::VK_DYNAMIC_STATE_LINE_WIDTH,
1023                         vk::VK_DYNAMIC_STATE_DEPTH_BIAS,
1024                         vk::VK_DYNAMIC_STATE_BLEND_CONSTANTS,
1025                         vk::VK_DYNAMIC_STATE_DEPTH_BOUNDS,
1026                         vk::VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK,
1027                         vk::VK_DYNAMIC_STATE_STENCIL_WRITE_MASK,
1028                         vk::VK_DYNAMIC_STATE_STENCIL_REFERENCE,
1029                 };
1030
1031                 for (size_t i = 0; i < DE_LENGTH_OF_ARRAY(dynamicState); ++i)
1032                 {
1033                         m_dynamicStates.push_back(dynamicState[i]);
1034                 }
1035         }
1036         else
1037                 m_dynamicStates = _dynamicStates;
1038
1039         dynamicStateCount = static_cast<deUint32>(m_dynamicStates.size());
1040         pDynamicStates = &m_dynamicStates[0];
1041 }
1042
1043 PipelineCreateInfo::DynamicState::DynamicState (const DynamicState &other)
1044 {
1045         sType = other.sType;
1046         pNext = other.pNext;
1047
1048         flags                           = other.flags;
1049         dynamicStateCount       = other.dynamicStateCount;
1050         m_dynamicStates         = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1051         pDynamicStates          = &m_dynamicStates[0];
1052 }
1053
1054 PipelineCreateInfo::DynamicState& PipelineCreateInfo::DynamicState::operator= (const DynamicState& other)
1055 {
1056         sType = other.sType;
1057         pNext = other.pNext;
1058
1059         flags                           = other.flags;
1060         dynamicStateCount       = other.dynamicStateCount;
1061         m_dynamicStates         = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1062         pDynamicStates          = &m_dynamicStates[0];
1063
1064         return *this;
1065 }
1066
1067 PipelineCreateInfo::PipelineCreateInfo (vk::VkPipelineLayout            _layout,
1068                                                                                 vk::VkRenderPass                        _renderPass,
1069                                                                                 int                                                     _subpass,
1070                                                                                 vk::VkPipelineCreateFlags       _flags)
1071 {
1072         deMemset(static_cast<vk::VkGraphicsPipelineCreateInfo *>(this), 0,
1073                 sizeof(vk::VkGraphicsPipelineCreateInfo));
1074
1075         sType = vk::VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
1076         pNext = DE_NULL;
1077         flags                           = _flags;
1078         renderPass                      = _renderPass;
1079         subpass                         = _subpass;
1080         layout                          = _layout;
1081         basePipelineHandle      = DE_NULL;
1082         basePipelineIndex       = 0;
1083         pDynamicState           = DE_NULL;
1084 }
1085
1086 PipelineCreateInfo& PipelineCreateInfo::addShader (const vk::VkPipelineShaderStageCreateInfo& shader)
1087 {
1088         m_shaders.push_back(shader);
1089
1090         stageCount      = static_cast<deUint32>(m_shaders.size());
1091         pStages         = &m_shaders[0];
1092
1093         return *this;
1094 }
1095
1096 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineVertexInputStateCreateInfo& state)
1097 {
1098         m_vertexInputState      = state;
1099         pVertexInputState       = &m_vertexInputState;
1100
1101         return *this;
1102 }
1103
1104 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state)
1105 {
1106         m_inputAssemblyState = state;
1107         pInputAssemblyState = &m_inputAssemblyState;
1108
1109         return *this;
1110 }
1111
1112 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineColorBlendStateCreateInfo& state)
1113 {
1114         m_colorBlendStateAttachments    = std::vector<vk::VkPipelineColorBlendAttachmentState>(state.pAttachments, state.pAttachments + state.attachmentCount);
1115         m_colorBlendState                               = state;
1116         m_colorBlendState.pAttachments  = &m_colorBlendStateAttachments[0];
1117         pColorBlendState                                = &m_colorBlendState;
1118
1119         return *this;
1120 }
1121
1122 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineViewportStateCreateInfo& state)
1123 {
1124         m_viewports                                     = std::vector<vk::VkViewport>(state.pViewports, state.pViewports + state.viewportCount);
1125         m_scissors                                      = std::vector<vk::VkRect2D>(state.pScissors, state.pScissors + state.scissorCount);
1126         m_viewportState                         = state;
1127         m_viewportState.pViewports      = &m_viewports[0];
1128         m_viewportState.pScissors       = &m_scissors[0];
1129         pViewportState                          = &m_viewportState;
1130
1131         return *this;
1132 }
1133
1134 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDepthStencilStateCreateInfo& state)
1135 {
1136         m_dynamicDepthStencilState      = state;
1137         pDepthStencilState                      = &m_dynamicDepthStencilState;
1138         return *this;
1139 }
1140
1141 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineTessellationStateCreateInfo& state)
1142 {
1143         m_tessState                     = state;
1144         pTessellationState      = &m_tessState;
1145
1146         return *this;
1147 }
1148
1149 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineRasterizationStateCreateInfo& state)
1150 {
1151         m_rasterState           = state;
1152         pRasterizationState     = &m_rasterState;
1153
1154         return *this;
1155 }
1156
1157 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineMultisampleStateCreateInfo& state)
1158 {
1159
1160         const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + state.rasterizationSamples) / ( sizeof(vk::VkSampleMask) * 8 );
1161         m_multisampleState                              = state;
1162         if (state.pSampleMask != DE_NULL)
1163         {
1164                 m_multisampleStateSampleMask    = std::vector<vk::VkSampleMask>(state.pSampleMask, state.pSampleMask + sampleMaskArrayLen);
1165                 m_multisampleState.pSampleMask  = &m_multisampleStateSampleMask[0];
1166         }
1167         pMultisampleState                               = &m_multisampleState;
1168
1169         return *this;
1170 }
1171 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDynamicStateCreateInfo& state)
1172 {
1173         m_dynamicStates                                 = std::vector<vk::VkDynamicState>(state.pDynamicStates, state.pDynamicStates + state.dynamicStateCount);
1174         m_dynamicState                                  = state;
1175         m_dynamicState.pDynamicStates   = &m_dynamicStates[0];
1176         pDynamicState                                   = &m_dynamicState;
1177
1178         return *this;
1179 }
1180
1181 SamplerCreateInfo::SamplerCreateInfo (vk::VkFilter                              _magFilter,
1182                                                                           vk::VkFilter                          _minFilter,
1183                                                                           vk::VkSamplerMipmapMode       _mipmapMode,
1184                                                                           vk::VkSamplerAddressMode      _addressModeU,
1185                                                                           vk::VkSamplerAddressMode      _addressModeV,
1186                                                                           vk::VkSamplerAddressMode      _addressModeW,
1187                                                                           float                                         _mipLodBias,
1188                                                                           vk::VkBool32                          _anisotropyEnable,
1189                                                                           float                                         _maxAnisotropy,
1190                                                                           vk::VkBool32                          _compareEnable,
1191                                                                           vk::VkCompareOp                       _compareOp,
1192                                                                           float                                         _minLod,
1193                                                                           float                                         _maxLod,
1194                                                                           vk::VkBorderColor                     _borderColor,
1195                                                                           vk::VkBool32                          _unnormalizedCoordinates)
1196 {
1197         sType                                   = vk::VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
1198         pNext                                   = DE_NULL;
1199         flags                                   = 0u;
1200         magFilter                               = _magFilter;
1201         minFilter                               = _minFilter;
1202         mipmapMode                              = _mipmapMode;
1203         addressModeU                    = _addressModeU;
1204         addressModeV                    = _addressModeV;
1205         addressModeW                    = _addressModeW;
1206         mipLodBias                              = _mipLodBias;
1207         anisotropyEnable                = _anisotropyEnable;
1208         maxAnisotropy                   = _maxAnisotropy;
1209         compareEnable                   = _compareEnable;
1210         compareOp                               = _compareOp;
1211         minLod                                  = _minLod;
1212         maxLod                                  = _maxLod;
1213         borderColor                             = _borderColor;
1214         unnormalizedCoordinates = _unnormalizedCoordinates;
1215 }
1216 } // Draw
1217 } // vkt