Alexis Hetu | 8f631c8 | 2018-11-15 15:11:36 -0500 | [diff] [blame] | 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_FRAMEBUFFER_HPP_ |
| 16 | #define VK_FRAMEBUFFER_HPP_ |
| 17 | |
| 18 | #include "VkObject.hpp" |
| 19 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 20 | namespace vk { |
Alexis Hetu | 8f631c8 | 2018-11-15 15:11:36 -0500 | [diff] [blame] | 21 | |
Alexis Hetu | 9fbaf69 | 2018-11-19 11:30:43 -0500 | [diff] [blame] | 22 | class ImageView; |
Alexis Hetu | 1cd31ea | 2019-01-17 17:14:57 -0500 | [diff] [blame] | 23 | class RenderPass; |
Alexis Hetu | 9fbaf69 | 2018-11-19 11:30:43 -0500 | [diff] [blame] | 24 | |
Alexis Hetu | 8f631c8 | 2018-11-15 15:11:36 -0500 | [diff] [blame] | 25 | class Framebuffer : public Object<Framebuffer, VkFramebuffer> |
| 26 | { |
| 27 | public: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 28 | Framebuffer(const VkFramebufferCreateInfo *pCreateInfo, void *mem); |
| 29 | void destroy(const VkAllocationCallbacks *pAllocator); |
Alexis Hetu | 8f631c8 | 2018-11-15 15:11:36 -0500 | [diff] [blame] | 30 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 31 | void clear(const RenderPass *renderPass, uint32_t clearValueCount, const VkClearValue *pClearValues, const VkRect2D &renderArea); |
| 32 | void clearAttachment(const RenderPass *renderPass, uint32_t subpassIndex, const VkClearAttachment &attachment, const VkClearRect &rect); |
Alexis Hetu | 9fbaf69 | 2018-11-19 11:30:43 -0500 | [diff] [blame] | 33 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 34 | static size_t ComputeRequiredAllocationSize(const VkFramebufferCreateInfo *pCreateInfo); |
Chris Forbes | 7c33e88 | 2019-02-21 14:58:28 -0800 | [diff] [blame] | 35 | ImageView *getAttachment(uint32_t index) const; |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 36 | void resolve(const RenderPass *renderPass, uint32_t subpassIndex); |
Alexis Hetu | 8f631c8 | 2018-11-15 15:11:36 -0500 | [diff] [blame] | 37 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 38 | const VkExtent3D &getExtent() const { return extent; } |
Alexis Hetu | d9ed1c2 | 2019-11-07 13:51:51 -0500 | [diff] [blame] | 39 | |
Alexis Hetu | 8f631c8 | 2018-11-15 15:11:36 -0500 | [diff] [blame] | 40 | private: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 41 | uint32_t attachmentCount = 0; |
| 42 | ImageView **attachments = nullptr; |
Alexis Hetu | d9ed1c2 | 2019-11-07 13:51:51 -0500 | [diff] [blame] | 43 | const VkExtent3D extent = {}; |
Alexis Hetu | 8f631c8 | 2018-11-15 15:11:36 -0500 | [diff] [blame] | 44 | }; |
| 45 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 46 | static inline Framebuffer *Cast(VkFramebuffer object) |
Alexis Hetu | 8f631c8 | 2018-11-15 15:11:36 -0500 | [diff] [blame] | 47 | { |
Alexis Hetu | bd4cf81 | 2019-06-14 15:14:07 -0400 | [diff] [blame] | 48 | return Framebuffer::Cast(object); |
Alexis Hetu | 8f631c8 | 2018-11-15 15:11:36 -0500 | [diff] [blame] | 49 | } |
| 50 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 51 | } // namespace vk |
Alexis Hetu | 8f631c8 | 2018-11-15 15:11:36 -0500 | [diff] [blame] | 52 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 53 | #endif // VK_FRAMEBUFFER_HPP_ |