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 "vktQueryPoolCreateInfoUtil.hpp"
38 #include "vkImageUtil.hpp"
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());
335 pAttachments = &m_attachmentsStructs[0];
339 pAttachments = DE_NULL;
342 subpassCount = static_cast<deUint32>(m_subpasses.size());
346 pSubpasses = &m_subpassesStructs[0];
350 pSubpasses = DE_NULL;
353 dependencyCount = static_cast<deUint32>(m_dependiences.size());
357 pDependencies = &m_dependiencesStructs[0];
361 pDependencies = DE_NULL;
366 RenderPassCreateInfo::addAttachment (vk::VkAttachmentDescription attachment)
369 m_attachments.push_back(attachment);
370 m_attachmentsStructs = std::vector<vk::VkAttachmentDescription>(m_attachments.begin(), m_attachments.end());
371 attachmentCount = static_cast<deUint32>(m_attachments.size());
372 pAttachments = &m_attachmentsStructs[0];
376 RenderPassCreateInfo::addSubpass (vk::VkSubpassDescription subpass)
379 m_subpasses.push_back(subpass);
380 m_subpassesStructs = std::vector<vk::VkSubpassDescription>(m_subpasses.begin(), m_subpasses.end());
381 subpassCount = static_cast<deUint32>(m_subpasses.size());
382 pSubpasses = &m_subpassesStructs[0];
386 RenderPassCreateInfo::addDependency (vk::VkSubpassDependency dependency)
389 m_dependiences.push_back(dependency);
390 m_dependiencesStructs = std::vector<vk::VkSubpassDependency>(m_dependiences.begin(), m_dependiences.end());
392 dependencyCount = static_cast<deUint32>(m_dependiences.size());
393 pDependencies = &m_dependiencesStructs[0];
396 RenderPassBeginInfo::RenderPassBeginInfo (vk::VkRenderPass _renderPass,
397 vk::VkFramebuffer _framebuffer,
398 vk::VkRect2D _renderArea,
399 const std::vector<vk::VkClearValue>& _clearValues)
402 m_clearValues = _clearValues;
404 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
406 renderPass = _renderPass;
407 framebuffer = _framebuffer;
408 renderArea = _renderArea;
409 clearValueCount = static_cast<deUint32>(m_clearValues.size());
410 pClearValues = m_clearValues.size() ? &m_clearValues[0] : DE_NULL;
413 CmdPoolCreateInfo::CmdPoolCreateInfo (deUint32 _queueFamilyIndex, unsigned int _flags)
415 sType = vk::VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
418 queueFamilyIndex = _queueFamilyIndex;
422 AttachmentDescription::AttachmentDescription (vk::VkFormat _format,
423 vk::VkSampleCountFlagBits _samples,
424 vk::VkAttachmentLoadOp _loadOp,
425 vk::VkAttachmentStoreOp _storeOp,
426 vk::VkAttachmentLoadOp _stencilLoadOp,
427 vk::VkAttachmentStoreOp _stencilStoreOp,
428 vk::VkImageLayout _initialLayout,
429 vk::VkImageLayout _finalLayout)
436 stencilLoadOp = _stencilLoadOp;
437 stencilStoreOp = _stencilStoreOp;
438 initialLayout = _initialLayout;
439 finalLayout = _finalLayout;
442 AttachmentDescription::AttachmentDescription (const vk::VkAttachmentDescription& rhs)
446 samples = rhs.samples;
448 storeOp = rhs.storeOp;
449 stencilLoadOp = rhs.stencilLoadOp;
450 stencilStoreOp = rhs.stencilStoreOp;
451 initialLayout = rhs.initialLayout;
452 finalLayout = rhs.finalLayout;
455 AttachmentReference::AttachmentReference (deUint32 _attachment, vk::VkImageLayout _layout)
457 attachment = _attachment;
461 AttachmentReference::AttachmentReference (void)
463 attachment = vk::VK_ATTACHMENT_UNUSED;
464 layout = vk::VK_IMAGE_LAYOUT_UNDEFINED;
467 SubpassDescription::SubpassDescription (vk::VkPipelineBindPoint _pipelineBindPoint,
468 vk::VkSubpassDescriptionFlags _flags,
469 deUint32 _inputAttachmentCount,
470 const vk::VkAttachmentReference* _inputAttachments,
471 deUint32 _colorAttachmentCount,
472 const vk::VkAttachmentReference* _colorAttachments,
473 const vk::VkAttachmentReference* _resolveAttachments,
474 vk::VkAttachmentReference depthStencilAttachment,
475 deUint32 _preserveAttachmentCount,
476 const deUint32* _preserveAttachments)
478 m_inputAttachments = std::vector<vk::VkAttachmentReference>(_inputAttachments, _inputAttachments + _inputAttachmentCount);
479 m_colorAttachments = std::vector<vk::VkAttachmentReference>(_colorAttachments, _colorAttachments + _colorAttachmentCount);
481 if (_resolveAttachments)
482 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(_resolveAttachments, _resolveAttachments + _colorAttachmentCount);
484 m_preserveAttachments = std::vector<deUint32>(_preserveAttachments, _preserveAttachments + _preserveAttachmentCount);
486 m_depthStencilAttachment = depthStencilAttachment;
489 pipelineBindPoint = _pipelineBindPoint;
490 inputAttachmentCount = _inputAttachmentCount;
491 pInputAttachments = DE_NULL;
492 colorAttachmentCount = _colorAttachmentCount;
493 pColorAttachments = DE_NULL;
494 pResolveAttachments = DE_NULL;
495 pDepthStencilAttachment = &m_depthStencilAttachment;
496 pPreserveAttachments = DE_NULL;
497 preserveAttachmentCount = _preserveAttachmentCount;
499 if (!m_inputAttachments.empty())
500 pInputAttachments = &m_inputAttachments[0];
502 if (!m_colorAttachments.empty())
503 pColorAttachments = &m_colorAttachments[0];
505 if (!m_resolveAttachments.empty())
506 pResolveAttachments = &m_resolveAttachments[0];
508 if (!m_preserveAttachments.empty())
509 pPreserveAttachments = &m_preserveAttachments[0];
512 SubpassDescription::SubpassDescription (const vk::VkSubpassDescription& rhs)
514 *static_cast<vk::VkSubpassDescription*>(this) = rhs;
516 m_inputAttachments = std::vector<vk::VkAttachmentReference>(
517 rhs.pInputAttachments, rhs.pInputAttachments + rhs.inputAttachmentCount);
519 m_colorAttachments = std::vector<vk::VkAttachmentReference>(
520 rhs.pColorAttachments, rhs.pColorAttachments + rhs.colorAttachmentCount);
522 if (rhs.pResolveAttachments)
523 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(
524 rhs.pResolveAttachments, rhs.pResolveAttachments + rhs.colorAttachmentCount);
526 m_preserveAttachments = std::vector<deUint32>(
527 rhs.pPreserveAttachments, rhs.pPreserveAttachments + rhs.preserveAttachmentCount);
529 if (rhs.pDepthStencilAttachment)
530 m_depthStencilAttachment = *rhs.pDepthStencilAttachment;
532 if (!m_inputAttachments.empty())
533 pInputAttachments = &m_inputAttachments[0];
535 if (!m_colorAttachments.empty())
536 pColorAttachments = &m_colorAttachments[0];
538 if (!m_resolveAttachments.empty())
539 pResolveAttachments = &m_resolveAttachments[0];
541 pDepthStencilAttachment = &m_depthStencilAttachment;
543 if (!m_preserveAttachments.empty())
544 pPreserveAttachments = &m_preserveAttachments[0];
547 SubpassDescription::SubpassDescription (const SubpassDescription& rhs) {
551 SubpassDescription& SubpassDescription::operator= (const SubpassDescription& rhs)
553 *static_cast<vk::VkSubpassDescription*>(this) = rhs;
555 m_inputAttachments = rhs.m_inputAttachments;
556 m_colorAttachments = rhs.m_colorAttachments;
557 m_resolveAttachments = rhs.m_resolveAttachments;
558 m_preserveAttachments = rhs.m_preserveAttachments;
559 m_depthStencilAttachment = rhs.m_depthStencilAttachment;
561 if (!m_inputAttachments.empty())
562 pInputAttachments = &m_inputAttachments[0];
564 if (!m_colorAttachments.empty())
565 pColorAttachments = &m_colorAttachments[0];
567 if (!m_resolveAttachments.empty())
568 pResolveAttachments = &m_resolveAttachments[0];
570 pDepthStencilAttachment = &m_depthStencilAttachment;
572 if (!m_preserveAttachments.empty())
573 pPreserveAttachments = &m_preserveAttachments[0];
578 SubpassDependency::SubpassDependency (deUint32 _srcSubpass,
579 deUint32 _dstSubpass,
580 vk::VkPipelineStageFlags _srcStageMask,
581 vk::VkPipelineStageFlags _dstStageMask,
582 vk::VkAccessFlags _srcAccessMask,
583 vk::VkAccessFlags _dstAccessMask,
584 vk::VkDependencyFlags _dependencyFlags)
586 srcSubpass = _srcSubpass;
587 dstSubpass = _dstSubpass;
588 srcStageMask = _srcStageMask;
589 dstStageMask = _dstStageMask;
590 srcAccessMask = _srcAccessMask;
591 dstAccessMask = _dstAccessMask;
592 dependencyFlags = _dependencyFlags;
595 SubpassDependency::SubpassDependency (const vk::VkSubpassDependency& rhs)
597 srcSubpass = rhs.srcSubpass;
598 dstSubpass = rhs.dstSubpass;
599 srcStageMask = rhs.srcStageMask;
600 dstStageMask = rhs.dstStageMask;
601 srcAccessMask = rhs.srcAccessMask;
602 dstAccessMask = rhs.dstAccessMask;
603 dependencyFlags = rhs.dependencyFlags;
606 CmdBufferBeginInfo::CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags _flags)
608 sType = vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
611 pInheritanceInfo = DE_NULL;
614 DescriptorPoolCreateInfo::DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>& poolSizeCounts,
615 vk::VkDescriptorPoolCreateFlags _flags,
617 : m_poolSizeCounts(poolSizeCounts)
619 sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
623 poolSizeCount = static_cast<deUint32>(m_poolSizeCounts.size());
624 pPoolSizes = &m_poolSizeCounts[0];
627 DescriptorPoolCreateInfo& DescriptorPoolCreateInfo::addDescriptors (vk::VkDescriptorType type, deUint32 count)
629 vk::VkDescriptorPoolSize descriptorTypeCount = { type, count };
630 m_poolSizeCounts.push_back(descriptorTypeCount);
632 poolSizeCount = static_cast<deUint32>(m_poolSizeCounts.size());
633 pPoolSizes = &m_poolSizeCounts[0];
638 DescriptorSetLayoutCreateInfo::DescriptorSetLayoutCreateInfo (deUint32 _bindingCount, const vk::VkDescriptorSetLayoutBinding* _pBindings)
640 sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
643 bindingCount = _bindingCount;
644 pBindings = _pBindings;
647 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (deUint32 _descriptorSetCount,
648 const vk::VkDescriptorSetLayout* _pSetLayouts,
649 deUint32 _pushConstantRangeCount,
650 const vk::VkPushConstantRange* _pPushConstantRanges)
651 : m_pushConstantRanges(_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
653 for (unsigned int i = 0; i < _descriptorSetCount; i++)
655 m_setLayouts.push_back(_pSetLayouts[i]);
658 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
662 setLayoutCount = static_cast<deUint32>(m_setLayouts.size());
663 pSetLayouts = setLayoutCount > 0 ? &m_setLayouts[0] : DE_NULL;
664 pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
666 if (m_pushConstantRanges.size())
668 pPushConstantRanges = &m_pushConstantRanges[0];
672 pPushConstantRanges = DE_NULL;
676 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (const std::vector<vk::VkDescriptorSetLayout>& setLayouts,
677 deUint32 _pushConstantRangeCount,
678 const vk::VkPushConstantRange* _pPushConstantRanges)
679 : m_setLayouts (setLayouts)
680 , m_pushConstantRanges (_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
682 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
686 setLayoutCount = static_cast<deUint32>(m_setLayouts.size());
690 pSetLayouts = &m_setLayouts[0];
694 pSetLayouts = DE_NULL;
697 pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
698 if (pushConstantRangeCount)
700 pPushConstantRanges = &m_pushConstantRanges[0];
704 pPushConstantRanges = DE_NULL;
708 PipelineCreateInfo::PipelineShaderStage::PipelineShaderStage (vk::VkShaderModule _module, const char* _pName, vk::VkShaderStageFlagBits _stage)
710 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
716 pSpecializationInfo = DE_NULL;
719 PipelineCreateInfo::VertexInputState::VertexInputState (deUint32 _vertexBindingDescriptionCount,
720 const vk::VkVertexInputBindingDescription* _pVertexBindingDescriptions,
721 deUint32 _vertexAttributeDescriptionCount,
722 const vk::VkVertexInputAttributeDescription* _pVertexAttributeDescriptions)
724 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
727 vertexBindingDescriptionCount = _vertexBindingDescriptionCount;
728 pVertexBindingDescriptions = _pVertexBindingDescriptions;
729 vertexAttributeDescriptionCount = _vertexAttributeDescriptionCount;
730 pVertexAttributeDescriptions = _pVertexAttributeDescriptions;
733 PipelineCreateInfo::InputAssemblerState::InputAssemblerState (vk::VkPrimitiveTopology _topology,
734 vk::VkBool32 _primitiveRestartEnable)
736 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
739 topology = _topology;
740 primitiveRestartEnable = _primitiveRestartEnable;
743 PipelineCreateInfo::TessellationState::TessellationState (deUint32 _patchControlPoints)
745 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
748 patchControlPoints = _patchControlPoints;
751 PipelineCreateInfo::ViewportState::ViewportState (deUint32 _viewportCount,
752 std::vector<vk::VkViewport> _viewports,
753 std::vector<vk::VkRect2D> _scissors)
755 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
758 viewportCount = _viewportCount;
759 scissorCount = _viewportCount;
761 if (!_viewports.size())
763 m_viewports.resize(viewportCount);
764 deMemset(&m_viewports[0], 0, sizeof(m_viewports[0]) * m_viewports.size());
768 m_viewports = _viewports;
771 if (!_scissors.size())
773 m_scissors.resize(scissorCount);
774 deMemset(&m_scissors[0], 0, sizeof(m_scissors[0]) * m_scissors.size());
778 m_scissors = _scissors;
781 pViewports = &m_viewports[0];
782 pScissors = &m_scissors[0];
785 PipelineCreateInfo::ViewportState::ViewportState (const ViewportState& other)
790 viewportCount = other.viewportCount;
791 scissorCount = other.scissorCount;
793 m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + viewportCount);
794 m_scissors = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
796 pViewports = &m_viewports[0];
797 pScissors = &m_scissors[0];
800 PipelineCreateInfo::ViewportState& PipelineCreateInfo::ViewportState::operator= (const ViewportState& other)
805 viewportCount = other.viewportCount;
806 scissorCount = other.scissorCount;
808 m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + scissorCount);
809 m_scissors = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
811 pViewports = &m_viewports[0];
812 pScissors = &m_scissors[0];
816 PipelineCreateInfo::RasterizerState::RasterizerState (vk::VkBool32 _depthClampEnable,
817 vk::VkBool32 _rasterizerDiscardEnable,
818 vk::VkPolygonMode _polygonMode,
819 vk::VkCullModeFlags _cullMode,
820 vk::VkFrontFace _frontFace,
821 vk::VkBool32 _depthBiasEnable,
822 float _depthBiasConstantFactor,
823 float _depthBiasClamp,
824 float _depthBiasSlopeFactor,
827 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
830 depthClampEnable = _depthClampEnable;
831 rasterizerDiscardEnable = _rasterizerDiscardEnable;
832 polygonMode = _polygonMode;
833 cullMode = _cullMode;
834 frontFace = _frontFace;
836 depthBiasEnable = _depthBiasEnable;
837 depthBiasConstantFactor = _depthBiasConstantFactor;
838 depthBiasClamp = _depthBiasClamp;
839 depthBiasSlopeFactor = _depthBiasSlopeFactor;
840 lineWidth = _lineWidth;
843 PipelineCreateInfo::MultiSampleState::MultiSampleState (vk::VkSampleCountFlagBits _rasterizationSamples,
844 vk::VkBool32 _sampleShadingEnable,
845 float _minSampleShading,
846 const std::vector<vk::VkSampleMask>& _sampleMask,
847 bool _alphaToCoverageEnable,
848 bool _alphaToOneEnable)
849 : m_sampleMask(_sampleMask)
851 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
854 rasterizationSamples = _rasterizationSamples;
855 sampleShadingEnable = _sampleShadingEnable;
856 minSampleShading = _minSampleShading;
857 pSampleMask = &m_sampleMask[0];
858 alphaToCoverageEnable = _alphaToCoverageEnable;
859 alphaToOneEnable = _alphaToOneEnable;
862 PipelineCreateInfo::MultiSampleState::MultiSampleState (const MultiSampleState& other)
867 rasterizationSamples = other.rasterizationSamples;
868 sampleShadingEnable = other.sampleShadingEnable;
869 minSampleShading = other.minSampleShading;
871 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
873 m_sampleMask = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
874 pSampleMask = &m_sampleMask[0];
877 PipelineCreateInfo::MultiSampleState& PipelineCreateInfo::MultiSampleState::operator= (const MultiSampleState& other)
882 rasterizationSamples = other.rasterizationSamples;
883 sampleShadingEnable = other.sampleShadingEnable;
884 minSampleShading = other.minSampleShading;
886 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
888 m_sampleMask = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
889 pSampleMask = &m_sampleMask[0];
894 PipelineCreateInfo::ColorBlendState::ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>& _attachments,
895 vk::VkBool32 _logicOpEnable,
896 vk::VkLogicOp _logicOp)
897 : m_attachments(_attachments)
899 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
902 logicOpEnable = _logicOpEnable;
904 attachmentCount = static_cast<deUint32>(m_attachments.size());
905 pAttachments = &m_attachments[0];
908 PipelineCreateInfo::ColorBlendState::ColorBlendState (deUint32 _attachmentCount,
909 const vk::VkPipelineColorBlendAttachmentState* _attachments,
910 vk::VkBool32 _logicOpEnable,
911 vk::VkLogicOp _logicOp)
912 : m_attachments(_attachments, _attachments + _attachmentCount)
914 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
917 logicOpEnable = _logicOpEnable;
919 attachmentCount = static_cast<deUint32>(m_attachments.size());
920 pAttachments = &m_attachments[0];
923 PipelineCreateInfo::ColorBlendState::ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo& createInfo)
924 : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
926 sType = createInfo.sType;
927 pNext = createInfo.pNext;
928 flags = createInfo.flags;
929 logicOpEnable = createInfo.logicOpEnable;
930 logicOp = createInfo.logicOp;
931 attachmentCount = static_cast<deUint32>(m_attachments.size());
932 pAttachments = &m_attachments[0];
935 PipelineCreateInfo::ColorBlendState::ColorBlendState (const ColorBlendState& createInfo, std::vector<float> _blendConstants)
936 : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
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));
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 deUint8 _colorWriteMask)
957 blendEnable = _blendEnable;
958 srcColorBlendFactor = _srcColorBlendFactor;
959 dstColorBlendFactor = _dstColorBlendFactor;
960 colorBlendOp = _colorBlendOp;
961 srcAlphaBlendFactor = _srcAlphaBlendFactor;
962 dstAlphaBlendFactor = _dstAlphaBlendFactor;
963 alphaBlendOp = _alphaBlendOp;
964 colorWriteMask = _colorWriteMask;
967 PipelineCreateInfo::DepthStencilState::StencilOpState::StencilOpState (vk::VkStencilOp _failOp,
968 vk::VkStencilOp _passOp,
969 vk::VkStencilOp _depthFailOp,
970 vk::VkCompareOp _compareOp,
971 deUint32 _compareMask,
977 depthFailOp = _depthFailOp;
978 compareOp = _compareOp;
980 compareMask = _compareMask;
981 writeMask = _writeMask;
982 reference = _reference;
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)
995 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
998 depthTestEnable = _depthTestEnable;
999 depthWriteEnable = _depthWriteEnable;
1000 depthCompareOp = _depthCompareOp;
1001 depthBoundsTestEnable = _depthBoundsTestEnable;
1002 stencilTestEnable = _stencilTestEnable;
1006 minDepthBounds = _minDepthBounds;
1007 maxDepthBounds = _maxDepthBounds;
1010 PipelineCreateInfo::DynamicState::DynamicState (const std::vector<vk::VkDynamicState>& _dynamicStates)
1012 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
1016 if (!_dynamicStates.size())
1018 for (size_t i = 0; i < vk::VK_DYNAMIC_STATE_LAST; ++i)
1020 m_dynamicStates.push_back(static_cast<vk::VkDynamicState>(i));
1024 m_dynamicStates = _dynamicStates;
1026 dynamicStateCount = static_cast<deUint32>(m_dynamicStates.size());
1027 pDynamicStates = &m_dynamicStates[0];
1030 PipelineCreateInfo::DynamicState::DynamicState (const DynamicState &other)
1032 sType = other.sType;
1033 pNext = other.pNext;
1034 flags = other.flags;
1036 dynamicStateCount = other.dynamicStateCount;
1038 m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1039 pDynamicStates = &m_dynamicStates[0];
1042 PipelineCreateInfo::DynamicState& PipelineCreateInfo::DynamicState::operator= (const DynamicState& other)
1044 sType = other.sType;
1045 pNext = other.pNext;
1046 flags = other.flags;
1048 dynamicStateCount = other.dynamicStateCount;
1050 m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1051 pDynamicStates = &m_dynamicStates[0];
1056 PipelineCreateInfo::PipelineCreateInfo (vk::VkPipelineLayout _layout,
1057 vk::VkRenderPass _renderPass,
1059 vk::VkPipelineCreateFlags _flags)
1061 deMemset(static_cast<vk::VkGraphicsPipelineCreateInfo *>(this), 0,
1062 sizeof(vk::VkGraphicsPipelineCreateInfo));
1064 sType = vk::VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
1067 renderPass = _renderPass;
1070 basePipelineHandle = DE_NULL;
1071 basePipelineIndex = 0;
1072 pDynamicState = DE_NULL;
1075 PipelineCreateInfo& PipelineCreateInfo::addShader (const vk::VkPipelineShaderStageCreateInfo& shader)
1077 m_shaders.push_back(shader);
1079 stageCount = static_cast<deUint32>(m_shaders.size());
1080 pStages = &m_shaders[0];
1085 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineVertexInputStateCreateInfo& state)
1087 m_vertexInputState = state;
1088 pVertexInputState = &m_vertexInputState;
1093 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state)
1095 m_inputAssemblyState = state;
1096 pInputAssemblyState = &m_inputAssemblyState;
1101 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineColorBlendStateCreateInfo& state)
1103 m_colorBlendStateAttachments = std::vector<vk::VkPipelineColorBlendAttachmentState>(state.pAttachments, state.pAttachments + state.attachmentCount);
1104 m_colorBlendState = state;
1105 m_colorBlendState.pAttachments = &m_colorBlendStateAttachments[0];
1106 pColorBlendState = &m_colorBlendState;
1111 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineViewportStateCreateInfo& state)
1113 m_viewports = std::vector<vk::VkViewport>(state.pViewports, state.pViewports + state.viewportCount);
1114 m_scissors = std::vector<vk::VkRect2D>(state.pScissors, state.pScissors + state.scissorCount);
1115 m_viewportState = state;
1116 m_viewportState.pViewports = &m_viewports[0];
1117 m_viewportState.pScissors = &m_scissors[0];
1118 pViewportState = &m_viewportState;
1123 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDepthStencilStateCreateInfo& state)
1125 m_dynamicDepthStencilState = state;
1126 pDepthStencilState = &m_dynamicDepthStencilState;
1130 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineTessellationStateCreateInfo& state)
1132 m_tessState = state;
1133 pTessellationState = &m_tessState;
1138 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineRasterizationStateCreateInfo& state)
1140 m_rasterState = state;
1141 pRasterizationState = &m_rasterState;
1146 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineMultisampleStateCreateInfo& state)
1149 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + state.rasterizationSamples) / ( sizeof(vk::VkSampleMask) * 8 );
1150 m_multisampleStateSampleMask = std::vector<vk::VkSampleMask>(state.pSampleMask, state.pSampleMask + sampleMaskArrayLen);
1151 m_multisampleState = state;
1152 m_multisampleState.pSampleMask = &m_multisampleStateSampleMask[0];
1153 pMultisampleState = &m_multisampleState;
1157 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDynamicStateCreateInfo& state)
1159 m_dynamicStates = std::vector<vk::VkDynamicState>(state.pDynamicStates, state.pDynamicStates + state.dynamicStateCount);
1160 m_dynamicState = state;
1161 m_dynamicState.pDynamicStates = &m_dynamicStates[0];
1162 pDynamicState = &m_dynamicState;
1167 SamplerCreateInfo::SamplerCreateInfo (vk::VkFilter _magFilter,
1168 vk::VkFilter _minFilter,
1169 vk::VkSamplerMipmapMode _mipmapMode,
1170 vk::VkSamplerAddressMode _addressModeU,
1171 vk::VkSamplerAddressMode _addressModeV,
1172 vk::VkSamplerAddressMode _addressModeW,
1174 vk::VkBool32 _anisotropyEnable,
1175 float _maxAnisotropy,
1176 vk::VkBool32 _compareEnable,
1177 vk::VkCompareOp _compareOp,
1180 vk::VkBorderColor _borderColor,
1181 vk::VkBool32 _unnormalizedCoordinates)
1183 sType = vk::VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
1186 magFilter = _magFilter;
1187 minFilter = _minFilter;
1188 mipmapMode = _mipmapMode;
1189 addressModeU = _addressModeU;
1190 addressModeV = _addressModeV;
1191 addressModeW = _addressModeW;
1192 mipLodBias = _mipLodBias;
1193 anisotropyEnable = _anisotropyEnable;
1194 maxAnisotropy = _maxAnisotropy;
1195 compareEnable = _compareEnable;
1196 compareOp = _compareOp;
1199 borderColor = _borderColor;
1200 unnormalizedCoordinates = _unnormalizedCoordinates;