1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 The Khronos Group Inc.
6 * Copyright (c) 2015 Intel Corporation
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * \brief CreateInfo utilities
23 *//*--------------------------------------------------------------------*/
25 #include "vktQueryPoolCreateInfoUtil.hpp"
27 #include "vkImageUtil.hpp"
34 ImageSubresourceRange::ImageSubresourceRange (vk::VkImageAspectFlags _aspectMask,
35 deUint32 _baseMipLevel,
37 deUint32 _baseArrayLayer,
40 aspectMask = _aspectMask;
41 baseMipLevel = _baseMipLevel;
42 levelCount = _levelCount;
43 baseArrayLayer = _baseArrayLayer;
44 layerCount = _layerCount;
47 ComponentMapping::ComponentMapping (vk::VkComponentSwizzle _r,
48 vk::VkComponentSwizzle _g,
49 vk::VkComponentSwizzle _b,
50 vk::VkComponentSwizzle _a)
58 ImageViewCreateInfo::ImageViewCreateInfo (vk::VkImage _image,
59 vk::VkImageViewType _viewType,
61 const vk::VkImageSubresourceRange& _subresourceRange,
62 const vk::VkComponentMapping& _components,
63 vk::VkImageViewCreateFlags _flags)
65 sType = vk::VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
71 components.r = _components.r;
72 components.g = _components.g;
73 components.b = _components.b;
74 components.a = _components.a;
75 subresourceRange = _subresourceRange;
79 ImageViewCreateInfo::ImageViewCreateInfo (vk::VkImage _image,
80 vk::VkImageViewType _viewType,
82 const vk::VkComponentMapping& _components,
83 vk::VkImageViewCreateFlags _flags)
85 sType = vk::VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
91 components.r = _components.r;
92 components.g = _components.g;
93 components.b = _components.b;
94 components.a = _components.a;
96 vk::VkImageAspectFlags aspectFlags;
97 const tcu::TextureFormat tcuFormat = vk::mapVkFormat(_format);
99 switch (tcuFormat.order)
101 case tcu::TextureFormat::D:
102 aspectFlags = vk::VK_IMAGE_ASPECT_DEPTH_BIT;
104 case tcu::TextureFormat::S:
105 aspectFlags = vk::VK_IMAGE_ASPECT_STENCIL_BIT;
107 case tcu::TextureFormat::DS:
108 aspectFlags = vk::VK_IMAGE_ASPECT_STENCIL_BIT | vk::VK_IMAGE_ASPECT_DEPTH_BIT;
111 aspectFlags = vk::VK_IMAGE_ASPECT_COLOR_BIT;
115 subresourceRange = ImageSubresourceRange(aspectFlags);;
119 BufferViewCreateInfo::BufferViewCreateInfo (vk::VkBuffer _buffer,
120 vk::VkFormat _format,
121 vk::VkDeviceSize _offset,
122 vk::VkDeviceSize _range)
124 sType = vk::VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO;
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)
141 sType = vk::VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
146 sharingMode = _sharingMode;
147 queueFamilyIndexCount = _queueFamilyIndexCount;
149 if (_queueFamilyIndexCount)
151 m_queueFamilyIndices = std::vector<deUint32>(
152 _pQueueFamilyIndices, _pQueueFamilyIndices + _queueFamilyIndexCount);
153 pQueueFamilyIndices = &m_queueFamilyIndices[0];
157 pQueueFamilyIndices = _pQueueFamilyIndices;
161 BufferCreateInfo::BufferCreateInfo (const BufferCreateInfo &other)
168 sharingMode = other.sharingMode;
169 queueFamilyIndexCount = other.queueFamilyIndexCount;
171 m_queueFamilyIndices = other.m_queueFamilyIndices;
172 DE_ASSERT(m_queueFamilyIndices.size() == queueFamilyIndexCount);
174 if (m_queueFamilyIndices.size())
176 pQueueFamilyIndices = &m_queueFamilyIndices[0];
180 pQueueFamilyIndices = DE_NULL;
184 BufferCreateInfo & BufferCreateInfo::operator= (const BufferCreateInfo &other)
191 sharingMode = other.sharingMode;
192 queueFamilyIndexCount = other.queueFamilyIndexCount;
194 m_queueFamilyIndices = other.m_queueFamilyIndices;
196 DE_ASSERT(m_queueFamilyIndices.size() == queueFamilyIndexCount);
198 if (m_queueFamilyIndices.size())
200 pQueueFamilyIndices = &m_queueFamilyIndices[0];
204 pQueueFamilyIndices = DE_NULL;
210 ImageCreateInfo::ImageCreateInfo (vk::VkImageType _imageType,
211 vk::VkFormat _format,
212 vk::VkExtent3D _extent,
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)
224 if (_queueFamilyIndexCount)
226 m_queueFamilyIndices = std::vector<deUint32>(_pQueueFamilyIndices, _pQueueFamilyIndices + _queueFamilyIndexCount);
229 sType = vk::VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
232 imageType = _imageType;
235 mipLevels = _mipLevels;
236 arrayLayers = _arrayLayers;
240 sharingMode = _sharingMode;
241 queueFamilyIndexCount = _queueFamilyIndexCount;
243 if (m_queueFamilyIndices.size())
245 pQueueFamilyIndices = &m_queueFamilyIndices[0];
249 pQueueFamilyIndices = DE_NULL;
251 initialLayout = _initialLayout;
254 FramebufferCreateInfo::FramebufferCreateInfo (vk::VkRenderPass _renderPass,
255 const std::vector<vk::VkImageView>& atachments,
260 sType = vk::VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
264 renderPass = _renderPass;
265 attachmentCount = static_cast<deUint32>(atachments.size());
269 pAttachments = const_cast<vk::VkImageView *>(&atachments[0]);
277 RenderPassCreateInfo::RenderPassCreateInfo (const std::vector<vk::VkAttachmentDescription>& attachments,
278 const std::vector<vk::VkSubpassDescription>& subpasses,
279 const std::vector<vk::VkSubpassDependency>& dependiences)
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())
288 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
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];
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)
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);
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());
316 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
320 attachmentCount = static_cast<deUint32>(m_attachments.size());
324 pAttachments = &m_attachmentsStructs[0];
328 pAttachments = DE_NULL;
331 subpassCount = static_cast<deUint32>(m_subpasses.size());
335 pSubpasses = &m_subpassesStructs[0];
339 pSubpasses = DE_NULL;
342 dependencyCount = static_cast<deUint32>(m_dependiences.size());
346 pDependencies = &m_dependiencesStructs[0];
350 pDependencies = DE_NULL;
355 RenderPassCreateInfo::addAttachment (vk::VkAttachmentDescription attachment)
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];
365 RenderPassCreateInfo::addSubpass (vk::VkSubpassDescription subpass)
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];
375 RenderPassCreateInfo::addDependency (vk::VkSubpassDependency dependency)
378 m_dependiences.push_back(dependency);
379 m_dependiencesStructs = std::vector<vk::VkSubpassDependency>(m_dependiences.begin(), m_dependiences.end());
381 dependencyCount = static_cast<deUint32>(m_dependiences.size());
382 pDependencies = &m_dependiencesStructs[0];
385 RenderPassBeginInfo::RenderPassBeginInfo (vk::VkRenderPass _renderPass,
386 vk::VkFramebuffer _framebuffer,
387 vk::VkRect2D _renderArea,
388 const std::vector<vk::VkClearValue>& _clearValues)
391 m_clearValues = _clearValues;
393 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
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;
402 CmdPoolCreateInfo::CmdPoolCreateInfo (deUint32 _queueFamilyIndex, unsigned int _flags)
404 sType = vk::VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
407 queueFamilyIndex = _queueFamilyIndex;
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)
425 stencilLoadOp = _stencilLoadOp;
426 stencilStoreOp = _stencilStoreOp;
427 initialLayout = _initialLayout;
428 finalLayout = _finalLayout;
431 AttachmentDescription::AttachmentDescription (const vk::VkAttachmentDescription& rhs)
435 samples = rhs.samples;
437 storeOp = rhs.storeOp;
438 stencilLoadOp = rhs.stencilLoadOp;
439 stencilStoreOp = rhs.stencilStoreOp;
440 initialLayout = rhs.initialLayout;
441 finalLayout = rhs.finalLayout;
444 AttachmentReference::AttachmentReference (deUint32 _attachment, vk::VkImageLayout _layout)
446 attachment = _attachment;
450 AttachmentReference::AttachmentReference (void)
452 attachment = VK_ATTACHMENT_UNUSED;
453 layout = vk::VK_IMAGE_LAYOUT_UNDEFINED;
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)
467 m_inputAttachments = std::vector<vk::VkAttachmentReference>(_inputAttachments, _inputAttachments + _inputAttachmentCount);
468 m_colorAttachments = std::vector<vk::VkAttachmentReference>(_colorAttachments, _colorAttachments + _colorAttachmentCount);
470 if (_resolveAttachments)
471 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(_resolveAttachments, _resolveAttachments + _colorAttachmentCount);
473 m_preserveAttachments = std::vector<deUint32>(_preserveAttachments, _preserveAttachments + _preserveAttachmentCount);
475 m_depthStencilAttachment = depthStencilAttachment;
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;
488 if (!m_inputAttachments.empty())
489 pInputAttachments = &m_inputAttachments[0];
491 if (!m_colorAttachments.empty())
492 pColorAttachments = &m_colorAttachments[0];
494 if (!m_resolveAttachments.empty())
495 pResolveAttachments = &m_resolveAttachments[0];
497 if (!m_preserveAttachments.empty())
498 pPreserveAttachments = &m_preserveAttachments[0];
501 SubpassDescription::SubpassDescription (const vk::VkSubpassDescription& rhs)
503 *static_cast<vk::VkSubpassDescription*>(this) = rhs;
505 m_inputAttachments = std::vector<vk::VkAttachmentReference>(
506 rhs.pInputAttachments, rhs.pInputAttachments + rhs.inputAttachmentCount);
508 m_colorAttachments = std::vector<vk::VkAttachmentReference>(
509 rhs.pColorAttachments, rhs.pColorAttachments + rhs.colorAttachmentCount);
511 if (rhs.pResolveAttachments)
512 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(
513 rhs.pResolveAttachments, rhs.pResolveAttachments + rhs.colorAttachmentCount);
515 m_preserveAttachments = std::vector<deUint32>(
516 rhs.pPreserveAttachments, rhs.pPreserveAttachments + rhs.preserveAttachmentCount);
518 if (rhs.pDepthStencilAttachment)
519 m_depthStencilAttachment = *rhs.pDepthStencilAttachment;
521 if (!m_inputAttachments.empty())
522 pInputAttachments = &m_inputAttachments[0];
524 if (!m_colorAttachments.empty())
525 pColorAttachments = &m_colorAttachments[0];
527 if (!m_resolveAttachments.empty())
528 pResolveAttachments = &m_resolveAttachments[0];
530 pDepthStencilAttachment = &m_depthStencilAttachment;
532 if (!m_preserveAttachments.empty())
533 pPreserveAttachments = &m_preserveAttachments[0];
536 SubpassDescription::SubpassDescription (const SubpassDescription& rhs) {
540 SubpassDescription& SubpassDescription::operator= (const SubpassDescription& rhs)
542 *static_cast<vk::VkSubpassDescription*>(this) = rhs;
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;
550 if (!m_inputAttachments.empty())
551 pInputAttachments = &m_inputAttachments[0];
553 if (!m_colorAttachments.empty())
554 pColorAttachments = &m_colorAttachments[0];
556 if (!m_resolveAttachments.empty())
557 pResolveAttachments = &m_resolveAttachments[0];
559 pDepthStencilAttachment = &m_depthStencilAttachment;
561 if (!m_preserveAttachments.empty())
562 pPreserveAttachments = &m_preserveAttachments[0];
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)
575 srcSubpass = _srcSubpass;
576 dstSubpass = _dstSubpass;
577 srcStageMask = _srcStageMask;
578 dstStageMask = _dstStageMask;
579 srcAccessMask = _srcAccessMask;
580 dstAccessMask = _dstAccessMask;
581 dependencyFlags = _dependencyFlags;
584 SubpassDependency::SubpassDependency (const vk::VkSubpassDependency& rhs)
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;
595 CmdBufferBeginInfo::CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags _flags)
597 sType = vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
600 pInheritanceInfo = DE_NULL;
603 DescriptorPoolCreateInfo::DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>& poolSizeCounts,
604 vk::VkDescriptorPoolCreateFlags _flags,
606 : m_poolSizeCounts(poolSizeCounts)
608 sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
612 poolSizeCount = static_cast<deUint32>(m_poolSizeCounts.size());
613 pPoolSizes = &m_poolSizeCounts[0];
616 DescriptorPoolCreateInfo& DescriptorPoolCreateInfo::addDescriptors (vk::VkDescriptorType type, deUint32 count)
618 vk::VkDescriptorPoolSize descriptorTypeCount = { type, count };
619 m_poolSizeCounts.push_back(descriptorTypeCount);
621 poolSizeCount = static_cast<deUint32>(m_poolSizeCounts.size());
622 pPoolSizes = &m_poolSizeCounts[0];
627 DescriptorSetLayoutCreateInfo::DescriptorSetLayoutCreateInfo (deUint32 _bindingCount, const vk::VkDescriptorSetLayoutBinding* _pBindings)
629 sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
632 bindingCount = _bindingCount;
633 pBindings = _pBindings;
636 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (deUint32 _descriptorSetCount,
637 const vk::VkDescriptorSetLayout* _pSetLayouts,
638 deUint32 _pushConstantRangeCount,
639 const vk::VkPushConstantRange* _pPushConstantRanges)
640 : m_pushConstantRanges(_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
642 for (unsigned int i = 0; i < _descriptorSetCount; i++)
644 m_setLayouts.push_back(_pSetLayouts[i]);
647 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
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());
655 if (m_pushConstantRanges.size())
657 pPushConstantRanges = &m_pushConstantRanges[0];
661 pPushConstantRanges = DE_NULL;
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)
671 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
675 setLayoutCount = static_cast<deUint32>(m_setLayouts.size());
679 pSetLayouts = &m_setLayouts[0];
683 pSetLayouts = DE_NULL;
686 pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
687 if (pushConstantRangeCount)
689 pPushConstantRanges = &m_pushConstantRanges[0];
693 pPushConstantRanges = DE_NULL;
697 PipelineCreateInfo::PipelineShaderStage::PipelineShaderStage (vk::VkShaderModule _module, const char* _pName, vk::VkShaderStageFlagBits _stage)
699 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
705 pSpecializationInfo = DE_NULL;
708 PipelineCreateInfo::VertexInputState::VertexInputState (deUint32 _vertexBindingDescriptionCount,
709 const vk::VkVertexInputBindingDescription* _pVertexBindingDescriptions,
710 deUint32 _vertexAttributeDescriptionCount,
711 const vk::VkVertexInputAttributeDescription* _pVertexAttributeDescriptions)
713 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
716 vertexBindingDescriptionCount = _vertexBindingDescriptionCount;
717 pVertexBindingDescriptions = _pVertexBindingDescriptions;
718 vertexAttributeDescriptionCount = _vertexAttributeDescriptionCount;
719 pVertexAttributeDescriptions = _pVertexAttributeDescriptions;
722 PipelineCreateInfo::InputAssemblerState::InputAssemblerState (vk::VkPrimitiveTopology _topology,
723 vk::VkBool32 _primitiveRestartEnable)
725 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
728 topology = _topology;
729 primitiveRestartEnable = _primitiveRestartEnable;
732 PipelineCreateInfo::TessellationState::TessellationState (deUint32 _patchControlPoints)
734 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
737 patchControlPoints = _patchControlPoints;
740 PipelineCreateInfo::ViewportState::ViewportState (deUint32 _viewportCount,
741 std::vector<vk::VkViewport> _viewports,
742 std::vector<vk::VkRect2D> _scissors)
744 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
747 viewportCount = _viewportCount;
748 scissorCount = _viewportCount;
750 if (!_viewports.size())
752 m_viewports.resize(viewportCount);
753 deMemset(&m_viewports[0], 0, sizeof(m_viewports[0]) * m_viewports.size());
757 m_viewports = _viewports;
760 if (!_scissors.size())
762 m_scissors.resize(scissorCount);
763 deMemset(&m_scissors[0], 0, sizeof(m_scissors[0]) * m_scissors.size());
767 m_scissors = _scissors;
770 pViewports = &m_viewports[0];
771 pScissors = &m_scissors[0];
774 PipelineCreateInfo::ViewportState::ViewportState (const ViewportState& other)
779 viewportCount = other.viewportCount;
780 scissorCount = other.scissorCount;
782 m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + viewportCount);
783 m_scissors = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
785 pViewports = &m_viewports[0];
786 pScissors = &m_scissors[0];
789 PipelineCreateInfo::ViewportState& PipelineCreateInfo::ViewportState::operator= (const ViewportState& other)
794 viewportCount = other.viewportCount;
795 scissorCount = other.scissorCount;
797 m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + scissorCount);
798 m_scissors = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
800 pViewports = &m_viewports[0];
801 pScissors = &m_scissors[0];
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,
816 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
819 depthClampEnable = _depthClampEnable;
820 rasterizerDiscardEnable = _rasterizerDiscardEnable;
821 polygonMode = _polygonMode;
822 cullMode = _cullMode;
823 frontFace = _frontFace;
825 depthBiasEnable = _depthBiasEnable;
826 depthBiasConstantFactor = _depthBiasConstantFactor;
827 depthBiasClamp = _depthBiasClamp;
828 depthBiasSlopeFactor = _depthBiasSlopeFactor;
829 lineWidth = _lineWidth;
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)
840 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
843 rasterizationSamples = _rasterizationSamples;
844 sampleShadingEnable = _sampleShadingEnable;
845 minSampleShading = _minSampleShading;
846 pSampleMask = &m_sampleMask[0];
847 alphaToCoverageEnable = _alphaToCoverageEnable;
848 alphaToOneEnable = _alphaToOneEnable;
851 PipelineCreateInfo::MultiSampleState::MultiSampleState (const MultiSampleState& other)
856 rasterizationSamples = other.rasterizationSamples;
857 sampleShadingEnable = other.sampleShadingEnable;
858 minSampleShading = other.minSampleShading;
860 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
862 m_sampleMask = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
863 pSampleMask = &m_sampleMask[0];
866 PipelineCreateInfo::MultiSampleState& PipelineCreateInfo::MultiSampleState::operator= (const MultiSampleState& other)
871 rasterizationSamples = other.rasterizationSamples;
872 sampleShadingEnable = other.sampleShadingEnable;
873 minSampleShading = other.minSampleShading;
875 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
877 m_sampleMask = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
878 pSampleMask = &m_sampleMask[0];
883 PipelineCreateInfo::ColorBlendState::ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>& _attachments,
884 vk::VkBool32 _logicOpEnable,
885 vk::VkLogicOp _logicOp)
886 : m_attachments(_attachments)
888 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
891 logicOpEnable = _logicOpEnable;
893 attachmentCount = static_cast<deUint32>(m_attachments.size());
894 pAttachments = &m_attachments[0];
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)
903 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
906 logicOpEnable = _logicOpEnable;
908 attachmentCount = static_cast<deUint32>(m_attachments.size());
909 pAttachments = &m_attachments[0];
912 PipelineCreateInfo::ColorBlendState::ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo& createInfo)
913 : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
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];
924 PipelineCreateInfo::ColorBlendState::ColorBlendState (const ColorBlendState& createInfo, std::vector<float> _blendConstants)
925 : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
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));
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)
946 blendEnable = _blendEnable;
947 srcColorBlendFactor = _srcColorBlendFactor;
948 dstColorBlendFactor = _dstColorBlendFactor;
949 colorBlendOp = _colorBlendOp;
950 srcAlphaBlendFactor = _srcAlphaBlendFactor;
951 dstAlphaBlendFactor = _dstAlphaBlendFactor;
952 alphaBlendOp = _alphaBlendOp;
953 colorWriteMask = _colorWriteMask;
956 PipelineCreateInfo::DepthStencilState::StencilOpState::StencilOpState (vk::VkStencilOp _failOp,
957 vk::VkStencilOp _passOp,
958 vk::VkStencilOp _depthFailOp,
959 vk::VkCompareOp _compareOp,
960 deUint32 _compareMask,
966 depthFailOp = _depthFailOp;
967 compareOp = _compareOp;
969 compareMask = _compareMask;
970 writeMask = _writeMask;
971 reference = _reference;
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)
984 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
987 depthTestEnable = _depthTestEnable;
988 depthWriteEnable = _depthWriteEnable;
989 depthCompareOp = _depthCompareOp;
990 depthBoundsTestEnable = _depthBoundsTestEnable;
991 stencilTestEnable = _stencilTestEnable;
995 minDepthBounds = _minDepthBounds;
996 maxDepthBounds = _maxDepthBounds;
999 PipelineCreateInfo::DynamicState::DynamicState (const std::vector<vk::VkDynamicState>& _dynamicStates)
1001 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
1005 if (!_dynamicStates.size())
1007 for (size_t i = 0; i < vk::VK_DYNAMIC_STATE_LAST; ++i)
1009 m_dynamicStates.push_back(static_cast<vk::VkDynamicState>(i));
1013 m_dynamicStates = _dynamicStates;
1015 dynamicStateCount = static_cast<deUint32>(m_dynamicStates.size());
1016 pDynamicStates = &m_dynamicStates[0];
1019 PipelineCreateInfo::DynamicState::DynamicState (const DynamicState &other)
1021 sType = other.sType;
1022 pNext = other.pNext;
1023 flags = other.flags;
1025 dynamicStateCount = other.dynamicStateCount;
1027 m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1028 pDynamicStates = &m_dynamicStates[0];
1031 PipelineCreateInfo::DynamicState& PipelineCreateInfo::DynamicState::operator= (const DynamicState& other)
1033 sType = other.sType;
1034 pNext = other.pNext;
1035 flags = other.flags;
1037 dynamicStateCount = other.dynamicStateCount;
1039 m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1040 pDynamicStates = &m_dynamicStates[0];
1045 PipelineCreateInfo::PipelineCreateInfo (vk::VkPipelineLayout _layout,
1046 vk::VkRenderPass _renderPass,
1048 vk::VkPipelineCreateFlags _flags)
1050 deMemset(static_cast<vk::VkGraphicsPipelineCreateInfo *>(this), 0,
1051 sizeof(vk::VkGraphicsPipelineCreateInfo));
1053 sType = vk::VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
1056 renderPass = _renderPass;
1059 basePipelineHandle = DE_NULL;
1060 basePipelineIndex = 0;
1061 pDynamicState = DE_NULL;
1064 PipelineCreateInfo& PipelineCreateInfo::addShader (const vk::VkPipelineShaderStageCreateInfo& shader)
1066 m_shaders.push_back(shader);
1068 stageCount = static_cast<deUint32>(m_shaders.size());
1069 pStages = &m_shaders[0];
1074 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineVertexInputStateCreateInfo& state)
1076 m_vertexInputState = state;
1077 pVertexInputState = &m_vertexInputState;
1082 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state)
1084 m_inputAssemblyState = state;
1085 pInputAssemblyState = &m_inputAssemblyState;
1090 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineColorBlendStateCreateInfo& state)
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;
1100 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineViewportStateCreateInfo& state)
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;
1112 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDepthStencilStateCreateInfo& state)
1114 m_dynamicDepthStencilState = state;
1115 pDepthStencilState = &m_dynamicDepthStencilState;
1119 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineTessellationStateCreateInfo& state)
1121 m_tessState = state;
1122 pTessellationState = &m_tessState;
1127 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineRasterizationStateCreateInfo& state)
1129 m_rasterState = state;
1130 pRasterizationState = &m_rasterState;
1135 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineMultisampleStateCreateInfo& state)
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;
1146 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDynamicStateCreateInfo& state)
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;
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,
1163 vk::VkBool32 _anisotropyEnable,
1164 float _maxAnisotropy,
1165 vk::VkBool32 _compareEnable,
1166 vk::VkCompareOp _compareOp,
1169 vk::VkBorderColor _borderColor,
1170 vk::VkBool32 _unnormalizedCoordinates)
1172 sType = vk::VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
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;
1188 borderColor = _borderColor;
1189 unnormalizedCoordinates = _unnormalizedCoordinates;