1 #ifndef _VKTRENDERPASSTESTSUTIL_HPP 2 #define _VKTRENDERPASSTESTSUTIL_HPP 3 /*------------------------------------------------------------------------ 4 * Vulkan Conformance Tests 5 * ------------------------ 6 * 7 * Copyright (c) 2018 The Khronos Group Inc. 8 * 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 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 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. 20 * 21 *//*! 22 * \file 23 * \brief RenderPass test utils 24 *//*--------------------------------------------------------------------*/ 25 26 #include "tcuDefs.hpp" 27 #include "vkRef.hpp" 28 #include "vkDefs.hpp" 29 #include "vkMemUtil.hpp" 30 #include "vkTypeUtil.hpp" 31 #include "vkTypeUtil.hpp" 32 #include "vktRenderPassGroupParams.hpp" 33 34 #include <vector> 35 36 namespace vkt 37 { 38 namespace renderpass 39 { 40 41 using namespace vk; 42 43 class AttachmentDescription1 : public vk::VkAttachmentDescription 44 { 45 public: 46 AttachmentDescription1 (const void* pNext, 47 VkAttachmentDescriptionFlags flags, 48 VkFormat format, 49 VkSampleCountFlagBits samples, 50 VkAttachmentLoadOp loadOp, 51 VkAttachmentStoreOp storeOp, 52 VkAttachmentLoadOp stencilLoadOp, 53 VkAttachmentStoreOp stencilStoreOp, 54 VkImageLayout initialLayout, 55 VkImageLayout finalLayout); 56 }; 57 58 class AttachmentDescription2 : public vk::VkAttachmentDescription2 59 { 60 public: 61 AttachmentDescription2 (const void* pNext, 62 VkAttachmentDescriptionFlags flags, 63 VkFormat format, 64 VkSampleCountFlagBits samples, 65 VkAttachmentLoadOp loadOp, 66 VkAttachmentStoreOp storeOp, 67 VkAttachmentLoadOp stencilLoadOp, 68 VkAttachmentStoreOp stencilStoreOp, 69 VkImageLayout initialLayout, 70 VkImageLayout finalLayout); 71 }; 72 73 class AttachmentReference1 : public vk::VkAttachmentReference 74 { 75 public: 76 AttachmentReference1 (const void* pNext, 77 deUint32 attachment, 78 VkImageLayout layout, 79 VkImageAspectFlags aspectMask); 80 }; 81 82 class AttachmentReference2 : public vk::VkAttachmentReference2 83 { 84 public: 85 AttachmentReference2 (const void* pNext, 86 deUint32 attachment, 87 VkImageLayout layout, 88 VkImageAspectFlags aspectMask); 89 }; 90 91 class SubpassDescription1 : public vk::VkSubpassDescription 92 { 93 public: 94 SubpassDescription1 (const void* pNext, 95 VkSubpassDescriptionFlags flags, 96 VkPipelineBindPoint pipelineBindPoint, 97 deUint32 viewMask, 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); 106 }; 107 108 class SubpassDescription2 : public vk::VkSubpassDescription2 109 { 110 public: 111 SubpassDescription2 (const void* pNext, 112 VkSubpassDescriptionFlags flags, 113 VkPipelineBindPoint pipelineBindPoint, 114 deUint32 viewMask, 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); 123 }; 124 125 class SubpassDependency1 : public vk::VkSubpassDependency 126 { 127 public: 128 SubpassDependency1 (const void* pNext, 129 deUint32 srcSubpass, 130 deUint32 dstSubpass, 131 VkPipelineStageFlags srcStageMask, 132 VkPipelineStageFlags dstStageMask, 133 VkAccessFlags srcAccessMask, 134 VkAccessFlags dstAccessMask, 135 VkDependencyFlags dependencyFlags, 136 deInt32 viewOffset); 137 }; 138 139 class SubpassDependency2 : public vk::VkSubpassDependency2 140 { 141 public: 142 SubpassDependency2 (const void* pNext, 143 deUint32 srcSubpass, 144 deUint32 dstSubpass, 145 VkPipelineStageFlags srcStageMask, 146 VkPipelineStageFlags dstStageMask, 147 VkAccessFlags srcAccessMask, 148 VkAccessFlags dstAccessMask, 149 VkDependencyFlags dependencyFlags, 150 deInt32 viewOffset); 151 }; 152 153 class RenderPassCreateInfo1 : public VkRenderPassCreateInfo 154 { 155 public: 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); 166 167 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk, 168 VkDevice device) const; 169 }; 170 171 class RenderPassCreateInfo2 : public VkRenderPassCreateInfo2 172 { 173 public: 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); 184 185 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk, 186 VkDevice device) const; 187 }; 188 189 class SubpassBeginInfo1 190 { 191 public: 192 SubpassBeginInfo1 (const void* pNext, 193 VkSubpassContents contents); 194 195 VkSubpassContents contents; 196 }; 197 198 class SubpassBeginInfo2 : public VkSubpassBeginInfo 199 { 200 public: 201 SubpassBeginInfo2 (const void* pNext, 202 VkSubpassContents contents); 203 }; 204 205 class SubpassEndInfo1 206 { 207 public: 208 SubpassEndInfo1 (const void* pNext); 209 }; 210 211 class SubpassEndInfo2 : public VkSubpassEndInfo 212 { 213 public: 214 SubpassEndInfo2 (const void* pNext); 215 }; 216 217 class RenderpassSubpass1 218 { 219 public: 220 typedef SubpassBeginInfo1 SubpassBeginInfo; 221 typedef SubpassEndInfo1 SubpassEndInfo; 222 223 static void cmdBeginRenderPass (const DeviceInterface& vk, 224 VkCommandBuffer cmdBuffer, 225 const VkRenderPassBeginInfo* pRenderPassBegin, 226 const SubpassBeginInfo* pSubpassBeginInfo); 227 228 static void cmdNextSubpass (const DeviceInterface& vk, 229 VkCommandBuffer cmdBuffer, 230 const SubpassBeginInfo* pSubpassBeginInfo, 231 const SubpassEndInfo* pSubpassEndInfo); 232 233 static void cmdEndRenderPass (const DeviceInterface& vk, 234 VkCommandBuffer cmdBuffer, 235 const SubpassEndInfo* pSubpassEndInfo); 236 }; 237 238 class RenderpassSubpass2 239 { 240 public: 241 typedef SubpassBeginInfo2 SubpassBeginInfo; 242 typedef SubpassEndInfo2 SubpassEndInfo; 243 244 static void cmdBeginRenderPass (const DeviceInterface& vk, 245 VkCommandBuffer cmdBuffer, 246 const VkRenderPassBeginInfo* pRenderPassBegin, 247 const SubpassBeginInfo* pSubpassBeginInfo); 248 249 static void cmdNextSubpass (const DeviceInterface& vk, 250 VkCommandBuffer cmdBuffer, 251 const SubpassBeginInfo* pSubpassBeginInfo, 252 const SubpassEndInfo* pSubpassEndInfo); 253 254 static void cmdEndRenderPass (const DeviceInterface& vk, 255 VkCommandBuffer cmdBuffer, 256 const SubpassEndInfo* pSubpassEndInfo); 257 }; 258 259 // For internal to RP/RP2 conversions 260 261 class AttachmentReference 262 { 263 public: 264 AttachmentReference (deUint32 attachment, 265 VkImageLayout layout, 266 VkImageAspectFlags aspectMask = static_cast<VkImageAspectFlags>(0u)); 267 268 deUint32 getAttachment (void) const; 269 VkImageLayout getImageLayout (void) const; 270 VkImageAspectFlags getAspectMask (void) const; 271 void setImageLayout (VkImageLayout layout); 272 273 private: 274 deUint32 m_attachment; 275 VkImageLayout m_layout; 276 VkImageAspectFlags m_aspectMask; 277 }; 278 279 class Subpass 280 { 281 public: 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); 290 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; 299 300 private: 301 VkPipelineBindPoint m_pipelineBindPoint; 302 VkSubpassDescriptionFlags m_flags; 303 304 std::vector<AttachmentReference> m_inputAttachments; 305 std::vector<AttachmentReference> m_colorAttachments; 306 std::vector<AttachmentReference> m_resolveAttachments; 307 AttachmentReference m_depthStencilAttachment; 308 309 std::vector<deUint32> m_preserveAttachments; 310 bool m_omitBlendState; 311 }; 312 313 class SubpassDependency 314 { 315 public: 316 SubpassDependency (deUint32 srcPass, 317 deUint32 dstPass, 318 319 VkPipelineStageFlags srcStageMask, 320 VkPipelineStageFlags dstStageMask, 321 322 VkAccessFlags srcAccessMask, 323 VkAccessFlags dstAccessMask, 324 325 VkDependencyFlags flags); 326 327 deUint32 getSrcPass (void) const; 328 deUint32 getDstPass (void) const; 329 330 VkPipelineStageFlags getSrcStageMask (void) const; 331 VkPipelineStageFlags getDstStageMask (void) const; 332 333 VkAccessFlags getSrcAccessMask (void) const; 334 VkAccessFlags getDstAccessMask (void) const; 335 336 VkDependencyFlags getFlags (void) const; 337 338 private: 339 deUint32 m_srcPass; 340 deUint32 m_dstPass; 341 342 VkPipelineStageFlags m_srcStageMask; 343 VkPipelineStageFlags m_dstStageMask; 344 345 VkAccessFlags m_srcAccessMask; 346 VkAccessFlags m_dstAccessMask; 347 VkDependencyFlags m_flags; 348 }; 349 350 class Attachment 351 { 352 public: 353 Attachment (VkFormat format, 354 VkSampleCountFlagBits samples, 355 356 VkAttachmentLoadOp loadOp, 357 VkAttachmentStoreOp storeOp, 358 359 VkAttachmentLoadOp stencilLoadOp, 360 VkAttachmentStoreOp stencilStoreOp, 361 362 VkImageLayout initialLayout, 363 VkImageLayout finalLayout); 364 365 VkFormat getFormat (void) const; 366 VkSampleCountFlagBits getSamples (void) const; 367 368 VkAttachmentLoadOp getLoadOp (void) const; 369 VkAttachmentStoreOp getStoreOp (void) const; 370 371 VkAttachmentLoadOp getStencilLoadOp (void) const; 372 VkAttachmentStoreOp getStencilStoreOp (void) const; 373 374 VkImageLayout getInitialLayout (void) const; 375 VkImageLayout getFinalLayout (void) const; 376 377 private: 378 VkFormat m_format; 379 VkSampleCountFlagBits m_samples; 380 381 VkAttachmentLoadOp m_loadOp; 382 VkAttachmentStoreOp m_storeOp; 383 384 VkAttachmentLoadOp m_stencilLoadOp; 385 VkAttachmentStoreOp m_stencilStoreOp; 386 387 VkImageLayout m_initialLayout; 388 VkImageLayout m_finalLayout; 389 }; 390 391 class RenderPass 392 { 393 public: 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>()); 398 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; 403 404 private: 405 std::vector<Attachment> m_attachments; 406 std::vector<Subpass> m_subpasses; 407 std::vector<SubpassDependency> m_dependencies; 408 std::vector<VkInputAttachmentAspectReference> m_inputAspects; 409 }; 410 411 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk, 412 VkDevice device, 413 const RenderPass& renderPassInfo, 414 RenderingType renderingType, 415 SynchronizationType synchronizationType = SYNCHRONIZATION_TYPE_LEGACY); 416 417 } // renderpass 418 419 } // vkt 420 421 #endif // _VKTRENDERPASSTESTSUTIL_HPP 422