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 "vktDrawCreateInfoUtil.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());
333 if (attachmentCount) {
334 pAttachments = &m_attachmentsStructs[0];
338 pAttachments = DE_NULL;
341 subpassCount = static_cast<deUint32>(m_subpasses.size());
344 pSubpasses = &m_subpassesStructs[0];
348 pSubpasses = DE_NULL;
351 dependencyCount = static_cast<deUint32>(m_dependiences.size());
353 if (dependencyCount) {
354 pDependencies = &m_dependiencesStructs[0];
358 pDependencies = DE_NULL;
363 RenderPassCreateInfo::addAttachment (vk::VkAttachmentDescription attachment)
366 m_attachments.push_back(attachment);
367 m_attachmentsStructs = std::vector<vk::VkAttachmentDescription>(m_attachments.begin(), m_attachments.end());
368 attachmentCount = static_cast<deUint32>(m_attachments.size());
369 pAttachments = &m_attachmentsStructs[0];
373 RenderPassCreateInfo::addSubpass (vk::VkSubpassDescription subpass)
376 m_subpasses.push_back(subpass);
377 m_subpassesStructs = std::vector<vk::VkSubpassDescription>(m_subpasses.begin(), m_subpasses.end());
378 subpassCount = static_cast<deUint32>(m_subpasses.size());
379 pSubpasses = &m_subpassesStructs[0];
383 RenderPassCreateInfo::addDependency (vk::VkSubpassDependency dependency)
386 m_dependiences.push_back(dependency);
387 m_dependiencesStructs = std::vector<vk::VkSubpassDependency>(m_dependiences.begin(), m_dependiences.end());
389 dependencyCount = static_cast<deUint32>(m_dependiences.size());
390 pDependencies = &m_dependiencesStructs[0];
393 RenderPassBeginInfo::RenderPassBeginInfo (vk::VkRenderPass _renderPass,
394 vk::VkFramebuffer _framebuffer,
395 vk::VkRect2D _renderArea,
396 const std::vector<vk::VkClearValue>& _clearValues)
399 m_clearValues = _clearValues;
401 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
403 renderPass = _renderPass;
404 framebuffer = _framebuffer;
405 renderArea = _renderArea;
406 clearValueCount = static_cast<deUint32>(m_clearValues.size());
407 pClearValues = m_clearValues.size() ? &m_clearValues[0] : DE_NULL;
410 CmdPoolCreateInfo::CmdPoolCreateInfo (deUint32 _queueFamilyIndex, unsigned int _flags)
412 sType = vk::VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
415 queueFamilyIndex = _queueFamilyIndex;
419 AttachmentDescription::AttachmentDescription (vk::VkFormat _format,
420 vk::VkSampleCountFlagBits _samples,
421 vk::VkAttachmentLoadOp _loadOp,
422 vk::VkAttachmentStoreOp _storeOp,
423 vk::VkAttachmentLoadOp _stencilLoadOp,
424 vk::VkAttachmentStoreOp _stencilStoreOp,
425 vk::VkImageLayout _initialLayout,
426 vk::VkImageLayout _finalLayout)
433 stencilLoadOp = _stencilLoadOp;
434 stencilStoreOp = _stencilStoreOp;
435 initialLayout = _initialLayout;
436 finalLayout = _finalLayout;
439 AttachmentDescription::AttachmentDescription (const vk::VkAttachmentDescription &rhs)
443 samples = rhs.samples;
445 storeOp = rhs.storeOp;
446 stencilLoadOp = rhs.stencilLoadOp;
447 stencilStoreOp = rhs.stencilStoreOp;
448 initialLayout = rhs.initialLayout;
449 finalLayout = rhs.finalLayout;
452 AttachmentReference::AttachmentReference (deUint32 _attachment, vk::VkImageLayout _layout)
454 attachment = _attachment;
458 AttachmentReference::AttachmentReference (void)
460 attachment = vk::VK_ATTACHMENT_UNUSED;
461 layout = vk::VK_IMAGE_LAYOUT_UNDEFINED;
464 SubpassDescription::SubpassDescription (vk::VkPipelineBindPoint _pipelineBindPoint,
465 vk::VkSubpassDescriptionFlags _flags,
466 deUint32 _inputAttachmentCount,
467 const vk::VkAttachmentReference* _inputAttachments,
468 deUint32 _colorAttachmentCount,
469 const vk::VkAttachmentReference* _colorAttachments,
470 const vk::VkAttachmentReference* _resolveAttachments,
471 vk::VkAttachmentReference depthStencilAttachment,
472 deUint32 _preserveAttachmentCount,
473 const vk::VkAttachmentReference* _preserveAttachments)
475 m_inputAttachments = std::vector<vk::VkAttachmentReference>(_inputAttachments, _inputAttachments + _inputAttachmentCount);
476 m_colorAttachments = std::vector<vk::VkAttachmentReference>(_colorAttachments, _colorAttachments + _colorAttachmentCount);
478 if (_resolveAttachments)
480 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(_resolveAttachments, _resolveAttachments + _colorAttachmentCount);
483 m_preserveAttachments = std::vector<vk::VkAttachmentReference>(_preserveAttachments, _preserveAttachments + _preserveAttachmentCount);
485 m_depthStencilAttachment = depthStencilAttachment;
488 pipelineBindPoint = _pipelineBindPoint;
489 inputAttachmentCount = _inputAttachmentCount;
490 pInputAttachments = DE_NULL;
491 colorAttachmentCount = _colorAttachmentCount;
492 pColorAttachments = DE_NULL;
493 pResolveAttachments = DE_NULL;
494 pDepthStencilAttachment = &m_depthStencilAttachment;
495 pPreserveAttachments = DE_NULL;
496 preserveAttachmentCount = _preserveAttachmentCount;
498 if (m_inputAttachments.size()) {
499 pInputAttachments = &m_inputAttachments[0];
502 if (m_colorAttachments.size()) {
503 pColorAttachments = &m_colorAttachments[0];
506 if (m_resolveAttachments.size()) {
507 pResolveAttachments = &m_resolveAttachments[0];
510 if (m_preserveAttachments.size()) {
511 pPreserveAttachments = &m_preserveAttachments[0];
515 SubpassDescription::SubpassDescription (const vk::VkSubpassDescription& rhs)
517 *static_cast<vk::VkSubpassDescription*>(this) = rhs;
519 m_inputAttachments = std::vector<vk::VkAttachmentReference>(
520 rhs.pInputAttachments, rhs.pInputAttachments + rhs.inputAttachmentCount);
522 m_colorAttachments = std::vector<vk::VkAttachmentReference>(
523 rhs.pColorAttachments, rhs.pColorAttachments + rhs.colorAttachmentCount);
525 if (rhs.pResolveAttachments) {
526 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(
527 rhs.pResolveAttachments, rhs.pResolveAttachments + rhs.colorAttachmentCount);
529 m_preserveAttachments = std::vector<vk::VkAttachmentReference>(
530 rhs.pPreserveAttachments, rhs.pPreserveAttachments + rhs.preserveAttachmentCount);
532 if (rhs.pDepthStencilAttachment)
534 m_depthStencilAttachment = *rhs.pDepthStencilAttachment;
537 if (m_inputAttachments.size()) {
538 pInputAttachments = &m_inputAttachments[0];
540 if (m_colorAttachments.size()) {
541 pColorAttachments = &m_colorAttachments[0];
544 if (m_resolveAttachments.size()) {
545 pResolveAttachments = &m_resolveAttachments[0];
548 pDepthStencilAttachment = &m_depthStencilAttachment;
550 if (m_preserveAttachments.size()) {
551 pPreserveAttachments = &m_preserveAttachments[0];
555 SubpassDescription::SubpassDescription (const SubpassDescription& rhs) {
559 SubpassDescription& SubpassDescription::operator= (const SubpassDescription& rhs)
561 *static_cast<vk::VkSubpassDescription*>(this) = rhs;
563 m_inputAttachments = rhs.m_inputAttachments;
564 m_colorAttachments = rhs.m_colorAttachments;
565 m_resolveAttachments = rhs.m_resolveAttachments;
566 m_preserveAttachments = rhs.m_preserveAttachments;
567 m_depthStencilAttachment = rhs.m_depthStencilAttachment;
569 if (m_inputAttachments.size()) {
570 pInputAttachments = &m_inputAttachments[0];
572 if (m_colorAttachments.size()) {
573 pColorAttachments = &m_colorAttachments[0];
576 if (m_resolveAttachments.size()) {
577 pResolveAttachments = &m_resolveAttachments[0];
580 pDepthStencilAttachment = &m_depthStencilAttachment;
582 if (m_preserveAttachments.size()) {
583 pPreserveAttachments = &m_preserveAttachments[0];
589 SubpassDependency::SubpassDependency (deUint32 _srcSubpass,
590 deUint32 _dstSubpass,
591 vk::VkPipelineStageFlags _srcStageMask,
592 vk::VkPipelineStageFlags _dstStageMask,
593 vk::VkAccessFlags _srcAccessMask,
594 vk::VkAccessFlags _dstAccessMask,
595 vk::VkDependencyFlags _dependencyFlags)
597 srcSubpass = _srcSubpass;
598 dstSubpass = _dstSubpass;
599 srcStageMask = _srcStageMask;
600 dstStageMask = _dstStageMask;
601 srcAccessMask = _srcAccessMask;
602 dstAccessMask = _dstAccessMask;
603 dependencyFlags = _dependencyFlags;
606 SubpassDependency::SubpassDependency (const vk::VkSubpassDependency &rhs)
608 srcSubpass = rhs.srcSubpass;
609 dstSubpass = rhs.dstSubpass;
610 srcStageMask = rhs.srcStageMask;
611 dstStageMask = rhs.dstStageMask;
612 srcAccessMask = rhs.srcAccessMask;
613 dstAccessMask = rhs.dstAccessMask;
614 dependencyFlags = rhs.dependencyFlags;
617 CmdBufferBeginInfo::CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags _flags)
619 sType = vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
621 renderPass = DE_NULL;
623 framebuffer = DE_NULL;
625 occlusionQueryEnable = false;
627 pipelineStatistics = 0u;
630 CmdBufferBeginInfo::CmdBufferBeginInfo (vk::VkRenderPass _renderPass,
632 vk::VkFramebuffer _framebuffer,
633 vk::VkCommandBufferUsageFlags _flags,
634 bool _occlusionQueryEnable,
\r
635 vk::VkQueryControlFlags _queryFlags,
\r
636 vk::VkQueryPipelineStatisticFlags _pipelineStatistics)
639 sType = vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
641 renderPass = _renderPass;
643 framebuffer = _framebuffer;
645 occlusionQueryEnable = _occlusionQueryEnable;
646 queryFlags = _queryFlags;
647 pipelineStatistics = _pipelineStatistics;
650 DescriptorPoolCreateInfo::DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>& poolSizeCounts,
651 vk::VkDescriptorPoolCreateFlags _flags,
653 : m_poolSizeCounts(poolSizeCounts)
655 sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
659 poolSizeCount = static_cast<deUint32>(m_poolSizeCounts.size());
660 pPoolSizes = &m_poolSizeCounts[0];
663 DescriptorPoolCreateInfo& DescriptorPoolCreateInfo::addDescriptors (vk::VkDescriptorType type, deUint32 count)
665 vk::VkDescriptorPoolSize descriptorTypeCount = { type, count };
666 m_poolSizeCounts.push_back(descriptorTypeCount);
668 poolSizeCount = static_cast<deUint32>(m_poolSizeCounts.size());
669 pPoolSizes = &m_poolSizeCounts[0];
674 DescriptorSetLayoutCreateInfo::DescriptorSetLayoutCreateInfo (deUint32 _bindingCount, const vk::VkDescriptorSetLayoutBinding* _pBindings)
676 sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
679 bindingCount = _bindingCount;
680 pBinding = _pBindings;
684 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (deUint32 _descriptorSetCount,
685 const vk::VkDescriptorSetLayout* _pSetLayouts,
686 deUint32 _pushConstantRangeCount,
687 const vk::VkPushConstantRange* _pPushConstantRanges)
688 : m_pushConstantRanges(_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
690 for (unsigned int i = 0; i < _descriptorSetCount; i++)
692 m_setLayouts.push_back(_pSetLayouts[i]);
695 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
697 setLayoutCount = static_cast<deUint32>(m_setLayouts.size());
698 pSetLayouts = setLayoutCount > 0 ? &m_setLayouts[0] : DE_NULL;
699 pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
701 if (m_pushConstantRanges.size()) {
702 pPushConstantRanges = &m_pushConstantRanges[0];
706 pPushConstantRanges = DE_NULL;
710 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (const std::vector<vk::VkDescriptorSetLayout>& setLayouts,
711 deUint32 _pushConstantRangeCount,
712 const vk::VkPushConstantRange* _pPushConstantRanges)
713 : m_setLayouts (setLayouts)
714 , m_pushConstantRanges (_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
716 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
719 setLayoutCount = static_cast<deUint32>(m_setLayouts.size());
723 pSetLayouts = &m_setLayouts[0];
727 pSetLayouts = DE_NULL;
730 pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
731 if (pushConstantRangeCount) {
732 pPushConstantRanges = &m_pushConstantRanges[0];
736 pPushConstantRanges = DE_NULL;
741 PipelineCreateInfo::PipelineShaderStage::PipelineShaderStage (vk::VkShaderModule _module, const char* _pName, vk::VkShaderStageFlagBits _stage)
743 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
749 pSpecializationInfo = DE_NULL;
752 PipelineCreateInfo::VertexInputState::VertexInputState (deUint32 _vertexBindingDescriptionCount,
753 const vk::VkVertexInputBindingDescription* _pVertexBindingDescriptions,
754 deUint32 _vertexAttributeDescriptionCount,
755 const vk::VkVertexInputAttributeDescription* _pVertexAttributeDescriptions)
757 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
760 vertexBindingDescriptionCount = _vertexBindingDescriptionCount;
761 pVertexBindingDescriptions = _pVertexBindingDescriptions;
762 vertexAttributeDescriptionCount = _vertexAttributeDescriptionCount;
763 pVertexAttributeDescriptions = _pVertexAttributeDescriptions;
766 PipelineCreateInfo::InputAssemblerState::InputAssemblerState (vk::VkPrimitiveTopology _topology,
767 vk::VkBool32 _primitiveRestartEnable)
769 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
772 topology = _topology;
773 primitiveRestartEnable = _primitiveRestartEnable;
776 PipelineCreateInfo::TesselationState::TesselationState (deUint32 _patchControlPoints)
778 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
780 patchControlPoints = _patchControlPoints;
783 PipelineCreateInfo::ViewportState::ViewportState (deUint32 _viewportCount,
784 std::vector<vk::VkViewport> _viewports,
785 std::vector<vk::VkRect2D> _scissors)
787 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
790 viewportCount = _viewportCount;
791 scissorCount = _viewportCount;
793 if (!_viewports.size())
795 m_viewports.resize(viewportCount);
796 deMemset(&m_viewports[0], 0, sizeof(m_viewports[0]) * m_viewports.size());
800 m_viewports = _viewports;
803 if (!_scissors.size())
805 m_scissors.resize(scissorCount);
806 deMemset(&m_scissors[0], 0, sizeof(m_scissors[0]) * m_scissors.size());
810 m_scissors = _scissors;
813 pViewports = &m_viewports[0];
814 pScissors = &m_scissors[0];
817 PipelineCreateInfo::ViewportState::ViewportState (const ViewportState &other)
821 viewportCount = other.viewportCount;
822 scissorCount = other.scissorCount;
824 m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + viewportCount);
825 m_scissors = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
827 pViewports = &m_viewports[0];
828 pScissors = &m_scissors[0];
831 PipelineCreateInfo::ViewportState & PipelineCreateInfo::ViewportState::operator= (const ViewportState &other)
835 viewportCount = other.viewportCount;
836 scissorCount = other.scissorCount;
838 m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + scissorCount);
839 m_scissors = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
841 pViewports = &m_viewports[0];
842 pScissors = &m_scissors[0];
846 PipelineCreateInfo::RasterizerState::RasterizerState (vk::VkBool32 _depthClampEnable,
847 vk::VkBool32 _rasterizerDiscardEnable,
848 vk::VkPolygonMode _polygonMode,
849 vk::VkCullModeFlags _cullMode,
850 vk::VkFrontFace _frontFace,
851 vk::VkBool32 _depthBiasEnable,
852 float _depthBiasConstantFactor,
853 float _depthBiasClamp,
854 float _depthBiasSlopeFactor,
857 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
860 depthClampEnable = _depthClampEnable;
861 rasterizerDiscardEnable = _rasterizerDiscardEnable;
862 polygonMode = _polygonMode;
863 cullMode = _cullMode;
864 frontFace = _frontFace;
866 depthBiasEnable = _depthBiasEnable;
867 depthBiasConstantFactor = _depthBiasConstantFactor;
868 depthBiasClamp = _depthBiasClamp;
869 depthBiasSlopeFactor = _depthBiasSlopeFactor;
870 lineWidth = _lineWidth;
873 PipelineCreateInfo::MultiSampleState::MultiSampleState (vk::VkSampleCountFlagBits _rasterizationSamples,
874 vk::VkBool32 _sampleShadingEnable,
875 float _minSampleShading,
876 const std::vector<vk::VkSampleMask>& _sampleMask,
877 bool _alphaToCoverageEnable,
878 bool _alphaToOneEnable)
879 : m_sampleMask(_sampleMask)
881 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
884 rasterizationSamples = _rasterizationSamples;
885 sampleShadingEnable = _sampleShadingEnable;
886 minSampleShading = _minSampleShading;
887 pSampleMask = &m_sampleMask[0];
888 alphaToCoverageEnable = _alphaToCoverageEnable;
889 alphaToOneEnable = _alphaToOneEnable;
892 PipelineCreateInfo::MultiSampleState::MultiSampleState (const MultiSampleState &other)
896 rasterizationSamples = other.rasterizationSamples;
897 sampleShadingEnable = other.sampleShadingEnable;
898 minSampleShading = other.minSampleShading;
900 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
902 m_sampleMask = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
903 pSampleMask = &m_sampleMask[0];
906 PipelineCreateInfo::MultiSampleState& PipelineCreateInfo::MultiSampleState::operator= (const MultiSampleState & other)
910 rasterizationSamples = other.rasterizationSamples;
911 sampleShadingEnable = other.sampleShadingEnable;
912 minSampleShading = other.minSampleShading;
914 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
916 m_sampleMask = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
917 pSampleMask = &m_sampleMask[0];
922 PipelineCreateInfo::ColorBlendState::ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>& _attachments,
923 vk::VkBool32 _logicOpEnable,
924 vk::VkLogicOp _logicOp)
925 : m_attachments(_attachments)
927 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
930 logicOpEnable = _logicOpEnable;
932 attachmentCount = static_cast<deUint32>(m_attachments.size());
933 pAttachments = &m_attachments[0];
936 PipelineCreateInfo::ColorBlendState::ColorBlendState (deUint32 _attachmentCount,
937 const vk::VkPipelineColorBlendAttachmentState* _attachments,
938 vk::VkBool32 _logicOpEnable,
939 vk::VkLogicOp _logicOp)
940 : m_attachments(_attachments, _attachments + _attachmentCount)
942 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
944 logicOpEnable = _logicOpEnable;
946 attachmentCount = static_cast<deUint32>(m_attachments.size());
947 pAttachments = &m_attachments[0];
950 PipelineCreateInfo::ColorBlendState::ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo &createInfo)
951 : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
953 sType = createInfo.sType;
954 pNext = createInfo.pNext;
955 logicOpEnable = createInfo.logicOpEnable;
956 logicOp = createInfo.logicOp;
957 attachmentCount = static_cast<deUint32>(m_attachments.size());
958 pAttachments = &m_attachments[0];
961 PipelineCreateInfo::ColorBlendState::ColorBlendState (const ColorBlendState &createInfo, std::vector<float> _blendConstants)
962 : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
964 sType = createInfo.sType;
965 pNext = createInfo.pNext;
966 logicOpEnable = createInfo.logicOpEnable;
967 logicOp = createInfo.logicOp;
968 attachmentCount = static_cast<deUint32>(m_attachments.size());
969 pAttachments = &m_attachments[0];
970 deMemcpy(blendConstants, &_blendConstants[0], 4 * sizeof(float));
973 PipelineCreateInfo::ColorBlendState::Attachment::Attachment (vk::VkBool32 _blendEnable,
974 vk::VkBlendFactor _srcColorBlendFactor,
975 vk::VkBlendFactor _dstColorBlendFactor,
976 vk::VkBlendOp _colorBlendOp,
977 vk::VkBlendFactor _srcAlphaBlendFactor,
978 vk::VkBlendFactor _dstAlphaBlendFactor,
979 vk::VkBlendOp _alphaBlendOp,
980 deUint8 _colorWriteMask)
982 blendEnable = _blendEnable;
983 srcColorBlendFactor = _srcColorBlendFactor;
984 dstColorBlendFactor = _dstColorBlendFactor;
985 colorBlendOp = _colorBlendOp;
986 srcAlphaBlendFactor = _srcAlphaBlendFactor;
987 dstAlphaBlendFactor = _dstAlphaBlendFactor;
988 alphaBlendOp = _alphaBlendOp;
989 colorWriteMask = _colorWriteMask;
992 PipelineCreateInfo::DepthStencilState::StencilOpState::StencilOpState (vk::VkStencilOp _failOp,
993 vk::VkStencilOp _passOp,
994 vk::VkStencilOp _depthFailOp,
995 vk::VkCompareOp _compareOp,
996 deUint32 _compareMask,
1002 depthFailOp = _depthFailOp;
1003 compareOp = _compareOp;
1005 compareMask = _compareMask;
1006 writeMask = _writeMask;
1007 reference = _reference;
1010 PipelineCreateInfo::DepthStencilState::DepthStencilState (vk::VkBool32 _depthTestEnable,
1011 vk::VkBool32 _depthWriteEnable,
1012 vk::VkCompareOp _depthCompareOp,
1013 vk::VkBool32 _depthBoundsTestEnable,
1014 vk::VkBool32 _stencilTestEnable,
1015 StencilOpState _front,
1016 StencilOpState _back,
1017 float _minDepthBounds,
1018 float _maxDepthBounds)
1020 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
1023 depthTestEnable = _depthTestEnable;
1024 depthWriteEnable = _depthWriteEnable;
1025 depthCompareOp = _depthCompareOp;
1026 depthBoundsTestEnable = _depthBoundsTestEnable;
1027 stencilTestEnable = _stencilTestEnable;
1031 minDepthBounds = _minDepthBounds;
1032 maxDepthBounds = _maxDepthBounds;
1035 PipelineCreateInfo::DynamicState::DynamicState (const std::vector<vk::VkDynamicState>& _dynamicStates)
1037 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
1040 if (!_dynamicStates.size())
1042 for (size_t i = 0; i < vk::VK_DYNAMIC_STATE_LAST; ++i)
1044 m_dynamicStates.push_back(static_cast<vk::VkDynamicState>(i));
1048 m_dynamicStates = _dynamicStates;
1050 dynamicStateCount = static_cast<deUint32>(m_dynamicStates.size());
1051 pDynamicStates = &m_dynamicStates[0];
1054 PipelineCreateInfo::DynamicState::DynamicState (const DynamicState &other)
1056 sType = other.sType;
1057 pNext = other.pNext;
1059 dynamicStateCount = other.dynamicStateCount;
1061 m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1062 pDynamicStates = &m_dynamicStates[0];
1065 PipelineCreateInfo::DynamicState & PipelineCreateInfo::DynamicState::operator= (const DynamicState &other)
1067 sType = other.sType;
1068 pNext = other.pNext;
1070 dynamicStateCount = other.dynamicStateCount;
1072 m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1073 pDynamicStates = &m_dynamicStates[0];
1078 PipelineCreateInfo::PipelineCreateInfo (vk::VkPipelineLayout _layout,
1079 vk::VkRenderPass _renderPass,
1081 vk::VkPipelineCreateFlags _flags)
1083 deMemset(static_cast<vk::VkGraphicsPipelineCreateInfo *>(this), 0,
1084 sizeof(vk::VkGraphicsPipelineCreateInfo));
1086 sType = vk::VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
1089 renderPass = _renderPass;
1092 basePipelineHandle = DE_NULL;
1093 basePipelineIndex = 0;
1094 pDynamicState = DE_NULL;
1097 PipelineCreateInfo& PipelineCreateInfo::addShader (const vk::VkPipelineShaderStageCreateInfo &shader)
1099 m_shaders.push_back(shader);
1101 stageCount = static_cast<deUint32>(m_shaders.size());
1102 pStages = &m_shaders[0];
1107 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineVertexInputStateCreateInfo& state)
1109 m_vertexInputState = state;
1110 pVertexInputState = &m_vertexInputState;
1115 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state)
1117 m_inputAssemblyState = state;
1118 pInputAssemblyState = &m_inputAssemblyState;
1123 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineColorBlendStateCreateInfo& state)
1125 m_colorBlendStateAttachments = std::vector<vk::VkPipelineColorBlendAttachmentState>(state.pAttachments, state.pAttachments + state.attachmentCount);
1126 m_colorBlendState = state;
1127 m_colorBlendState.pAttachments = &m_colorBlendStateAttachments[0];
1128 pColorBlendState = &m_colorBlendState;
1133 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineViewportStateCreateInfo& state)
1135 m_viewports = std::vector<vk::VkViewport>(state.pViewports, state.pViewports + state.viewportCount);
1136 m_scissors = std::vector<vk::VkRect2D>(state.pScissors, state.pScissors + state.scissorCount);
1137 m_viewportState = state;
1138 m_viewportState.pViewports = &m_viewports[0];
1139 m_viewportState.pScissors = &m_scissors[0];
1140 pViewportState = &m_viewportState;
1145 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDepthStencilStateCreateInfo& state)
1147 m_dynamicDepthStencilState = state;
1148 pDepthStencilState = &m_dynamicDepthStencilState;
1152 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineTessellationStateCreateInfo& state)
1154 m_tessState = state;
1155 pTessellationState = &m_tessState;
1160 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineRasterizationStateCreateInfo& state)
1162 m_rasterState = state;
1163 pRasterizationState = &m_rasterState;
1168 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineMultisampleStateCreateInfo& state)
1171 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + state.rasterizationSamples) / ( sizeof(vk::VkSampleMask) * 8 );
1172 m_multisampleStateSampleMask = std::vector<vk::VkSampleMask>(state.pSampleMask, state.pSampleMask + sampleMaskArrayLen);
1173 m_multisampleState = state;
1174 m_multisampleState.pSampleMask = &m_multisampleStateSampleMask[0];
1175 pMultisampleState = &m_multisampleState;
1179 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDynamicStateCreateInfo& state)
1181 m_dynamicStates = std::vector<vk::VkDynamicState>(state.pDynamicStates, state.pDynamicStates + state.dynamicStateCount);
1182 m_dynamicState = state;
1183 m_dynamicState.pDynamicStates = &m_dynamicStates[0];
1184 pDynamicState = &m_dynamicState;
1189 SamplerCreateInfo::SamplerCreateInfo (vk::VkFilter _magFilter,
1190 vk::VkFilter _minFilter,
1191 vk::VkSamplerMipmapMode _mipmapMode,
1192 vk::VkSamplerAddressMode _addressModeU,
1193 vk::VkSamplerAddressMode _addressModeV,
1194 vk::VkSamplerAddressMode _addressModeW,
1196 float _maxAnisotropy,
1197 vk::VkBool32 _compareEnable,
1198 vk::VkCompareOp _compareOp,
1201 vk::VkBorderColor _borderColor,
1202 vk::VkBool32 _unnormalizedCoordinates)
1204 sType = vk::VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
1207 magFilter = _magFilter;
1208 minFilter = _minFilter;
1209 mipmapMode = _mipmapMode;
1210 addressModeU = _addressModeU;
1211 addressModeV = _addressModeV;
1212 addressModeW = _addressModeW;
1213 mipLodBias = _mipLodBias;
1214 maxAnisotropy = _maxAnisotropy;
1215 compareEnable = _compareEnable;
1216 compareOp = _compareOp;
1219 borderColor = _borderColor;
1220 unnormalizedCoordinates = _unnormalizedCoordinates;