1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2018 The Khronos Group Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief RenderPass test utils
22 *//*--------------------------------------------------------------------*/
24 #include "vktRenderPassTestsUtil.hpp"
25 #include "tcuTestCase.hpp"
26 #include "vkMemUtil.hpp"
27 #include "vkRefUtil.hpp"
38 AttachmentDescription1::AttachmentDescription1 (const void* pNext_,
39 VkAttachmentDescriptionFlags flags_,
41 VkSampleCountFlagBits samples_,
42 VkAttachmentLoadOp loadOp_,
43 VkAttachmentStoreOp storeOp_,
44 VkAttachmentLoadOp stencilLoadOp_,
45 VkAttachmentStoreOp stencilStoreOp_,
46 VkImageLayout initialLayout_,
47 VkImageLayout finalLayout_)
49 DE_ASSERT(pNext_ == DE_NULL);
51 // No sType field in this struct
58 stencilLoadOp = stencilLoadOp_;
59 stencilStoreOp = stencilStoreOp_;
60 initialLayout = initialLayout_;
61 finalLayout = finalLayout_;
64 AttachmentDescription2::AttachmentDescription2 (const void* pNext_,
65 VkAttachmentDescriptionFlags flags_,
67 VkSampleCountFlagBits samples_,
68 VkAttachmentLoadOp loadOp_,
69 VkAttachmentStoreOp storeOp_,
70 VkAttachmentLoadOp stencilLoadOp_,
71 VkAttachmentStoreOp stencilStoreOp_,
72 VkImageLayout initialLayout_,
73 VkImageLayout finalLayout_)
75 sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2;
82 stencilLoadOp = stencilLoadOp_;
83 stencilStoreOp = stencilStoreOp_;
84 initialLayout = initialLayout_;
85 finalLayout = finalLayout_;
88 AttachmentReference1::AttachmentReference1 (const void* pNext_,
90 VkImageLayout layout_,
91 VkImageAspectFlags aspectMask_)
93 DE_ASSERT(pNext_ == DE_NULL);
95 // No sType field in this struct
97 attachment = attachment_;
99 DE_UNREF (aspectMask_);
102 AttachmentReference2::AttachmentReference2 (const void* pNext_,
103 deUint32 attachment_,
104 VkImageLayout layout_,
105 VkImageAspectFlags aspectMask_)
107 sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2;
109 attachment = attachment_;
111 aspectMask = aspectMask_;
114 SubpassDescription1::SubpassDescription1 (const void* pNext_,
115 VkSubpassDescriptionFlags flags_,
116 VkPipelineBindPoint pipelineBindPoint_,
118 deUint32 inputAttachmentCount_,
119 const VkAttachmentReference* pInputAttachments_,
120 deUint32 colorAttachmentCount_,
121 const VkAttachmentReference* pColorAttachments_,
122 const VkAttachmentReference* pResolveAttachments_,
123 const VkAttachmentReference* pDepthStencilAttachment_,
124 deUint32 preserveAttachmentCount_,
125 const deUint32* pPreserveAttachments_)
127 DE_ASSERT(pNext_ == DE_NULL);
128 DE_ASSERT(viewMask_ == 0);
130 // No sType field in this struct
133 pipelineBindPoint = pipelineBindPoint_;
134 DE_UNREF (viewMask_);
135 inputAttachmentCount = inputAttachmentCount_;
136 pInputAttachments = pInputAttachments_;
137 colorAttachmentCount = colorAttachmentCount_;
138 pColorAttachments = pColorAttachments_;
139 pResolveAttachments = pResolveAttachments_;
140 pDepthStencilAttachment = pDepthStencilAttachment_;
141 preserveAttachmentCount = preserveAttachmentCount_;
142 pPreserveAttachments = pPreserveAttachments_;
145 SubpassDescription2::SubpassDescription2 (const void* pNext_,
146 VkSubpassDescriptionFlags flags_,
147 VkPipelineBindPoint pipelineBindPoint_,
149 deUint32 inputAttachmentCount_,
150 const VkAttachmentReference2* pInputAttachments_,
151 deUint32 colorAttachmentCount_,
152 const VkAttachmentReference2* pColorAttachments_,
153 const VkAttachmentReference2* pResolveAttachments_,
154 const VkAttachmentReference2* pDepthStencilAttachment_,
155 deUint32 preserveAttachmentCount_,
156 const deUint32* pPreserveAttachments_)
158 sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2;
161 pipelineBindPoint = pipelineBindPoint_;
162 viewMask = viewMask_;
163 inputAttachmentCount = inputAttachmentCount_;
164 pInputAttachments = pInputAttachments_;
165 colorAttachmentCount = colorAttachmentCount_;
166 pColorAttachments = pColorAttachments_;
167 pResolveAttachments = pResolveAttachments_;
168 pDepthStencilAttachment = pDepthStencilAttachment_;
169 preserveAttachmentCount = preserveAttachmentCount_;
170 pPreserveAttachments = pPreserveAttachments_;
173 SubpassDependency1::SubpassDependency1 (const void* pNext_,
174 deUint32 srcSubpass_,
175 deUint32 dstSubpass_,
176 VkPipelineStageFlags srcStageMask_,
177 VkPipelineStageFlags dstStageMask_,
178 VkAccessFlags srcAccessMask_,
179 VkAccessFlags dstAccessMask_,
180 VkDependencyFlags dependencyFlags_,
183 DE_ASSERT(pNext_ == DE_NULL);
184 DE_ASSERT(viewOffset_ == 0);
186 // No sType field in this struct
188 srcSubpass = srcSubpass_;
189 dstSubpass = dstSubpass_;
190 srcStageMask = srcStageMask_;
191 dstStageMask = dstStageMask_;
192 srcAccessMask = srcAccessMask_;
193 dstAccessMask = dstAccessMask_;
194 dependencyFlags = dependencyFlags_;
195 DE_UNREF (viewOffset_);
198 SubpassDependency2::SubpassDependency2 (const void* pNext_,
199 deUint32 srcSubpass_,
200 deUint32 dstSubpass_,
201 VkPipelineStageFlags srcStageMask_,
202 VkPipelineStageFlags dstStageMask_,
203 VkAccessFlags srcAccessMask_,
204 VkAccessFlags dstAccessMask_,
205 VkDependencyFlags dependencyFlags_,
208 sType = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2;
210 srcSubpass = srcSubpass_;
211 dstSubpass = dstSubpass_;
212 srcStageMask = srcStageMask_;
213 dstStageMask = dstStageMask_;
214 srcAccessMask = srcAccessMask_;
215 dstAccessMask = dstAccessMask_;
216 dependencyFlags = dependencyFlags_;
217 viewOffset = viewOffset_;
220 RenderPassCreateInfo1::RenderPassCreateInfo1 (const void* pNext_,
221 VkRenderPassCreateFlags flags_,
222 deUint32 attachmentCount_,
223 const VkAttachmentDescription* pAttachments_,
224 deUint32 subpassCount_,
225 const VkSubpassDescription* pSubpasses_,
226 deUint32 dependencyCount_,
227 const VkSubpassDependency* pDependencies_,
228 deUint32 correlatedViewMaskCount_,
229 const deUint32* pCorrelatedViewMasks_)
231 DE_ASSERT(correlatedViewMaskCount_ == 0);
232 DE_ASSERT(pCorrelatedViewMasks_ == DE_NULL);
234 sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
237 attachmentCount = attachmentCount_;
238 pAttachments = pAttachments_;
239 subpassCount = subpassCount_;
240 pSubpasses = pSubpasses_;
241 dependencyCount = dependencyCount_;
242 pDependencies = pDependencies_;
243 DE_UNREF (correlatedViewMaskCount_);
244 DE_UNREF (pCorrelatedViewMasks_);
247 Move<VkRenderPass> RenderPassCreateInfo1::createRenderPass (const DeviceInterface& vk, VkDevice device) const
249 return vk::createRenderPass(vk, device, this);
252 RenderPassCreateInfo2::RenderPassCreateInfo2 (const void* pNext_,
253 VkRenderPassCreateFlags flags_,
254 deUint32 attachmentCount_,
255 const VkAttachmentDescription2* pAttachments_,
256 deUint32 subpassCount_,
257 const VkSubpassDescription2* pSubpasses_,
258 deUint32 dependencyCount_,
259 const VkSubpassDependency2* pDependencies_,
260 deUint32 correlatedViewMaskCount_,
261 const deUint32* pCorrelatedViewMasks_)
263 sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2;
266 attachmentCount = attachmentCount_;
267 pAttachments = pAttachments_;
268 subpassCount = subpassCount_;
269 pSubpasses = pSubpasses_;
270 dependencyCount = dependencyCount_;
271 pDependencies = pDependencies_;
272 correlatedViewMaskCount = correlatedViewMaskCount_;
273 pCorrelatedViewMasks = pCorrelatedViewMasks_;
276 Move<VkRenderPass> RenderPassCreateInfo2::createRenderPass (const DeviceInterface& vk, VkDevice device) const
278 return vk::createRenderPass2(vk, device, this);
281 SubpassBeginInfo1::SubpassBeginInfo1 (const void* pNext_,
282 VkSubpassContents contents_)
283 : contents (contents_)
285 DE_ASSERT(pNext_ == DE_NULL);
290 SubpassBeginInfo2::SubpassBeginInfo2 (const void* pNext_,
291 VkSubpassContents contents_)
293 sType = VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO;
295 contents = contents_;
298 SubpassEndInfo1::SubpassEndInfo1 (const void* pNext_)
300 DE_ASSERT(pNext_ == DE_NULL);
305 SubpassEndInfo2::SubpassEndInfo2 (const void* pNext_)
307 sType = VK_STRUCTURE_TYPE_SUBPASS_END_INFO;
311 void RenderpassSubpass1::cmdBeginRenderPass (const DeviceInterface& vk,
312 VkCommandBuffer cmdBuffer,
313 const VkRenderPassBeginInfo* pRenderPassBegin,
314 const SubpassBeginInfo* pSubpassBeginInfo)
316 DE_ASSERT(pSubpassBeginInfo != DE_NULL);
318 vk.cmdBeginRenderPass(cmdBuffer, pRenderPassBegin, pSubpassBeginInfo->contents);
321 void RenderpassSubpass1::cmdNextSubpass (const DeviceInterface& vk,
322 VkCommandBuffer cmdBuffer,
323 const SubpassBeginInfo* pSubpassBeginInfo,
324 const SubpassEndInfo* pSubpassEndInfo)
326 DE_UNREF(pSubpassEndInfo);
327 DE_ASSERT(pSubpassBeginInfo != DE_NULL);
329 vk.cmdNextSubpass(cmdBuffer, pSubpassBeginInfo->contents);
332 void RenderpassSubpass1::cmdEndRenderPass (const DeviceInterface& vk,
333 VkCommandBuffer cmdBuffer,
334 const SubpassEndInfo* pSubpassEndInfo)
336 DE_UNREF(pSubpassEndInfo);
338 vk.cmdEndRenderPass(cmdBuffer);
341 void RenderpassSubpass2::cmdBeginRenderPass (const DeviceInterface& vk,
342 VkCommandBuffer cmdBuffer,
343 const VkRenderPassBeginInfo* pRenderPassBegin,
344 const SubpassBeginInfo* pSubpassBeginInfo)
346 vk.cmdBeginRenderPass2(cmdBuffer, pRenderPassBegin, pSubpassBeginInfo);
349 void RenderpassSubpass2::cmdNextSubpass (const DeviceInterface& vk,
350 VkCommandBuffer cmdBuffer,
351 const SubpassBeginInfo* pSubpassBeginInfo,
352 const SubpassEndInfo* pSubpassEndInfo)
354 DE_ASSERT(pSubpassBeginInfo != DE_NULL);
355 DE_ASSERT(pSubpassEndInfo != DE_NULL);
357 vk.cmdNextSubpass2(cmdBuffer, pSubpassBeginInfo, pSubpassEndInfo);
360 void RenderpassSubpass2::cmdEndRenderPass (const DeviceInterface& vk,
361 VkCommandBuffer cmdBuffer,
362 const SubpassEndInfo* pSubpassEndInfo)
364 DE_ASSERT(pSubpassEndInfo != DE_NULL);
366 vk.cmdEndRenderPass2(cmdBuffer, pSubpassEndInfo);
369 // For internal to RP/RP2 conversions
371 AttachmentReference::AttachmentReference (deUint32 attachment,
372 VkImageLayout layout,
373 VkImageAspectFlags aspectMask)
375 :m_attachment (attachment)
377 ,m_aspectMask (aspectMask)
381 deUint32 AttachmentReference::getAttachment (void) const
386 VkImageLayout AttachmentReference::getImageLayout (void) const
391 VkImageAspectFlags AttachmentReference::getAspectMask (void) const
396 void AttachmentReference::setImageLayout (VkImageLayout layout)
401 Subpass::Subpass (VkPipelineBindPoint pipelineBindPoint,
402 VkSubpassDescriptionFlags flags,
403 const std::vector<AttachmentReference>& inputAttachments,
404 const std::vector<AttachmentReference>& colorAttachments,
405 const std::vector<AttachmentReference>& resolveAttachments,
406 AttachmentReference depthStencilAttachment,
407 const std::vector<deUint32>& preserveAttachments,
410 :m_pipelineBindPoint (pipelineBindPoint)
412 ,m_inputAttachments (inputAttachments)
413 ,m_colorAttachments (colorAttachments)
414 ,m_resolveAttachments (resolveAttachments)
415 ,m_depthStencilAttachment (depthStencilAttachment)
416 ,m_preserveAttachments (preserveAttachments)
417 ,m_omitBlendState (omitBlendState)
421 VkPipelineBindPoint Subpass::getPipelineBindPoint (void) const
423 return m_pipelineBindPoint;
426 VkSubpassDescriptionFlags Subpass::getFlags (void) const
431 const std::vector<AttachmentReference>& Subpass::getInputAttachments (void) const
433 return m_inputAttachments;
436 const std::vector<AttachmentReference>& Subpass::getColorAttachments (void) const
438 return m_colorAttachments;
441 const std::vector<AttachmentReference>& Subpass::getResolveAttachments (void) const
443 return m_resolveAttachments;
446 const AttachmentReference& Subpass::getDepthStencilAttachment (void) const
448 return m_depthStencilAttachment;
451 const std::vector<deUint32>& Subpass::getPreserveAttachments (void) const
453 return m_preserveAttachments;
456 bool Subpass::getOmitBlendState (void) const
458 return m_omitBlendState;
461 SubpassDependency::SubpassDependency (deUint32 srcPass,
464 VkPipelineStageFlags srcStageMask,
465 VkPipelineStageFlags dstStageMask,
467 VkAccessFlags srcAccessMask,
468 VkAccessFlags dstAccessMask,
470 VkDependencyFlags flags)
472 : m_srcPass (srcPass)
473 , m_dstPass (dstPass)
475 , m_srcStageMask (srcStageMask)
476 , m_dstStageMask (dstStageMask)
478 , m_srcAccessMask (srcAccessMask)
479 , m_dstAccessMask (dstAccessMask)
484 deUint32 SubpassDependency::getSrcPass (void) const
489 deUint32 SubpassDependency::getDstPass (void) const
494 VkPipelineStageFlags SubpassDependency::getSrcStageMask (void) const
496 return m_srcStageMask;
499 VkPipelineStageFlags SubpassDependency::getDstStageMask (void) const
501 return m_dstStageMask;
504 VkAccessFlags SubpassDependency::getSrcAccessMask (void) const
506 return m_srcAccessMask;
509 VkAccessFlags SubpassDependency::getDstAccessMask (void) const
511 return m_dstAccessMask;
514 VkDependencyFlags SubpassDependency::getFlags (void) const
519 Attachment::Attachment (VkFormat format,
520 VkSampleCountFlagBits samples,
522 VkAttachmentLoadOp loadOp,
523 VkAttachmentStoreOp storeOp,
525 VkAttachmentLoadOp stencilLoadOp,
526 VkAttachmentStoreOp stencilStoreOp,
528 VkImageLayout initialLayout,
529 VkImageLayout finalLayout)
532 , m_samples (samples)
534 , m_storeOp (storeOp)
535 , m_stencilLoadOp (stencilLoadOp)
536 , m_stencilStoreOp (stencilStoreOp)
537 , m_initialLayout (initialLayout)
538 , m_finalLayout (finalLayout)
542 VkFormat Attachment::getFormat (void) const
547 VkSampleCountFlagBits Attachment::getSamples (void) const
552 VkAttachmentLoadOp Attachment::getLoadOp (void) const
557 VkAttachmentStoreOp Attachment::getStoreOp (void) const
562 VkAttachmentLoadOp Attachment::getStencilLoadOp (void) const
564 return m_stencilLoadOp;
567 VkAttachmentStoreOp Attachment::getStencilStoreOp (void) const
569 return m_stencilStoreOp;
572 VkImageLayout Attachment::getInitialLayout (void) const
574 return m_initialLayout;
577 VkImageLayout Attachment::getFinalLayout (void) const
579 return m_finalLayout;
582 RenderPass::RenderPass (const std::vector<Attachment>& attachments,
583 const std::vector<Subpass>& subpasses,
584 const std::vector<SubpassDependency>& dependencies,
585 const std::vector<VkInputAttachmentAspectReference> inputAspects)
587 : m_attachments (attachments)
588 , m_subpasses (subpasses)
589 , m_dependencies (dependencies)
590 , m_inputAspects (inputAspects)
594 const std::vector<Attachment>& RenderPass::getAttachments (void) const
596 return m_attachments;
599 const std::vector<Subpass>& RenderPass::getSubpasses (void) const
604 const std::vector<SubpassDependency>& RenderPass::getDependencies (void) const
606 return m_dependencies;
609 const std::vector<VkInputAttachmentAspectReference>& RenderPass::getInputAspects (void) const
611 return m_inputAspects;
614 template <typename AttachmentDesc>
615 AttachmentDesc createAttachmentDescription (const Attachment& attachment)
617 const AttachmentDesc attachmentDescription // VkAttachmentDescription || VkAttachmentDescription2
619 // || VkStructureType sType;
620 DE_NULL, // || const void* pNext;
621 0u, // VkAttachmentDescriptionFlags flags; || VkAttachmentDescriptionFlags flags;
622 attachment.getFormat(), // VkFormat format; || VkFormat format;
623 attachment.getSamples(), // VkSampleCountFlagBits samples; || VkSampleCountFlagBits samples;
624 attachment.getLoadOp(), // VkAttachmentLoadOp loadOp; || VkAttachmentLoadOp loadOp;
625 attachment.getStoreOp(), // VkAttachmentStoreOp storeOp; || VkAttachmentStoreOp storeOp;
626 attachment.getStencilLoadOp(), // VkAttachmentLoadOp stencilLoadOp; || VkAttachmentLoadOp stencilLoadOp;
627 attachment.getStencilStoreOp(), // VkAttachmentStoreOp stencilStoreOp; || VkAttachmentStoreOp stencilStoreOp;
628 attachment.getInitialLayout(), // VkImageLayout initialLayout; || VkImageLayout initialLayout;
629 attachment.getFinalLayout() // VkImageLayout finalLayout; || VkImageLayout finalLayout;
632 return attachmentDescription;
635 template <typename AttachmentRef>
636 AttachmentRef createAttachmentReference (const AttachmentReference& referenceInfo)
638 const AttachmentRef reference // VkAttachmentReference || VkAttachmentReference2
640 // || VkStructureType sType;
641 DE_NULL, // || const void* pNext;
642 referenceInfo.getAttachment(), // deUint32 attachment; || deUint32 attachment;
643 referenceInfo.getImageLayout(), // VkImageLayout layout; || VkImageLayout layout;
644 referenceInfo.getAspectMask() // || VkImageAspectFlags aspectMask;
650 template <typename SubpassDesc, typename AttachmentRef>
651 SubpassDesc createSubpassDescription (const Subpass& subpass,
652 std::vector<AttachmentRef>* attachmentReferenceLists,
653 std::vector<deUint32>* preserveAttachmentReferences)
655 std::vector<AttachmentRef>& inputAttachmentReferences = attachmentReferenceLists[0];
656 std::vector<AttachmentRef>& colorAttachmentReferences = attachmentReferenceLists[1];
657 std::vector<AttachmentRef>& resolveAttachmentReferences = attachmentReferenceLists[2];
658 std::vector<AttachmentRef>& depthStencilAttachmentReferences = attachmentReferenceLists[3];
660 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
661 colorAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getColorAttachments()[attachmentNdx]));
663 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
664 inputAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getInputAttachments()[attachmentNdx]));
666 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getResolveAttachments().size(); attachmentNdx++)
667 resolveAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getResolveAttachments()[attachmentNdx]));
669 depthStencilAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getDepthStencilAttachment()));
671 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getPreserveAttachments().size(); attachmentNdx++)
672 preserveAttachmentReferences->push_back(subpass.getPreserveAttachments()[attachmentNdx]);
674 DE_ASSERT(resolveAttachmentReferences.empty() || colorAttachmentReferences.size() == resolveAttachmentReferences.size());
677 const SubpassDesc subpassDescription // VkSubpassDescription || VkSubpassDescription2
679 // || VkStructureType sType;
680 DE_NULL, // || const void* pNext;
681 subpass.getFlags(), // VkSubpassDescriptionFlags flags; || VkSubpassDescriptionFlags flags;
682 subpass.getPipelineBindPoint(), // VkPipelineBindPoint pipelineBindPoint; || VkPipelineBindPoint pipelineBindPoint;
683 0u, // || deUint32 viewMask;
684 (deUint32)inputAttachmentReferences.size(), // deUint32 inputAttachmentCount; || deUint32 inputAttachmentCount;
685 inputAttachmentReferences.empty() ? DE_NULL : &inputAttachmentReferences[0], // const VkAttachmentReference* pInputAttachments; || const VkAttachmentReference2* pInputAttachments;
686 (deUint32)colorAttachmentReferences.size(), // deUint32 colorAttachmentCount; || deUint32 colorAttachmentCount;
687 colorAttachmentReferences.empty() ? DE_NULL : &colorAttachmentReferences[0], // const VkAttachmentReference* pColorAttachments; || const VkAttachmentReference2* pColorAttachments;
688 resolveAttachmentReferences.empty() ? DE_NULL : &resolveAttachmentReferences[0], // const VkAttachmentReference* pResolveAttachments; || const VkAttachmentReference2* pResolveAttachments;
689 &depthStencilAttachmentReferences[0], // const VkAttachmentReference* pDepthStencilAttachment; || const VkAttachmentReference2* pDepthStencilAttachment;
690 (deUint32)preserveAttachmentReferences->size(), // deUint32 preserveAttachmentCount; || deUint32 preserveAttachmentCount;
691 preserveAttachmentReferences->empty() ? DE_NULL : &(*preserveAttachmentReferences)[0] // const deUint32* pPreserveAttachments; || const deUint32* pPreserveAttachments;
694 return subpassDescription;
698 VkMemoryBarrier2KHR createMemoryBarrierFromSubpassDependency(const SubpassDependency& dependencyInfo)
702 VK_STRUCTURE_TYPE_MEMORY_BARRIER_2_KHR, // VkStructureType sType
703 DE_NULL, // const void* pNext
704 static_cast<VkPipelineStageFlags2KHR> (dependencyInfo.getSrcStageMask()), // VkPipelineStageFlags2KHR srcStageMask
705 static_cast<VkAccessFlags2KHR> (dependencyInfo.getSrcAccessMask()), // VkAccessFlags2KHR srcAccessMask
706 static_cast<VkPipelineStageFlags2KHR> (dependencyInfo.getDstStageMask()), // VkPipelineStageFlags2KHR dstStageMask
707 static_cast<VkAccessFlags2KHR> (dependencyInfo.getDstAccessMask()) // VkAccessFlags2KHR dstAccessMask
711 template <typename SubpassDep>
712 SubpassDep createSubpassDependency (const SubpassDependency& dependencyInfo, VkMemoryBarrier2KHR* memoryBarrierPtr = DE_NULL)
714 VkPipelineStageFlags srcStageMask = dependencyInfo.getSrcStageMask();
715 VkPipelineStageFlags dstStageMask = dependencyInfo.getDstStageMask();
716 VkAccessFlags srcAccessMask = dependencyInfo.getSrcAccessMask();
717 VkAccessFlags dstAccessMask = dependencyInfo.getDstAccessMask();
719 // If an instance of VkMemoryBarrier2KHR is included in the pNext chain, srcStageMask,
720 // dstStageMask, srcAccessMask and dstAccessMask parameters are ignored. The synchronization
721 // and access scopes instead are defined by the parameters of VkMemoryBarrier2KHR.
722 if (memoryBarrierPtr)
730 return // VkSubpassDependency || VkSubpassDependency2
732 memoryBarrierPtr, // || const void* pNext
733 dependencyInfo.getSrcPass(), // deUint32 srcSubpass || deUint32 srcSubpass
734 dependencyInfo.getDstPass(), // deUint32 dstSubpass || deUint32 dstSubpass
735 srcStageMask, // VkPipelineStageFlags srcStageMask || VkPipelineStageFlags srcStageMask
736 dstStageMask, // VkPipelineStageFlags dstStageMask || VkPipelineStageFlags dstStageMask
737 srcAccessMask, // VkAccessFlags srcAccessMask || VkAccessFlags srcAccessMask
738 dstAccessMask, // VkAccessFlags dstAccessMask || VkAccessFlags dstAccessMask
739 dependencyInfo.getFlags(), // VkDependencyFlags dependencyFlags || VkDependencyFlags dependencyFlags
740 0u // deInt32 viewOffset || deInt32 viewOffset
744 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> createRenderPassInputAttachmentAspectCreateInfo (const RenderPass& renderPassInfo)
746 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> result (DE_NULL);
748 if (!renderPassInfo.getInputAspects().empty())
750 const VkRenderPassInputAttachmentAspectCreateInfo inputAspectCreateInfo =
752 VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO,
755 (deUint32)renderPassInfo.getInputAspects().size(),
756 renderPassInfo.getInputAspects().data(),
759 result = de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo>(new VkRenderPassInputAttachmentAspectCreateInfo(inputAspectCreateInfo));
765 template<typename AttachmentDesc, typename AttachmentRef, typename SubpassDesc, typename SubpassDep, typename RenderPassCreateInfo>
766 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
768 const RenderPass& renderPassInfo,
769 SynchronizationType synchronizationType)
771 const size_t perSubpassAttachmentReferenceLists = 4;
772 std::vector<AttachmentDesc> attachments;
773 std::vector<SubpassDesc> subpasses;
774 std::vector<SubpassDep> dependencies;
775 std::vector<VkMemoryBarrier2KHR> memoryBarriers;
776 std::vector<std::vector<AttachmentRef> > attachmentReferenceLists(renderPassInfo.getSubpasses().size() * perSubpassAttachmentReferenceLists);
777 std::vector<std::vector<deUint32> > preserveAttachments(renderPassInfo.getSubpasses().size());
778 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> inputAspectCreateInfo(createRenderPassInputAttachmentAspectCreateInfo(renderPassInfo));
780 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
781 attachments.push_back(createAttachmentDescription<AttachmentDesc>(renderPassInfo.getAttachments()[attachmentNdx]));
783 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
784 subpasses.push_back(createSubpassDescription<SubpassDesc>(renderPassInfo.getSubpasses()[subpassNdx], &(attachmentReferenceLists[subpassNdx * perSubpassAttachmentReferenceLists]), &preserveAttachments[subpassNdx]));
786 if (synchronizationType == SYNCHRONIZATION_TYPE_SYNCHRONIZATION2)
788 // reserve space to avoid reallocation in vector that will invalidate pointers
789 memoryBarriers.reserve(renderPassInfo.getDependencies().size());
790 for (const auto& dependency : renderPassInfo.getDependencies())
792 memoryBarriers.push_back(createMemoryBarrierFromSubpassDependency(dependency));
793 dependencies.push_back(createSubpassDependency<SubpassDep>(dependency, &memoryBarriers.back()));
798 for (const auto& dependency : renderPassInfo.getDependencies())
799 dependencies.push_back(createSubpassDependency<SubpassDep>(dependency));
802 const RenderPassCreateInfo renderPassCreator // VkRenderPassCreateInfo || VkRenderPassCreateInfo2
804 // VkStructureType sType; || VkStructureType sType;
805 inputAspectCreateInfo.get(), // const void* pNext; || const void* pNext;
806 (VkRenderPassCreateFlags)0u, // VkRenderPassCreateFlags flags; || VkRenderPassCreateFlags flags;
807 (deUint32)attachments.size(), // deUint32 attachmentCount; || deUint32 attachmentCount;
808 (attachments.empty() ? DE_NULL : &attachments[0]), // const VkAttachmentDescription* pAttachments; || const VkAttachmentDescription2* pAttachments;
809 (deUint32)subpasses.size(), // deUint32 subpassCount; || deUint32 subpassCount;
810 (subpasses.empty() ? DE_NULL : &subpasses[0]), // const VkSubpassDescription* pSubpasses; || const VkSubpassDescription2* pSubpasses;
811 (deUint32)dependencies.size(), // deUint32 dependencyCount; || deUint32 dependencyCount;
812 (dependencies.empty() ? DE_NULL : &dependencies[0]), // const VkSubpassDependency* pDependencies; || const VkSubpassDependency2* pDependencies;
813 0u, // || deUint32 correlatedViewMaskCount;
814 DE_NULL // || const deUint32* pCorrelatedViewMasks;
817 return renderPassCreator.createRenderPass(vk, device);
820 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
822 const RenderPass& renderPassInfo,
823 RenderingType renderingType,
824 SynchronizationType synchronizationType)
826 switch (renderingType)
828 case RENDERING_TYPE_RENDERPASS_LEGACY:
829 return createRenderPass<AttachmentDescription1,
830 AttachmentReference1,
833 RenderPassCreateInfo1>(vk, device, renderPassInfo, SYNCHRONIZATION_TYPE_LEGACY);
834 case RENDERING_TYPE_RENDERPASS2:
835 return createRenderPass<AttachmentDescription2,
836 AttachmentReference2,
839 RenderPassCreateInfo2>(vk, device, renderPassInfo, synchronizationType);
841 TCU_THROW(InternalError, "Impossible");