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