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 28using namespace vk; 29 30namespace vkt 31{ 32namespace MultiView 33{ 34 35AttachmentDescription1::AttachmentDescription1 (const void* pNext_, 36 VkAttachmentDescriptionFlags flags_, 37 VkFormat format_, 38 VkSampleCountFlagBits samples_, 39 VkAttachmentLoadOp loadOp_, 40 VkAttachmentStoreOp storeOp_, 41 VkAttachmentLoadOp stencilLoadOp_, 42 VkAttachmentStoreOp stencilStoreOp_, 43 VkImageLayout initialLayout_, 44 VkImageLayout finalLayout_) 45{ 46 DE_ASSERT(pNext_ == DE_NULL); 47 48 // No sType field in this struct 49 DE_UNREF(pNext_); 50 flags = flags_; 51 format = format_; 52 samples = samples_; 53 loadOp = loadOp_; 54 storeOp = storeOp_; 55 stencilLoadOp = stencilLoadOp_; 56 stencilStoreOp = stencilStoreOp_; 57 initialLayout = initialLayout_; 58 finalLayout = finalLayout_; 59} 60 61AttachmentDescription2::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 sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2; 73 pNext = pNext_; 74 flags = flags_; 75 format = format_; 76 samples = samples_; 77 loadOp = loadOp_; 78 storeOp = storeOp_; 79 stencilLoadOp = stencilLoadOp_; 80 stencilStoreOp = stencilStoreOp_; 81 initialLayout = initialLayout_; 82 finalLayout = finalLayout_; 83} 84 85AttachmentReference1::AttachmentReference1 (const void* pNext_, 86 deUint32 attachment_, 87 VkImageLayout layout_, 88 VkImageAspectFlags aspectMask_) 89{ 90 DE_ASSERT(pNext_ == DE_NULL); 91 DE_ASSERT(aspectMask_ == 0); 92 93 // No sType field in this struct 94 DE_UNREF (pNext_); 95 attachment = attachment_; 96 layout = layout_; 97 DE_UNREF (aspectMask_); 98} 99 100AttachmentReference2::AttachmentReference2 (const void* pNext_, 101 deUint32 attachment_, 102 VkImageLayout layout_, 103 VkImageAspectFlags aspectMask_) 104{ 105 sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2; 106 pNext = pNext_; 107 attachment = attachment_; 108 layout = layout_; 109 aspectMask = aspectMask_; 110} 111 112SubpassDescription1::SubpassDescription1 (const void* pNext_, 113 VkSubpassDescriptionFlags flags_, 114 VkPipelineBindPoint pipelineBindPoint_, 115 deUint32 viewMask_, 116 deUint32 inputAttachmentCount_, 117 const VkAttachmentReference* pInputAttachments_, 118 deUint32 colorAttachmentCount_, 119 const VkAttachmentReference* pColorAttachments_, 120 const VkAttachmentReference* pResolveAttachments_, 121 const VkAttachmentReference* pDepthStencilAttachment_, 122 deUint32 preserveAttachmentCount_, 123 const deUint32* pPreserveAttachments_) 124{ 125 DE_ASSERT(pNext_ == DE_NULL); 126 DE_ASSERT(viewMask_ == 0); 127 128 // No sType field in this struct 129 DE_UNREF (pNext_); 130 flags = flags_; 131 pipelineBindPoint = pipelineBindPoint_; 132 DE_UNREF (viewMask_); 133 inputAttachmentCount = inputAttachmentCount_; 134 pInputAttachments = pInputAttachments_; 135 colorAttachmentCount = colorAttachmentCount_; 136 pColorAttachments = pColorAttachments_; 137 pResolveAttachments = pResolveAttachments_; 138 pDepthStencilAttachment = pDepthStencilAttachment_; 139 preserveAttachmentCount = preserveAttachmentCount_; 140 pPreserveAttachments = pPreserveAttachments_; 141} 142 143SubpassDescription2::SubpassDescription2 (const void* pNext_, 144 VkSubpassDescriptionFlags flags_, 145 VkPipelineBindPoint pipelineBindPoint_, 146 deUint32 viewMask_, 147 deUint32 inputAttachmentCount_, 148 const VkAttachmentReference2* pInputAttachments_, 149 deUint32 colorAttachmentCount_, 150 const VkAttachmentReference2* pColorAttachments_, 151 const VkAttachmentReference2* pResolveAttachments_, 152 const VkAttachmentReference2* pDepthStencilAttachment_, 153 deUint32 preserveAttachmentCount_, 154 const deUint32* pPreserveAttachments_) 155{ 156 sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2; 157 pNext = pNext_; 158 flags = flags_; 159 pipelineBindPoint = pipelineBindPoint_; 160 viewMask = viewMask_; 161 inputAttachmentCount = inputAttachmentCount_; 162 pInputAttachments = pInputAttachments_; 163 colorAttachmentCount = colorAttachmentCount_; 164 pColorAttachments = pColorAttachments_; 165 pResolveAttachments = pResolveAttachments_; 166 pDepthStencilAttachment = pDepthStencilAttachment_; 167 preserveAttachmentCount = preserveAttachmentCount_; 168 pPreserveAttachments = pPreserveAttachments_; 169} 170 171SubpassDependency1::SubpassDependency1 (const void* pNext_, 172 deUint32 srcSubpass_, 173 deUint32 dstSubpass_, 174 VkPipelineStageFlags srcStageMask_, 175 VkPipelineStageFlags dstStageMask_, 176 VkAccessFlags srcAccessMask_, 177 VkAccessFlags dstAccessMask_, 178 VkDependencyFlags dependencyFlags_, 179 deInt32 viewOffset_) 180{ 181 DE_ASSERT(pNext_ == DE_NULL); 182 DE_ASSERT(viewOffset_ == 0); 183 184 // No sType field in this struct 185 DE_UNREF (pNext_); 186 srcSubpass = srcSubpass_; 187 dstSubpass = dstSubpass_; 188 srcStageMask = srcStageMask_; 189 dstStageMask = dstStageMask_; 190 srcAccessMask = srcAccessMask_; 191 dstAccessMask = dstAccessMask_; 192 dependencyFlags = dependencyFlags_; 193 DE_UNREF (viewOffset_); 194} 195 196SubpassDependency2::SubpassDependency2 (const void* pNext_, 197 deUint32 srcSubpass_, 198 deUint32 dstSubpass_, 199 VkPipelineStageFlags srcStageMask_, 200 VkPipelineStageFlags dstStageMask_, 201 VkAccessFlags srcAccessMask_, 202 VkAccessFlags dstAccessMask_, 203 VkDependencyFlags dependencyFlags_, 204 deInt32 viewOffset_) 205{ 206 sType = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2; 207 pNext = pNext_; 208 srcSubpass = srcSubpass_; 209 dstSubpass = dstSubpass_; 210 srcStageMask = srcStageMask_; 211 dstStageMask = dstStageMask_; 212 srcAccessMask = srcAccessMask_; 213 dstAccessMask = dstAccessMask_; 214 dependencyFlags = dependencyFlags_; 215 viewOffset = viewOffset_; 216} 217 218RenderPassCreateInfo1::RenderPassCreateInfo1 (const void* pNext_, 219 VkRenderPassCreateFlags flags_, 220 deUint32 attachmentCount_, 221 const VkAttachmentDescription* pAttachments_, 222 deUint32 subpassCount_, 223 const VkSubpassDescription* pSubpasses_, 224 deUint32 dependencyCount_, 225 const VkSubpassDependency* pDependencies_, 226 deUint32 correlatedViewMaskCount_, 227 const deUint32* pCorrelatedViewMasks_) 228{ 229 DE_ASSERT(correlatedViewMaskCount_ == 0); 230 DE_ASSERT(pCorrelatedViewMasks_ == DE_NULL); 231 232 sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; 233 pNext = pNext_; 234 flags = flags_; 235 attachmentCount = attachmentCount_; 236 pAttachments = pAttachments_; 237 subpassCount = subpassCount_; 238 pSubpasses = pSubpasses_; 239 dependencyCount = dependencyCount_; 240 pDependencies = pDependencies_; 241 DE_UNREF (correlatedViewMaskCount_); 242 DE_UNREF (pCorrelatedViewMasks_); 243} 244 245Move<VkRenderPass> RenderPassCreateInfo1::createRenderPass (const DeviceInterface& vk, VkDevice device) const 246{ 247 return vk::createRenderPass(vk, device, this); 248} 249 250RenderPassCreateInfo2::RenderPassCreateInfo2 (const void* pNext_, 251 VkRenderPassCreateFlags flags_, 252 deUint32 attachmentCount_, 253 const VkAttachmentDescription2* pAttachments_, 254 deUint32 subpassCount_, 255 const VkSubpassDescription2* pSubpasses_, 256 deUint32 dependencyCount_, 257 const VkSubpassDependency2* pDependencies_, 258 deUint32 correlatedViewMaskCount_, 259 const deUint32* pCorrelatedViewMasks_) 260{ 261 sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2; 262 pNext = pNext_; 263 flags = flags_; 264 attachmentCount = attachmentCount_; 265 pAttachments = pAttachments_; 266 subpassCount = subpassCount_; 267 pSubpasses = pSubpasses_; 268 dependencyCount = dependencyCount_; 269 pDependencies = pDependencies_; 270 correlatedViewMaskCount = correlatedViewMaskCount_; 271 pCorrelatedViewMasks = pCorrelatedViewMasks_; 272} 273 274Move<VkRenderPass> RenderPassCreateInfo2::createRenderPass (const DeviceInterface& vk, VkDevice device) const 275{ 276 return vk::createRenderPass2(vk, device, this); 277} 278 279SubpassBeginInfo1::SubpassBeginInfo1 (const void* pNext_, 280 VkSubpassContents contents_) 281 : contents (contents_) 282{ 283 DE_ASSERT(pNext_ == DE_NULL); 284 285 DE_UNREF(pNext_); 286} 287 288SubpassBeginInfo2::SubpassBeginInfo2 (const void* pNext_, 289 VkSubpassContents contents_) 290{ 291 sType = VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO; 292 pNext = pNext_; 293 contents = contents_; 294} 295 296SubpassEndInfo1::SubpassEndInfo1 (const void* pNext_) 297{ 298 DE_ASSERT(pNext_ == DE_NULL); 299 300 DE_UNREF(pNext_); 301} 302 303SubpassEndInfo2::SubpassEndInfo2 (const void* pNext_) 304{ 305 sType = VK_STRUCTURE_TYPE_SUBPASS_END_INFO; 306 pNext = pNext_; 307} 308 309void RenderpassSubpass1::cmdBeginRenderPass (const DeviceInterface& vk, 310 VkCommandBuffer cmdBuffer, 311 const VkRenderPassBeginInfo* pRenderPassBegin, 312 const SubpassBeginInfo* pSubpassBeginInfo) 313{ 314 DE_ASSERT(pSubpassBeginInfo != DE_NULL); 315 316 vk.cmdBeginRenderPass(cmdBuffer, pRenderPassBegin, pSubpassBeginInfo->contents); 317} 318 319void RenderpassSubpass1::cmdNextSubpass (const DeviceInterface& vk, 320 VkCommandBuffer cmdBuffer, 321 const SubpassBeginInfo* pSubpassBeginInfo, 322 const SubpassEndInfo* pSubpassEndInfo) 323{ 324 DE_UNREF(pSubpassEndInfo); 325 DE_ASSERT(pSubpassBeginInfo != DE_NULL); 326 327 vk.cmdNextSubpass(cmdBuffer, pSubpassBeginInfo->contents); 328} 329 330void RenderpassSubpass1::cmdEndRenderPass (const DeviceInterface& vk, 331 VkCommandBuffer cmdBuffer, 332 const SubpassEndInfo* pSubpassEndInfo) 333{ 334 DE_UNREF(pSubpassEndInfo); 335 336 vk.cmdEndRenderPass(cmdBuffer); 337} 338 339void RenderpassSubpass2::cmdBeginRenderPass (const DeviceInterface& vk, 340 VkCommandBuffer cmdBuffer, 341 const VkRenderPassBeginInfo* pRenderPassBegin, 342 const SubpassBeginInfo* pSubpassBeginInfo) 343{ 344 vk.cmdBeginRenderPass2(cmdBuffer, pRenderPassBegin, pSubpassBeginInfo); 345} 346 347void RenderpassSubpass2::cmdNextSubpass (const DeviceInterface& vk, 348 VkCommandBuffer cmdBuffer, 349 const SubpassBeginInfo* pSubpassBeginInfo, 350 const SubpassEndInfo* pSubpassEndInfo) 351{ 352 DE_ASSERT(pSubpassBeginInfo != DE_NULL); 353 DE_ASSERT(pSubpassEndInfo != DE_NULL); 354 355 vk.cmdNextSubpass2(cmdBuffer, pSubpassBeginInfo, pSubpassEndInfo); 356} 357 358void RenderpassSubpass2::cmdEndRenderPass (const DeviceInterface& vk, 359 VkCommandBuffer cmdBuffer, 360 const SubpassEndInfo* pSubpassEndInfo) 361{ 362 DE_ASSERT(pSubpassEndInfo != DE_NULL); 363 364 vk.cmdEndRenderPass2(cmdBuffer, pSubpassEndInfo); 365} 366 367} // renderpass 368 369} // vkt 370 371