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 test utils
22 *//*--------------------------------------------------------------------*/
23
24 #include "vktRenderPassTestsUtil.hpp"
25 #include "tcuTestCase.hpp"
26 #include "vkMemUtil.hpp"
27 #include "vkRefUtil.hpp"
28
29 #include <vector>
30
31 using namespace vk;
32
33 namespace vkt
34 {
35 namespace renderpass
36 {
37
AttachmentDescription1(const void * pNext_,VkAttachmentDescriptionFlags flags_,VkFormat format_,VkSampleCountFlagBits samples_,VkAttachmentLoadOp loadOp_,VkAttachmentStoreOp storeOp_,VkAttachmentLoadOp stencilLoadOp_,VkAttachmentStoreOp stencilStoreOp_,VkImageLayout initialLayout_,VkImageLayout finalLayout_)38 AttachmentDescription1::AttachmentDescription1 (const void* pNext_,
39 VkAttachmentDescriptionFlags flags_,
40 VkFormat format_,
41 VkSampleCountFlagBits samples_,
42 VkAttachmentLoadOp loadOp_,
43 VkAttachmentStoreOp storeOp_,
44 VkAttachmentLoadOp stencilLoadOp_,
45 VkAttachmentStoreOp stencilStoreOp_,
46 VkImageLayout initialLayout_,
47 VkImageLayout finalLayout_)
48 {
49 DE_ASSERT(pNext_ == DE_NULL);
50
51 // No sType field in this struct
52 DE_UNREF(pNext_);
53 flags = flags_;
54 format = format_;
55 samples = samples_;
56 loadOp = loadOp_;
57 storeOp = storeOp_;
58 stencilLoadOp = stencilLoadOp_;
59 stencilStoreOp = stencilStoreOp_;
60 initialLayout = initialLayout_;
61 finalLayout = finalLayout_;
62 }
63
AttachmentDescription2(const void * pNext_,VkAttachmentDescriptionFlags flags_,VkFormat format_,VkSampleCountFlagBits samples_,VkAttachmentLoadOp loadOp_,VkAttachmentStoreOp storeOp_,VkAttachmentLoadOp stencilLoadOp_,VkAttachmentStoreOp stencilStoreOp_,VkImageLayout initialLayout_,VkImageLayout finalLayout_)64 AttachmentDescription2::AttachmentDescription2 (const void* pNext_,
65 VkAttachmentDescriptionFlags flags_,
66 VkFormat format_,
67 VkSampleCountFlagBits samples_,
68 VkAttachmentLoadOp loadOp_,
69 VkAttachmentStoreOp storeOp_,
70 VkAttachmentLoadOp stencilLoadOp_,
71 VkAttachmentStoreOp stencilStoreOp_,
72 VkImageLayout initialLayout_,
73 VkImageLayout finalLayout_)
74 {
75 sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2_KHR;
76 pNext = pNext_;
77 flags = flags_;
78 format = format_;
79 samples = samples_;
80 loadOp = loadOp_;
81 storeOp = storeOp_;
82 stencilLoadOp = stencilLoadOp_;
83 stencilStoreOp = stencilStoreOp_;
84 initialLayout = initialLayout_;
85 finalLayout = finalLayout_;
86 }
87
AttachmentReference1(const void * pNext_,deUint32 attachment_,VkImageLayout layout_,VkImageAspectFlags aspectMask_)88 AttachmentReference1::AttachmentReference1 (const void* pNext_,
89 deUint32 attachment_,
90 VkImageLayout layout_,
91 VkImageAspectFlags aspectMask_)
92 {
93 DE_ASSERT(pNext_ == DE_NULL);
94 DE_ASSERT(aspectMask_ == 0);
95
96 // No sType field in this struct
97 DE_UNREF (pNext_);
98 attachment = attachment_;
99 layout = layout_;
100 DE_UNREF (aspectMask_);
101 }
102
AttachmentReference2(const void * pNext_,deUint32 attachment_,VkImageLayout layout_,VkImageAspectFlags aspectMask_)103 AttachmentReference2::AttachmentReference2 (const void* pNext_,
104 deUint32 attachment_,
105 VkImageLayout layout_,
106 VkImageAspectFlags aspectMask_)
107 {
108 sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2_KHR;
109 pNext = pNext_;
110 attachment = attachment_;
111 layout = layout_;
112 aspectMask = aspectMask_;
113 }
114
SubpassDescription1(const void * pNext_,VkSubpassDescriptionFlags flags_,VkPipelineBindPoint pipelineBindPoint_,deUint32 viewMask_,deUint32 inputAttachmentCount_,const VkAttachmentReference * pInputAttachments_,deUint32 colorAttachmentCount_,const VkAttachmentReference * pColorAttachments_,const VkAttachmentReference * pResolveAttachments_,const VkAttachmentReference * pDepthStencilAttachment_,deUint32 preserveAttachmentCount_,const deUint32 * pPreserveAttachments_)115 SubpassDescription1::SubpassDescription1 (const void* pNext_,
116 VkSubpassDescriptionFlags flags_,
117 VkPipelineBindPoint pipelineBindPoint_,
118 deUint32 viewMask_,
119 deUint32 inputAttachmentCount_,
120 const VkAttachmentReference* pInputAttachments_,
121 deUint32 colorAttachmentCount_,
122 const VkAttachmentReference* pColorAttachments_,
123 const VkAttachmentReference* pResolveAttachments_,
124 const VkAttachmentReference* pDepthStencilAttachment_,
125 deUint32 preserveAttachmentCount_,
126 const deUint32* pPreserveAttachments_)
127 {
128 DE_ASSERT(pNext_ == DE_NULL);
129 DE_ASSERT(viewMask_ == 0);
130
131 // No sType field in this struct
132 DE_UNREF (pNext_);
133 flags = flags_;
134 pipelineBindPoint = pipelineBindPoint_;
135 DE_UNREF (viewMask_);
136 inputAttachmentCount = inputAttachmentCount_;
137 pInputAttachments = pInputAttachments_;
138 colorAttachmentCount = colorAttachmentCount_;
139 pColorAttachments = pColorAttachments_;
140 pResolveAttachments = pResolveAttachments_;
141 pDepthStencilAttachment = pDepthStencilAttachment_;
142 preserveAttachmentCount = preserveAttachmentCount_;
143 pPreserveAttachments = pPreserveAttachments_;
144 }
145
SubpassDescription2(const void * pNext_,VkSubpassDescriptionFlags flags_,VkPipelineBindPoint pipelineBindPoint_,deUint32 viewMask_,deUint32 inputAttachmentCount_,const VkAttachmentReference2KHR * pInputAttachments_,deUint32 colorAttachmentCount_,const VkAttachmentReference2KHR * pColorAttachments_,const VkAttachmentReference2KHR * pResolveAttachments_,const VkAttachmentReference2KHR * pDepthStencilAttachment_,deUint32 preserveAttachmentCount_,const deUint32 * pPreserveAttachments_)146 SubpassDescription2::SubpassDescription2 (const void* pNext_,
147 VkSubpassDescriptionFlags flags_,
148 VkPipelineBindPoint pipelineBindPoint_,
149 deUint32 viewMask_,
150 deUint32 inputAttachmentCount_,
151 const VkAttachmentReference2KHR* pInputAttachments_,
152 deUint32 colorAttachmentCount_,
153 const VkAttachmentReference2KHR* pColorAttachments_,
154 const VkAttachmentReference2KHR* pResolveAttachments_,
155 const VkAttachmentReference2KHR* pDepthStencilAttachment_,
156 deUint32 preserveAttachmentCount_,
157 const deUint32* pPreserveAttachments_)
158 {
159 sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2_KHR;
160 pNext = pNext_;
161 flags = flags_;
162 pipelineBindPoint = pipelineBindPoint_;
163 viewMask = viewMask_;
164 inputAttachmentCount = inputAttachmentCount_;
165 pInputAttachments = pInputAttachments_;
166 colorAttachmentCount = colorAttachmentCount_;
167 pColorAttachments = pColorAttachments_;
168 pResolveAttachments = pResolveAttachments_;
169 pDepthStencilAttachment = pDepthStencilAttachment_;
170 preserveAttachmentCount = preserveAttachmentCount_;
171 pPreserveAttachments = pPreserveAttachments_;
172 }
173
SubpassDependency1(const void * pNext_,deUint32 srcSubpass_,deUint32 dstSubpass_,VkPipelineStageFlags srcStageMask_,VkPipelineStageFlags dstStageMask_,VkAccessFlags srcAccessMask_,VkAccessFlags dstAccessMask_,VkDependencyFlags dependencyFlags_,deInt32 viewOffset_)174 SubpassDependency1::SubpassDependency1 (const void* pNext_,
175 deUint32 srcSubpass_,
176 deUint32 dstSubpass_,
177 VkPipelineStageFlags srcStageMask_,
178 VkPipelineStageFlags dstStageMask_,
179 VkAccessFlags srcAccessMask_,
180 VkAccessFlags dstAccessMask_,
181 VkDependencyFlags dependencyFlags_,
182 deInt32 viewOffset_)
183 {
184 DE_ASSERT(pNext_ == DE_NULL);
185 DE_ASSERT(viewOffset_ == 0);
186
187 // No sType field in this struct
188 DE_UNREF (pNext_);
189 srcSubpass = srcSubpass_;
190 dstSubpass = dstSubpass_;
191 srcStageMask = srcStageMask_;
192 dstStageMask = dstStageMask_;
193 srcAccessMask = srcAccessMask_;
194 dstAccessMask = dstAccessMask_;
195 dependencyFlags = dependencyFlags_;
196 DE_UNREF (viewOffset_);
197 }
198
SubpassDependency2(const void * pNext_,deUint32 srcSubpass_,deUint32 dstSubpass_,VkPipelineStageFlags srcStageMask_,VkPipelineStageFlags dstStageMask_,VkAccessFlags srcAccessMask_,VkAccessFlags dstAccessMask_,VkDependencyFlags dependencyFlags_,deInt32 viewOffset_)199 SubpassDependency2::SubpassDependency2 (const void* pNext_,
200 deUint32 srcSubpass_,
201 deUint32 dstSubpass_,
202 VkPipelineStageFlags srcStageMask_,
203 VkPipelineStageFlags dstStageMask_,
204 VkAccessFlags srcAccessMask_,
205 VkAccessFlags dstAccessMask_,
206 VkDependencyFlags dependencyFlags_,
207 deInt32 viewOffset_)
208 {
209 sType = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2_KHR;
210 pNext = pNext_;
211 srcSubpass = srcSubpass_;
212 dstSubpass = dstSubpass_;
213 srcStageMask = srcStageMask_;
214 dstStageMask = dstStageMask_;
215 srcAccessMask = srcAccessMask_;
216 dstAccessMask = dstAccessMask_;
217 dependencyFlags = dependencyFlags_;
218 viewOffset = viewOffset_;
219 }
220
RenderPassCreateInfo1(const void * pNext_,VkRenderPassCreateFlags flags_,deUint32 attachmentCount_,const VkAttachmentDescription * pAttachments_,deUint32 subpassCount_,const VkSubpassDescription * pSubpasses_,deUint32 dependencyCount_,const VkSubpassDependency * pDependencies_,deUint32 correlatedViewMaskCount_,const deUint32 * pCorrelatedViewMasks_)221 RenderPassCreateInfo1::RenderPassCreateInfo1 (const void* pNext_,
222 VkRenderPassCreateFlags flags_,
223 deUint32 attachmentCount_,
224 const VkAttachmentDescription* pAttachments_,
225 deUint32 subpassCount_,
226 const VkSubpassDescription* pSubpasses_,
227 deUint32 dependencyCount_,
228 const VkSubpassDependency* pDependencies_,
229 deUint32 correlatedViewMaskCount_,
230 const deUint32* pCorrelatedViewMasks_)
231 {
232 DE_ASSERT(correlatedViewMaskCount_ == 0);
233 DE_ASSERT(pCorrelatedViewMasks_ == DE_NULL);
234
235 sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
236 pNext = pNext_;
237 flags = flags_;
238 attachmentCount = attachmentCount_;
239 pAttachments = pAttachments_;
240 subpassCount = subpassCount_;
241 pSubpasses = pSubpasses_;
242 dependencyCount = dependencyCount_;
243 pDependencies = pDependencies_;
244 DE_UNREF (correlatedViewMaskCount_);
245 DE_UNREF (pCorrelatedViewMasks_);
246 }
247
createRenderPass(const DeviceInterface & vk,VkDevice device) const248 Move<VkRenderPass> RenderPassCreateInfo1::createRenderPass (const DeviceInterface& vk, VkDevice device) const
249 {
250 return vk::createRenderPass(vk, device, this);
251 }
252
RenderPassCreateInfo2(const void * pNext_,VkRenderPassCreateFlags flags_,deUint32 attachmentCount_,const VkAttachmentDescription2KHR * pAttachments_,deUint32 subpassCount_,const VkSubpassDescription2KHR * pSubpasses_,deUint32 dependencyCount_,const VkSubpassDependency2KHR * pDependencies_,deUint32 correlatedViewMaskCount_,const deUint32 * pCorrelatedViewMasks_)253 RenderPassCreateInfo2::RenderPassCreateInfo2 (const void* pNext_,
254 VkRenderPassCreateFlags flags_,
255 deUint32 attachmentCount_,
256 const VkAttachmentDescription2KHR* pAttachments_,
257 deUint32 subpassCount_,
258 const VkSubpassDescription2KHR* pSubpasses_,
259 deUint32 dependencyCount_,
260 const VkSubpassDependency2KHR* pDependencies_,
261 deUint32 correlatedViewMaskCount_,
262 const deUint32* pCorrelatedViewMasks_)
263 {
264 sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2_KHR;
265 pNext = pNext_;
266 flags = flags_;
267 attachmentCount = attachmentCount_;
268 pAttachments = pAttachments_;
269 subpassCount = subpassCount_;
270 pSubpasses = pSubpasses_;
271 dependencyCount = dependencyCount_;
272 pDependencies = pDependencies_;
273 correlatedViewMaskCount = correlatedViewMaskCount_;
274 pCorrelatedViewMasks = pCorrelatedViewMasks_;
275 }
276
createRenderPass(const DeviceInterface & vk,VkDevice device) const277 Move<VkRenderPass> RenderPassCreateInfo2::createRenderPass (const DeviceInterface& vk, VkDevice device) const
278 {
279 return vk::createRenderPass2KHR(vk, device, this);
280 }
281
SubpassBeginInfo1(const void * pNext_,VkSubpassContents contents_)282 SubpassBeginInfo1::SubpassBeginInfo1 (const void* pNext_,
283 VkSubpassContents contents_)
284 : contents (contents_)
285 {
286 DE_ASSERT(pNext_ == DE_NULL);
287
288 DE_UNREF(pNext_);
289 }
290
SubpassBeginInfo2(const void * pNext_,VkSubpassContents contents_)291 SubpassBeginInfo2::SubpassBeginInfo2 (const void* pNext_,
292 VkSubpassContents contents_)
293 {
294 sType = VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO_KHR;
295 pNext = pNext_;
296 contents = contents_;
297 }
298
SubpassEndInfo1(const void * pNext_)299 SubpassEndInfo1::SubpassEndInfo1 (const void* pNext_)
300 {
301 DE_ASSERT(pNext_ == DE_NULL);
302
303 DE_UNREF(pNext_);
304 }
305
SubpassEndInfo2(const void * pNext_)306 SubpassEndInfo2::SubpassEndInfo2 (const void* pNext_)
307 {
308 sType = VK_STRUCTURE_TYPE_SUBPASS_END_INFO_KHR;
309 pNext = pNext_;
310 }
311
cmdBeginRenderPass(const DeviceInterface & vk,VkCommandBuffer cmdBuffer,const VkRenderPassBeginInfo * pRenderPassBegin,const SubpassBeginInfo * pSubpassBeginInfo)312 void RenderpassSubpass1::cmdBeginRenderPass (const DeviceInterface& vk,
313 VkCommandBuffer cmdBuffer,
314 const VkRenderPassBeginInfo* pRenderPassBegin,
315 const SubpassBeginInfo* pSubpassBeginInfo)
316 {
317 DE_ASSERT(pSubpassBeginInfo != DE_NULL);
318
319 vk.cmdBeginRenderPass(cmdBuffer, pRenderPassBegin, pSubpassBeginInfo->contents);
320 }
321
cmdNextSubpass(const DeviceInterface & vk,VkCommandBuffer cmdBuffer,const SubpassBeginInfo * pSubpassBeginInfo,const SubpassEndInfo * pSubpassEndInfo)322 void RenderpassSubpass1::cmdNextSubpass (const DeviceInterface& vk,
323 VkCommandBuffer cmdBuffer,
324 const SubpassBeginInfo* pSubpassBeginInfo,
325 const SubpassEndInfo* pSubpassEndInfo)
326 {
327 DE_UNREF(pSubpassEndInfo);
328 DE_ASSERT(pSubpassBeginInfo != DE_NULL);
329
330 vk.cmdNextSubpass(cmdBuffer, pSubpassBeginInfo->contents);
331 }
332
cmdEndRenderPass(const DeviceInterface & vk,VkCommandBuffer cmdBuffer,const SubpassEndInfo * pSubpassEndInfo)333 void RenderpassSubpass1::cmdEndRenderPass (const DeviceInterface& vk,
334 VkCommandBuffer cmdBuffer,
335 const SubpassEndInfo* pSubpassEndInfo)
336 {
337 DE_UNREF(pSubpassEndInfo);
338
339 vk.cmdEndRenderPass(cmdBuffer);
340 }
341
cmdBeginRenderPass(const DeviceInterface & vk,VkCommandBuffer cmdBuffer,const VkRenderPassBeginInfo * pRenderPassBegin,const SubpassBeginInfo * pSubpassBeginInfo)342 void RenderpassSubpass2::cmdBeginRenderPass (const DeviceInterface& vk,
343 VkCommandBuffer cmdBuffer,
344 const VkRenderPassBeginInfo* pRenderPassBegin,
345 const SubpassBeginInfo* pSubpassBeginInfo)
346 {
347 vk.cmdBeginRenderPass2KHR(cmdBuffer, pRenderPassBegin, pSubpassBeginInfo);
348 }
349
cmdNextSubpass(const DeviceInterface & vk,VkCommandBuffer cmdBuffer,const SubpassBeginInfo * pSubpassBeginInfo,const SubpassEndInfo * pSubpassEndInfo)350 void RenderpassSubpass2::cmdNextSubpass (const DeviceInterface& vk,
351 VkCommandBuffer cmdBuffer,
352 const SubpassBeginInfo* pSubpassBeginInfo,
353 const SubpassEndInfo* pSubpassEndInfo)
354 {
355 DE_ASSERT(pSubpassBeginInfo != DE_NULL);
356 DE_ASSERT(pSubpassEndInfo != DE_NULL);
357
358 vk.cmdNextSubpass2KHR(cmdBuffer, pSubpassBeginInfo, pSubpassEndInfo);
359 }
360
cmdEndRenderPass(const DeviceInterface & vk,VkCommandBuffer cmdBuffer,const SubpassEndInfo * pSubpassEndInfo)361 void RenderpassSubpass2::cmdEndRenderPass (const DeviceInterface& vk,
362 VkCommandBuffer cmdBuffer,
363 const SubpassEndInfo* pSubpassEndInfo)
364 {
365 DE_ASSERT(pSubpassEndInfo != DE_NULL);
366
367 vk.cmdEndRenderPass2KHR(cmdBuffer, pSubpassEndInfo);
368 }
369
370 // For internal to RP/RP2 conversions
371
AttachmentReference(deUint32 attachment,VkImageLayout layout,VkImageAspectFlags aspectMask)372 AttachmentReference::AttachmentReference (deUint32 attachment,
373 VkImageLayout layout,
374 VkImageAspectFlags aspectMask)
375
376 :m_attachment (attachment)
377 ,m_layout (layout)
378 ,m_aspectMask (aspectMask)
379 {
380 }
381
getAttachment(void) const382 deUint32 AttachmentReference::getAttachment (void) const
383 {
384 return m_attachment;
385 }
386
getImageLayout(void) const387 VkImageLayout AttachmentReference::getImageLayout (void) const
388 {
389 return m_layout;
390 }
391
getAspectMask(void) const392 VkImageAspectFlags AttachmentReference::getAspectMask (void) const
393 {
394 return m_aspectMask;
395 }
396
setImageLayout(VkImageLayout layout)397 void AttachmentReference::setImageLayout (VkImageLayout layout)
398 {
399 m_layout = layout;
400 }
401
Subpass(VkPipelineBindPoint pipelineBindPoint,VkSubpassDescriptionFlags flags,const std::vector<AttachmentReference> & inputAttachments,const std::vector<AttachmentReference> & colorAttachments,const std::vector<AttachmentReference> & resolveAttachments,AttachmentReference depthStencilAttachment,const std::vector<deUint32> & preserveAttachments,bool omitBlendState)402 Subpass::Subpass (VkPipelineBindPoint pipelineBindPoint,
403 VkSubpassDescriptionFlags flags,
404 const std::vector<AttachmentReference>& inputAttachments,
405 const std::vector<AttachmentReference>& colorAttachments,
406 const std::vector<AttachmentReference>& resolveAttachments,
407 AttachmentReference depthStencilAttachment,
408 const std::vector<deUint32>& preserveAttachments,
409 bool omitBlendState)
410
411 :m_pipelineBindPoint (pipelineBindPoint)
412 ,m_flags (flags)
413 ,m_inputAttachments (inputAttachments)
414 ,m_colorAttachments (colorAttachments)
415 ,m_resolveAttachments (resolveAttachments)
416 ,m_depthStencilAttachment (depthStencilAttachment)
417 ,m_preserveAttachments (preserveAttachments)
418 ,m_omitBlendState (omitBlendState)
419 {
420 }
421
getPipelineBindPoint(void) const422 VkPipelineBindPoint Subpass::getPipelineBindPoint (void) const
423 {
424 return m_pipelineBindPoint;
425 }
426
getFlags(void) const427 VkSubpassDescriptionFlags Subpass::getFlags (void) const
428 {
429 return m_flags;
430 }
431
getInputAttachments(void) const432 const std::vector<AttachmentReference>& Subpass::getInputAttachments (void) const
433 {
434 return m_inputAttachments;
435 }
436
getColorAttachments(void) const437 const std::vector<AttachmentReference>& Subpass::getColorAttachments (void) const
438 {
439 return m_colorAttachments;
440 }
441
getResolveAttachments(void) const442 const std::vector<AttachmentReference>& Subpass::getResolveAttachments (void) const
443 {
444 return m_resolveAttachments;
445 }
446
getDepthStencilAttachment(void) const447 const AttachmentReference& Subpass::getDepthStencilAttachment (void) const
448 {
449 return m_depthStencilAttachment;
450 }
451
getPreserveAttachments(void) const452 const std::vector<deUint32>& Subpass::getPreserveAttachments (void) const
453 {
454 return m_preserveAttachments;
455 }
456
getOmitBlendState(void) const457 bool Subpass::getOmitBlendState (void) const
458 {
459 return m_omitBlendState;
460 }
461
SubpassDependency(deUint32 srcPass,deUint32 dstPass,VkPipelineStageFlags srcStageMask,VkPipelineStageFlags dstStageMask,VkAccessFlags srcAccessMask,VkAccessFlags dstAccessMask,VkDependencyFlags flags)462 SubpassDependency::SubpassDependency (deUint32 srcPass,
463 deUint32 dstPass,
464
465 VkPipelineStageFlags srcStageMask,
466 VkPipelineStageFlags dstStageMask,
467
468 VkAccessFlags srcAccessMask,
469 VkAccessFlags dstAccessMask,
470
471 VkDependencyFlags flags)
472
473 : m_srcPass (srcPass)
474 , m_dstPass (dstPass)
475
476 , m_srcStageMask (srcStageMask)
477 , m_dstStageMask (dstStageMask)
478
479 , m_srcAccessMask (srcAccessMask)
480 , m_dstAccessMask (dstAccessMask)
481 , m_flags (flags)
482 {
483 }
484
getSrcPass(void) const485 deUint32 SubpassDependency::getSrcPass (void) const
486 {
487 return m_srcPass;
488 }
489
getDstPass(void) const490 deUint32 SubpassDependency::getDstPass (void) const
491 {
492 return m_dstPass;
493 }
494
getSrcStageMask(void) const495 VkPipelineStageFlags SubpassDependency::getSrcStageMask (void) const
496 {
497 return m_srcStageMask;
498 }
499
getDstStageMask(void) const500 VkPipelineStageFlags SubpassDependency::getDstStageMask (void) const
501 {
502 return m_dstStageMask;
503 }
504
getSrcAccessMask(void) const505 VkAccessFlags SubpassDependency::getSrcAccessMask (void) const
506 {
507 return m_srcAccessMask;
508 }
509
getDstAccessMask(void) const510 VkAccessFlags SubpassDependency::getDstAccessMask (void) const
511 {
512 return m_dstAccessMask;
513 }
514
getFlags(void) const515 VkDependencyFlags SubpassDependency::getFlags (void) const
516 {
517 return m_flags;
518 }
519
Attachment(VkFormat format,VkSampleCountFlagBits samples,VkAttachmentLoadOp loadOp,VkAttachmentStoreOp storeOp,VkAttachmentLoadOp stencilLoadOp,VkAttachmentStoreOp stencilStoreOp,VkImageLayout initialLayout,VkImageLayout finalLayout)520 Attachment::Attachment (VkFormat format,
521 VkSampleCountFlagBits samples,
522
523 VkAttachmentLoadOp loadOp,
524 VkAttachmentStoreOp storeOp,
525
526 VkAttachmentLoadOp stencilLoadOp,
527 VkAttachmentStoreOp stencilStoreOp,
528
529 VkImageLayout initialLayout,
530 VkImageLayout finalLayout)
531
532 : m_format (format)
533 , m_samples (samples)
534 , m_loadOp (loadOp)
535 , m_storeOp (storeOp)
536 , m_stencilLoadOp (stencilLoadOp)
537 , m_stencilStoreOp (stencilStoreOp)
538 , m_initialLayout (initialLayout)
539 , m_finalLayout (finalLayout)
540 {
541 }
542
getFormat(void) const543 VkFormat Attachment::getFormat (void) const
544 {
545 return m_format;
546 }
547
getSamples(void) const548 VkSampleCountFlagBits Attachment::getSamples (void) const
549 {
550 return m_samples;
551 }
552
getLoadOp(void) const553 VkAttachmentLoadOp Attachment::getLoadOp (void) const
554 {
555 return m_loadOp;
556 }
557
getStoreOp(void) const558 VkAttachmentStoreOp Attachment::getStoreOp (void) const
559 {
560 return m_storeOp;
561 }
562
getStencilLoadOp(void) const563 VkAttachmentLoadOp Attachment::getStencilLoadOp (void) const
564 {
565 return m_stencilLoadOp;
566 }
567
getStencilStoreOp(void) const568 VkAttachmentStoreOp Attachment::getStencilStoreOp (void) const
569 {
570 return m_stencilStoreOp;
571 }
572
getInitialLayout(void) const573 VkImageLayout Attachment::getInitialLayout (void) const
574 {
575 return m_initialLayout;
576 }
577
getFinalLayout(void) const578 VkImageLayout Attachment::getFinalLayout (void) const
579 {
580 return m_finalLayout;
581 }
582
RenderPass(const std::vector<Attachment> & attachments,const std::vector<Subpass> & subpasses,const std::vector<SubpassDependency> & dependencies,const std::vector<VkInputAttachmentAspectReference> inputAspects)583 RenderPass::RenderPass (const std::vector<Attachment>& attachments,
584 const std::vector<Subpass>& subpasses,
585 const std::vector<SubpassDependency>& dependencies,
586 const std::vector<VkInputAttachmentAspectReference> inputAspects)
587
588 : m_attachments (attachments)
589 , m_subpasses (subpasses)
590 , m_dependencies (dependencies)
591 , m_inputAspects (inputAspects)
592 {
593 }
594
getAttachments(void) const595 const std::vector<Attachment>& RenderPass::getAttachments (void) const
596 {
597 return m_attachments;
598 }
599
getSubpasses(void) const600 const std::vector<Subpass>& RenderPass::getSubpasses (void) const
601 {
602 return m_subpasses;
603 }
604
getDependencies(void) const605 const std::vector<SubpassDependency>& RenderPass::getDependencies (void) const
606 {
607 return m_dependencies;
608 }
609
getInputAspects(void) const610 const std::vector<VkInputAttachmentAspectReference>& RenderPass::getInputAspects (void) const
611 {
612 return m_inputAspects;
613 }
614
615 template <typename AttachmentDesc>
createAttachmentDescription(const Attachment & attachment)616 AttachmentDesc createAttachmentDescription (const Attachment& attachment)
617 {
618 const AttachmentDesc attachmentDescription // VkAttachmentDescription || VkAttachmentDescription2KHR
619 (
620 // || VkStructureType sType;
621 DE_NULL, // || const void* pNext;
622 0u, // VkAttachmentDescriptionFlags flags; || VkAttachmentDescriptionFlags flags;
623 attachment.getFormat(), // VkFormat format; || VkFormat format;
624 attachment.getSamples(), // VkSampleCountFlagBits samples; || VkSampleCountFlagBits samples;
625 attachment.getLoadOp(), // VkAttachmentLoadOp loadOp; || VkAttachmentLoadOp loadOp;
626 attachment.getStoreOp(), // VkAttachmentStoreOp storeOp; || VkAttachmentStoreOp storeOp;
627 attachment.getStencilLoadOp(), // VkAttachmentLoadOp stencilLoadOp; || VkAttachmentLoadOp stencilLoadOp;
628 attachment.getStencilStoreOp(), // VkAttachmentStoreOp stencilStoreOp; || VkAttachmentStoreOp stencilStoreOp;
629 attachment.getInitialLayout(), // VkImageLayout initialLayout; || VkImageLayout initialLayout;
630 attachment.getFinalLayout() // VkImageLayout finalLayout; || VkImageLayout finalLayout;
631 );
632
633 return attachmentDescription;
634 }
635
636 template <typename AttachmentRef>
createAttachmentReference(const AttachmentReference & referenceInfo)637 AttachmentRef createAttachmentReference (const AttachmentReference& referenceInfo)
638 {
639 const AttachmentRef reference // VkAttachmentReference || VkAttachmentReference2KHR
640 (
641 // || VkStructureType sType;
642 DE_NULL, // || const void* pNext;
643 referenceInfo.getAttachment(), // deUint32 attachment; || deUint32 attachment;
644 referenceInfo.getImageLayout(), // VkImageLayout layout; || VkImageLayout layout;
645 referenceInfo.getAspectMask() // || VkImageAspectFlags aspectMask;
646 );
647
648 return reference;
649 }
650
651 template <typename SubpassDesc, typename AttachmentRef>
createSubpassDescription(const Subpass & subpass,std::vector<AttachmentRef> * attachmentReferenceLists,std::vector<deUint32> * preserveAttachmentReferences)652 SubpassDesc createSubpassDescription (const Subpass& subpass,
653 std::vector<AttachmentRef>* attachmentReferenceLists,
654 std::vector<deUint32>* preserveAttachmentReferences)
655 {
656 std::vector<AttachmentRef>& inputAttachmentReferences = attachmentReferenceLists[0];
657 std::vector<AttachmentRef>& colorAttachmentReferences = attachmentReferenceLists[1];
658 std::vector<AttachmentRef>& resolveAttachmentReferences = attachmentReferenceLists[2];
659 std::vector<AttachmentRef>& depthStencilAttachmentReferences = attachmentReferenceLists[3];
660
661 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
662 colorAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getColorAttachments()[attachmentNdx]));
663
664 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
665 inputAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getInputAttachments()[attachmentNdx]));
666
667 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getResolveAttachments().size(); attachmentNdx++)
668 resolveAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getResolveAttachments()[attachmentNdx]));
669
670 depthStencilAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getDepthStencilAttachment()));
671
672 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getPreserveAttachments().size(); attachmentNdx++)
673 preserveAttachmentReferences->push_back(subpass.getPreserveAttachments()[attachmentNdx]);
674
675 DE_ASSERT(resolveAttachmentReferences.empty() || colorAttachmentReferences.size() == resolveAttachmentReferences.size());
676
677 {
678 const SubpassDesc subpassDescription // VkSubpassDescription || VkSubpassDescription2KHR
679 (
680 // || VkStructureType sType;
681 DE_NULL, // || const void* pNext;
682 subpass.getFlags(), // VkSubpassDescriptionFlags flags; || VkSubpassDescriptionFlags flags;
683 subpass.getPipelineBindPoint(), // VkPipelineBindPoint pipelineBindPoint; || VkPipelineBindPoint pipelineBindPoint;
684 0u, // || deUint32 viewMask;
685 (deUint32)inputAttachmentReferences.size(), // deUint32 inputAttachmentCount; || deUint32 inputAttachmentCount;
686 inputAttachmentReferences.empty() ? DE_NULL : &inputAttachmentReferences[0], // const VkAttachmentReference* pInputAttachments; || const VkAttachmentReference2KHR* pInputAttachments;
687 (deUint32)colorAttachmentReferences.size(), // deUint32 colorAttachmentCount; || deUint32 colorAttachmentCount;
688 colorAttachmentReferences.empty() ? DE_NULL : &colorAttachmentReferences[0], // const VkAttachmentReference* pColorAttachments; || const VkAttachmentReference2KHR* pColorAttachments;
689 resolveAttachmentReferences.empty() ? DE_NULL : &resolveAttachmentReferences[0], // const VkAttachmentReference* pResolveAttachments; || const VkAttachmentReference2KHR* pResolveAttachments;
690 &depthStencilAttachmentReferences[0], // const VkAttachmentReference* pDepthStencilAttachment; || const VkAttachmentReference2KHR* pDepthStencilAttachment;
691 (deUint32)preserveAttachmentReferences->size(), // deUint32 preserveAttachmentCount; || deUint32 preserveAttachmentCount;
692 preserveAttachmentReferences->empty() ? DE_NULL : &(*preserveAttachmentReferences)[0] // const deUint32* pPreserveAttachments; || const deUint32* pPreserveAttachments;
693 );
694
695 return subpassDescription;
696 }
697 }
698
699 template <typename SubpassDep>
createSubpassDependency(const SubpassDependency & dependencyInfo)700 SubpassDep createSubpassDependency (const SubpassDependency& dependencyInfo)
701 {
702 const SubpassDep dependency // VkSubpassDependency || VkSubpassDependency2KHR
703 (
704 // || VkStructureType sType
705 DE_NULL, // || const void* pNext
706 dependencyInfo.getSrcPass(), // deUint32 srcSubpass || deUint32 srcSubpass
707 dependencyInfo.getDstPass(), // deUint32 dstSubpass || deUint32 dstSubpass
708 dependencyInfo.getSrcStageMask(), // VkPipelineStageFlags srcStageMask || VkPipelineStageFlags srcStageMask
709 dependencyInfo.getDstStageMask(), // VkPipelineStageFlags dstStageMask || VkPipelineStageFlags dstStageMask
710 dependencyInfo.getSrcAccessMask(), // VkAccessFlags srcAccessMask || VkAccessFlags srcAccessMask
711 dependencyInfo.getDstAccessMask(), // VkAccessFlags dstAccessMask || VkAccessFlags dstAccessMask
712 dependencyInfo.getFlags(), // VkDependencyFlags dependencyFlags || VkDependencyFlags dependencyFlags
713 0u // deInt32 viewOffset || deInt32 viewOffset
714 );
715
716 return dependency;
717 }
718
createRenderPassInputAttachmentAspectCreateInfo(const RenderPass & renderPassInfo)719 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> createRenderPassInputAttachmentAspectCreateInfo (const RenderPass& renderPassInfo)
720 {
721 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> result (DE_NULL);
722
723 if (!renderPassInfo.getInputAspects().empty())
724 {
725 const VkRenderPassInputAttachmentAspectCreateInfo inputAspectCreateInfo =
726 {
727 VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO,
728 DE_NULL,
729
730 (deUint32)renderPassInfo.getInputAspects().size(),
731 renderPassInfo.getInputAspects().data(),
732 };
733
734 result = de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo>(new VkRenderPassInputAttachmentAspectCreateInfo(inputAspectCreateInfo));
735 }
736
737 return result;
738 }
739
740 template<typename AttachmentDesc, typename AttachmentRef, typename SubpassDesc, typename SubpassDep, typename RenderPassCreateInfo>
createRenderPass(const DeviceInterface & vk,VkDevice device,const RenderPass & renderPassInfo)741 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
742 VkDevice device,
743 const RenderPass& renderPassInfo)
744 {
745 const size_t perSubpassAttachmentReferenceLists = 4;
746 std::vector<AttachmentDesc> attachments;
747 std::vector<SubpassDesc> subpasses;
748 std::vector<SubpassDep> dependencies;
749 std::vector<std::vector<AttachmentRef> > attachmentReferenceLists(renderPassInfo.getSubpasses().size() * perSubpassAttachmentReferenceLists);
750 std::vector<std::vector<deUint32> > preserveAttachments(renderPassInfo.getSubpasses().size());
751 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> inputAspectCreateInfo(createRenderPassInputAttachmentAspectCreateInfo(renderPassInfo));
752
753 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
754 attachments.push_back(createAttachmentDescription<AttachmentDesc>(renderPassInfo.getAttachments()[attachmentNdx]));
755
756 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
757 subpasses.push_back(createSubpassDescription<SubpassDesc>(renderPassInfo.getSubpasses()[subpassNdx], &(attachmentReferenceLists[subpassNdx * perSubpassAttachmentReferenceLists]), &preserveAttachments[subpassNdx]));
758
759 for (size_t depNdx = 0; depNdx < renderPassInfo.getDependencies().size(); depNdx++)
760 dependencies.push_back(createSubpassDependency<SubpassDep>(renderPassInfo.getDependencies()[depNdx]));
761
762 const RenderPassCreateInfo renderPassCreator // VkRenderPassCreateInfo || VkRenderPassCreateInfo2KHR
763 (
764 // VkStructureType sType; || VkStructureType sType;
765 inputAspectCreateInfo.get(), // const void* pNext; || const void* pNext;
766 (VkRenderPassCreateFlags)0u, // VkRenderPassCreateFlags flags; || VkRenderPassCreateFlags flags;
767 (deUint32)attachments.size(), // deUint32 attachmentCount; || deUint32 attachmentCount;
768 (attachments.empty() ? DE_NULL : &attachments[0]), // const VkAttachmentDescription* pAttachments; || const VkAttachmentDescription2KHR* pAttachments;
769 (deUint32)subpasses.size(), // deUint32 subpassCount; || deUint32 subpassCount;
770 (subpasses.empty() ? DE_NULL : &subpasses[0]), // const VkSubpassDescription* pSubpasses; || const VkSubpassDescription2KHR* pSubpasses;
771 (deUint32)dependencies.size(), // deUint32 dependencyCount; || deUint32 dependencyCount;
772 (dependencies.empty() ? DE_NULL : &dependencies[0]), // const VkSubpassDependency* pDependencies; || const VkSubpassDependency2KHR* pDependencies;
773 0u, // || deUint32 correlatedViewMaskCount;
774 DE_NULL // || const deUint32* pCorrelatedViewMasks;
775 );
776
777 return renderPassCreator.createRenderPass(vk, device);
778 }
779
createRenderPass(const DeviceInterface & vk,VkDevice device,const RenderPass & renderPassInfo,const RenderPassType renderPassType)780 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
781 VkDevice device,
782 const RenderPass& renderPassInfo,
783 const RenderPassType renderPassType)
784 {
785 switch (renderPassType)
786 {
787 case RENDERPASS_TYPE_LEGACY:
788 return createRenderPass<AttachmentDescription1, AttachmentReference1, SubpassDescription1, SubpassDependency1, RenderPassCreateInfo1>(vk, device, renderPassInfo);
789 case RENDERPASS_TYPE_RENDERPASS2:
790 return createRenderPass<AttachmentDescription2, AttachmentReference2, SubpassDescription2, SubpassDependency2, RenderPassCreateInfo2>(vk, device, renderPassInfo);
791 default:
792 TCU_THROW(InternalError, "Impossible");
793 }
794 }
795
796 } // renderpass
797
798 } // vkt
799