| 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 | |
| 25 | class RenderPass : public Object<RenderPass, VkRenderPass> |
| 26 | { |
| 27 | public: |
| 28 | RenderPass(const VkRenderPassCreateInfo* pCreateInfo, void* mem); |
| 29 | void destroy(const VkAllocationCallbacks* pAllocator); |
| 30 | |
| 31 | static size_t ComputeRequiredAllocationSize(const VkRenderPassCreateInfo* pCreateInfo); |
| 32 | |
| 33 | void getRenderAreaGranularity(VkExtent2D* pGranularity) const; |
| 34 | |
| 35 | uint32_t getAttachmentCount() const |
| 36 | { |
| 37 | return attachmentCount; |
| 38 | } |
| 39 | |
| 40 | VkAttachmentDescription getAttachment(uint32_t attachmentIndex) const |
| 41 | { |
| 42 | return attachments[attachmentIndex]; |
| 43 | } |
| 44 | |
| 45 | uint32_t getSubpassCount() const |
| 46 | { |
| 47 | return subpassCount; |
| 48 | } |
| 49 | |
| 50 | VkSubpassDescription const& getSubpass(uint32_t subpassIndex) const |
| 51 | { |
| 52 | return subpasses[subpassIndex]; |
| 53 | } |
| 54 | |
| 55 | uint32_t getDependencyCount() const |
| 56 | { |
| 57 | return dependencyCount; |
| 58 | } |
| 59 | |
| 60 | VkSubpassDependency getDependency(uint32_t i) const |
| 61 | { |
| 62 | return dependencies[i]; |
| 63 | } |
| 64 | |
| 65 | bool isAttachmentUsed(uint32_t i) const |
| 66 | { |
| 67 | return attachmentFirstUse[i] >= 0; |
| 68 | } |
| 69 | |
| 70 | uint32_t getViewMask(uint32_t subpassIndex) const |
| 71 | { |
| 72 | return viewMasks ? viewMasks[subpassIndex] : 1; |
| 73 | } |
| 74 | |
| 75 | bool isMultiView() const |
| 76 | { |
| 77 | return viewMasks != nullptr; |
| 78 | } |
| 79 | |
| 80 | uint32_t getAttachmentViewMask(uint32_t attachmentIndex) const |
| 81 | { |
| 82 | return attachmentViewMasks[attachmentIndex]; |
| 83 | } |
| 84 | |
| 85 | private: |
| 86 | uint32_t attachmentCount = 0; |
| 87 | VkAttachmentDescription* attachments = nullptr; |
| 88 | uint32_t subpassCount = 0; |
| 89 | VkSubpassDescription* subpasses = nullptr; |
| 90 | uint32_t dependencyCount = 0; |
| 91 | VkSubpassDependency* dependencies = nullptr; |
| 92 | int* attachmentFirstUse = nullptr; |
| 93 | uint32_t* viewMasks = nullptr; |
| 94 | uint32_t* attachmentViewMasks = nullptr; |
| 95 | |
| 96 | void MarkFirstUse(int attachment, int subpass); |
| 97 | }; |
| 98 | |
| 99 | static inline RenderPass* Cast(VkRenderPass object) |
| 100 | { |
| 101 | return RenderPass::Cast(object); |
| 102 | } |
| 103 | |
| 104 | } // namespace vk |
| 105 | |
| 106 | #endif // VK_RENDER_PASS_HPP_ |