1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 The Khronos Group Inc.
6 * Copyright (c) 2015 Intel Corporation
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 * \brief CreateInfo utilities
23 *//*--------------------------------------------------------------------*/
25 #include "vktDrawCreateInfoUtil.hpp"
27 #include "vkImageUtil.hpp"
34 ImageSubresourceRange::ImageSubresourceRange (vk::VkImageAspectFlags _aspectMask,
35 deUint32 _baseMipLevel,
37 deUint32 _baseArrayLayer,
40 aspectMask = _aspectMask;
41 baseMipLevel = _baseMipLevel;
42 levelCount = _levelCount;
43 baseArrayLayer = _baseArrayLayer;
44 layerCount = _layerCount;
47 ComponentMapping::ComponentMapping (vk::VkComponentSwizzle _r,
48 vk::VkComponentSwizzle _g,
49 vk::VkComponentSwizzle _b,
50 vk::VkComponentSwizzle _a)
58 ImageViewCreateInfo::ImageViewCreateInfo (vk::VkImage _image,
59 vk::VkImageViewType _viewType,
61 const vk::VkImageSubresourceRange& _subresourceRange,
62 const vk::VkComponentMapping& _components,
63 vk::VkImageViewCreateFlags _flags)
65 sType = vk::VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
71 components.r = _components.r;
72 components.g = _components.g;
73 components.b = _components.b;
74 components.a = _components.a;
75 subresourceRange = _subresourceRange;
79 ImageViewCreateInfo::ImageViewCreateInfo (vk::VkImage _image,
80 vk::VkImageViewType _viewType,
82 const vk::VkComponentMapping& _components,
83 vk::VkImageViewCreateFlags _flags)
85 sType = vk::VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
91 components.r = _components.r;
92 components.g = _components.g;
93 components.b = _components.b;
94 components.a = _components.a;
96 vk::VkImageAspectFlags aspectFlags;
97 const tcu::TextureFormat tcuFormat = vk::mapVkFormat(_format);
99 switch (tcuFormat.order)
101 case tcu::TextureFormat::D:
102 aspectFlags = vk::VK_IMAGE_ASPECT_DEPTH_BIT;
104 case tcu::TextureFormat::S:
105 aspectFlags = vk::VK_IMAGE_ASPECT_STENCIL_BIT;
107 case tcu::TextureFormat::DS:
108 aspectFlags = vk::VK_IMAGE_ASPECT_STENCIL_BIT | vk::VK_IMAGE_ASPECT_DEPTH_BIT;
111 aspectFlags = vk::VK_IMAGE_ASPECT_COLOR_BIT;
115 subresourceRange = ImageSubresourceRange(aspectFlags);;
119 BufferViewCreateInfo::BufferViewCreateInfo (vk::VkBuffer _buffer,
120 vk::VkFormat _format,
121 vk::VkDeviceSize _offset,
122 vk::VkDeviceSize _range)
124 sType = vk::VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO;
134 BufferCreateInfo::BufferCreateInfo (vk::VkDeviceSize _size,
135 vk::VkBufferUsageFlags _usage,
136 vk::VkSharingMode _sharingMode,
137 deUint32 _queueFamilyIndexCount,
138 const deUint32* _pQueueFamilyIndices,
139 vk::VkBufferCreateFlags _flags)
141 sType = vk::VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
146 sharingMode = _sharingMode;
147 queueFamilyIndexCount = _queueFamilyIndexCount;
149 if (_queueFamilyIndexCount)
151 m_queueFamilyIndices = std::vector<deUint32>(
152 _pQueueFamilyIndices, _pQueueFamilyIndices + _queueFamilyIndexCount);
153 pQueueFamilyIndices = &m_queueFamilyIndices[0];
157 pQueueFamilyIndices = _pQueueFamilyIndices;
161 BufferCreateInfo::BufferCreateInfo (const BufferCreateInfo &other)
168 sharingMode = other.sharingMode;
169 queueFamilyIndexCount = other.queueFamilyIndexCount;
171 m_queueFamilyIndices = other.m_queueFamilyIndices;
172 DE_ASSERT(m_queueFamilyIndices.size() == queueFamilyIndexCount);
174 if (m_queueFamilyIndices.size())
176 pQueueFamilyIndices = &m_queueFamilyIndices[0];
180 pQueueFamilyIndices = DE_NULL;
184 BufferCreateInfo & BufferCreateInfo::operator= (const BufferCreateInfo &other)
191 sharingMode = other.sharingMode;
192 queueFamilyIndexCount = other.queueFamilyIndexCount;
194 m_queueFamilyIndices = other.m_queueFamilyIndices;
196 DE_ASSERT(m_queueFamilyIndices.size() == queueFamilyIndexCount);
198 if (m_queueFamilyIndices.size())
200 pQueueFamilyIndices = &m_queueFamilyIndices[0];
204 pQueueFamilyIndices = DE_NULL;
210 ImageCreateInfo::ImageCreateInfo (vk::VkImageType _imageType,
211 vk::VkFormat _format,
212 vk::VkExtent3D _extent,
214 deUint32 _arrayLayers,
215 vk::VkSampleCountFlagBits _samples,
216 vk::VkImageTiling _tiling,
217 vk::VkImageUsageFlags _usage,
218 vk::VkSharingMode _sharingMode,
219 deUint32 _queueFamilyIndexCount,
220 const deUint32* _pQueueFamilyIndices,
221 vk::VkImageCreateFlags _flags,
222 vk::VkImageLayout _initialLayout)
224 if (_queueFamilyIndexCount)
226 m_queueFamilyIndices = std::vector<deUint32>(_pQueueFamilyIndices, _pQueueFamilyIndices + _queueFamilyIndexCount);
229 sType = vk::VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
232 imageType = _imageType;
235 mipLevels = _mipLevels;
236 arrayLayers = _arrayLayers;
240 sharingMode = _sharingMode;
241 queueFamilyIndexCount = _queueFamilyIndexCount;
243 if (m_queueFamilyIndices.size())
245 pQueueFamilyIndices = &m_queueFamilyIndices[0];
249 pQueueFamilyIndices = DE_NULL;
251 initialLayout = _initialLayout;
254 FramebufferCreateInfo::FramebufferCreateInfo (vk::VkRenderPass _renderPass,
255 const std::vector<vk::VkImageView>& atachments,
260 sType = vk::VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
264 renderPass = _renderPass;
265 attachmentCount = static_cast<deUint32>(atachments.size());
269 pAttachments = const_cast<vk::VkImageView *>(&atachments[0]);
277 RenderPassCreateInfo::RenderPassCreateInfo (const std::vector<vk::VkAttachmentDescription>& attachments,
278 const std::vector<vk::VkSubpassDescription>& subpasses,
279 const std::vector<vk::VkSubpassDependency>& dependiences)
281 : m_attachments (attachments.begin(), attachments.end())
282 , m_subpasses (subpasses.begin(), subpasses.end())
283 , m_dependiences (dependiences.begin(), dependiences.end())
284 , m_attachmentsStructs (m_attachments.begin(), m_attachments.end())
285 , m_subpassesStructs (m_subpasses.begin(), m_subpasses.end())
286 , m_dependiencesStructs (m_dependiences.begin(), m_dependiences.end())
288 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
292 attachmentCount = static_cast<deUint32>(m_attachments.size());
293 pAttachments = &m_attachmentsStructs[0];
294 subpassCount = static_cast<deUint32>(m_subpasses.size());
295 pSubpasses = &m_subpassesStructs[0];
296 dependencyCount = static_cast<deUint32>(m_dependiences.size());
297 pDependencies = &m_dependiencesStructs[0];
300 RenderPassCreateInfo::RenderPassCreateInfo (deUint32 _attachmentCount,
301 const vk::VkAttachmentDescription* _pAttachments,
302 deUint32 _subpassCount,
303 const vk::VkSubpassDescription* _pSubpasses,
304 deUint32 _dependencyCount,
305 const vk::VkSubpassDependency* _pDependiences)
308 m_attachments = std::vector<AttachmentDescription>(_pAttachments, _pAttachments + _attachmentCount);
309 m_subpasses = std::vector<SubpassDescription>(_pSubpasses, _pSubpasses + _subpassCount);
310 m_dependiences = std::vector<SubpassDependency>(_pDependiences, _pDependiences + _dependencyCount);
312 m_attachmentsStructs = std::vector<vk::VkAttachmentDescription> (m_attachments.begin(), m_attachments.end());
313 m_subpassesStructs = std::vector<vk::VkSubpassDescription> (m_subpasses.begin(), m_subpasses.end());
314 m_dependiencesStructs = std::vector<vk::VkSubpassDependency> (m_dependiences.begin(), m_dependiences.end());
316 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
320 attachmentCount = static_cast<deUint32>(m_attachments.size());
322 if (attachmentCount) {
323 pAttachments = &m_attachmentsStructs[0];
327 pAttachments = DE_NULL;
330 subpassCount = static_cast<deUint32>(m_subpasses.size());
333 pSubpasses = &m_subpassesStructs[0];
337 pSubpasses = DE_NULL;
340 dependencyCount = static_cast<deUint32>(m_dependiences.size());
342 if (dependencyCount) {
343 pDependencies = &m_dependiencesStructs[0];
347 pDependencies = DE_NULL;
352 RenderPassCreateInfo::addAttachment (vk::VkAttachmentDescription attachment)
355 m_attachments.push_back(attachment);
356 m_attachmentsStructs = std::vector<vk::VkAttachmentDescription>(m_attachments.begin(), m_attachments.end());
357 attachmentCount = static_cast<deUint32>(m_attachments.size());
358 pAttachments = &m_attachmentsStructs[0];
362 RenderPassCreateInfo::addSubpass (vk::VkSubpassDescription subpass)
365 m_subpasses.push_back(subpass);
366 m_subpassesStructs = std::vector<vk::VkSubpassDescription>(m_subpasses.begin(), m_subpasses.end());
367 subpassCount = static_cast<deUint32>(m_subpasses.size());
368 pSubpasses = &m_subpassesStructs[0];
372 RenderPassCreateInfo::addDependency (vk::VkSubpassDependency dependency)
375 m_dependiences.push_back(dependency);
376 m_dependiencesStructs = std::vector<vk::VkSubpassDependency>(m_dependiences.begin(), m_dependiences.end());
378 dependencyCount = static_cast<deUint32>(m_dependiences.size());
379 pDependencies = &m_dependiencesStructs[0];
382 RenderPassBeginInfo::RenderPassBeginInfo (vk::VkRenderPass _renderPass,
383 vk::VkFramebuffer _framebuffer,
384 vk::VkRect2D _renderArea,
385 const std::vector<vk::VkClearValue>& _clearValues)
388 m_clearValues = _clearValues;
390 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
392 renderPass = _renderPass;
393 framebuffer = _framebuffer;
394 renderArea = _renderArea;
395 clearValueCount = static_cast<deUint32>(m_clearValues.size());
396 pClearValues = m_clearValues.size() ? &m_clearValues[0] : DE_NULL;
399 CmdPoolCreateInfo::CmdPoolCreateInfo (deUint32 _queueFamilyIndex, unsigned int _flags)
401 sType = vk::VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
404 queueFamilyIndex = _queueFamilyIndex;
408 AttachmentDescription::AttachmentDescription (vk::VkFormat _format,
409 vk::VkSampleCountFlagBits _samples,
410 vk::VkAttachmentLoadOp _loadOp,
411 vk::VkAttachmentStoreOp _storeOp,
412 vk::VkAttachmentLoadOp _stencilLoadOp,
413 vk::VkAttachmentStoreOp _stencilStoreOp,
414 vk::VkImageLayout _initialLayout,
415 vk::VkImageLayout _finalLayout)
422 stencilLoadOp = _stencilLoadOp;
423 stencilStoreOp = _stencilStoreOp;
424 initialLayout = _initialLayout;
425 finalLayout = _finalLayout;
428 AttachmentDescription::AttachmentDescription (const vk::VkAttachmentDescription& rhs)
432 samples = rhs.samples;
434 storeOp = rhs.storeOp;
435 stencilLoadOp = rhs.stencilLoadOp;
436 stencilStoreOp = rhs.stencilStoreOp;
437 initialLayout = rhs.initialLayout;
438 finalLayout = rhs.finalLayout;
441 AttachmentReference::AttachmentReference (deUint32 _attachment, vk::VkImageLayout _layout)
443 attachment = _attachment;
447 AttachmentReference::AttachmentReference (void)
449 attachment = VK_ATTACHMENT_UNUSED;
450 layout = vk::VK_IMAGE_LAYOUT_UNDEFINED;
453 SubpassDescription::SubpassDescription (vk::VkPipelineBindPoint _pipelineBindPoint,
454 vk::VkSubpassDescriptionFlags _flags,
455 deUint32 _inputAttachmentCount,
456 const vk::VkAttachmentReference* _inputAttachments,
457 deUint32 _colorAttachmentCount,
458 const vk::VkAttachmentReference* _colorAttachments,
459 const vk::VkAttachmentReference* _resolveAttachments,
460 vk::VkAttachmentReference depthStencilAttachment,
461 deUint32 _preserveAttachmentCount,
462 const deUint32* _preserveAttachments)
464 m_inputAttachments = std::vector<vk::VkAttachmentReference>(_inputAttachments, _inputAttachments + _inputAttachmentCount);
465 m_colorAttachments = std::vector<vk::VkAttachmentReference>(_colorAttachments, _colorAttachments + _colorAttachmentCount);
467 if (_resolveAttachments)
468 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(_resolveAttachments, _resolveAttachments + _colorAttachmentCount);
470 m_preserveAttachments = std::vector<deUint32>(_preserveAttachments, _preserveAttachments + _preserveAttachmentCount);
472 m_depthStencilAttachment = depthStencilAttachment;
475 pipelineBindPoint = _pipelineBindPoint;
476 inputAttachmentCount = _inputAttachmentCount;
477 pInputAttachments = DE_NULL;
478 colorAttachmentCount = _colorAttachmentCount;
479 pColorAttachments = DE_NULL;
480 pResolveAttachments = DE_NULL;
481 pDepthStencilAttachment = &m_depthStencilAttachment;
482 pPreserveAttachments = DE_NULL;
483 preserveAttachmentCount = _preserveAttachmentCount;
485 if (!m_inputAttachments.empty())
486 pInputAttachments = &m_inputAttachments[0];
488 if (!m_colorAttachments.empty())
489 pColorAttachments = &m_colorAttachments[0];
491 if (!m_resolveAttachments.empty())
492 pResolveAttachments = &m_resolveAttachments[0];
494 if (!m_preserveAttachments.empty())
495 pPreserveAttachments = &m_preserveAttachments[0];
498 SubpassDescription::SubpassDescription (const vk::VkSubpassDescription& rhs)
500 *static_cast<vk::VkSubpassDescription*>(this) = rhs;
502 m_inputAttachments = std::vector<vk::VkAttachmentReference>(
503 rhs.pInputAttachments, rhs.pInputAttachments + rhs.inputAttachmentCount);
505 m_colorAttachments = std::vector<vk::VkAttachmentReference>(
506 rhs.pColorAttachments, rhs.pColorAttachments + rhs.colorAttachmentCount);
508 if (rhs.pResolveAttachments)
509 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(
510 rhs.pResolveAttachments, rhs.pResolveAttachments + rhs.colorAttachmentCount);
512 m_preserveAttachments = std::vector<deUint32>(
513 rhs.pPreserveAttachments, rhs.pPreserveAttachments + rhs.preserveAttachmentCount);
515 if (rhs.pDepthStencilAttachment)
516 m_depthStencilAttachment = *rhs.pDepthStencilAttachment;
518 if (!m_inputAttachments.empty())
519 pInputAttachments = &m_inputAttachments[0];
521 if (!m_colorAttachments.empty())
522 pColorAttachments = &m_colorAttachments[0];
524 if (!m_resolveAttachments.empty())
525 pResolveAttachments = &m_resolveAttachments[0];
527 pDepthStencilAttachment = &m_depthStencilAttachment;
529 if (!m_preserveAttachments.empty())
530 pPreserveAttachments = &m_preserveAttachments[0];
533 SubpassDescription::SubpassDescription (const SubpassDescription& rhs) {
537 SubpassDescription& SubpassDescription::operator= (const SubpassDescription& rhs)
539 *static_cast<vk::VkSubpassDescription*>(this) = rhs;
541 m_inputAttachments = rhs.m_inputAttachments;
542 m_colorAttachments = rhs.m_colorAttachments;
543 m_resolveAttachments = rhs.m_resolveAttachments;
544 m_preserveAttachments = rhs.m_preserveAttachments;
545 m_depthStencilAttachment = rhs.m_depthStencilAttachment;
547 if (!m_inputAttachments.empty())
548 pInputAttachments = &m_inputAttachments[0];
550 if (!m_colorAttachments.empty())
551 pColorAttachments = &m_colorAttachments[0];
553 if (!m_resolveAttachments.empty())
554 pResolveAttachments = &m_resolveAttachments[0];
556 pDepthStencilAttachment = &m_depthStencilAttachment;
558 if (!m_preserveAttachments.empty())
559 pPreserveAttachments = &m_preserveAttachments[0];
564 SubpassDependency::SubpassDependency (deUint32 _srcSubpass,
565 deUint32 _dstSubpass,
566 vk::VkPipelineStageFlags _srcStageMask,
567 vk::VkPipelineStageFlags _dstStageMask,
568 vk::VkAccessFlags _srcAccessMask,
569 vk::VkAccessFlags _dstAccessMask,
570 vk::VkDependencyFlags _dependencyFlags)
572 srcSubpass = _srcSubpass;
573 dstSubpass = _dstSubpass;
574 srcStageMask = _srcStageMask;
575 dstStageMask = _dstStageMask;
576 srcAccessMask = _srcAccessMask;
577 dstAccessMask = _dstAccessMask;
578 dependencyFlags = _dependencyFlags;
581 SubpassDependency::SubpassDependency (const vk::VkSubpassDependency& rhs)
583 srcSubpass = rhs.srcSubpass;
584 dstSubpass = rhs.dstSubpass;
585 srcStageMask = rhs.srcStageMask;
586 dstStageMask = rhs.dstStageMask;
587 srcAccessMask = rhs.srcAccessMask;
588 dstAccessMask = rhs.dstAccessMask;
589 dependencyFlags = rhs.dependencyFlags;
592 CmdBufferBeginInfo::CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags _flags)
594 sType = vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
597 pInheritanceInfo = DE_NULL;
600 DescriptorPoolCreateInfo::DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>& poolSizeCounts,
601 vk::VkDescriptorPoolCreateFlags _flags,
603 : m_poolSizeCounts(poolSizeCounts)
605 sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
609 poolSizeCount = static_cast<deUint32>(m_poolSizeCounts.size());
610 pPoolSizes = &m_poolSizeCounts[0];
613 DescriptorPoolCreateInfo& DescriptorPoolCreateInfo::addDescriptors (vk::VkDescriptorType type, deUint32 count)
615 vk::VkDescriptorPoolSize descriptorTypeCount = { type, count };
616 m_poolSizeCounts.push_back(descriptorTypeCount);
618 poolSizeCount = static_cast<deUint32>(m_poolSizeCounts.size());
619 pPoolSizes = &m_poolSizeCounts[0];
624 DescriptorSetLayoutCreateInfo::DescriptorSetLayoutCreateInfo (deUint32 _bindingCount, const vk::VkDescriptorSetLayoutBinding* _pBindings)
626 sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
629 bindingCount = _bindingCount;
630 pBindings = _pBindings;
633 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (deUint32 _descriptorSetCount,
634 const vk::VkDescriptorSetLayout* _pSetLayouts,
635 deUint32 _pushConstantRangeCount,
636 const vk::VkPushConstantRange* _pPushConstantRanges)
637 : m_pushConstantRanges(_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
639 for (unsigned int i = 0; i < _descriptorSetCount; i++)
641 m_setLayouts.push_back(_pSetLayouts[i]);
644 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
647 setLayoutCount = static_cast<deUint32>(m_setLayouts.size());
648 pSetLayouts = setLayoutCount > 0 ? &m_setLayouts[0] : DE_NULL;
649 pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
651 if (m_pushConstantRanges.size()) {
652 pPushConstantRanges = &m_pushConstantRanges[0];
656 pPushConstantRanges = DE_NULL;
660 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (const std::vector<vk::VkDescriptorSetLayout>& setLayouts,
661 deUint32 _pushConstantRangeCount,
662 const vk::VkPushConstantRange* _pPushConstantRanges)
663 : m_setLayouts (setLayouts)
664 , m_pushConstantRanges (_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
666 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
670 setLayoutCount = static_cast<deUint32>(m_setLayouts.size());
674 pSetLayouts = &m_setLayouts[0];
678 pSetLayouts = DE_NULL;
681 pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
682 if (pushConstantRangeCount) {
683 pPushConstantRanges = &m_pushConstantRanges[0];
687 pPushConstantRanges = DE_NULL;
691 PipelineCreateInfo::PipelineShaderStage::PipelineShaderStage (vk::VkShaderModule _module, const char* _pName, vk::VkShaderStageFlagBits _stage)
693 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
699 pSpecializationInfo = DE_NULL;
702 PipelineCreateInfo::VertexInputState::VertexInputState (deUint32 _vertexBindingDescriptionCount,
703 const vk::VkVertexInputBindingDescription* _pVertexBindingDescriptions,
704 deUint32 _vertexAttributeDescriptionCount,
705 const vk::VkVertexInputAttributeDescription* _pVertexAttributeDescriptions)
707 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
710 vertexBindingDescriptionCount = _vertexBindingDescriptionCount;
711 pVertexBindingDescriptions = _pVertexBindingDescriptions;
712 vertexAttributeDescriptionCount = _vertexAttributeDescriptionCount;
713 pVertexAttributeDescriptions = _pVertexAttributeDescriptions;
716 PipelineCreateInfo::InputAssemblerState::InputAssemblerState (vk::VkPrimitiveTopology _topology,
717 vk::VkBool32 _primitiveRestartEnable)
719 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
722 topology = _topology;
723 primitiveRestartEnable = _primitiveRestartEnable;
726 PipelineCreateInfo::TessellationState::TessellationState (deUint32 _patchControlPoints)
728 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
731 patchControlPoints = _patchControlPoints;
734 PipelineCreateInfo::ViewportState::ViewportState (deUint32 _viewportCount,
735 std::vector<vk::VkViewport> _viewports,
736 std::vector<vk::VkRect2D> _scissors)
738 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
741 viewportCount = _viewportCount;
742 scissorCount = _viewportCount;
744 if (!_viewports.size())
746 m_viewports.resize(viewportCount);
747 deMemset(&m_viewports[0], 0, sizeof(m_viewports[0]) * m_viewports.size());
751 m_viewports = _viewports;
754 if (!_scissors.size())
756 m_scissors.resize(scissorCount);
757 deMemset(&m_scissors[0], 0, sizeof(m_scissors[0]) * m_scissors.size());
761 m_scissors = _scissors;
764 pViewports = &m_viewports[0];
765 pScissors = &m_scissors[0];
768 PipelineCreateInfo::ViewportState::ViewportState (const ViewportState& other)
773 viewportCount = other.viewportCount;
774 scissorCount = other.scissorCount;
776 m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + viewportCount);
777 m_scissors = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
779 pViewports = &m_viewports[0];
780 pScissors = &m_scissors[0];
783 PipelineCreateInfo::ViewportState& PipelineCreateInfo::ViewportState::operator= (const ViewportState& other)
788 viewportCount = other.viewportCount;
789 scissorCount = other.scissorCount;
791 m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + scissorCount);
792 m_scissors = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
794 pViewports = &m_viewports[0];
795 pScissors = &m_scissors[0];
799 PipelineCreateInfo::RasterizerState::RasterizerState (vk::VkBool32 _depthClampEnable,
800 vk::VkBool32 _rasterizerDiscardEnable,
801 vk::VkPolygonMode _polygonMode,
802 vk::VkCullModeFlags _cullMode,
803 vk::VkFrontFace _frontFace,
804 vk::VkBool32 _depthBiasEnable,
805 float _depthBiasConstantFactor,
806 float _depthBiasClamp,
807 float _depthBiasSlopeFactor,
810 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
813 depthClampEnable = _depthClampEnable;
814 rasterizerDiscardEnable = _rasterizerDiscardEnable;
815 polygonMode = _polygonMode;
816 cullMode = _cullMode;
817 frontFace = _frontFace;
819 depthBiasEnable = _depthBiasEnable;
820 depthBiasConstantFactor = _depthBiasConstantFactor;
821 depthBiasClamp = _depthBiasClamp;
822 depthBiasSlopeFactor = _depthBiasSlopeFactor;
823 lineWidth = _lineWidth;
826 PipelineCreateInfo::MultiSampleState::MultiSampleState (vk::VkSampleCountFlagBits _rasterizationSamples,
827 vk::VkBool32 _sampleShadingEnable,
828 float _minSampleShading,
829 const std::vector<vk::VkSampleMask>& _sampleMask,
830 bool _alphaToCoverageEnable,
831 bool _alphaToOneEnable)
832 : m_sampleMask(_sampleMask)
834 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
837 rasterizationSamples = _rasterizationSamples;
838 sampleShadingEnable = _sampleShadingEnable;
839 minSampleShading = _minSampleShading;
840 pSampleMask = &m_sampleMask[0];
841 alphaToCoverageEnable = _alphaToCoverageEnable;
842 alphaToOneEnable = _alphaToOneEnable;
845 PipelineCreateInfo::MultiSampleState::MultiSampleState (const MultiSampleState& other)
850 rasterizationSamples = other.rasterizationSamples;
851 sampleShadingEnable = other.sampleShadingEnable;
852 minSampleShading = other.minSampleShading;
854 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
856 m_sampleMask = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
857 pSampleMask = &m_sampleMask[0];
860 PipelineCreateInfo::MultiSampleState& PipelineCreateInfo::MultiSampleState::operator= (const MultiSampleState& other)
865 rasterizationSamples = other.rasterizationSamples;
866 sampleShadingEnable = other.sampleShadingEnable;
867 minSampleShading = other.minSampleShading;
869 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
871 m_sampleMask = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
872 pSampleMask = &m_sampleMask[0];
877 PipelineCreateInfo::ColorBlendState::ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>& _attachments,
878 vk::VkBool32 _logicOpEnable,
879 vk::VkLogicOp _logicOp)
880 : m_attachments(_attachments)
882 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
885 logicOpEnable = _logicOpEnable;
887 attachmentCount = static_cast<deUint32>(m_attachments.size());
888 pAttachments = &m_attachments[0];
891 PipelineCreateInfo::ColorBlendState::ColorBlendState (deUint32 _attachmentCount,
892 const vk::VkPipelineColorBlendAttachmentState* _attachments,
893 vk::VkBool32 _logicOpEnable,
894 vk::VkLogicOp _logicOp)
895 : m_attachments(_attachments, _attachments + _attachmentCount)
897 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
900 logicOpEnable = _logicOpEnable;
902 attachmentCount = static_cast<deUint32>(m_attachments.size());
903 pAttachments = &m_attachments[0];
906 PipelineCreateInfo::ColorBlendState::ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo& createInfo)
907 : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
909 sType = createInfo.sType;
910 pNext = createInfo.pNext;
911 flags = createInfo.flags;
912 logicOpEnable = createInfo.logicOpEnable;
913 logicOp = createInfo.logicOp;
914 attachmentCount = static_cast<deUint32>(m_attachments.size());
915 pAttachments = &m_attachments[0];
918 PipelineCreateInfo::ColorBlendState::ColorBlendState (const ColorBlendState& createInfo, std::vector<float> _blendConstants)
919 : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
921 sType = createInfo.sType;
922 pNext = createInfo.pNext;
923 flags = createInfo.flags;
924 logicOpEnable = createInfo.logicOpEnable;
925 logicOp = createInfo.logicOp;
926 attachmentCount = static_cast<deUint32>(m_attachments.size());
927 pAttachments = &m_attachments[0];
928 deMemcpy(blendConstants, &_blendConstants[0], 4 * sizeof(float));
931 PipelineCreateInfo::ColorBlendState::Attachment::Attachment (vk::VkBool32 _blendEnable,
932 vk::VkBlendFactor _srcColorBlendFactor,
933 vk::VkBlendFactor _dstColorBlendFactor,
934 vk::VkBlendOp _colorBlendOp,
935 vk::VkBlendFactor _srcAlphaBlendFactor,
936 vk::VkBlendFactor _dstAlphaBlendFactor,
937 vk::VkBlendOp _alphaBlendOp,
938 vk::VkColorComponentFlags _colorWriteMask)
940 blendEnable = _blendEnable;
941 srcColorBlendFactor = _srcColorBlendFactor;
942 dstColorBlendFactor = _dstColorBlendFactor;
943 colorBlendOp = _colorBlendOp;
944 srcAlphaBlendFactor = _srcAlphaBlendFactor;
945 dstAlphaBlendFactor = _dstAlphaBlendFactor;
946 alphaBlendOp = _alphaBlendOp;
947 colorWriteMask = _colorWriteMask;
950 PipelineCreateInfo::DepthStencilState::StencilOpState::StencilOpState (vk::VkStencilOp _failOp,
951 vk::VkStencilOp _passOp,
952 vk::VkStencilOp _depthFailOp,
953 vk::VkCompareOp _compareOp,
954 deUint32 _compareMask,
960 depthFailOp = _depthFailOp;
961 compareOp = _compareOp;
963 compareMask = _compareMask;
964 writeMask = _writeMask;
965 reference = _reference;
968 PipelineCreateInfo::DepthStencilState::DepthStencilState (vk::VkBool32 _depthTestEnable,
969 vk::VkBool32 _depthWriteEnable,
970 vk::VkCompareOp _depthCompareOp,
971 vk::VkBool32 _depthBoundsTestEnable,
972 vk::VkBool32 _stencilTestEnable,
973 StencilOpState _front,
974 StencilOpState _back,
975 float _minDepthBounds,
976 float _maxDepthBounds)
978 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
981 depthTestEnable = _depthTestEnable;
982 depthWriteEnable = _depthWriteEnable;
983 depthCompareOp = _depthCompareOp;
984 depthBoundsTestEnable = _depthBoundsTestEnable;
985 stencilTestEnable = _stencilTestEnable;
989 minDepthBounds = _minDepthBounds;
990 maxDepthBounds = _maxDepthBounds;
993 PipelineCreateInfo::DynamicState::DynamicState (const std::vector<vk::VkDynamicState>& _dynamicStates)
995 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
999 if (!_dynamicStates.size())
1001 for (size_t i = 0; i < vk::VK_DYNAMIC_STATE_LAST; ++i)
1003 m_dynamicStates.push_back(static_cast<vk::VkDynamicState>(i));
1007 m_dynamicStates = _dynamicStates;
1009 dynamicStateCount = static_cast<deUint32>(m_dynamicStates.size());
1010 pDynamicStates = &m_dynamicStates[0];
1013 PipelineCreateInfo::DynamicState::DynamicState (const DynamicState &other)
1015 sType = other.sType;
1016 pNext = other.pNext;
1018 flags = other.flags;
1019 dynamicStateCount = other.dynamicStateCount;
1020 m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1021 pDynamicStates = &m_dynamicStates[0];
1024 PipelineCreateInfo::DynamicState& PipelineCreateInfo::DynamicState::operator= (const DynamicState& other)
1026 sType = other.sType;
1027 pNext = other.pNext;
1029 flags = other.flags;
1030 dynamicStateCount = other.dynamicStateCount;
1031 m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1032 pDynamicStates = &m_dynamicStates[0];
1037 PipelineCreateInfo::PipelineCreateInfo (vk::VkPipelineLayout _layout,
1038 vk::VkRenderPass _renderPass,
1040 vk::VkPipelineCreateFlags _flags)
1042 deMemset(static_cast<vk::VkGraphicsPipelineCreateInfo *>(this), 0,
1043 sizeof(vk::VkGraphicsPipelineCreateInfo));
1045 sType = vk::VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
1048 renderPass = _renderPass;
1051 basePipelineHandle = DE_NULL;
1052 basePipelineIndex = 0;
1053 pDynamicState = DE_NULL;
1056 PipelineCreateInfo& PipelineCreateInfo::addShader (const vk::VkPipelineShaderStageCreateInfo& shader)
1058 m_shaders.push_back(shader);
1060 stageCount = static_cast<deUint32>(m_shaders.size());
1061 pStages = &m_shaders[0];
1066 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineVertexInputStateCreateInfo& state)
1068 m_vertexInputState = state;
1069 pVertexInputState = &m_vertexInputState;
1074 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state)
1076 m_inputAssemblyState = state;
1077 pInputAssemblyState = &m_inputAssemblyState;
1082 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineColorBlendStateCreateInfo& state)
1084 m_colorBlendStateAttachments = std::vector<vk::VkPipelineColorBlendAttachmentState>(state.pAttachments, state.pAttachments + state.attachmentCount);
1085 m_colorBlendState = state;
1086 m_colorBlendState.pAttachments = &m_colorBlendStateAttachments[0];
1087 pColorBlendState = &m_colorBlendState;
1092 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineViewportStateCreateInfo& state)
1094 m_viewports = std::vector<vk::VkViewport>(state.pViewports, state.pViewports + state.viewportCount);
1095 m_scissors = std::vector<vk::VkRect2D>(state.pScissors, state.pScissors + state.scissorCount);
1096 m_viewportState = state;
1097 m_viewportState.pViewports = &m_viewports[0];
1098 m_viewportState.pScissors = &m_scissors[0];
1099 pViewportState = &m_viewportState;
1104 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDepthStencilStateCreateInfo& state)
1106 m_dynamicDepthStencilState = state;
1107 pDepthStencilState = &m_dynamicDepthStencilState;
1111 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineTessellationStateCreateInfo& state)
1113 m_tessState = state;
1114 pTessellationState = &m_tessState;
1119 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineRasterizationStateCreateInfo& state)
1121 m_rasterState = state;
1122 pRasterizationState = &m_rasterState;
1127 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineMultisampleStateCreateInfo& state)
1130 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + state.rasterizationSamples) / ( sizeof(vk::VkSampleMask) * 8 );
1131 m_multisampleStateSampleMask = std::vector<vk::VkSampleMask>(state.pSampleMask, state.pSampleMask + sampleMaskArrayLen);
1132 m_multisampleState = state;
1133 m_multisampleState.pSampleMask = &m_multisampleStateSampleMask[0];
1134 pMultisampleState = &m_multisampleState;
1138 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDynamicStateCreateInfo& state)
1140 m_dynamicStates = std::vector<vk::VkDynamicState>(state.pDynamicStates, state.pDynamicStates + state.dynamicStateCount);
1141 m_dynamicState = state;
1142 m_dynamicState.pDynamicStates = &m_dynamicStates[0];
1143 pDynamicState = &m_dynamicState;
1148 SamplerCreateInfo::SamplerCreateInfo (vk::VkFilter _magFilter,
1149 vk::VkFilter _minFilter,
1150 vk::VkSamplerMipmapMode _mipmapMode,
1151 vk::VkSamplerAddressMode _addressModeU,
1152 vk::VkSamplerAddressMode _addressModeV,
1153 vk::VkSamplerAddressMode _addressModeW,
1155 vk::VkBool32 _anisotropyEnable,
1156 float _maxAnisotropy,
1157 vk::VkBool32 _compareEnable,
1158 vk::VkCompareOp _compareOp,
1161 vk::VkBorderColor _borderColor,
1162 vk::VkBool32 _unnormalizedCoordinates)
1164 sType = vk::VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
1167 magFilter = _magFilter;
1168 minFilter = _minFilter;
1169 mipmapMode = _mipmapMode;
1170 addressModeU = _addressModeU;
1171 addressModeV = _addressModeV;
1172 addressModeW = _addressModeW;
1173 mipLodBias = _mipLodBias;
1174 anisotropyEnable = _anisotropyEnable;
1175 maxAnisotropy = _maxAnisotropy;
1176 compareEnable = _compareEnable;
1177 compareOp = _compareOp;
1180 borderColor = _borderColor;
1181 unnormalizedCoordinates = _unnormalizedCoordinates;