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;
144 BufferCreateInfo::BufferCreateInfo (vk::VkDeviceSize _size,
145 vk::VkBufferUsageFlags _usage,
146 vk::VkSharingMode _sharingMode,
147 deUint32 _queueFamilyIndexCount,
148 const deUint32* _pQueueFamilyIndices,
149 vk::VkBufferCreateFlags _flags)
151 sType = vk::VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
156 sharingMode = _sharingMode;
157 queueFamilyIndexCount = _queueFamilyIndexCount;
159 if (_queueFamilyIndexCount)
161 m_queueFamilyIndices = std::vector<deUint32>(
162 _pQueueFamilyIndices, _pQueueFamilyIndices + _queueFamilyIndexCount);
163 pQueueFamilyIndices = &m_queueFamilyIndices[0];
167 pQueueFamilyIndices = _pQueueFamilyIndices;
171 BufferCreateInfo::BufferCreateInfo (const BufferCreateInfo &other)
178 sharingMode = other.sharingMode;
179 queueFamilyIndexCount = other.queueFamilyIndexCount;
181 m_queueFamilyIndices = other.m_queueFamilyIndices;
182 DE_ASSERT(m_queueFamilyIndices.size() == queueFamilyIndexCount);
184 if (m_queueFamilyIndices.size())
186 pQueueFamilyIndices = &m_queueFamilyIndices[0];
190 pQueueFamilyIndices = DE_NULL;
194 BufferCreateInfo & BufferCreateInfo::operator= (const BufferCreateInfo &other)
201 sharingMode = other.sharingMode;
202 queueFamilyIndexCount = other.queueFamilyIndexCount;
204 m_queueFamilyIndices = other.m_queueFamilyIndices;
206 DE_ASSERT(m_queueFamilyIndices.size() == queueFamilyIndexCount);
208 if (m_queueFamilyIndices.size())
210 pQueueFamilyIndices = &m_queueFamilyIndices[0];
214 pQueueFamilyIndices = DE_NULL;
220 ImageCreateInfo::ImageCreateInfo (vk::VkImageType _imageType,
221 vk::VkFormat _format,
222 vk::VkExtent3D _extent,
224 deUint32 _arrayLayers,
225 vk::VkSampleCountFlagBits _samples,
226 vk::VkImageTiling _tiling,
227 vk::VkImageUsageFlags _usage,
228 vk::VkSharingMode _sharingMode,
229 deUint32 _queueFamilyIndexCount,
230 const deUint32* _pQueueFamilyIndices,
231 vk::VkImageCreateFlags _flags,
232 vk::VkImageLayout _initialLayout)
234 if (_queueFamilyIndexCount)
236 m_queueFamilyIndices = std::vector<deUint32>(_pQueueFamilyIndices, _pQueueFamilyIndices + _queueFamilyIndexCount);
239 sType = vk::VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
242 imageType = _imageType;
245 mipLevels = _mipLevels;
246 arrayLayers = _arrayLayers;
250 sharingMode = _sharingMode;
251 queueFamilyIndexCount = _queueFamilyIndexCount;
253 if (m_queueFamilyIndices.size())
255 pQueueFamilyIndices = &m_queueFamilyIndices[0];
259 pQueueFamilyIndices = DE_NULL;
261 initialLayout = _initialLayout;
264 FramebufferCreateInfo::FramebufferCreateInfo (vk::VkRenderPass _renderPass,
265 const std::vector<vk::VkImageView>& atachments,
270 sType = vk::VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
274 renderPass = _renderPass;
275 attachmentCount = static_cast<deUint32>(atachments.size());
279 pAttachments = const_cast<vk::VkImageView *>(&atachments[0]);
287 RenderPassCreateInfo::RenderPassCreateInfo (const std::vector<vk::VkAttachmentDescription>& attachments,
288 const std::vector<vk::VkSubpassDescription>& subpasses,
289 const std::vector<vk::VkSubpassDependency>& dependiences)
291 : m_attachments (attachments.begin(), attachments.end())
292 , m_subpasses (subpasses.begin(), subpasses.end())
293 , m_dependiences (dependiences.begin(), dependiences.end())
294 , m_attachmentsStructs (m_attachments.begin(), m_attachments.end())
295 , m_subpassesStructs (m_subpasses.begin(), m_subpasses.end())
296 , m_dependiencesStructs (m_dependiences.begin(), m_dependiences.end())
298 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
302 attachmentCount = static_cast<deUint32>(m_attachments.size());
303 pAttachments = &m_attachmentsStructs[0];
304 subpassCount = static_cast<deUint32>(m_subpasses.size());
305 pSubpasses = &m_subpassesStructs[0];
306 dependencyCount = static_cast<deUint32>(m_dependiences.size());
307 pDependencies = &m_dependiencesStructs[0];
310 RenderPassCreateInfo::RenderPassCreateInfo (deUint32 _attachmentCount,
311 const vk::VkAttachmentDescription* _pAttachments,
312 deUint32 _subpassCount,
313 const vk::VkSubpassDescription* _pSubpasses,
314 deUint32 _dependencyCount,
315 const vk::VkSubpassDependency* _pDependiences)
318 m_attachments = std::vector<AttachmentDescription>(_pAttachments, _pAttachments + _attachmentCount);
319 m_subpasses = std::vector<SubpassDescription>(_pSubpasses, _pSubpasses + _subpassCount);
320 m_dependiences = std::vector<SubpassDependency>(_pDependiences, _pDependiences + _dependencyCount);
322 m_attachmentsStructs = std::vector<vk::VkAttachmentDescription> (m_attachments.begin(), m_attachments.end());
323 m_subpassesStructs = std::vector<vk::VkSubpassDescription> (m_subpasses.begin(), m_subpasses.end());
324 m_dependiencesStructs = std::vector<vk::VkSubpassDependency> (m_dependiences.begin(), m_dependiences.end());
326 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
330 attachmentCount = static_cast<deUint32>(m_attachments.size());
334 pAttachments = &m_attachmentsStructs[0];
338 pAttachments = DE_NULL;
341 subpassCount = static_cast<deUint32>(m_subpasses.size());
345 pSubpasses = &m_subpassesStructs[0];
349 pSubpasses = DE_NULL;
352 dependencyCount = static_cast<deUint32>(m_dependiences.size());
356 pDependencies = &m_dependiencesStructs[0];
360 pDependencies = DE_NULL;
365 RenderPassCreateInfo::addAttachment (vk::VkAttachmentDescription attachment)
368 m_attachments.push_back(attachment);
369 m_attachmentsStructs = std::vector<vk::VkAttachmentDescription>(m_attachments.begin(), m_attachments.end());
370 attachmentCount = static_cast<deUint32>(m_attachments.size());
371 pAttachments = &m_attachmentsStructs[0];
375 RenderPassCreateInfo::addSubpass (vk::VkSubpassDescription subpass)
378 m_subpasses.push_back(subpass);
379 m_subpassesStructs = std::vector<vk::VkSubpassDescription>(m_subpasses.begin(), m_subpasses.end());
380 subpassCount = static_cast<deUint32>(m_subpasses.size());
381 pSubpasses = &m_subpassesStructs[0];
385 RenderPassCreateInfo::addDependency (vk::VkSubpassDependency dependency)
388 m_dependiences.push_back(dependency);
389 m_dependiencesStructs = std::vector<vk::VkSubpassDependency>(m_dependiences.begin(), m_dependiences.end());
391 dependencyCount = static_cast<deUint32>(m_dependiences.size());
392 pDependencies = &m_dependiencesStructs[0];
395 RenderPassBeginInfo::RenderPassBeginInfo (vk::VkRenderPass _renderPass,
396 vk::VkFramebuffer _framebuffer,
397 vk::VkRect2D _renderArea,
398 const std::vector<vk::VkClearValue>& _clearValues)
401 m_clearValues = _clearValues;
403 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
405 renderPass = _renderPass;
406 framebuffer = _framebuffer;
407 renderArea = _renderArea;
408 clearValueCount = static_cast<deUint32>(m_clearValues.size());
409 pClearValues = m_clearValues.size() ? &m_clearValues[0] : DE_NULL;
412 CmdPoolCreateInfo::CmdPoolCreateInfo (deUint32 _queueFamilyIndex, unsigned int _flags)
414 sType = vk::VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
417 queueFamilyIndex = _queueFamilyIndex;
421 AttachmentDescription::AttachmentDescription (vk::VkFormat _format,
422 vk::VkSampleCountFlagBits _samples,
423 vk::VkAttachmentLoadOp _loadOp,
424 vk::VkAttachmentStoreOp _storeOp,
425 vk::VkAttachmentLoadOp _stencilLoadOp,
426 vk::VkAttachmentStoreOp _stencilStoreOp,
427 vk::VkImageLayout _initialLayout,
428 vk::VkImageLayout _finalLayout)
435 stencilLoadOp = _stencilLoadOp;
436 stencilStoreOp = _stencilStoreOp;
437 initialLayout = _initialLayout;
438 finalLayout = _finalLayout;
441 AttachmentDescription::AttachmentDescription (const vk::VkAttachmentDescription& rhs)
445 samples = rhs.samples;
447 storeOp = rhs.storeOp;
448 stencilLoadOp = rhs.stencilLoadOp;
449 stencilStoreOp = rhs.stencilStoreOp;
450 initialLayout = rhs.initialLayout;
451 finalLayout = rhs.finalLayout;
454 AttachmentReference::AttachmentReference (deUint32 _attachment, vk::VkImageLayout _layout)
456 attachment = _attachment;
460 AttachmentReference::AttachmentReference (void)
462 attachment = vk::VK_ATTACHMENT_UNUSED;
463 layout = vk::VK_IMAGE_LAYOUT_UNDEFINED;
466 SubpassDescription::SubpassDescription (vk::VkPipelineBindPoint _pipelineBindPoint,
467 vk::VkSubpassDescriptionFlags _flags,
468 deUint32 _inputAttachmentCount,
469 const vk::VkAttachmentReference* _inputAttachments,
470 deUint32 _colorAttachmentCount,
471 const vk::VkAttachmentReference* _colorAttachments,
472 const vk::VkAttachmentReference* _resolveAttachments,
473 vk::VkAttachmentReference depthStencilAttachment,
474 deUint32 _preserveAttachmentCount,
475 const vk::VkAttachmentReference* _preserveAttachments)
477 m_inputAttachments = std::vector<vk::VkAttachmentReference>(_inputAttachments, _inputAttachments + _inputAttachmentCount);
478 m_colorAttachments = std::vector<vk::VkAttachmentReference>(_colorAttachments, _colorAttachments + _colorAttachmentCount);
480 if (_resolveAttachments)
482 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(_resolveAttachments, _resolveAttachments + _colorAttachmentCount);
485 m_preserveAttachments = std::vector<vk::VkAttachmentReference>(_preserveAttachments, _preserveAttachments + _preserveAttachmentCount);
487 m_depthStencilAttachment = depthStencilAttachment;
490 pipelineBindPoint = _pipelineBindPoint;
491 inputAttachmentCount = _inputAttachmentCount;
492 pInputAttachments = DE_NULL;
493 colorAttachmentCount = _colorAttachmentCount;
494 pColorAttachments = DE_NULL;
495 pResolveAttachments = DE_NULL;
496 pDepthStencilAttachment = &m_depthStencilAttachment;
497 pPreserveAttachments = DE_NULL;
498 preserveAttachmentCount = _preserveAttachmentCount;
500 if (m_inputAttachments.size())
502 pInputAttachments = &m_inputAttachments[0];
505 if (m_colorAttachments.size())
507 pColorAttachments = &m_colorAttachments[0];
510 if (m_resolveAttachments.size())
512 pResolveAttachments = &m_resolveAttachments[0];
515 if (m_preserveAttachments.size())
517 pPreserveAttachments = &m_preserveAttachments[0];
521 SubpassDescription::SubpassDescription (const vk::VkSubpassDescription& rhs)
523 *static_cast<vk::VkSubpassDescription*>(this) = rhs;
525 m_inputAttachments = std::vector<vk::VkAttachmentReference>(
526 rhs.pInputAttachments, rhs.pInputAttachments + rhs.inputAttachmentCount);
528 m_colorAttachments = std::vector<vk::VkAttachmentReference>(
529 rhs.pColorAttachments, rhs.pColorAttachments + rhs.colorAttachmentCount);
531 if (rhs.pResolveAttachments)
533 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(
534 rhs.pResolveAttachments, rhs.pResolveAttachments + rhs.colorAttachmentCount);
536 m_preserveAttachments = std::vector<vk::VkAttachmentReference>(
537 rhs.pPreserveAttachments, rhs.pPreserveAttachments + rhs.preserveAttachmentCount);
539 if (rhs.pDepthStencilAttachment)
541 m_depthStencilAttachment = *rhs.pDepthStencilAttachment;
544 if (m_inputAttachments.size())
546 pInputAttachments = &m_inputAttachments[0];
548 if (m_colorAttachments.size())
550 pColorAttachments = &m_colorAttachments[0];
553 if (m_resolveAttachments.size())
555 pResolveAttachments = &m_resolveAttachments[0];
558 pDepthStencilAttachment = &m_depthStencilAttachment;
560 if (m_preserveAttachments.size())
562 pPreserveAttachments = &m_preserveAttachments[0];
566 SubpassDescription::SubpassDescription (const SubpassDescription& rhs)
571 SubpassDescription& SubpassDescription::operator= (const SubpassDescription& rhs)
573 *static_cast<vk::VkSubpassDescription*>(this) = rhs;
575 m_inputAttachments = rhs.m_inputAttachments;
576 m_colorAttachments = rhs.m_colorAttachments;
577 m_resolveAttachments = rhs.m_resolveAttachments;
578 m_preserveAttachments = rhs.m_preserveAttachments;
579 m_depthStencilAttachment = rhs.m_depthStencilAttachment;
581 if (m_inputAttachments.size())
583 pInputAttachments = &m_inputAttachments[0];
585 if (m_colorAttachments.size())
587 pColorAttachments = &m_colorAttachments[0];
590 if (m_resolveAttachments.size())
592 pResolveAttachments = &m_resolveAttachments[0];
595 pDepthStencilAttachment = &m_depthStencilAttachment;
597 if (m_preserveAttachments.size())
599 pPreserveAttachments = &m_preserveAttachments[0];
605 SubpassDependency::SubpassDependency (deUint32 _srcSubpass,
606 deUint32 _dstSubpass,
607 vk::VkPipelineStageFlags _srcStageMask,
608 vk::VkPipelineStageFlags _dstStageMask,
609 vk::VkAccessFlags _srcAccessMask,
610 vk::VkAccessFlags _dstAccessMask,
611 vk::VkDependencyFlags _dependencyFlags)
613 srcSubpass = _srcSubpass;
614 dstSubpass = _dstSubpass;
615 srcStageMask = _srcStageMask;
616 dstStageMask = _dstStageMask;
617 srcAccessMask = _srcAccessMask;
618 dstAccessMask = _dstAccessMask;
619 dependencyFlags = _dependencyFlags;
622 SubpassDependency::SubpassDependency (const vk::VkSubpassDependency& rhs)
624 srcSubpass = rhs.srcSubpass;
625 dstSubpass = rhs.dstSubpass;
626 srcStageMask = rhs.srcStageMask;
627 dstStageMask = rhs.dstStageMask;
628 srcAccessMask = rhs.srcAccessMask;
629 dstAccessMask = rhs.dstAccessMask;
630 dependencyFlags = rhs.dependencyFlags;
633 CmdBufferBeginInfo::CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags _flags)
635 sType = vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
637 renderPass = DE_NULL;
639 framebuffer = DE_NULL;
641 occlusionQueryEnable = false;
643 pipelineStatistics = 0u;
646 CmdBufferBeginInfo::CmdBufferBeginInfo (vk::VkRenderPass _renderPass,
648 vk::VkFramebuffer _framebuffer,
649 vk::VkCommandBufferUsageFlags _flags,
650 bool _occlusionQueryEnable,
\r
651 vk::VkQueryControlFlags _queryFlags,
\r
652 vk::VkQueryPipelineStatisticFlags _pipelineStatistics)
655 sType = vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
657 renderPass = _renderPass;
659 framebuffer = _framebuffer;
661 occlusionQueryEnable = _occlusionQueryEnable;
662 queryFlags = _queryFlags;
663 pipelineStatistics = _pipelineStatistics;
666 DescriptorPoolCreateInfo::DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>& poolSizeCounts,
667 vk::VkDescriptorPoolCreateFlags _flags,
669 : m_poolSizeCounts(poolSizeCounts)
671 sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
675 poolSizeCount = static_cast<deUint32>(m_poolSizeCounts.size());
676 pPoolSizes = &m_poolSizeCounts[0];
679 DescriptorPoolCreateInfo& DescriptorPoolCreateInfo::addDescriptors (vk::VkDescriptorType type, deUint32 count)
681 vk::VkDescriptorPoolSize descriptorTypeCount = { type, count };
682 m_poolSizeCounts.push_back(descriptorTypeCount);
684 poolSizeCount = static_cast<deUint32>(m_poolSizeCounts.size());
685 pPoolSizes = &m_poolSizeCounts[0];
690 DescriptorSetLayoutCreateInfo::DescriptorSetLayoutCreateInfo (deUint32 _bindingCount, const vk::VkDescriptorSetLayoutBinding* _pBindings)
692 sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
695 bindingCount = _bindingCount;
696 pBinding = _pBindings;
699 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (deUint32 _descriptorSetCount,
700 const vk::VkDescriptorSetLayout* _pSetLayouts,
701 deUint32 _pushConstantRangeCount,
702 const vk::VkPushConstantRange* _pPushConstantRanges)
703 : m_pushConstantRanges(_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
705 for (unsigned int i = 0; i < _descriptorSetCount; i++)
707 m_setLayouts.push_back(_pSetLayouts[i]);
710 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
712 setLayoutCount = static_cast<deUint32>(m_setLayouts.size());
713 pSetLayouts = setLayoutCount > 0 ? &m_setLayouts[0] : DE_NULL;
714 pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
716 if (m_pushConstantRanges.size())
718 pPushConstantRanges = &m_pushConstantRanges[0];
722 pPushConstantRanges = DE_NULL;
726 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (const std::vector<vk::VkDescriptorSetLayout>& setLayouts,
727 deUint32 _pushConstantRangeCount,
728 const vk::VkPushConstantRange* _pPushConstantRanges)
729 : m_setLayouts (setLayouts)
730 , m_pushConstantRanges (_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
732 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
735 setLayoutCount = static_cast<deUint32>(m_setLayouts.size());
739 pSetLayouts = &m_setLayouts[0];
743 pSetLayouts = DE_NULL;
746 pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
747 if (pushConstantRangeCount)
749 pPushConstantRanges = &m_pushConstantRanges[0];
753 pPushConstantRanges = DE_NULL;
757 PipelineCreateInfo::PipelineShaderStage::PipelineShaderStage (vk::VkShaderModule _module, const char* _pName, vk::VkShaderStageFlagBits _stage)
759 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
765 pSpecializationInfo = DE_NULL;
768 PipelineCreateInfo::VertexInputState::VertexInputState (deUint32 _vertexBindingDescriptionCount,
769 const vk::VkVertexInputBindingDescription* _pVertexBindingDescriptions,
770 deUint32 _vertexAttributeDescriptionCount,
771 const vk::VkVertexInputAttributeDescription* _pVertexAttributeDescriptions)
773 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
776 vertexBindingDescriptionCount = _vertexBindingDescriptionCount;
777 pVertexBindingDescriptions = _pVertexBindingDescriptions;
778 vertexAttributeDescriptionCount = _vertexAttributeDescriptionCount;
779 pVertexAttributeDescriptions = _pVertexAttributeDescriptions;
782 PipelineCreateInfo::InputAssemblerState::InputAssemblerState (vk::VkPrimitiveTopology _topology,
783 vk::VkBool32 _primitiveRestartEnable)
785 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
788 topology = _topology;
789 primitiveRestartEnable = _primitiveRestartEnable;
792 PipelineCreateInfo::TesselationState::TesselationState (deUint32 _patchControlPoints)
794 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
796 patchControlPoints = _patchControlPoints;
799 PipelineCreateInfo::ViewportState::ViewportState (deUint32 _viewportCount,
800 std::vector<vk::VkViewport> _viewports,
801 std::vector<vk::VkRect2D> _scissors)
803 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
806 viewportCount = _viewportCount;
807 scissorCount = _viewportCount;
809 if (!_viewports.size())
811 m_viewports.resize(viewportCount);
812 deMemset(&m_viewports[0], 0, sizeof(m_viewports[0]) * m_viewports.size());
816 m_viewports = _viewports;
819 if (!_scissors.size())
821 m_scissors.resize(scissorCount);
822 deMemset(&m_scissors[0], 0, sizeof(m_scissors[0]) * m_scissors.size());
826 m_scissors = _scissors;
829 pViewports = &m_viewports[0];
830 pScissors = &m_scissors[0];
833 PipelineCreateInfo::ViewportState::ViewportState (const ViewportState& other)
837 viewportCount = other.viewportCount;
838 scissorCount = other.scissorCount;
840 m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + viewportCount);
841 m_scissors = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
843 pViewports = &m_viewports[0];
844 pScissors = &m_scissors[0];
847 PipelineCreateInfo::ViewportState& PipelineCreateInfo::ViewportState::operator= (const ViewportState& other)
851 viewportCount = other.viewportCount;
852 scissorCount = other.scissorCount;
854 m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + scissorCount);
855 m_scissors = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
857 pViewports = &m_viewports[0];
858 pScissors = &m_scissors[0];
862 PipelineCreateInfo::RasterizerState::RasterizerState (vk::VkBool32 _depthClampEnable,
863 vk::VkBool32 _rasterizerDiscardEnable,
864 vk::VkPolygonMode _polygonMode,
865 vk::VkCullModeFlags _cullMode,
866 vk::VkFrontFace _frontFace,
867 vk::VkBool32 _depthBiasEnable,
868 float _depthBiasConstantFactor,
869 float _depthBiasClamp,
870 float _depthBiasSlopeFactor,
873 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
876 depthClampEnable = _depthClampEnable;
877 rasterizerDiscardEnable = _rasterizerDiscardEnable;
878 polygonMode = _polygonMode;
879 cullMode = _cullMode;
880 frontFace = _frontFace;
882 depthBiasEnable = _depthBiasEnable;
883 depthBiasConstantFactor = _depthBiasConstantFactor;
884 depthBiasClamp = _depthBiasClamp;
885 depthBiasSlopeFactor = _depthBiasSlopeFactor;
886 lineWidth = _lineWidth;
889 PipelineCreateInfo::MultiSampleState::MultiSampleState (vk::VkSampleCountFlagBits _rasterizationSamples,
890 vk::VkBool32 _sampleShadingEnable,
891 float _minSampleShading,
892 const std::vector<vk::VkSampleMask>& _sampleMask,
893 bool _alphaToCoverageEnable,
894 bool _alphaToOneEnable)
895 : m_sampleMask(_sampleMask)
897 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
900 rasterizationSamples = _rasterizationSamples;
901 sampleShadingEnable = _sampleShadingEnable;
902 minSampleShading = _minSampleShading;
903 pSampleMask = &m_sampleMask[0];
904 alphaToCoverageEnable = _alphaToCoverageEnable;
905 alphaToOneEnable = _alphaToOneEnable;
908 PipelineCreateInfo::MultiSampleState::MultiSampleState (const MultiSampleState& other)
912 rasterizationSamples = other.rasterizationSamples;
913 sampleShadingEnable = other.sampleShadingEnable;
914 minSampleShading = other.minSampleShading;
916 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
918 m_sampleMask = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
919 pSampleMask = &m_sampleMask[0];
922 PipelineCreateInfo::MultiSampleState& PipelineCreateInfo::MultiSampleState::operator= (const MultiSampleState& other)
926 rasterizationSamples = other.rasterizationSamples;
927 sampleShadingEnable = other.sampleShadingEnable;
928 minSampleShading = other.minSampleShading;
930 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
932 m_sampleMask = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
933 pSampleMask = &m_sampleMask[0];
938 PipelineCreateInfo::ColorBlendState::ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>& _attachments,
939 vk::VkBool32 _logicOpEnable,
940 vk::VkLogicOp _logicOp)
941 : m_attachments(_attachments)
943 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
946 logicOpEnable = _logicOpEnable;
948 attachmentCount = static_cast<deUint32>(m_attachments.size());
949 pAttachments = &m_attachments[0];
952 PipelineCreateInfo::ColorBlendState::ColorBlendState (deUint32 _attachmentCount,
953 const vk::VkPipelineColorBlendAttachmentState* _attachments,
954 vk::VkBool32 _logicOpEnable,
955 vk::VkLogicOp _logicOp)
956 : m_attachments(_attachments, _attachments + _attachmentCount)
958 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
960 logicOpEnable = _logicOpEnable;
962 attachmentCount = static_cast<deUint32>(m_attachments.size());
963 pAttachments = &m_attachments[0];
966 PipelineCreateInfo::ColorBlendState::ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo& createInfo)
967 : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
969 sType = createInfo.sType;
970 pNext = createInfo.pNext;
971 logicOpEnable = createInfo.logicOpEnable;
972 logicOp = createInfo.logicOp;
973 attachmentCount = static_cast<deUint32>(m_attachments.size());
974 pAttachments = &m_attachments[0];
977 PipelineCreateInfo::ColorBlendState::ColorBlendState (const ColorBlendState& createInfo, std::vector<float> _blendConstants)
978 : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
980 sType = createInfo.sType;
981 pNext = createInfo.pNext;
982 logicOpEnable = createInfo.logicOpEnable;
983 logicOp = createInfo.logicOp;
984 attachmentCount = static_cast<deUint32>(m_attachments.size());
985 pAttachments = &m_attachments[0];
986 deMemcpy(blendConstants, &_blendConstants[0], 4 * sizeof(float));
989 PipelineCreateInfo::ColorBlendState::Attachment::Attachment (vk::VkBool32 _blendEnable,
990 vk::VkBlendFactor _srcColorBlendFactor,
991 vk::VkBlendFactor _dstColorBlendFactor,
992 vk::VkBlendOp _colorBlendOp,
993 vk::VkBlendFactor _srcAlphaBlendFactor,
994 vk::VkBlendFactor _dstAlphaBlendFactor,
995 vk::VkBlendOp _alphaBlendOp,
996 deUint8 _colorWriteMask)
998 blendEnable = _blendEnable;
999 srcColorBlendFactor = _srcColorBlendFactor;
1000 dstColorBlendFactor = _dstColorBlendFactor;
1001 colorBlendOp = _colorBlendOp;
1002 srcAlphaBlendFactor = _srcAlphaBlendFactor;
1003 dstAlphaBlendFactor = _dstAlphaBlendFactor;
1004 alphaBlendOp = _alphaBlendOp;
1005 colorWriteMask = _colorWriteMask;
1008 PipelineCreateInfo::DepthStencilState::StencilOpState::StencilOpState (vk::VkStencilOp _failOp,
1009 vk::VkStencilOp _passOp,
1010 vk::VkStencilOp _depthFailOp,
1011 vk::VkCompareOp _compareOp,
1012 deUint32 _compareMask,
1013 deUint32 _writeMask,
1014 deUint32 _reference)
1018 depthFailOp = _depthFailOp;
1019 compareOp = _compareOp;
1021 compareMask = _compareMask;
1022 writeMask = _writeMask;
1023 reference = _reference;
1026 PipelineCreateInfo::DepthStencilState::DepthStencilState (vk::VkBool32 _depthTestEnable,
1027 vk::VkBool32 _depthWriteEnable,
1028 vk::VkCompareOp _depthCompareOp,
1029 vk::VkBool32 _depthBoundsTestEnable,
1030 vk::VkBool32 _stencilTestEnable,
1031 StencilOpState _front,
1032 StencilOpState _back,
1033 float _minDepthBounds,
1034 float _maxDepthBounds)
1036 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
1039 depthTestEnable = _depthTestEnable;
1040 depthWriteEnable = _depthWriteEnable;
1041 depthCompareOp = _depthCompareOp;
1042 depthBoundsTestEnable = _depthBoundsTestEnable;
1043 stencilTestEnable = _stencilTestEnable;
1047 minDepthBounds = _minDepthBounds;
1048 maxDepthBounds = _maxDepthBounds;
1051 PipelineCreateInfo::DynamicState::DynamicState (const std::vector<vk::VkDynamicState>& _dynamicStates)
1053 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
1056 if (!_dynamicStates.size())
1058 for (size_t i = 0; i < vk::VK_DYNAMIC_STATE_LAST; ++i)
1060 m_dynamicStates.push_back(static_cast<vk::VkDynamicState>(i));
1064 m_dynamicStates = _dynamicStates;
1066 dynamicStateCount = static_cast<deUint32>(m_dynamicStates.size());
1067 pDynamicStates = &m_dynamicStates[0];
1070 PipelineCreateInfo::DynamicState::DynamicState (const DynamicState &other)
1072 sType = other.sType;
1073 pNext = other.pNext;
1075 dynamicStateCount = other.dynamicStateCount;
1077 m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1078 pDynamicStates = &m_dynamicStates[0];
1081 PipelineCreateInfo::DynamicState& PipelineCreateInfo::DynamicState::operator= (const DynamicState& other)
1083 sType = other.sType;
1084 pNext = other.pNext;
1086 dynamicStateCount = other.dynamicStateCount;
1088 m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1089 pDynamicStates = &m_dynamicStates[0];
1094 PipelineCreateInfo::PipelineCreateInfo (vk::VkPipelineLayout _layout,
1095 vk::VkRenderPass _renderPass,
1097 vk::VkPipelineCreateFlags _flags)
1099 deMemset(static_cast<vk::VkGraphicsPipelineCreateInfo *>(this), 0,
1100 sizeof(vk::VkGraphicsPipelineCreateInfo));
1102 sType = vk::VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
1105 renderPass = _renderPass;
1108 basePipelineHandle = DE_NULL;
1109 basePipelineIndex = 0;
1110 pDynamicState = DE_NULL;
1113 PipelineCreateInfo& PipelineCreateInfo::addShader (const vk::VkPipelineShaderStageCreateInfo& shader)
1115 m_shaders.push_back(shader);
1117 stageCount = static_cast<deUint32>(m_shaders.size());
1118 pStages = &m_shaders[0];
1123 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineVertexInputStateCreateInfo& state)
1125 m_vertexInputState = state;
1126 pVertexInputState = &m_vertexInputState;
1131 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state)
1133 m_inputAssemblyState = state;
1134 pInputAssemblyState = &m_inputAssemblyState;
1139 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineColorBlendStateCreateInfo& state)
1141 m_colorBlendStateAttachments = std::vector<vk::VkPipelineColorBlendAttachmentState>(state.pAttachments, state.pAttachments + state.attachmentCount);
1142 m_colorBlendState = state;
1143 m_colorBlendState.pAttachments = &m_colorBlendStateAttachments[0];
1144 pColorBlendState = &m_colorBlendState;
1149 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineViewportStateCreateInfo& state)
1151 m_viewports = std::vector<vk::VkViewport>(state.pViewports, state.pViewports + state.viewportCount);
1152 m_scissors = std::vector<vk::VkRect2D>(state.pScissors, state.pScissors + state.scissorCount);
1153 m_viewportState = state;
1154 m_viewportState.pViewports = &m_viewports[0];
1155 m_viewportState.pScissors = &m_scissors[0];
1156 pViewportState = &m_viewportState;
1161 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDepthStencilStateCreateInfo& state)
1163 m_dynamicDepthStencilState = state;
1164 pDepthStencilState = &m_dynamicDepthStencilState;
1168 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineTessellationStateCreateInfo& state)
1170 m_tessState = state;
1171 pTessellationState = &m_tessState;
1176 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineRasterizationStateCreateInfo& state)
1178 m_rasterState = state;
1179 pRasterizationState = &m_rasterState;
1184 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineMultisampleStateCreateInfo& state)
1187 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + state.rasterizationSamples) / ( sizeof(vk::VkSampleMask) * 8 );
1188 m_multisampleStateSampleMask = std::vector<vk::VkSampleMask>(state.pSampleMask, state.pSampleMask + sampleMaskArrayLen);
1189 m_multisampleState = state;
1190 m_multisampleState.pSampleMask = &m_multisampleStateSampleMask[0];
1191 pMultisampleState = &m_multisampleState;
1195 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDynamicStateCreateInfo& state)
1197 m_dynamicStates = std::vector<vk::VkDynamicState>(state.pDynamicStates, state.pDynamicStates + state.dynamicStateCount);
1198 m_dynamicState = state;
1199 m_dynamicState.pDynamicStates = &m_dynamicStates[0];
1200 pDynamicState = &m_dynamicState;
1205 SamplerCreateInfo::SamplerCreateInfo (vk::VkFilter _magFilter,
1206 vk::VkFilter _minFilter,
1207 vk::VkSamplerMipmapMode _mipmapMode,
1208 vk::VkSamplerAddressMode _addressModeU,
1209 vk::VkSamplerAddressMode _addressModeV,
1210 vk::VkSamplerAddressMode _addressModeW,
1212 float _maxAnisotropy,
1213 vk::VkBool32 _compareEnable,
1214 vk::VkCompareOp _compareOp,
1217 vk::VkBorderColor _borderColor,
1218 vk::VkBool32 _unnormalizedCoordinates)
1220 sType = vk::VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
1223 magFilter = _magFilter;
1224 minFilter = _minFilter;
1225 mipmapMode = _mipmapMode;
1226 addressModeU = _addressModeU;
1227 addressModeV = _addressModeV;
1228 addressModeW = _addressModeW;
1229 mipLodBias = _mipLodBias;
1230 maxAnisotropy = _maxAnisotropy;
1231 compareEnable = _compareEnable;
1232 compareOp = _compareOp;
1235 borderColor = _borderColor;
1236 unnormalizedCoordinates = _unnormalizedCoordinates;