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;
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());
332 if (attachmentCount) {
333 pAttachments = &m_attachmentsStructs[0];
337 pAttachments = DE_NULL;
340 subpassCount = static_cast<deUint32>(m_subpasses.size());
343 pSubpasses = &m_subpassesStructs[0];
347 pSubpasses = DE_NULL;
350 dependencyCount = static_cast<deUint32>(m_dependiences.size());
352 if (dependencyCount) {
353 pDependencies = &m_dependiencesStructs[0];
357 pDependencies = DE_NULL;
362 RenderPassCreateInfo::addAttachment (vk::VkAttachmentDescription attachment)
365 m_attachments.push_back(attachment);
366 m_attachmentsStructs = std::vector<vk::VkAttachmentDescription>(m_attachments.begin(), m_attachments.end());
367 attachmentCount = static_cast<deUint32>(m_attachments.size());
368 pAttachments = &m_attachmentsStructs[0];
372 RenderPassCreateInfo::addSubpass (vk::VkSubpassDescription subpass)
375 m_subpasses.push_back(subpass);
376 m_subpassesStructs = std::vector<vk::VkSubpassDescription>(m_subpasses.begin(), m_subpasses.end());
377 subpassCount = static_cast<deUint32>(m_subpasses.size());
378 pSubpasses = &m_subpassesStructs[0];
382 RenderPassCreateInfo::addDependency (vk::VkSubpassDependency dependency)
385 m_dependiences.push_back(dependency);
386 m_dependiencesStructs = std::vector<vk::VkSubpassDependency>(m_dependiences.begin(), m_dependiences.end());
388 dependencyCount = static_cast<deUint32>(m_dependiences.size());
389 pDependencies = &m_dependiencesStructs[0];
392 RenderPassBeginInfo::RenderPassBeginInfo (vk::VkRenderPass _renderPass,
393 vk::VkFramebuffer _framebuffer,
394 vk::VkRect2D _renderArea,
395 const std::vector<vk::VkClearValue>& _clearValues)
398 m_clearValues = _clearValues;
400 sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
402 renderPass = _renderPass;
403 framebuffer = _framebuffer;
404 renderArea = _renderArea;
405 clearValueCount = static_cast<deUint32>(m_clearValues.size());
406 pClearValues = m_clearValues.size() ? &m_clearValues[0] : DE_NULL;
409 CmdPoolCreateInfo::CmdPoolCreateInfo (deUint32 _queueFamilyIndex, unsigned int _flags)
411 sType = vk::VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
414 queueFamilyIndex = _queueFamilyIndex;
418 AttachmentDescription::AttachmentDescription (vk::VkFormat _format,
419 vk::VkSampleCountFlagBits _samples,
420 vk::VkAttachmentLoadOp _loadOp,
421 vk::VkAttachmentStoreOp _storeOp,
422 vk::VkAttachmentLoadOp _stencilLoadOp,
423 vk::VkAttachmentStoreOp _stencilStoreOp,
424 vk::VkImageLayout _initialLayout,
425 vk::VkImageLayout _finalLayout)
432 stencilLoadOp = _stencilLoadOp;
433 stencilStoreOp = _stencilStoreOp;
434 initialLayout = _initialLayout;
435 finalLayout = _finalLayout;
438 AttachmentDescription::AttachmentDescription (const vk::VkAttachmentDescription& rhs)
442 samples = rhs.samples;
444 storeOp = rhs.storeOp;
445 stencilLoadOp = rhs.stencilLoadOp;
446 stencilStoreOp = rhs.stencilStoreOp;
447 initialLayout = rhs.initialLayout;
448 finalLayout = rhs.finalLayout;
451 AttachmentReference::AttachmentReference (deUint32 _attachment, vk::VkImageLayout _layout)
453 attachment = _attachment;
457 AttachmentReference::AttachmentReference (void)
459 attachment = vk::VK_ATTACHMENT_UNUSED;
460 layout = vk::VK_IMAGE_LAYOUT_UNDEFINED;
463 SubpassDescription::SubpassDescription (vk::VkPipelineBindPoint _pipelineBindPoint,
464 vk::VkSubpassDescriptionFlags _flags,
465 deUint32 _inputAttachmentCount,
466 const vk::VkAttachmentReference* _inputAttachments,
467 deUint32 _colorAttachmentCount,
468 const vk::VkAttachmentReference* _colorAttachments,
469 const vk::VkAttachmentReference* _resolveAttachments,
470 vk::VkAttachmentReference depthStencilAttachment,
471 deUint32 _preserveAttachmentCount,
472 const vk::VkAttachmentReference* _preserveAttachments)
474 m_inputAttachments = std::vector<vk::VkAttachmentReference>(_inputAttachments, _inputAttachments + _inputAttachmentCount);
475 m_colorAttachments = std::vector<vk::VkAttachmentReference>(_colorAttachments, _colorAttachments + _colorAttachmentCount);
477 if (_resolveAttachments)
479 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(_resolveAttachments, _resolveAttachments + _colorAttachmentCount);
482 m_preserveAttachments = std::vector<vk::VkAttachmentReference>(_preserveAttachments, _preserveAttachments + _preserveAttachmentCount);
484 m_depthStencilAttachment = depthStencilAttachment;
487 pipelineBindPoint = _pipelineBindPoint;
488 inputAttachmentCount = _inputAttachmentCount;
489 pInputAttachments = DE_NULL;
490 colorAttachmentCount = _colorAttachmentCount;
491 pColorAttachments = DE_NULL;
492 pResolveAttachments = DE_NULL;
493 pDepthStencilAttachment = &m_depthStencilAttachment;
494 pPreserveAttachments = DE_NULL;
495 preserveAttachmentCount = _preserveAttachmentCount;
497 if (m_inputAttachments.size()) {
498 pInputAttachments = &m_inputAttachments[0];
501 if (m_colorAttachments.size()) {
502 pColorAttachments = &m_colorAttachments[0];
505 if (m_resolveAttachments.size()) {
506 pResolveAttachments = &m_resolveAttachments[0];
509 if (m_preserveAttachments.size()) {
510 pPreserveAttachments = &m_preserveAttachments[0];
514 SubpassDescription::SubpassDescription (const vk::VkSubpassDescription& rhs)
516 *static_cast<vk::VkSubpassDescription*>(this) = rhs;
518 m_inputAttachments = std::vector<vk::VkAttachmentReference>(
519 rhs.pInputAttachments, rhs.pInputAttachments + rhs.inputAttachmentCount);
521 m_colorAttachments = std::vector<vk::VkAttachmentReference>(
522 rhs.pColorAttachments, rhs.pColorAttachments + rhs.colorAttachmentCount);
524 if (rhs.pResolveAttachments) {
525 m_resolveAttachments = std::vector<vk::VkAttachmentReference>(
526 rhs.pResolveAttachments, rhs.pResolveAttachments + rhs.colorAttachmentCount);
528 m_preserveAttachments = std::vector<vk::VkAttachmentReference>(
529 rhs.pPreserveAttachments, rhs.pPreserveAttachments + rhs.preserveAttachmentCount);
531 if (rhs.pDepthStencilAttachment)
533 m_depthStencilAttachment = *rhs.pDepthStencilAttachment;
536 if (m_inputAttachments.size()) {
537 pInputAttachments = &m_inputAttachments[0];
539 if (m_colorAttachments.size()) {
540 pColorAttachments = &m_colorAttachments[0];
543 if (m_resolveAttachments.size()) {
544 pResolveAttachments = &m_resolveAttachments[0];
547 pDepthStencilAttachment = &m_depthStencilAttachment;
549 if (m_preserveAttachments.size()) {
550 pPreserveAttachments = &m_preserveAttachments[0];
554 SubpassDescription::SubpassDescription (const SubpassDescription& rhs) {
558 SubpassDescription& SubpassDescription::operator= (const SubpassDescription& rhs)
560 *static_cast<vk::VkSubpassDescription*>(this) = rhs;
562 m_inputAttachments = rhs.m_inputAttachments;
563 m_colorAttachments = rhs.m_colorAttachments;
564 m_resolveAttachments = rhs.m_resolveAttachments;
565 m_preserveAttachments = rhs.m_preserveAttachments;
566 m_depthStencilAttachment = rhs.m_depthStencilAttachment;
568 if (m_inputAttachments.size()) {
569 pInputAttachments = &m_inputAttachments[0];
571 if (m_colorAttachments.size()) {
572 pColorAttachments = &m_colorAttachments[0];
575 if (m_resolveAttachments.size()) {
576 pResolveAttachments = &m_resolveAttachments[0];
579 pDepthStencilAttachment = &m_depthStencilAttachment;
581 if (m_preserveAttachments.size()) {
582 pPreserveAttachments = &m_preserveAttachments[0];
588 SubpassDependency::SubpassDependency (deUint32 _srcSubpass,
589 deUint32 _dstSubpass,
590 vk::VkPipelineStageFlags _srcStageMask,
591 vk::VkPipelineStageFlags _dstStageMask,
592 vk::VkAccessFlags _srcAccessMask,
593 vk::VkAccessFlags _dstAccessMask,
594 vk::VkDependencyFlags _dependencyFlags)
596 srcSubpass = _srcSubpass;
597 dstSubpass = _dstSubpass;
598 srcStageMask = _srcStageMask;
599 dstStageMask = _dstStageMask;
600 srcAccessMask = _srcAccessMask;
601 dstAccessMask = _dstAccessMask;
602 dependencyFlags = _dependencyFlags;
605 SubpassDependency::SubpassDependency (const vk::VkSubpassDependency& rhs)
607 srcSubpass = rhs.srcSubpass;
608 dstSubpass = rhs.dstSubpass;
609 srcStageMask = rhs.srcStageMask;
610 dstStageMask = rhs.dstStageMask;
611 srcAccessMask = rhs.srcAccessMask;
612 dstAccessMask = rhs.dstAccessMask;
613 dependencyFlags = rhs.dependencyFlags;
616 CmdBufferBeginInfo::CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags _flags)
618 sType = vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
620 renderPass = DE_NULL;
622 framebuffer = DE_NULL;
624 occlusionQueryEnable = false;
626 pipelineStatistics = 0u;
629 CmdBufferBeginInfo::CmdBufferBeginInfo (vk::VkRenderPass _renderPass,
631 vk::VkFramebuffer _framebuffer,
632 vk::VkCommandBufferUsageFlags _flags,
633 bool _occlusionQueryEnable,
\r
634 vk::VkQueryControlFlags _queryFlags,
\r
635 vk::VkQueryPipelineStatisticFlags _pipelineStatistics)
638 sType = vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
640 renderPass = _renderPass;
642 framebuffer = _framebuffer;
644 occlusionQueryEnable = _occlusionQueryEnable;
645 queryFlags = _queryFlags;
646 pipelineStatistics = _pipelineStatistics;
649 DescriptorPoolCreateInfo::DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>& poolSizeCounts,
650 vk::VkDescriptorPoolCreateFlags _flags,
652 : m_poolSizeCounts(poolSizeCounts)
654 sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
658 poolSizeCount = static_cast<deUint32>(m_poolSizeCounts.size());
659 pPoolSizes = &m_poolSizeCounts[0];
662 DescriptorPoolCreateInfo& DescriptorPoolCreateInfo::addDescriptors (vk::VkDescriptorType type, deUint32 count)
664 vk::VkDescriptorPoolSize descriptorTypeCount = { type, count };
665 m_poolSizeCounts.push_back(descriptorTypeCount);
667 poolSizeCount = static_cast<deUint32>(m_poolSizeCounts.size());
668 pPoolSizes = &m_poolSizeCounts[0];
673 DescriptorSetLayoutCreateInfo::DescriptorSetLayoutCreateInfo (deUint32 _bindingCount, const vk::VkDescriptorSetLayoutBinding* _pBindings)
675 sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
678 bindingCount = _bindingCount;
679 pBinding = _pBindings;
682 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (deUint32 _descriptorSetCount,
683 const vk::VkDescriptorSetLayout* _pSetLayouts,
684 deUint32 _pushConstantRangeCount,
685 const vk::VkPushConstantRange* _pPushConstantRanges)
686 : m_pushConstantRanges(_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
688 for (unsigned int i = 0; i < _descriptorSetCount; i++)
690 m_setLayouts.push_back(_pSetLayouts[i]);
693 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
695 setLayoutCount = static_cast<deUint32>(m_setLayouts.size());
696 pSetLayouts = setLayoutCount > 0 ? &m_setLayouts[0] : DE_NULL;
697 pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
699 if (m_pushConstantRanges.size()) {
700 pPushConstantRanges = &m_pushConstantRanges[0];
704 pPushConstantRanges = DE_NULL;
708 PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (const std::vector<vk::VkDescriptorSetLayout>& setLayouts,
709 deUint32 _pushConstantRangeCount,
710 const vk::VkPushConstantRange* _pPushConstantRanges)
711 : m_setLayouts (setLayouts)
712 , m_pushConstantRanges (_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
714 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
717 setLayoutCount = static_cast<deUint32>(m_setLayouts.size());
721 pSetLayouts = &m_setLayouts[0];
725 pSetLayouts = DE_NULL;
728 pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
729 if (pushConstantRangeCount) {
730 pPushConstantRanges = &m_pushConstantRanges[0];
734 pPushConstantRanges = DE_NULL;
738 PipelineCreateInfo::PipelineShaderStage::PipelineShaderStage (vk::VkShaderModule _module, const char* _pName, vk::VkShaderStageFlagBits _stage)
740 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
746 pSpecializationInfo = DE_NULL;
749 PipelineCreateInfo::VertexInputState::VertexInputState (deUint32 _vertexBindingDescriptionCount,
750 const vk::VkVertexInputBindingDescription* _pVertexBindingDescriptions,
751 deUint32 _vertexAttributeDescriptionCount,
752 const vk::VkVertexInputAttributeDescription* _pVertexAttributeDescriptions)
754 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
757 vertexBindingDescriptionCount = _vertexBindingDescriptionCount;
758 pVertexBindingDescriptions = _pVertexBindingDescriptions;
759 vertexAttributeDescriptionCount = _vertexAttributeDescriptionCount;
760 pVertexAttributeDescriptions = _pVertexAttributeDescriptions;
763 PipelineCreateInfo::InputAssemblerState::InputAssemblerState (vk::VkPrimitiveTopology _topology,
764 vk::VkBool32 _primitiveRestartEnable)
766 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
769 topology = _topology;
770 primitiveRestartEnable = _primitiveRestartEnable;
773 PipelineCreateInfo::TesselationState::TesselationState (deUint32 _patchControlPoints)
775 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
777 patchControlPoints = _patchControlPoints;
780 PipelineCreateInfo::ViewportState::ViewportState (deUint32 _viewportCount,
781 std::vector<vk::VkViewport> _viewports,
782 std::vector<vk::VkRect2D> _scissors)
784 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
787 viewportCount = _viewportCount;
788 scissorCount = _viewportCount;
790 if (!_viewports.size())
792 m_viewports.resize(viewportCount);
793 deMemset(&m_viewports[0], 0, sizeof(m_viewports[0]) * m_viewports.size());
797 m_viewports = _viewports;
800 if (!_scissors.size())
802 m_scissors.resize(scissorCount);
803 deMemset(&m_scissors[0], 0, sizeof(m_scissors[0]) * m_scissors.size());
807 m_scissors = _scissors;
810 pViewports = &m_viewports[0];
811 pScissors = &m_scissors[0];
814 PipelineCreateInfo::ViewportState::ViewportState (const ViewportState& other)
818 viewportCount = other.viewportCount;
819 scissorCount = other.scissorCount;
821 m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + viewportCount);
822 m_scissors = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
824 pViewports = &m_viewports[0];
825 pScissors = &m_scissors[0];
828 PipelineCreateInfo::ViewportState& PipelineCreateInfo::ViewportState::operator= (const ViewportState& other)
832 viewportCount = other.viewportCount;
833 scissorCount = other.scissorCount;
835 m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + scissorCount);
836 m_scissors = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
838 pViewports = &m_viewports[0];
839 pScissors = &m_scissors[0];
843 PipelineCreateInfo::RasterizerState::RasterizerState (vk::VkBool32 _depthClampEnable,
844 vk::VkBool32 _rasterizerDiscardEnable,
845 vk::VkPolygonMode _polygonMode,
846 vk::VkCullModeFlags _cullMode,
847 vk::VkFrontFace _frontFace,
848 vk::VkBool32 _depthBiasEnable,
849 float _depthBiasConstantFactor,
850 float _depthBiasClamp,
851 float _depthBiasSlopeFactor,
854 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
857 depthClampEnable = _depthClampEnable;
858 rasterizerDiscardEnable = _rasterizerDiscardEnable;
859 polygonMode = _polygonMode;
860 cullMode = _cullMode;
861 frontFace = _frontFace;
863 depthBiasEnable = _depthBiasEnable;
864 depthBiasConstantFactor = _depthBiasConstantFactor;
865 depthBiasClamp = _depthBiasClamp;
866 depthBiasSlopeFactor = _depthBiasSlopeFactor;
867 lineWidth = _lineWidth;
870 PipelineCreateInfo::MultiSampleState::MultiSampleState (vk::VkSampleCountFlagBits _rasterizationSamples,
871 vk::VkBool32 _sampleShadingEnable,
872 float _minSampleShading,
873 const std::vector<vk::VkSampleMask>& _sampleMask,
874 bool _alphaToCoverageEnable,
875 bool _alphaToOneEnable)
876 : m_sampleMask(_sampleMask)
878 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
881 rasterizationSamples = _rasterizationSamples;
882 sampleShadingEnable = _sampleShadingEnable;
883 minSampleShading = _minSampleShading;
884 pSampleMask = &m_sampleMask[0];
885 alphaToCoverageEnable = _alphaToCoverageEnable;
886 alphaToOneEnable = _alphaToOneEnable;
889 PipelineCreateInfo::MultiSampleState::MultiSampleState (const MultiSampleState& other)
893 rasterizationSamples = other.rasterizationSamples;
894 sampleShadingEnable = other.sampleShadingEnable;
895 minSampleShading = other.minSampleShading;
897 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
899 m_sampleMask = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
900 pSampleMask = &m_sampleMask[0];
903 PipelineCreateInfo::MultiSampleState& PipelineCreateInfo::MultiSampleState::operator= (const MultiSampleState& other)
907 rasterizationSamples = other.rasterizationSamples;
908 sampleShadingEnable = other.sampleShadingEnable;
909 minSampleShading = other.minSampleShading;
911 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
913 m_sampleMask = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
914 pSampleMask = &m_sampleMask[0];
919 PipelineCreateInfo::ColorBlendState::ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>& _attachments,
920 vk::VkBool32 _logicOpEnable,
921 vk::VkLogicOp _logicOp)
922 : m_attachments(_attachments)
924 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
927 logicOpEnable = _logicOpEnable;
929 attachmentCount = static_cast<deUint32>(m_attachments.size());
930 pAttachments = &m_attachments[0];
933 PipelineCreateInfo::ColorBlendState::ColorBlendState (deUint32 _attachmentCount,
934 const vk::VkPipelineColorBlendAttachmentState* _attachments,
935 vk::VkBool32 _logicOpEnable,
936 vk::VkLogicOp _logicOp)
937 : m_attachments(_attachments, _attachments + _attachmentCount)
939 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
941 logicOpEnable = _logicOpEnable;
943 attachmentCount = static_cast<deUint32>(m_attachments.size());
944 pAttachments = &m_attachments[0];
947 PipelineCreateInfo::ColorBlendState::ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo& createInfo)
948 : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
950 sType = createInfo.sType;
951 pNext = createInfo.pNext;
952 logicOpEnable = createInfo.logicOpEnable;
953 logicOp = createInfo.logicOp;
954 attachmentCount = static_cast<deUint32>(m_attachments.size());
955 pAttachments = &m_attachments[0];
958 PipelineCreateInfo::ColorBlendState::ColorBlendState (const ColorBlendState& createInfo, std::vector<float> _blendConstants)
959 : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
961 sType = createInfo.sType;
962 pNext = createInfo.pNext;
963 logicOpEnable = createInfo.logicOpEnable;
964 logicOp = createInfo.logicOp;
965 attachmentCount = static_cast<deUint32>(m_attachments.size());
966 pAttachments = &m_attachments[0];
967 deMemcpy(blendConstants, &_blendConstants[0], 4 * sizeof(float));
970 PipelineCreateInfo::ColorBlendState::Attachment::Attachment (vk::VkBool32 _blendEnable,
971 vk::VkBlendFactor _srcColorBlendFactor,
972 vk::VkBlendFactor _dstColorBlendFactor,
973 vk::VkBlendOp _colorBlendOp,
974 vk::VkBlendFactor _srcAlphaBlendFactor,
975 vk::VkBlendFactor _dstAlphaBlendFactor,
976 vk::VkBlendOp _alphaBlendOp,
977 deUint8 _colorWriteMask)
979 blendEnable = _blendEnable;
980 srcColorBlendFactor = _srcColorBlendFactor;
981 dstColorBlendFactor = _dstColorBlendFactor;
982 colorBlendOp = _colorBlendOp;
983 srcAlphaBlendFactor = _srcAlphaBlendFactor;
984 dstAlphaBlendFactor = _dstAlphaBlendFactor;
985 alphaBlendOp = _alphaBlendOp;
986 colorWriteMask = _colorWriteMask;
989 PipelineCreateInfo::DepthStencilState::StencilOpState::StencilOpState (vk::VkStencilOp _failOp,
990 vk::VkStencilOp _passOp,
991 vk::VkStencilOp _depthFailOp,
992 vk::VkCompareOp _compareOp,
993 deUint32 _compareMask,
999 depthFailOp = _depthFailOp;
1000 compareOp = _compareOp;
1002 compareMask = _compareMask;
1003 writeMask = _writeMask;
1004 reference = _reference;
1007 PipelineCreateInfo::DepthStencilState::DepthStencilState (vk::VkBool32 _depthTestEnable,
1008 vk::VkBool32 _depthWriteEnable,
1009 vk::VkCompareOp _depthCompareOp,
1010 vk::VkBool32 _depthBoundsTestEnable,
1011 vk::VkBool32 _stencilTestEnable,
1012 StencilOpState _front,
1013 StencilOpState _back,
1014 float _minDepthBounds,
1015 float _maxDepthBounds)
1017 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
1020 depthTestEnable = _depthTestEnable;
1021 depthWriteEnable = _depthWriteEnable;
1022 depthCompareOp = _depthCompareOp;
1023 depthBoundsTestEnable = _depthBoundsTestEnable;
1024 stencilTestEnable = _stencilTestEnable;
1028 minDepthBounds = _minDepthBounds;
1029 maxDepthBounds = _maxDepthBounds;
1032 PipelineCreateInfo::DynamicState::DynamicState (const std::vector<vk::VkDynamicState>& _dynamicStates)
1034 sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
1037 if (!_dynamicStates.size())
1039 for (size_t i = 0; i < vk::VK_DYNAMIC_STATE_LAST; ++i)
1041 m_dynamicStates.push_back(static_cast<vk::VkDynamicState>(i));
1045 m_dynamicStates = _dynamicStates;
1047 dynamicStateCount = static_cast<deUint32>(m_dynamicStates.size());
1048 pDynamicStates = &m_dynamicStates[0];
1051 PipelineCreateInfo::DynamicState::DynamicState (const DynamicState &other)
1053 sType = other.sType;
1054 pNext = other.pNext;
1056 dynamicStateCount = other.dynamicStateCount;
1058 m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1059 pDynamicStates = &m_dynamicStates[0];
1062 PipelineCreateInfo::DynamicState& PipelineCreateInfo::DynamicState::operator= (const DynamicState& other)
1064 sType = other.sType;
1065 pNext = other.pNext;
1067 dynamicStateCount = other.dynamicStateCount;
1069 m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
1070 pDynamicStates = &m_dynamicStates[0];
1075 PipelineCreateInfo::PipelineCreateInfo (vk::VkPipelineLayout _layout,
1076 vk::VkRenderPass _renderPass,
1078 vk::VkPipelineCreateFlags _flags)
1080 deMemset(static_cast<vk::VkGraphicsPipelineCreateInfo *>(this), 0,
1081 sizeof(vk::VkGraphicsPipelineCreateInfo));
1083 sType = vk::VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
1086 renderPass = _renderPass;
1089 basePipelineHandle = DE_NULL;
1090 basePipelineIndex = 0;
1091 pDynamicState = DE_NULL;
1094 PipelineCreateInfo& PipelineCreateInfo::addShader (const vk::VkPipelineShaderStageCreateInfo& shader)
1096 m_shaders.push_back(shader);
1098 stageCount = static_cast<deUint32>(m_shaders.size());
1099 pStages = &m_shaders[0];
1104 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineVertexInputStateCreateInfo& state)
1106 m_vertexInputState = state;
1107 pVertexInputState = &m_vertexInputState;
1112 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state)
1114 m_inputAssemblyState = state;
1115 pInputAssemblyState = &m_inputAssemblyState;
1120 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineColorBlendStateCreateInfo& state)
1122 m_colorBlendStateAttachments = std::vector<vk::VkPipelineColorBlendAttachmentState>(state.pAttachments, state.pAttachments + state.attachmentCount);
1123 m_colorBlendState = state;
1124 m_colorBlendState.pAttachments = &m_colorBlendStateAttachments[0];
1125 pColorBlendState = &m_colorBlendState;
1130 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineViewportStateCreateInfo& state)
1132 m_viewports = std::vector<vk::VkViewport>(state.pViewports, state.pViewports + state.viewportCount);
1133 m_scissors = std::vector<vk::VkRect2D>(state.pScissors, state.pScissors + state.scissorCount);
1134 m_viewportState = state;
1135 m_viewportState.pViewports = &m_viewports[0];
1136 m_viewportState.pScissors = &m_scissors[0];
1137 pViewportState = &m_viewportState;
1142 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDepthStencilStateCreateInfo& state)
1144 m_dynamicDepthStencilState = state;
1145 pDepthStencilState = &m_dynamicDepthStencilState;
1149 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineTessellationStateCreateInfo& state)
1151 m_tessState = state;
1152 pTessellationState = &m_tessState;
1157 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineRasterizationStateCreateInfo& state)
1159 m_rasterState = state;
1160 pRasterizationState = &m_rasterState;
1165 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineMultisampleStateCreateInfo& state)
1168 const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + state.rasterizationSamples) / ( sizeof(vk::VkSampleMask) * 8 );
1169 m_multisampleStateSampleMask = std::vector<vk::VkSampleMask>(state.pSampleMask, state.pSampleMask + sampleMaskArrayLen);
1170 m_multisampleState = state;
1171 m_multisampleState.pSampleMask = &m_multisampleStateSampleMask[0];
1172 pMultisampleState = &m_multisampleState;
1176 PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDynamicStateCreateInfo& state)
1178 m_dynamicStates = std::vector<vk::VkDynamicState>(state.pDynamicStates, state.pDynamicStates + state.dynamicStateCount);
1179 m_dynamicState = state;
1180 m_dynamicState.pDynamicStates = &m_dynamicStates[0];
1181 pDynamicState = &m_dynamicState;
1186 SamplerCreateInfo::SamplerCreateInfo (vk::VkFilter _magFilter,
1187 vk::VkFilter _minFilter,
1188 vk::VkSamplerMipmapMode _mipmapMode,
1189 vk::VkSamplerAddressMode _addressModeU,
1190 vk::VkSamplerAddressMode _addressModeV,
1191 vk::VkSamplerAddressMode _addressModeW,
1193 float _maxAnisotropy,
1194 vk::VkBool32 _compareEnable,
1195 vk::VkCompareOp _compareOp,
1198 vk::VkBorderColor _borderColor,
1199 vk::VkBool32 _unnormalizedCoordinates)
1201 sType = vk::VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
1204 magFilter = _magFilter;
1205 minFilter = _minFilter;
1206 mipmapMode = _mipmapMode;
1207 addressModeU = _addressModeU;
1208 addressModeV = _addressModeV;
1209 addressModeW = _addressModeW;
1210 mipLodBias = _mipLodBias;
1211 maxAnisotropy = _maxAnisotropy;
1212 compareEnable = _compareEnable;
1213 compareOp = _compareOp;
1216 borderColor = _borderColor;
1217 unnormalizedCoordinates = _unnormalizedCoordinates;