xref: /aosp_15_r20/external/deqp/external/vulkancts/modules/vulkan/multiview/vktMultiViewRenderPassUtil.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2018 The Khronos Group Inc.
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  *//*!
20  * \file
21  * \brief RenderPass utils
22  *//*--------------------------------------------------------------------*/
23 
24 #include "vktMultiViewRenderPassUtil.hpp"
25 #include "tcuTestCase.hpp"
26 #include "vkRefUtil.hpp"
27 
28 using namespace vk;
29 
30 namespace vkt
31 {
32 namespace MultiView
33 {
34 
AttachmentDescription1(const void * pNext_,VkAttachmentDescriptionFlags flags_,VkFormat format_,VkSampleCountFlagBits samples_,VkAttachmentLoadOp loadOp_,VkAttachmentStoreOp storeOp_,VkAttachmentLoadOp stencilLoadOp_,VkAttachmentStoreOp stencilStoreOp_,VkImageLayout initialLayout_,VkImageLayout finalLayout_)35 AttachmentDescription1::AttachmentDescription1(const void *pNext_, VkAttachmentDescriptionFlags flags_,
36                                                VkFormat format_, VkSampleCountFlagBits samples_,
37                                                VkAttachmentLoadOp loadOp_, VkAttachmentStoreOp storeOp_,
38                                                VkAttachmentLoadOp stencilLoadOp_, VkAttachmentStoreOp stencilStoreOp_,
39                                                VkImageLayout initialLayout_, VkImageLayout finalLayout_)
40 {
41     DE_ASSERT(pNext_ == DE_NULL);
42 
43     // No sType field in this struct
44     DE_UNREF(pNext_);
45     flags          = flags_;
46     format         = format_;
47     samples        = samples_;
48     loadOp         = loadOp_;
49     storeOp        = storeOp_;
50     stencilLoadOp  = stencilLoadOp_;
51     stencilStoreOp = stencilStoreOp_;
52     initialLayout  = initialLayout_;
53     finalLayout    = finalLayout_;
54 }
55 
AttachmentDescription2(const void * pNext_,VkAttachmentDescriptionFlags flags_,VkFormat format_,VkSampleCountFlagBits samples_,VkAttachmentLoadOp loadOp_,VkAttachmentStoreOp storeOp_,VkAttachmentLoadOp stencilLoadOp_,VkAttachmentStoreOp stencilStoreOp_,VkImageLayout initialLayout_,VkImageLayout finalLayout_)56 AttachmentDescription2::AttachmentDescription2(const void *pNext_, VkAttachmentDescriptionFlags flags_,
57                                                VkFormat format_, VkSampleCountFlagBits samples_,
58                                                VkAttachmentLoadOp loadOp_, VkAttachmentStoreOp storeOp_,
59                                                VkAttachmentLoadOp stencilLoadOp_, VkAttachmentStoreOp stencilStoreOp_,
60                                                VkImageLayout initialLayout_, VkImageLayout finalLayout_)
61 {
62     sType          = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2;
63     pNext          = pNext_;
64     flags          = flags_;
65     format         = format_;
66     samples        = samples_;
67     loadOp         = loadOp_;
68     storeOp        = storeOp_;
69     stencilLoadOp  = stencilLoadOp_;
70     stencilStoreOp = stencilStoreOp_;
71     initialLayout  = initialLayout_;
72     finalLayout    = finalLayout_;
73 }
74 
AttachmentReference1(const void * pNext_,uint32_t attachment_,VkImageLayout layout_,VkImageAspectFlags aspectMask_)75 AttachmentReference1::AttachmentReference1(const void *pNext_, uint32_t attachment_, VkImageLayout layout_,
76                                            VkImageAspectFlags aspectMask_)
77 {
78     DE_ASSERT(pNext_ == DE_NULL);
79     DE_ASSERT(aspectMask_ == 0);
80 
81     // No sType field in this struct
82     DE_UNREF(pNext_);
83     attachment = attachment_;
84     layout     = layout_;
85     DE_UNREF(aspectMask_);
86 }
87 
AttachmentReference2(const void * pNext_,uint32_t attachment_,VkImageLayout layout_,VkImageAspectFlags aspectMask_)88 AttachmentReference2::AttachmentReference2(const void *pNext_, uint32_t attachment_, VkImageLayout layout_,
89                                            VkImageAspectFlags aspectMask_)
90 {
91     sType      = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2;
92     pNext      = pNext_;
93     attachment = attachment_;
94     layout     = layout_;
95     aspectMask = aspectMask_;
96 }
97 
SubpassDescription1(const void * pNext_,VkSubpassDescriptionFlags flags_,VkPipelineBindPoint pipelineBindPoint_,uint32_t viewMask_,uint32_t inputAttachmentCount_,const VkAttachmentReference * pInputAttachments_,uint32_t colorAttachmentCount_,const VkAttachmentReference * pColorAttachments_,const VkAttachmentReference * pResolveAttachments_,const VkAttachmentReference * pDepthStencilAttachment_,uint32_t preserveAttachmentCount_,const uint32_t * pPreserveAttachments_)98 SubpassDescription1::SubpassDescription1(
99     const void *pNext_, VkSubpassDescriptionFlags flags_, VkPipelineBindPoint pipelineBindPoint_, uint32_t viewMask_,
100     uint32_t inputAttachmentCount_, const VkAttachmentReference *pInputAttachments_, uint32_t colorAttachmentCount_,
101     const VkAttachmentReference *pColorAttachments_, const VkAttachmentReference *pResolveAttachments_,
102     const VkAttachmentReference *pDepthStencilAttachment_, uint32_t preserveAttachmentCount_,
103     const uint32_t *pPreserveAttachments_)
104 {
105     DE_ASSERT(pNext_ == DE_NULL);
106     DE_ASSERT(viewMask_ == 0);
107 
108     // No sType field in this struct
109     DE_UNREF(pNext_);
110     flags             = flags_;
111     pipelineBindPoint = pipelineBindPoint_;
112     DE_UNREF(viewMask_);
113     inputAttachmentCount    = inputAttachmentCount_;
114     pInputAttachments       = pInputAttachments_;
115     colorAttachmentCount    = colorAttachmentCount_;
116     pColorAttachments       = pColorAttachments_;
117     pResolveAttachments     = pResolveAttachments_;
118     pDepthStencilAttachment = pDepthStencilAttachment_;
119     preserveAttachmentCount = preserveAttachmentCount_;
120     pPreserveAttachments    = pPreserveAttachments_;
121 }
122 
SubpassDescription2(const void * pNext_,VkSubpassDescriptionFlags flags_,VkPipelineBindPoint pipelineBindPoint_,uint32_t viewMask_,uint32_t inputAttachmentCount_,const VkAttachmentReference2 * pInputAttachments_,uint32_t colorAttachmentCount_,const VkAttachmentReference2 * pColorAttachments_,const VkAttachmentReference2 * pResolveAttachments_,const VkAttachmentReference2 * pDepthStencilAttachment_,uint32_t preserveAttachmentCount_,const uint32_t * pPreserveAttachments_)123 SubpassDescription2::SubpassDescription2(
124     const void *pNext_, VkSubpassDescriptionFlags flags_, VkPipelineBindPoint pipelineBindPoint_, uint32_t viewMask_,
125     uint32_t inputAttachmentCount_, const VkAttachmentReference2 *pInputAttachments_, uint32_t colorAttachmentCount_,
126     const VkAttachmentReference2 *pColorAttachments_, const VkAttachmentReference2 *pResolveAttachments_,
127     const VkAttachmentReference2 *pDepthStencilAttachment_, uint32_t preserveAttachmentCount_,
128     const uint32_t *pPreserveAttachments_)
129 {
130     sType                   = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2;
131     pNext                   = pNext_;
132     flags                   = flags_;
133     pipelineBindPoint       = pipelineBindPoint_;
134     viewMask                = 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_;
143 }
144 
SubpassDependency1(const void * pNext_,uint32_t srcSubpass_,uint32_t dstSubpass_,VkPipelineStageFlags srcStageMask_,VkPipelineStageFlags dstStageMask_,VkAccessFlags srcAccessMask_,VkAccessFlags dstAccessMask_,VkDependencyFlags dependencyFlags_,int32_t viewOffset_)145 SubpassDependency1::SubpassDependency1(const void *pNext_, uint32_t srcSubpass_, uint32_t dstSubpass_,
146                                        VkPipelineStageFlags srcStageMask_, VkPipelineStageFlags dstStageMask_,
147                                        VkAccessFlags srcAccessMask_, VkAccessFlags dstAccessMask_,
148                                        VkDependencyFlags dependencyFlags_, int32_t viewOffset_)
149 {
150     DE_ASSERT(pNext_ == DE_NULL);
151     DE_ASSERT(viewOffset_ == 0);
152 
153     // No sType field in this struct
154     DE_UNREF(pNext_);
155     srcSubpass      = srcSubpass_;
156     dstSubpass      = dstSubpass_;
157     srcStageMask    = srcStageMask_;
158     dstStageMask    = dstStageMask_;
159     srcAccessMask   = srcAccessMask_;
160     dstAccessMask   = dstAccessMask_;
161     dependencyFlags = dependencyFlags_;
162     DE_UNREF(viewOffset_);
163 }
164 
SubpassDependency2(const void * pNext_,uint32_t srcSubpass_,uint32_t dstSubpass_,VkPipelineStageFlags srcStageMask_,VkPipelineStageFlags dstStageMask_,VkAccessFlags srcAccessMask_,VkAccessFlags dstAccessMask_,VkDependencyFlags dependencyFlags_,int32_t viewOffset_)165 SubpassDependency2::SubpassDependency2(const void *pNext_, uint32_t srcSubpass_, uint32_t dstSubpass_,
166                                        VkPipelineStageFlags srcStageMask_, VkPipelineStageFlags dstStageMask_,
167                                        VkAccessFlags srcAccessMask_, VkAccessFlags dstAccessMask_,
168                                        VkDependencyFlags dependencyFlags_, int32_t viewOffset_)
169 {
170     sType           = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2;
171     pNext           = pNext_;
172     srcSubpass      = srcSubpass_;
173     dstSubpass      = dstSubpass_;
174     srcStageMask    = srcStageMask_;
175     dstStageMask    = dstStageMask_;
176     srcAccessMask   = srcAccessMask_;
177     dstAccessMask   = dstAccessMask_;
178     dependencyFlags = dependencyFlags_;
179     viewOffset      = viewOffset_;
180 }
181 
RenderPassCreateInfo1(const void * pNext_,VkRenderPassCreateFlags flags_,uint32_t attachmentCount_,const VkAttachmentDescription * pAttachments_,uint32_t subpassCount_,const VkSubpassDescription * pSubpasses_,uint32_t dependencyCount_,const VkSubpassDependency * pDependencies_,uint32_t correlatedViewMaskCount_,const uint32_t * pCorrelatedViewMasks_)182 RenderPassCreateInfo1::RenderPassCreateInfo1(const void *pNext_, VkRenderPassCreateFlags flags_,
183                                              uint32_t attachmentCount_, const VkAttachmentDescription *pAttachments_,
184                                              uint32_t subpassCount_, const VkSubpassDescription *pSubpasses_,
185                                              uint32_t dependencyCount_, const VkSubpassDependency *pDependencies_,
186                                              uint32_t correlatedViewMaskCount_, const uint32_t *pCorrelatedViewMasks_)
187 {
188     DE_ASSERT(correlatedViewMaskCount_ == 0);
189     DE_ASSERT(pCorrelatedViewMasks_ == DE_NULL);
190 
191     sType           = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
192     pNext           = pNext_;
193     flags           = flags_;
194     attachmentCount = attachmentCount_;
195     pAttachments    = pAttachments_;
196     subpassCount    = subpassCount_;
197     pSubpasses      = pSubpasses_;
198     dependencyCount = dependencyCount_;
199     pDependencies   = pDependencies_;
200     DE_UNREF(correlatedViewMaskCount_);
201     DE_UNREF(pCorrelatedViewMasks_);
202 }
203 
createRenderPass(const DeviceInterface & vk,VkDevice device) const204 Move<VkRenderPass> RenderPassCreateInfo1::createRenderPass(const DeviceInterface &vk, VkDevice device) const
205 {
206     return vk::createRenderPass(vk, device, this);
207 }
208 
RenderPassCreateInfo2(const void * pNext_,VkRenderPassCreateFlags flags_,uint32_t attachmentCount_,const VkAttachmentDescription2 * pAttachments_,uint32_t subpassCount_,const VkSubpassDescription2 * pSubpasses_,uint32_t dependencyCount_,const VkSubpassDependency2 * pDependencies_,uint32_t correlatedViewMaskCount_,const uint32_t * pCorrelatedViewMasks_)209 RenderPassCreateInfo2::RenderPassCreateInfo2(const void *pNext_, VkRenderPassCreateFlags flags_,
210                                              uint32_t attachmentCount_, const VkAttachmentDescription2 *pAttachments_,
211                                              uint32_t subpassCount_, const VkSubpassDescription2 *pSubpasses_,
212                                              uint32_t dependencyCount_, const VkSubpassDependency2 *pDependencies_,
213                                              uint32_t correlatedViewMaskCount_, const uint32_t *pCorrelatedViewMasks_)
214 {
215     sType                   = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2;
216     pNext                   = pNext_;
217     flags                   = flags_;
218     attachmentCount         = attachmentCount_;
219     pAttachments            = pAttachments_;
220     subpassCount            = subpassCount_;
221     pSubpasses              = pSubpasses_;
222     dependencyCount         = dependencyCount_;
223     pDependencies           = pDependencies_;
224     correlatedViewMaskCount = correlatedViewMaskCount_;
225     pCorrelatedViewMasks    = pCorrelatedViewMasks_;
226 }
227 
createRenderPass(const DeviceInterface & vk,VkDevice device) const228 Move<VkRenderPass> RenderPassCreateInfo2::createRenderPass(const DeviceInterface &vk, VkDevice device) const
229 {
230     return vk::createRenderPass2(vk, device, this);
231 }
232 
SubpassBeginInfo1(const void * pNext_,VkSubpassContents contents_)233 SubpassBeginInfo1::SubpassBeginInfo1(const void *pNext_, VkSubpassContents contents_) : contents(contents_)
234 {
235     DE_ASSERT(pNext_ == DE_NULL);
236 
237     DE_UNREF(pNext_);
238 }
239 
SubpassBeginInfo2(const void * pNext_,VkSubpassContents contents_)240 SubpassBeginInfo2::SubpassBeginInfo2(const void *pNext_, VkSubpassContents contents_)
241 {
242     sType    = VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO;
243     pNext    = pNext_;
244     contents = contents_;
245 }
246 
SubpassEndInfo1(const void * pNext_)247 SubpassEndInfo1::SubpassEndInfo1(const void *pNext_)
248 {
249     DE_ASSERT(pNext_ == DE_NULL);
250 
251     DE_UNREF(pNext_);
252 }
253 
SubpassEndInfo2(const void * pNext_)254 SubpassEndInfo2::SubpassEndInfo2(const void *pNext_)
255 {
256     sType = VK_STRUCTURE_TYPE_SUBPASS_END_INFO;
257     pNext = pNext_;
258 }
259 
cmdBeginRenderPass(const DeviceInterface & vk,VkCommandBuffer cmdBuffer,const VkRenderPassBeginInfo * pRenderPassBegin,const SubpassBeginInfo * pSubpassBeginInfo)260 void RenderpassSubpass1::cmdBeginRenderPass(const DeviceInterface &vk, VkCommandBuffer cmdBuffer,
261                                             const VkRenderPassBeginInfo *pRenderPassBegin,
262                                             const SubpassBeginInfo *pSubpassBeginInfo)
263 {
264     DE_ASSERT(pSubpassBeginInfo != DE_NULL);
265 
266     vk.cmdBeginRenderPass(cmdBuffer, pRenderPassBegin, pSubpassBeginInfo->contents);
267 }
268 
cmdNextSubpass(const DeviceInterface & vk,VkCommandBuffer cmdBuffer,const SubpassBeginInfo * pSubpassBeginInfo,const SubpassEndInfo * pSubpassEndInfo)269 void RenderpassSubpass1::cmdNextSubpass(const DeviceInterface &vk, VkCommandBuffer cmdBuffer,
270                                         const SubpassBeginInfo *pSubpassBeginInfo,
271                                         const SubpassEndInfo *pSubpassEndInfo)
272 {
273     DE_UNREF(pSubpassEndInfo);
274     DE_ASSERT(pSubpassBeginInfo != DE_NULL);
275 
276     vk.cmdNextSubpass(cmdBuffer, pSubpassBeginInfo->contents);
277 }
278 
cmdEndRenderPass(const DeviceInterface & vk,VkCommandBuffer cmdBuffer,const SubpassEndInfo * pSubpassEndInfo)279 void RenderpassSubpass1::cmdEndRenderPass(const DeviceInterface &vk, VkCommandBuffer cmdBuffer,
280                                           const SubpassEndInfo *pSubpassEndInfo)
281 {
282     DE_UNREF(pSubpassEndInfo);
283 
284     vk.cmdEndRenderPass(cmdBuffer);
285 }
286 
cmdBeginRenderPass(const DeviceInterface & vk,VkCommandBuffer cmdBuffer,const VkRenderPassBeginInfo * pRenderPassBegin,const SubpassBeginInfo * pSubpassBeginInfo)287 void RenderpassSubpass2::cmdBeginRenderPass(const DeviceInterface &vk, VkCommandBuffer cmdBuffer,
288                                             const VkRenderPassBeginInfo *pRenderPassBegin,
289                                             const SubpassBeginInfo *pSubpassBeginInfo)
290 {
291     vk.cmdBeginRenderPass2(cmdBuffer, pRenderPassBegin, pSubpassBeginInfo);
292 }
293 
cmdNextSubpass(const DeviceInterface & vk,VkCommandBuffer cmdBuffer,const SubpassBeginInfo * pSubpassBeginInfo,const SubpassEndInfo * pSubpassEndInfo)294 void RenderpassSubpass2::cmdNextSubpass(const DeviceInterface &vk, VkCommandBuffer cmdBuffer,
295                                         const SubpassBeginInfo *pSubpassBeginInfo,
296                                         const SubpassEndInfo *pSubpassEndInfo)
297 {
298     DE_ASSERT(pSubpassBeginInfo != DE_NULL);
299     DE_ASSERT(pSubpassEndInfo != DE_NULL);
300 
301     vk.cmdNextSubpass2(cmdBuffer, pSubpassBeginInfo, pSubpassEndInfo);
302 }
303 
cmdEndRenderPass(const DeviceInterface & vk,VkCommandBuffer cmdBuffer,const SubpassEndInfo * pSubpassEndInfo)304 void RenderpassSubpass2::cmdEndRenderPass(const DeviceInterface &vk, VkCommandBuffer cmdBuffer,
305                                           const SubpassEndInfo *pSubpassEndInfo)
306 {
307     DE_ASSERT(pSubpassEndInfo != DE_NULL);
308 
309     vk.cmdEndRenderPass2(cmdBuffer, pSubpassEndInfo);
310 }
311 
312 } // namespace MultiView
313 
314 } // namespace vkt
315