1 #ifndef _VKTRENDERPASSTESTSUTIL_HPP
2 #define _VKTRENDERPASSTESTSUTIL_HPP
3 /*------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2018 The Khronos Group Inc.
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief RenderPass test utils
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
29 #include "vkMemUtil.hpp"
30 #include "vkTypeUtil.hpp"
31 #include "vkTypeUtil.hpp"
32 #include "vktRenderPassGroupParams.hpp"
43 class AttachmentDescription1 : public vk::VkAttachmentDescription
46 AttachmentDescription1 (const void* pNext,
47 VkAttachmentDescriptionFlags flags,
49 VkSampleCountFlagBits samples,
50 VkAttachmentLoadOp loadOp,
51 VkAttachmentStoreOp storeOp,
52 VkAttachmentLoadOp stencilLoadOp,
53 VkAttachmentStoreOp stencilStoreOp,
54 VkImageLayout initialLayout,
55 VkImageLayout finalLayout);
58 class AttachmentDescription2 : public vk::VkAttachmentDescription2
61 AttachmentDescription2 (const void* pNext,
62 VkAttachmentDescriptionFlags flags,
64 VkSampleCountFlagBits samples,
65 VkAttachmentLoadOp loadOp,
66 VkAttachmentStoreOp storeOp,
67 VkAttachmentLoadOp stencilLoadOp,
68 VkAttachmentStoreOp stencilStoreOp,
69 VkImageLayout initialLayout,
70 VkImageLayout finalLayout);
73 class AttachmentReference1 : public vk::VkAttachmentReference
76 AttachmentReference1 (const void* pNext,
79 VkImageAspectFlags aspectMask);
82 class AttachmentReference2 : public vk::VkAttachmentReference2
85 AttachmentReference2 (const void* pNext,
88 VkImageAspectFlags aspectMask);
91 class SubpassDescription1 : public vk::VkSubpassDescription
94 SubpassDescription1 (const void* pNext,
95 VkSubpassDescriptionFlags flags,
96 VkPipelineBindPoint pipelineBindPoint,
98 deUint32 inputAttachmentCount,
99 const VkAttachmentReference* pInputAttachments,
100 deUint32 colorAttachmentCount,
101 const VkAttachmentReference* pColorAttachments,
102 const VkAttachmentReference* pResolveAttachments,
103 const VkAttachmentReference* pDepthStencilAttachment,
104 deUint32 preserveAttachmentCount,
105 const deUint32* pPreserveAttachments);
108 class SubpassDescription2 : public vk::VkSubpassDescription2
111 SubpassDescription2 (const void* pNext,
112 VkSubpassDescriptionFlags flags,
113 VkPipelineBindPoint pipelineBindPoint,
115 deUint32 inputAttachmentCount,
116 const VkAttachmentReference2* pInputAttachments,
117 deUint32 colorAttachmentCount,
118 const VkAttachmentReference2* pColorAttachments,
119 const VkAttachmentReference2* pResolveAttachments,
120 const VkAttachmentReference2* pDepthStencilAttachment,
121 deUint32 preserveAttachmentCount,
122 const deUint32* pPreserveAttachments);
125 class SubpassDependency1 : public vk::VkSubpassDependency
128 SubpassDependency1 (const void* pNext,
131 VkPipelineStageFlags srcStageMask,
132 VkPipelineStageFlags dstStageMask,
133 VkAccessFlags srcAccessMask,
134 VkAccessFlags dstAccessMask,
135 VkDependencyFlags dependencyFlags,
139 class SubpassDependency2 : public vk::VkSubpassDependency2
142 SubpassDependency2 (const void* pNext,
145 VkPipelineStageFlags srcStageMask,
146 VkPipelineStageFlags dstStageMask,
147 VkAccessFlags srcAccessMask,
148 VkAccessFlags dstAccessMask,
149 VkDependencyFlags dependencyFlags,
153 class RenderPassCreateInfo1 : public VkRenderPassCreateInfo
156 RenderPassCreateInfo1 (const void* pNext,
157 VkRenderPassCreateFlags flags,
158 deUint32 attachmentCount,
159 const VkAttachmentDescription* pAttachments,
160 deUint32 subpassCount,
161 const VkSubpassDescription* pSubpasses,
162 deUint32 dependencyCount,
163 const VkSubpassDependency* pDependencies,
164 deUint32 correlatedViewMaskCount,
165 const deUint32* pCorrelatedViewMasks);
167 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
168 VkDevice device) const;
171 class RenderPassCreateInfo2 : public VkRenderPassCreateInfo2
174 RenderPassCreateInfo2 (const void* pNext,
175 VkRenderPassCreateFlags flags,
176 deUint32 attachmentCount,
177 const VkAttachmentDescription2* pAttachments,
178 deUint32 subpassCount,
179 const VkSubpassDescription2* pSubpasses,
180 deUint32 dependencyCount,
181 const VkSubpassDependency2* pDependencies,
182 deUint32 correlatedViewMaskCount,
183 const deUint32* pCorrelatedViewMasks);
185 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
186 VkDevice device) const;
189 class SubpassBeginInfo1
192 SubpassBeginInfo1 (const void* pNext,
193 VkSubpassContents contents);
195 VkSubpassContents contents;
198 class SubpassBeginInfo2 : public VkSubpassBeginInfo
201 SubpassBeginInfo2 (const void* pNext,
202 VkSubpassContents contents);
205 class SubpassEndInfo1
208 SubpassEndInfo1 (const void* pNext);
211 class SubpassEndInfo2 : public VkSubpassEndInfo
214 SubpassEndInfo2 (const void* pNext);
217 class RenderpassSubpass1
220 typedef SubpassBeginInfo1 SubpassBeginInfo;
221 typedef SubpassEndInfo1 SubpassEndInfo;
223 static void cmdBeginRenderPass (const DeviceInterface& vk,
224 VkCommandBuffer cmdBuffer,
225 const VkRenderPassBeginInfo* pRenderPassBegin,
226 const SubpassBeginInfo* pSubpassBeginInfo);
228 static void cmdNextSubpass (const DeviceInterface& vk,
229 VkCommandBuffer cmdBuffer,
230 const SubpassBeginInfo* pSubpassBeginInfo,
231 const SubpassEndInfo* pSubpassEndInfo);
233 static void cmdEndRenderPass (const DeviceInterface& vk,
234 VkCommandBuffer cmdBuffer,
235 const SubpassEndInfo* pSubpassEndInfo);
238 class RenderpassSubpass2
241 typedef SubpassBeginInfo2 SubpassBeginInfo;
242 typedef SubpassEndInfo2 SubpassEndInfo;
244 static void cmdBeginRenderPass (const DeviceInterface& vk,
245 VkCommandBuffer cmdBuffer,
246 const VkRenderPassBeginInfo* pRenderPassBegin,
247 const SubpassBeginInfo* pSubpassBeginInfo);
249 static void cmdNextSubpass (const DeviceInterface& vk,
250 VkCommandBuffer cmdBuffer,
251 const SubpassBeginInfo* pSubpassBeginInfo,
252 const SubpassEndInfo* pSubpassEndInfo);
254 static void cmdEndRenderPass (const DeviceInterface& vk,
255 VkCommandBuffer cmdBuffer,
256 const SubpassEndInfo* pSubpassEndInfo);
259 // For internal to RP/RP2 conversions
261 class AttachmentReference
264 AttachmentReference (deUint32 attachment,
265 VkImageLayout layout,
266 VkImageAspectFlags aspectMask = static_cast<VkImageAspectFlags>(0u));
268 deUint32 getAttachment (void) const;
269 VkImageLayout getImageLayout (void) const;
270 VkImageAspectFlags getAspectMask (void) const;
271 void setImageLayout (VkImageLayout layout);
274 deUint32 m_attachment;
275 VkImageLayout m_layout;
276 VkImageAspectFlags m_aspectMask;
282 Subpass (VkPipelineBindPoint pipelineBindPoint,
283 VkSubpassDescriptionFlags flags,
284 const std::vector<AttachmentReference>& inputAttachments,
285 const std::vector<AttachmentReference>& colorAttachments,
286 const std::vector<AttachmentReference>& resolveAttachments,
287 AttachmentReference depthStencilAttachment,
288 const std::vector<deUint32>& preserveAttachments,
289 bool omitBlendState = false);
291 VkPipelineBindPoint getPipelineBindPoint (void) const;
292 VkSubpassDescriptionFlags getFlags (void) const;
293 const std::vector<AttachmentReference>& getInputAttachments (void) const;
294 const std::vector<AttachmentReference>& getColorAttachments (void) const;
295 const std::vector<AttachmentReference>& getResolveAttachments (void) const;
296 const AttachmentReference& getDepthStencilAttachment (void) const;
297 const std::vector<deUint32>& getPreserveAttachments (void) const;
298 bool getOmitBlendState (void) const;
301 VkPipelineBindPoint m_pipelineBindPoint;
302 VkSubpassDescriptionFlags m_flags;
304 std::vector<AttachmentReference> m_inputAttachments;
305 std::vector<AttachmentReference> m_colorAttachments;
306 std::vector<AttachmentReference> m_resolveAttachments;
307 AttachmentReference m_depthStencilAttachment;
309 std::vector<deUint32> m_preserveAttachments;
310 bool m_omitBlendState;
313 class SubpassDependency
316 SubpassDependency (deUint32 srcPass,
319 VkPipelineStageFlags srcStageMask,
320 VkPipelineStageFlags dstStageMask,
322 VkAccessFlags srcAccessMask,
323 VkAccessFlags dstAccessMask,
325 VkDependencyFlags flags);
327 deUint32 getSrcPass (void) const;
328 deUint32 getDstPass (void) const;
330 VkPipelineStageFlags getSrcStageMask (void) const;
331 VkPipelineStageFlags getDstStageMask (void) const;
333 VkAccessFlags getSrcAccessMask (void) const;
334 VkAccessFlags getDstAccessMask (void) const;
336 VkDependencyFlags getFlags (void) const;
342 VkPipelineStageFlags m_srcStageMask;
343 VkPipelineStageFlags m_dstStageMask;
345 VkAccessFlags m_srcAccessMask;
346 VkAccessFlags m_dstAccessMask;
347 VkDependencyFlags m_flags;
353 Attachment (VkFormat format,
354 VkSampleCountFlagBits samples,
356 VkAttachmentLoadOp loadOp,
357 VkAttachmentStoreOp storeOp,
359 VkAttachmentLoadOp stencilLoadOp,
360 VkAttachmentStoreOp stencilStoreOp,
362 VkImageLayout initialLayout,
363 VkImageLayout finalLayout);
365 VkFormat getFormat (void) const;
366 VkSampleCountFlagBits getSamples (void) const;
368 VkAttachmentLoadOp getLoadOp (void) const;
369 VkAttachmentStoreOp getStoreOp (void) const;
371 VkAttachmentLoadOp getStencilLoadOp (void) const;
372 VkAttachmentStoreOp getStencilStoreOp (void) const;
374 VkImageLayout getInitialLayout (void) const;
375 VkImageLayout getFinalLayout (void) const;
379 VkSampleCountFlagBits m_samples;
381 VkAttachmentLoadOp m_loadOp;
382 VkAttachmentStoreOp m_storeOp;
384 VkAttachmentLoadOp m_stencilLoadOp;
385 VkAttachmentStoreOp m_stencilStoreOp;
387 VkImageLayout m_initialLayout;
388 VkImageLayout m_finalLayout;
394 RenderPass (const std::vector<Attachment>& attachments,
395 const std::vector<Subpass>& subpasses,
396 const std::vector<SubpassDependency>& dependencies,
397 const std::vector<VkInputAttachmentAspectReference> inputAspects = std::vector<VkInputAttachmentAspectReference>());
399 const std::vector<Attachment>& getAttachments (void) const;
400 const std::vector<Subpass>& getSubpasses (void) const;
401 const std::vector<SubpassDependency>& getDependencies (void) const;
402 const std::vector<VkInputAttachmentAspectReference>& getInputAspects (void) const;
405 std::vector<Attachment> m_attachments;
406 std::vector<Subpass> m_subpasses;
407 std::vector<SubpassDependency> m_dependencies;
408 std::vector<VkInputAttachmentAspectReference> m_inputAspects;
411 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
413 const RenderPass& renderPassInfo,
414 RenderingType renderingType,
415 SynchronizationType synchronizationType = SYNCHRONIZATION_TYPE_LEGACY);
421 #endif // _VKTRENDERPASSTESTSUTIL_HPP