1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 The Khronos Group Inc.
6 * Copyright (c) 2015 Intel Corporation
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and/or associated documentation files (the
10 * "Materials"), to deal in the Materials without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Materials, and to
13 * permit persons to whom the Materials are furnished to do so, subject to
14 * the following conditions:
16 * The above copyright notice(s) and this permission notice shall be included
17 * in all copies or substantial portions of the Materials.
19 * The Materials are Confidential Information as defined by the
20 * Khronos Membership Agreement until designated non-confidential by Khronos,
21 * at which point this condition clause shall be removed.
23 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
27 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
28 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
29 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
33 * \brief CreateInfo utilities
34 *//*--------------------------------------------------------------------*/
36 #include "vktDynamicStateCreateInfoUtil.hpp"
38 #include "vkImageUtil.hpp"
42 namespace DynamicState
45 ImageSubresourceRange::ImageSubresourceRange (vk::VkImageAspectFlags _aspectMask,
46 deUint32 _baseMipLevel,
48 deUint32 _baseArrayLayer,
51 aspectMask = _aspectMask;
52 baseMipLevel = _baseMipLevel;
53 levelCount = _levelCount;
54 baseArrayLayer = _baseArrayLayer;
55 layerCount = _layerCount;
58 ComponentMapping::ComponentMapping (vk::VkComponentSwizzle _r,
59 vk::VkComponentSwizzle _g,
60 vk::VkComponentSwizzle _b,
61 vk::VkComponentSwizzle _a)
69 ImageViewCreateInfo::ImageViewCreateInfo (vk::VkImage _image,
70 vk::VkImageViewType _viewType,
72 const vk::VkImageSubresourceRange& _subresourceRange,
73 const vk::VkComponentMapping& _components,
74 vk::VkImageViewCreateFlags _flags)
76 sType = vk::VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
82 components.r = _components.r;
83 components.g = _components.g;
84 components.b = _components.b;
85 components.a = _components.a;
86 subresourceRange = _subresourceRange;
90 ImageViewCreateInfo::ImageViewCreateInfo (vk::VkImage _image,
91 vk::VkImageViewType _viewType,
93 const vk::VkComponentMapping& _components,
94 vk::VkImageViewCreateFlags _flags)
96 sType = vk::VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
100 viewType = _viewType;
102 components.r = _components.r;
103 components.g = _components.g;
104 components.b = _components.b;
105 components.a = _components.a;
107 vk::VkImageAspectFlags aspectFlags;
108 const tcu::TextureFormat tcuFormat = vk::mapVkFormat(_format);
110 switch (tcuFormat.order)
112 case tcu::TextureFormat::D:
113 aspectFlags = vk::VK_IMAGE_ASPECT_DEPTH_BIT;
115 case tcu::TextureFormat::S:
116 aspectFlags = vk::VK_IMAGE_ASPECT_STENCIL_BIT;
118 case tcu::TextureFormat::DS:
119 aspectFlags = vk::VK_IMAGE_ASPECT_STENCIL_BIT | vk::VK_IMAGE_ASPECT_DEPTH_BIT;
122 aspectFlags = vk::VK_IMAGE_ASPECT_COLOR_BIT;
126 subresourceRange = ImageSubresourceRange(aspectFlags);;
130 BufferViewCreateInfo::BufferViewCreateInfo (vk::VkBuffer _buffer,
131 vk::VkFormat _format,
132 vk::VkDeviceSize _offset,
133 vk::VkDeviceSize _range)
135 sType = vk::VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO;
145 BufferCreateInfo::BufferCreateInfo (vk::VkDeviceSize _size,
146 vk::VkBufferUsageFlags _usage,
147 vk::VkSharingMode _sharingMode,
148 deUint32 _queueFamilyIndexCount,
149 const deUint32* _pQueueFamilyIndices,
150 vk::VkBufferCreateFlags _flags)
152 sType = vk::VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
157 sharingMode = _sharingMode;
158 queueFamilyIndexCount = _queueFamilyIndexCount;
160 if (_queueFamilyIndexCount)
162 m_queueFamilyIndices = std::vector<deUint32>(
163 _pQueueFamilyIndices, _pQueueFamilyIndices + _queueFamilyIndexCount);
164 pQueueFamilyIndices = &m_queueFamilyIndices[0];
168 pQueueFamilyIndices = _pQueueFamilyIndices;
172 BufferCreateInfo::BufferCreateInfo (const BufferCreateInfo &other)
179 sharingMode = other.sharingMode;
180 queueFamilyIndexCount = other.queueFamilyIndexCount;
182 m_queueFamilyIndices = other.m_queueFamilyIndices;
183 DE_ASSERT(m_queueFamilyIndices.size() == queueFamilyIndexCount);
185 if (m_queueFamilyIndices.size())
187 pQueueFamilyIndices = &m_queueFamilyIndices[0];
191 pQueueFamilyIndices = DE_NULL;
195 BufferCreateInfo & BufferCreateInfo::operator= (const BufferCreateInfo &other)
202 sharingMode = other.sharingMode;
203 queueFamilyIndexCount = other.queueFamilyIndexCount;
205 m_queueFamilyIndices = other.m_queueFamilyIndices;
207 DE_ASSERT(m_queueFamilyIndices.size() == queueFamilyIndexCount);
209 if (m_queueFamilyIndices.size())
211 pQueueFamilyIndices = &m_queueFamilyIndices[0];
215 pQueueFamilyIndices = DE_NULL;
221 ImageCreateInfo::ImageCreateInfo (vk::VkImageType _imageType,
222 vk::VkFormat _format,
223 vk::VkExtent3D _extent,
225 deUint32 _arrayLayers,
226 vk::VkSampleCountFlagBits _samples,
227 vk::VkImageTiling _tiling,
228 vk::VkImageUsageFlags _usage,
229 vk::VkSharingMode _sharingMode,
230 deUint32 _queueFamilyIndexCount,
231 const deUint32* _pQueueFamilyIndices,
232 vk::VkImageCreateFlags _flags,
233 vk::VkImageLayout _initialLayout)
235 if (_queueFamilyIndexCount)
237 m_queueFamilyIndices = std::vector<deUint32>(_pQueueFamilyIndices, _pQueueFamilyIndices + _queueFamilyIndexCount);
240 sType = vk::VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
243 imageType = _imageType;
246 mipLevels = _mipLevels;
247 arrayLayers = _arrayLayers;
251 sharingMode = _sharingMode;
252 queueFamilyIndexCount = _queueFamilyIndexCount;
254 if (m_queueFamilyIndices.size())
256 pQueueFamilyIndices = &m_queueFamilyIndices[0];
260 pQueueFamilyIndices = DE_NULL;
262 initialLayout = _initialLayout;
265 FramebufferCreateInfo::FramebufferCreateInfo (vk::VkRenderPass _renderPass,
266 const std::vector<vk::VkImageView>& atachments,
271 sType = vk::VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
275 renderPass = _renderPass;
276 attachmentCount = static_cast<deUint32>(atachments.size());
280 pAttachments = const_cast<vk::VkImageView *>(&atachments[0]);
288 RenderPassCreateInfo::RenderPassCreateInfo (const std::vector<vk::VkAttachmentDescription>& attachments,
289 const std::vector<vk::VkSubpassDescription>& subpasses,
290 const std::vector<vk::VkSubpassDependency>& dependiences)
292 : m_attachments (attachments.begin(), attachments.end())
293 , m_subpasses (subpasses.begin(), subpasses.end())
294 , m_dependiences (dependiences.begin(), dependiences.end())
295 , m_attachmentsStructs (m_attachments.begin(), m_attachments.end())
296 , m_subpassesStructs (m_subpasses.begin(), m_subpasses.end())
297 , m_dependiencesStructs (m_dependiences.begin(), m_dependiences.end())
299 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
303 attachmentCount = static_cast<deUint32>(m_attachments.size());
304 pAttachments = &m_attachmentsStructs[0];
305 subpassCount = static_cast<deUint32>(m_subpasses.size());
306 pSubpasses = &m_subpassesStructs[0];
307 dependencyCount = static_cast<deUint32>(m_dependiences.size());
308 pDependencies = &m_dependiencesStructs[0];
311 RenderPassCreateInfo::RenderPassCreateInfo (deUint32 _attachmentCount,
312 const vk::VkAttachmentDescription* _pAttachments,
313 deUint32 _subpassCount,
314 const vk::VkSubpassDescription* _pSubpasses,
315 deUint32 _dependencyCount,
316 const vk::VkSubpassDependency* _pDependiences)
319 m_attachments = std::vector<AttachmentDescription>(_pAttachments, _pAttachments + _attachmentCount);
320 m_subpasses = std::vector<SubpassDescription>(_pSubpasses, _pSubpasses + _subpassCount);
321 m_dependiences = std::vector<SubpassDependency>(_pDependiences, _pDependiences + _dependencyCount);
323 m_attachmentsStructs = std::vector<vk::VkAttachmentDescription> (m_attachments.begin(), m_attachments.end());
324 m_subpassesStructs = std::vector<vk::VkSubpassDescription> (m_subpasses.begin(), m_subpasses.end());
325 m_dependiencesStructs = std::vector<vk::VkSubpassDependency> (m_dependiences.begin(), m_dependiences.end());
327 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
331 attachmentCount = static_cast<deUint32>(m_attachments.size());
333 if (attachmentCount) {
334 pAttachments = &m_attachmentsStructs[0];
338 pAttachments = DE_NULL;
341 subpassCount = static_cast<deUint32>(m_subpasses.size());
344 pSubpasses = &m_subpassesStructs[0];
348 pSubpasses = DE_NULL;
351 dependencyCount = static_cast<deUint32>(m_dependiences.size());
353 if (dependencyCount) {
354 pDependencies = &m_dependiencesStructs[0];
358 pDependencies = DE_NULL;
363 RenderPassCreateInfo::addAttachment (vk::VkAttachmentDescription attachment)
366 m_attachments.push_back(attachment);
367 m_attachmentsStructs = std::vector<vk::VkAttachmentDescription>(m_attachments.begin(), m_attachments.end());
368 attachmentCount = static_cast<deUint32>(m_attachments.size());
369 pAttachments = &m_attachmentsStructs[0];
373 RenderPassCreateInfo::addSubpass (vk::VkSubpassDescription subpass)
376 m_subpasses.push_back(subpass);
377 m_subpassesStructs = std::vector<vk::VkSubpassDescription>(m_subpasses.begin(), m_subpasses.end());
378 subpassCount = static_cast<deUint32>(m_subpasses.size());
379 pSubpasses = &m_subpassesStructs[0];
383 RenderPassCreateInfo::addDependency (vk::VkSubpassDependency dependency)
386 m_dependiences.push_back(dependency);
387 m_dependiencesStructs = std::vector<vk::VkSubpassDependency>(m_dependiences.begin(), m_dependiences.end());
389 dependencyCount = static_cast<deUint32>(m_dependiences.size());
390 pDependencies = &m_dependiencesStructs[0];
393 RenderPassBeginInfo::RenderPassBeginInfo (vk::VkRenderPass _renderPass,
394 vk::VkFramebuffer _framebuffer,
395 vk::VkRect2D _renderArea,
396 const std::vector<vk::VkClearValue>& _clearValues)
399 m_clearValues = _clearValues;
401 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
403 renderPass = _renderPass;
404 framebuffer = _framebuffer;
405 renderArea = _renderArea;
406 clearValueCount = static_cast<deUint32>(m_clearValues.size());
407 pClearValues = m_clearValues.size() ? &m_clearValues[0] : DE_NULL;
410 CmdPoolCreateInfo::CmdPoolCreateInfo (deUint32 _queueFamilyIndex, unsigned int _flags)
412 sType = vk::VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
415 queueFamilyIndex = _queueFamilyIndex;
419 AttachmentDescription::AttachmentDescription (vk::VkFormat _format,
420 vk::VkSampleCountFlagBits _samples,
421 vk::VkAttachmentLoadOp _loadOp,
422 vk::VkAttachmentStoreOp _storeOp,
423 vk::VkAttachmentLoadOp _stencilLoadOp,
424 vk::VkAttachmentStoreOp _stencilStoreOp,
425 vk::VkImageLayout _initialLayout,
426 vk::VkImageLayout _finalLayout)
433 stencilLoadOp = _stencilLoadOp;
434 stencilStoreOp = _stencilStoreOp;
435 initialLayout = _initialLayout;
436 finalLayout = _finalLayout;
439 AttachmentDescription::AttachmentDescription (const vk::VkAttachmentDescription& rhs)
443 samples = rhs.samples;
445 storeOp = rhs.storeOp;
446 stencilLoadOp = rhs.stencilLoadOp;
447 stencilStoreOp = rhs.stencilStoreOp;
448 initialLayout = rhs.initialLayout;
449 finalLayout = rhs.finalLayout;
452 AttachmentReference::AttachmentReference (deUint32 _attachment, vk::VkImageLayout _layout)
454 attachment = _attachment;
458 AttachmentReference::AttachmentReference (void)
460 attachment = vk::VK_ATTACHMENT_UNUSED;
461 layout = vk::VK_IMAGE_LAYOUT_UNDEFINED;
464 SubpassDescription::SubpassDescription (vk::VkPipelineBindPoint _pipelineBindPoint,
465 vk::VkSubpassDescriptionFlags _flags,
466 deUint32 _inputAttachmentCount,
467 const vk::VkAttachmentReference* _inputAttachments,
468 deUint32 _colorAttachmentCount,
469 const vk::VkAttachmentReference* _colorAttachments,
470 const vk::VkAttachmentReference* _resolveAttachments,
471 vk::VkAttachmentReference depthStencilAttachment,
472 deUint32 _preserveAttachmentCount,
473 const deUint32* _preserveAttachments)
475 m_inputAttachments = std::vector<vk::VkAttachmentReference>(_inputAttachments, _inputAttachments + _inputAttachmentCount);
476 m_colorAttachments = std::vector<vk::VkAttachmentReference>(_colorAttachments, _colorAttachments + _colorAttachmentCount);
478 if (_resolveAttachments)
479 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(_resolveAttachments, _resolveAttachments + _colorAttachmentCount);
481 m_preserveAttachments = std::vector<deUint32>(_preserveAttachments, _preserveAttachments + _preserveAttachmentCount);
483 m_depthStencilAttachment = depthStencilAttachment;
486 pipelineBindPoint = _pipelineBindPoint;
487 inputAttachmentCount = _inputAttachmentCount;
488 pInputAttachments = DE_NULL;
489 colorAttachmentCount = _colorAttachmentCount;
490 pColorAttachments = DE_NULL;
491 pResolveAttachments = DE_NULL;
492 pDepthStencilAttachment = &m_depthStencilAttachment;
493 pPreserveAttachments = DE_NULL;
494 preserveAttachmentCount = _preserveAttachmentCount;
496 if (!m_inputAttachments.empty())
497 pInputAttachments = &m_inputAttachments[0];
499 if (!m_colorAttachments.empty())
500 pColorAttachments = &m_colorAttachments[0];
502 if (!m_resolveAttachments.empty())
503 pResolveAttachments = &m_resolveAttachments[0];
505 if (!m_preserveAttachments.empty())
506 pPreserveAttachments = &m_preserveAttachments[0];
509 SubpassDescription::SubpassDescription (const vk::VkSubpassDescription& rhs)
511 *static_cast<vk::VkSubpassDescription*>(this) = rhs;
513 m_inputAttachments = std::vector<vk::VkAttachmentReference>(
514 rhs.pInputAttachments, rhs.pInputAttachments + rhs.inputAttachmentCount);
516 m_colorAttachments = std::vector<vk::VkAttachmentReference>(
517 rhs.pColorAttachments, rhs.pColorAttachments + rhs.colorAttachmentCount);
519 if (rhs.pResolveAttachments)
520 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(
521 rhs.pResolveAttachments, rhs.pResolveAttachments + rhs.colorAttachmentCount);
523 m_preserveAttachments = std::vector<deUint32>(
524 rhs.pPreserveAttachments, rhs.pPreserveAttachments + rhs.preserveAttachmentCount);
526 if (rhs.pDepthStencilAttachment)
527 m_depthStencilAttachment = *rhs.pDepthStencilAttachment;
529 if (!m_inputAttachments.empty())
530 pInputAttachments = &m_inputAttachments[0];
532 if (!m_colorAttachments.empty())
533 pColorAttachments = &m_colorAttachments[0];
535 if (!m_resolveAttachments.empty())
536 pResolveAttachments = &m_resolveAttachments[0];
538 pDepthStencilAttachment = &m_depthStencilAttachment;
540 if (!m_preserveAttachments.empty())
541 pPreserveAttachments = &m_preserveAttachments[0];
544 SubpassDescription::SubpassDescription (const SubpassDescription& rhs) {
548 SubpassDescription& SubpassDescription::operator= (const SubpassDescription& rhs)
550 *static_cast<vk::VkSubpassDescription*>(this) = rhs;
552 m_inputAttachments = rhs.m_inputAttachments;
553 m_colorAttachments = rhs.m_colorAttachments;
554 m_resolveAttachments = rhs.m_resolveAttachments;
555 m_preserveAttachments = rhs.m_preserveAttachments;
556 m_depthStencilAttachment = rhs.m_depthStencilAttachment;
558 if (!m_inputAttachments.empty())
559 pInputAttachments = &m_inputAttachments[0];
561 if (!m_colorAttachments.empty())
562 pColorAttachments = &m_colorAttachments[0];
564 if (!m_resolveAttachments.empty())
565 pResolveAttachments = &m_resolveAttachments[0];
567 pDepthStencilAttachment = &m_depthStencilAttachment;
569 if (!m_preserveAttachments.empty())
570 pPreserveAttachments = &m_preserveAttachments[0];
575 SubpassDependency::SubpassDependency (deUint32 _srcSubpass,
576 deUint32 _dstSubpass,
577 vk::VkPipelineStageFlags _srcStageMask,
578 vk::VkPipelineStageFlags _dstStageMask,
579 vk::VkAccessFlags _srcAccessMask,
580 vk::VkAccessFlags _dstAccessMask,
581 vk::VkDependencyFlags _dependencyFlags)
583 srcSubpass = _srcSubpass;
584 dstSubpass = _dstSubpass;
585 srcStageMask = _srcStageMask;
586 dstStageMask = _dstStageMask;
587 srcAccessMask = _srcAccessMask;
588 dstAccessMask = _dstAccessMask;
589 dependencyFlags = _dependencyFlags;
592 SubpassDependency::SubpassDependency (const vk::VkSubpassDependency& rhs)
594 srcSubpass = rhs.srcSubpass;
595 dstSubpass = rhs.dstSubpass;
596 srcStageMask = rhs.srcStageMask;
597 dstStageMask = rhs.dstStageMask;
598 srcAccessMask = rhs.srcAccessMask;
599 dstAccessMask = rhs.dstAccessMask;
600 dependencyFlags = rhs.dependencyFlags;
603 CmdBufferBeginInfo::CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags _flags)
605 sType = vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
608 pInheritanceInfo = DE_NULL;
611 DescriptorPoolCreateInfo::DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>& poolSizeCounts,
612 vk::VkDescriptorPoolCreateFlags _flags,
614 : m_poolSizeCounts(poolSizeCounts)
616 sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
620 poolSizeCount = static_cast<deUint32>(m_poolSizeCounts.size());
621 pPoolSizes = &m_poolSizeCounts[0];
624 DescriptorPoolCreateInfo& DescriptorPoolCreateInfo::addDescriptors (vk::VkDescriptorType type, deUint32 count)
626 vk::VkDescriptorPoolSize descriptorTypeCount = { type, count };
627 m_poolSizeCounts.push_back(descriptorTypeCount);
629 poolSizeCount = static_cast<deUint32>(m_poolSizeCounts.size());
630 pPoolSizes = &m_poolSizeCounts[0];
635 DescriptorSetLayoutCreateInfo::DescriptorSetLayoutCreateInfo (deUint32 _bindingCount, const vk::VkDescriptorSetLayoutBinding* _pBindings)
637 sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
640 bindingCount = _bindingCount;
641 pBindings = _pBindings;
644 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (deUint32 _descriptorSetCount,
645 const vk::VkDescriptorSetLayout* _pSetLayouts,
646 deUint32 _pushConstantRangeCount,
647 const vk::VkPushConstantRange* _pPushConstantRanges)
648 : m_pushConstantRanges(_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
650 for (unsigned int i = 0; i < _descriptorSetCount; i++)
652 m_setLayouts.push_back(_pSetLayouts[i]);
655 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
657 setLayoutCount = static_cast<deUint32>(m_setLayouts.size());
658 pSetLayouts = setLayoutCount > 0 ? &m_setLayouts[0] : DE_NULL;
659 pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
661 if (m_pushConstantRanges.size()) {
662 pPushConstantRanges = &m_pushConstantRanges[0];
666 pPushConstantRanges = DE_NULL;
670 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (const std::vector<vk::VkDescriptorSetLayout>& setLayouts,
671 deUint32 _pushConstantRangeCount,
672 const vk::VkPushConstantRange* _pPushConstantRanges)
673 : m_setLayouts (setLayouts)
674 , m_pushConstantRanges (_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
676 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
680 setLayoutCount = static_cast<deUint32>(m_setLayouts.size());
684 pSetLayouts = &m_setLayouts[0];
688 pSetLayouts = DE_NULL;
691 pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
692 if (pushConstantRangeCount) {
693 pPushConstantRanges = &m_pushConstantRanges[0];
697 pPushConstantRanges = DE_NULL;
701 PipelineCreateInfo::PipelineShaderStage::PipelineShaderStage (vk::VkShaderModule _module, const char* _pName, vk::VkShaderStageFlagBits _stage)
703 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
709 pSpecializationInfo = DE_NULL;
712 PipelineCreateInfo::VertexInputState::VertexInputState (deUint32 _vertexBindingDescriptionCount,
713 const vk::VkVertexInputBindingDescription* _pVertexBindingDescriptions,
714 deUint32 _vertexAttributeDescriptionCount,
715 const vk::VkVertexInputAttributeDescription* _pVertexAttributeDescriptions)
717 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
720 vertexBindingDescriptionCount = _vertexBindingDescriptionCount;
721 pVertexBindingDescriptions = _pVertexBindingDescriptions;
722 vertexAttributeDescriptionCount = _vertexAttributeDescriptionCount;
723 pVertexAttributeDescriptions = _pVertexAttributeDescriptions;
726 PipelineCreateInfo::InputAssemblerState::InputAssemblerState (vk::VkPrimitiveTopology _topology,
727 vk::VkBool32 _primitiveRestartEnable)
729 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
732 topology = _topology;
733 primitiveRestartEnable = _primitiveRestartEnable;
736 PipelineCreateInfo::TessellationState::TessellationState (deUint32 _patchControlPoints)
738 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
741 patchControlPoints = _patchControlPoints;
744 PipelineCreateInfo::ViewportState::ViewportState (deUint32 _viewportCount,
745 std::vector<vk::VkViewport> _viewports,
746 std::vector<vk::VkRect2D> _scissors)
748 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
751 viewportCount = _viewportCount;
752 scissorCount = _viewportCount;
754 if (!_viewports.size())
756 m_viewports.resize(viewportCount);
757 deMemset(&m_viewports[0], 0, sizeof(m_viewports[0]) * m_viewports.size());
761 m_viewports = _viewports;
764 if (!_scissors.size())
766 m_scissors.resize(scissorCount);
767 deMemset(&m_scissors[0], 0, sizeof(m_scissors[0]) * m_scissors.size());
771 m_scissors = _scissors;
774 pViewports = &m_viewports[0];
775 pScissors = &m_scissors[0];
778 PipelineCreateInfo::ViewportState::ViewportState (const ViewportState& other)
783 viewportCount = other.viewportCount;
784 scissorCount = other.scissorCount;
786 m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + viewportCount);
787 m_scissors = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
789 pViewports = &m_viewports[0];
790 pScissors = &m_scissors[0];
793 PipelineCreateInfo::ViewportState& PipelineCreateInfo::ViewportState::operator= (const ViewportState& other)
798 viewportCount = other.viewportCount;
799 scissorCount = other.scissorCount;
801 m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + scissorCount);
802 m_scissors = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
804 pViewports = &m_viewports[0];
805 pScissors = &m_scissors[0];
809 PipelineCreateInfo::RasterizerState::RasterizerState (vk::VkBool32 _depthClampEnable,
810 vk::VkBool32 _rasterizerDiscardEnable,
811 vk::VkPolygonMode _polygonMode,
812 vk::VkCullModeFlags _cullMode,
813 vk::VkFrontFace _frontFace,
814 vk::VkBool32 _depthBiasEnable,
815 float _depthBiasConstantFactor,
816 float _depthBiasClamp,
817 float _depthBiasSlopeFactor,
820 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
823 depthClampEnable = _depthClampEnable;
824 rasterizerDiscardEnable = _rasterizerDiscardEnable;
825 polygonMode = _polygonMode;
826 cullMode = _cullMode;
827 frontFace = _frontFace;
829 depthBiasEnable = _depthBiasEnable;
830 depthBiasConstantFactor = _depthBiasConstantFactor;
831 depthBiasClamp = _depthBiasClamp;
832 depthBiasSlopeFactor = _depthBiasSlopeFactor;
833 lineWidth = _lineWidth;
836 PipelineCreateInfo::MultiSampleState::MultiSampleState (vk::VkSampleCountFlagBits _rasterizationSamples,
837 vk::VkBool32 _sampleShadingEnable,
838 float _minSampleShading,
839 const std::vector<vk::VkSampleMask>& _sampleMask,
840 bool _alphaToCoverageEnable,
841 bool _alphaToOneEnable)
842 : m_sampleMask(_sampleMask)
844 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
847 rasterizationSamples = _rasterizationSamples;
848 sampleShadingEnable = _sampleShadingEnable;
849 minSampleShading = _minSampleShading;
850 pSampleMask = &m_sampleMask[0];
851 alphaToCoverageEnable = _alphaToCoverageEnable;
852 alphaToOneEnable = _alphaToOneEnable;
855 PipelineCreateInfo::MultiSampleState::MultiSampleState (const MultiSampleState& other)
860 rasterizationSamples = other.rasterizationSamples;
861 sampleShadingEnable = other.sampleShadingEnable;
862 minSampleShading = other.minSampleShading;
864 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
866 m_sampleMask = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
867 pSampleMask = &m_sampleMask[0];
870 PipelineCreateInfo::MultiSampleState& PipelineCreateInfo::MultiSampleState::operator= (const MultiSampleState& other)
875 rasterizationSamples = other.rasterizationSamples;
876 sampleShadingEnable = other.sampleShadingEnable;
877 minSampleShading = other.minSampleShading;
879 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
881 m_sampleMask = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
882 pSampleMask = &m_sampleMask[0];
887 PipelineCreateInfo::ColorBlendState::ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>& _attachments,
888 vk::VkBool32 _logicOpEnable,
889 vk::VkLogicOp _logicOp)
890 : m_attachments(_attachments)
892 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
895 logicOpEnable = _logicOpEnable;
897 attachmentCount = static_cast<deUint32>(m_attachments.size());
898 pAttachments = &m_attachments[0];
901 PipelineCreateInfo::ColorBlendState::ColorBlendState (deUint32 _attachmentCount,
902 const vk::VkPipelineColorBlendAttachmentState* _attachments,
903 vk::VkBool32 _logicOpEnable,
904 vk::VkLogicOp _logicOp)
905 : m_attachments(_attachments, _attachments + _attachmentCount)
907 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
910 logicOpEnable = _logicOpEnable;
912 attachmentCount = static_cast<deUint32>(m_attachments.size());
913 pAttachments = &m_attachments[0];
916 PipelineCreateInfo::ColorBlendState::ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo& createInfo)
917 : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
919 sType = createInfo.sType;
920 pNext = createInfo.pNext;
921 flags = createInfo.flags;
922 logicOpEnable = createInfo.logicOpEnable;
923 logicOp = createInfo.logicOp;
924 attachmentCount = static_cast<deUint32>(m_attachments.size());
925 pAttachments = &m_attachments[0];
928 PipelineCreateInfo::ColorBlendState::ColorBlendState (const ColorBlendState& createInfo, std::vector<float> _blendConstants)
929 : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
931 sType = createInfo.sType;
932 pNext = createInfo.pNext;
933 flags = createInfo.flags;
934 logicOpEnable = createInfo.logicOpEnable;
935 logicOp = createInfo.logicOp;
936 attachmentCount = static_cast<deUint32>(m_attachments.size());
937 pAttachments = &m_attachments[0];
938 deMemcpy(blendConstants, &_blendConstants[0], 4 * sizeof(float));
941 PipelineCreateInfo::ColorBlendState::Attachment::Attachment (vk::VkBool32 _blendEnable,
942 vk::VkBlendFactor _srcColorBlendFactor,
943 vk::VkBlendFactor _dstColorBlendFactor,
944 vk::VkBlendOp _colorBlendOp,
945 vk::VkBlendFactor _srcAlphaBlendFactor,
946 vk::VkBlendFactor _dstAlphaBlendFactor,
947 vk::VkBlendOp _alphaBlendOp,
948 deUint8 _colorWriteMask)
950 blendEnable = _blendEnable;
951 srcColorBlendFactor = _srcColorBlendFactor;
952 dstColorBlendFactor = _dstColorBlendFactor;
953 colorBlendOp = _colorBlendOp;
954 srcAlphaBlendFactor = _srcAlphaBlendFactor;
955 dstAlphaBlendFactor = _dstAlphaBlendFactor;
956 alphaBlendOp = _alphaBlendOp;
957 colorWriteMask = _colorWriteMask;
960 PipelineCreateInfo::DepthStencilState::StencilOpState::StencilOpState (vk::VkStencilOp _failOp,
961 vk::VkStencilOp _passOp,
962 vk::VkStencilOp _depthFailOp,
963 vk::VkCompareOp _compareOp,
964 deUint32 _compareMask,
970 depthFailOp = _depthFailOp;
971 compareOp = _compareOp;
973 compareMask = _compareMask;
974 writeMask = _writeMask;
975 reference = _reference;
978 PipelineCreateInfo::DepthStencilState::DepthStencilState (vk::VkBool32 _depthTestEnable,
979 vk::VkBool32 _depthWriteEnable,
980 vk::VkCompareOp _depthCompareOp,
981 vk::VkBool32 _depthBoundsTestEnable,
982 vk::VkBool32 _stencilTestEnable,
983 StencilOpState _front,
984 StencilOpState _back,
985 float _minDepthBounds,
986 float _maxDepthBounds)
988 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
991 depthTestEnable = _depthTestEnable;
992 depthWriteEnable = _depthWriteEnable;
993 depthCompareOp = _depthCompareOp;
994 depthBoundsTestEnable = _depthBoundsTestEnable;
995 stencilTestEnable = _stencilTestEnable;
999 minDepthBounds = _minDepthBounds;
1000 maxDepthBounds = _maxDepthBounds;
1003 PipelineCreateInfo::DynamicState::DynamicState (const std::vector<vk::VkDynamicState>& _dynamicStates)
1005 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
1009 if (!_dynamicStates.size())
1011 for (size_t i = 0; i < vk::VK_DYNAMIC_STATE_LAST; ++i)
1013 m_dynamicStates.push_back(static_cast<vk::VkDynamicState>(i));
1017 m_dynamicStates = _dynamicStates;
1019 dynamicStateCount = static_cast<deUint32>(m_dynamicStates.size());
1020 pDynamicStates = &m_dynamicStates[0];
1023 PipelineCreateInfo::DynamicState::DynamicState (const DynamicState &other)
1025 sType = other.sType;
1026 pNext = other.pNext;
1027 flags = other.flags;
1029 dynamicStateCount = other.dynamicStateCount;
1031 m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1032 pDynamicStates = &m_dynamicStates[0];
1035 PipelineCreateInfo::DynamicState& PipelineCreateInfo::DynamicState::operator= (const DynamicState& other)
1037 sType = other.sType;
1038 pNext = other.pNext;
1039 flags = other.flags;
1041 dynamicStateCount = other.dynamicStateCount;
1043 m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1044 pDynamicStates = &m_dynamicStates[0];
1049 PipelineCreateInfo::PipelineCreateInfo (vk::VkPipelineLayout _layout,
1050 vk::VkRenderPass _renderPass,
1052 vk::VkPipelineCreateFlags _flags)
1054 deMemset(static_cast<vk::VkGraphicsPipelineCreateInfo *>(this), 0,
1055 sizeof(vk::VkGraphicsPipelineCreateInfo));
1057 sType = vk::VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
1060 renderPass = _renderPass;
1063 basePipelineHandle = DE_NULL;
1064 basePipelineIndex = 0;
1065 pDynamicState = DE_NULL;
1068 PipelineCreateInfo& PipelineCreateInfo::addShader (const vk::VkPipelineShaderStageCreateInfo& shader)
1070 m_shaders.push_back(shader);
1072 stageCount = static_cast<deUint32>(m_shaders.size());
1073 pStages = &m_shaders[0];
1078 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineVertexInputStateCreateInfo& state)
1080 m_vertexInputState = state;
1081 pVertexInputState = &m_vertexInputState;
1086 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state)
1088 m_inputAssemblyState = state;
1089 pInputAssemblyState = &m_inputAssemblyState;
1094 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineColorBlendStateCreateInfo& state)
1096 m_colorBlendStateAttachments = std::vector<vk::VkPipelineColorBlendAttachmentState>(state.pAttachments, state.pAttachments + state.attachmentCount);
1097 m_colorBlendState = state;
1098 m_colorBlendState.pAttachments = &m_colorBlendStateAttachments[0];
1099 pColorBlendState = &m_colorBlendState;
1104 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineViewportStateCreateInfo& state)
1106 m_viewports = std::vector<vk::VkViewport>(state.pViewports, state.pViewports + state.viewportCount);
1107 m_scissors = std::vector<vk::VkRect2D>(state.pScissors, state.pScissors + state.scissorCount);
1108 m_viewportState = state;
1109 m_viewportState.pViewports = &m_viewports[0];
1110 m_viewportState.pScissors = &m_scissors[0];
1111 pViewportState = &m_viewportState;
1116 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDepthStencilStateCreateInfo& state)
1118 m_dynamicDepthStencilState = state;
1119 pDepthStencilState = &m_dynamicDepthStencilState;
1123 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineTessellationStateCreateInfo& state)
1125 m_tessState = state;
1126 pTessellationState = &m_tessState;
1131 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineRasterizationStateCreateInfo& state)
1133 m_rasterState = state;
1134 pRasterizationState = &m_rasterState;
1139 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineMultisampleStateCreateInfo& state)
1142 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + state.rasterizationSamples) / ( sizeof(vk::VkSampleMask) * 8 );
1143 m_multisampleStateSampleMask = std::vector<vk::VkSampleMask>(state.pSampleMask, state.pSampleMask + sampleMaskArrayLen);
1144 m_multisampleState = state;
1145 m_multisampleState.pSampleMask = &m_multisampleStateSampleMask[0];
1146 pMultisampleState = &m_multisampleState;
1150 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDynamicStateCreateInfo& state)
1152 m_dynamicStates = std::vector<vk::VkDynamicState>(state.pDynamicStates, state.pDynamicStates + state.dynamicStateCount);
1153 m_dynamicState = state;
1154 m_dynamicState.pDynamicStates = &m_dynamicStates[0];
1155 pDynamicState = &m_dynamicState;
1160 SamplerCreateInfo::SamplerCreateInfo (vk::VkFilter _magFilter,
1161 vk::VkFilter _minFilter,
1162 vk::VkSamplerMipmapMode _mipmapMode,
1163 vk::VkSamplerAddressMode _addressModeU,
1164 vk::VkSamplerAddressMode _addressModeV,
1165 vk::VkSamplerAddressMode _addressModeW,
1167 vk::VkBool32 _anisotropyEnable,
1168 float _maxAnisotropy,
1169 vk::VkBool32 _compareEnable,
1170 vk::VkCompareOp _compareOp,
1173 vk::VkBorderColor _borderColor,
1174 vk::VkBool32 _unnormalizedCoordinates)
1176 sType = vk::VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
1179 magFilter = _magFilter;
1180 minFilter = _minFilter;
1181 mipmapMode = _mipmapMode;
1182 addressModeU = _addressModeU;
1183 addressModeV = _addressModeV;
1184 addressModeW = _addressModeW;
1185 mipLodBias = _mipLodBias;
1186 anisotropyEnable = _anisotropyEnable;
1187 maxAnisotropy = _maxAnisotropy;
1188 compareEnable = _compareEnable;
1189 compareOp = _compareOp;
1192 borderColor = _borderColor;
1193 unnormalizedCoordinates = _unnormalizedCoordinates;