1 // Copyright 2018 The SwiftShader Authors. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef VK_RENDER_PASS_HPP_ 16 #define VK_RENDER_PASS_HPP_ 17 18 #include "VkObject.hpp" 19 20 #include <vector> 21 22 namespace vk { 23 24 class RenderPass : public Object<RenderPass, VkRenderPass> 25 { 26 public: 27 RenderPass(const VkRenderPassCreateInfo *pCreateInfo, void *mem); 28 RenderPass(const VkRenderPassCreateInfo2KHR *pCreateInfo, void *mem); 29 void destroy(const VkAllocationCallbacks *pAllocator); 30 31 static size_t ComputeRequiredAllocationSize(const VkRenderPassCreateInfo *pCreateInfo); 32 static size_t ComputeRequiredAllocationSize(const VkRenderPassCreateInfo2KHR *pCreateInfo); 33 34 void getRenderAreaGranularity(VkExtent2D *pGranularity) const; 35 getAttachmentCount() const36 uint32_t getAttachmentCount() const 37 { 38 return attachmentCount; 39 } 40 getAttachment(uint32_t attachmentIndex) const41 VkAttachmentDescription getAttachment(uint32_t attachmentIndex) const 42 { 43 return attachments[attachmentIndex]; 44 } 45 getSubpassCount() const46 uint32_t getSubpassCount() const 47 { 48 return subpassCount; 49 } 50 getSubpass(uint32_t subpassIndex) const51 VkSubpassDescription const &getSubpass(uint32_t subpassIndex) const 52 { 53 return subpasses[subpassIndex]; 54 } 55 hasDepthStencilResolve() const56 bool hasDepthStencilResolve() const 57 { 58 return subpassDepthStencilResolves != nullptr; 59 } 60 getSubpassDepthStencilResolve(uint32_t subpassIndex) const61 VkSubpassDescriptionDepthStencilResolve getSubpassDepthStencilResolve(uint32_t subpassIndex) const 62 { 63 return subpassDepthStencilResolves[subpassIndex]; 64 } 65 getDependencyCount() const66 uint32_t getDependencyCount() const 67 { 68 return dependencyCount; 69 } 70 getDependency(uint32_t i) const71 VkSubpassDependency getDependency(uint32_t i) const 72 { 73 return dependencies[i]; 74 } 75 isAttachmentUsed(uint32_t i) const76 bool isAttachmentUsed(uint32_t i) const 77 { 78 return attachmentFirstUse[i] >= 0; 79 } 80 getViewMask(uint32_t subpassIndex) const81 uint32_t getViewMask(uint32_t subpassIndex) const 82 { 83 return viewMasks ? viewMasks[subpassIndex] : 1; 84 } 85 isMultiView() const86 bool isMultiView() const 87 { 88 return viewMasks != nullptr; 89 } 90 getAttachmentViewMask(uint32_t attachmentIndex) const91 uint32_t getAttachmentViewMask(uint32_t attachmentIndex) const 92 { 93 return attachmentViewMasks[attachmentIndex]; 94 } 95 96 private: 97 uint32_t attachmentCount = 0; 98 VkAttachmentDescription *attachments = nullptr; 99 uint32_t subpassCount = 0; 100 VkSubpassDescription *subpasses = nullptr; 101 VkSubpassDescriptionDepthStencilResolve *subpassDepthStencilResolves = nullptr; 102 uint32_t dependencyCount = 0; 103 VkSubpassDependency *dependencies = nullptr; 104 int *attachmentFirstUse = nullptr; 105 uint32_t *viewMasks = nullptr; 106 uint32_t *attachmentViewMasks = nullptr; 107 108 void MarkFirstUse(int attachment, int subpass); 109 template<class T> 110 void init(const T *pCreateInfo, void **mem); 111 }; 112 Cast(VkRenderPass object)113static inline RenderPass *Cast(VkRenderPass object) 114 { 115 return RenderPass::Cast(object); 116 } 117 118 } // namespace vk 119 120 #endif // VK_RENDER_PASS_HPP_ 121